Радуга Сталина (symbioid) wrote in perl,
  • Music: The Police - Secret Journey

multiple matches on a single line? (edited for proper < > formatting)

Hello! This is my first night working with Perl so please forgive my severe ignorance.

I'm trying to extract from my past month archive the various LJ users whom I've mentioned. I've found out about greedy matching (so I learned how to use "?" to be non-greedy) However, what I'm noticing now is that if there is more than one lj-user tag on a line, it disregards them. So I'm only pulling up the first match, and then it goes to the second line. I thought the /g would fix that, as it sounded from what I read that it's a global switch and would go left to right in the string, and thus pull up any matches in the full line, not just the first match. But it doesn't seem to be working.

How can I pull up multiple matches of the below pattern that appear in the same line?

(note: in the search pattern I replaced < with [ and likewise for > and ], so it wouldn't replace with an "unknown user")


open(LJA,"sym0307.csv") or die "Can't open: $!";
if ($string = /<lj user=""(.*?)"">/g){
print $1;
print "\n";
  • Post a new comment


    default userpic