in reply to Basic regex to parse source code

What have you tried? We are happy to help you learn the Perl needed to solve this problem yourself, but you need to make the first step. Please post some code with your best guess at how to solve this problem.

Some documentation to help you:

Best, beth

Replies are listed 'Best First'.
Re^2: Basic regex to parse source code
by Anonymous Monk on Jul 13, 2009 at 16:25 UTC
    This is what I have (roughly).
    my @output; foreach my $line (@log) { $line =~ m#\[(\d+)\,\'(.+)\]#i; print "we found $1 and $2\n\n"; my $one = $1; my $two = $2; $two =~ s/'//g; print LOG "<a href='http://stpap11/EAD/administrator/EditPackage.aspx? +PackageID=$one&SMSPackageID=$one&Title=&PackageType=0' target='new'>$ +two</a><br>"; }
      In your regex, you do not have to escape the comma and your (.+) will slurp everything up to the last ] in your line, which is definitely not what you want. You only need the characters up to the next ', so the (negated) character class [^']+ will do what you want.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James