#! perl -w use strict; my @site; push @site, "" for (1..10); =pod ### Start with a typical sample // ### Escape anything that might cause a problem (Nothing to do here!) // ### Add some anchors if I KNOW that they are true /^$/ ### Bracket the bit(s) I want to keep. /^$/ ### Substitute appropriate wildcards (Right term?) for the bits I know will change ### The start/end of html comments have to be fixed pretty much. ### The whitespace could vary, but the /x modifier ??should?? handle that nicely /^$/ ### Add any modifiers that might help. ### /x so each space will match any number or combination of whitespace. ### /o to compile for speed, ??not clear to me if this is necessary or advantagous ### if there are no variables to be interpolated in the regex?? ### /i incase "USER" might vary in case. ### If its not needed, don't! I think it is probably expensive. /^$/xio =cut # qr// can have some speed benefits, ??when?? my $regex1 = qr/^$/iox; # I had to remove the /x else it didn't match SOMETIMES???????? my $regex2 = qr/^$/io; for (@site ) { ## Standalone with /x on qr// NEVER matches ????????? # next unless $_ =~ $regex1; # This FAILS to match also ??????????? # next unless m/$regex1/; # Adding the /x to $regex2 this way works ok # next unless m/$regex2/x; next unless $_ =~ $regex2; # And this works. my $userid = $1; print $userid,$/; } # use the map trick # using $regex1 with the /x modifier WORKS ok here!! my @users = map { $regex1 ? $1 : () } @site; my $doc=join "\n", @site; # Simulating slurp mode here!!! study $doc; ## Could give big boost on long strings? # Again, adding the /x modifier here.... my $regex3 = qr/^$/oi; #my @users2 = $doc =~ /$regex3/mgc; # means this FAILS! ?? my @users2 = $doc =~ /$regex3/xmgc; # Adding here it works. print 'results:', ~~@users, ' ', ~~@users2, $/;