--- Yvonne Murphy <[EMAIL PROTECTED]> wrote:
> I have the following piece of code which matches perfectly for a
> string between the single qoute and the semi-colon:-
>
> use strict;
>
> my($mymatch,$line,@arr,$arr,$i);
>
> open (FILE, "functions2.log") or die $!;
> open (OUTFILE, ">thosecoolfuncs.log");
>
> while ($mymatch = <FILE>) {
> if ($mymatch =~ m/\'(.+)\;/gis) {
> print OUTFILE $1, "\n\n";
> }
> }
> close (OUTFILE);
(My apologies for the reformatting -- my mail prog went nuts. =o)
> But the problem occurs when I add this into a bigger code segment, it
> just goes crazy! And seems to match te complete opposite.
Scoping issue?
Try putting the match return into a named variable instead od trusting
$1 (this is frequently less confusing than the extra {}'s that would
solve the same problem....)
> while ($mymatch = <FILE>) {
# () required in "my($match) =" for list context
my($match) = $mymatch =~ m/\'(.+)\;/gis;
print OUTFILE $match, "\n\n" if $match;
> }
If that doesn't fix it, then I'm probably off base, but it still might
aid readability a little (at the cost of an additioanl variable).
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/