in reply to (jeffa) Re: regex in html
in thread regex in html
But also, I think Jeff misunderstands how your data is coming in, I'm assuming you're opening a file b4 the code you listed, and not using the __DATA__ token in your script.
I don't like redefining $/, especially shown by Jeff, because it's not local and may cause issues later in your program. If you insist, use:
For more on $/, see '6.7. Reading Records with a Pattern Seperator' in The Perl Cookbook.# assuming DATA pipe opened for reading... # declare my $current; # begin local code block { # locally define $/ local $/ = undef; # slurp $current = <DATA>; # end local code block }
But I'd do it this way, anyway...
Jeff's match also grabs an extra \n at beginning and end which you may not need (small point :)# open open (DATA,"/path/to/webpage.htm") || die "Can't open page - $!"; # slurp $current = join '', (<DATA>); # close close(DATA); # match $current =~ /<!---CURCON-->\n(.*?)\n<!---CURCON-->s; # store my $match = $1;
hope this makes sense.
cLive ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Re: regex in html
by jeffa (Bishop) on Apr 02, 2001 at 17:29 UTC |