Rudif has asked for the wisdom of the Perl Monks concerning the following question:
which produced the following output#! perl -w use strict; $|++; my $source = 'blahperlblahjavablah'; my ($f1, $f2) = $source =~ /blah(\w+)blah(\w+)blah/; # first attempt print "#1==$1==$2==\n"; print "#2==$f1==$f2==\n"; $source = 'blahblahblah'; ($f1, $f2) = $source =~ /blah(\w+)blah(\w+)blah/; # second attempt print "#3==$1==$2==\n"; print "#4==$f1==$f2==\n"; printf "#5==%s\n", unpack "H*", "$2";
OK, prints #1 and #2 confirm the obvious: the first attempt produces 2 successful matches, reflected both in variables $1, $2 and in my variables $f1, $f2.H:\devperl\perlmonks>scoping-assign.pl #1==perl==java== #2==perl==java== #3==blah== ava== #4====== #5==00617661
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Another regex variable puzzle
by archon (Monk) on Mar 03, 2001 at 04:32 UTC | |
|
Re: Another regex variable puzzle
by japhy (Canon) on Mar 03, 2001 at 21:08 UTC | |
by premchai21 (Curate) on Mar 03, 2001 at 21:47 UTC | |
by Rudif (Hermit) on Mar 04, 2001 at 03:23 UTC | |
by japhy (Canon) on Mar 04, 2001 at 03:46 UTC | |
by Rudif (Hermit) on Mar 07, 2001 at 04:05 UTC |