GaijinPunch has asked for the wisdom of the Perl Monks concerning the following question:
The above works, but if I try to replace "\n" in the regex with something else which I would assume would work (namely * or .+) I of course get complaints. Yes, I know that newline characters are special, but if you can't recognize them with a wildcard, isn't slurp mode kinda pointless? The data I'm slurping now is very pretty and well layed out, but what if I was slurping a news article or something?local $/ = undef; my $names = <DATA>; $names =~ /First: (\w+)\nSecond: (\w+)\nThird: (\w+)/; my ( $first, $second, $third ) = ( $1, $2, $3 ); print "$first, $second, $third\n"; __DATA__ First: Bob Second: Me Third: You
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: slurping (matching \n)
by BrowserUk (Patriarch) on Apr 18, 2005 at 01:15 UTC | |
by GaijinPunch (Pilgrim) on Apr 18, 2005 at 01:33 UTC | |
|
Re: slurping (matching \n)
by bart (Canon) on Apr 18, 2005 at 04:20 UTC | |
by ysth (Canon) on Apr 18, 2005 at 06:08 UTC | |
|
Re: slurping (matching \n)
by maa (Pilgrim) on Apr 18, 2005 at 07:44 UTC |