I think the escaping is still necessary in that case....

Maybe something like this would be cleaner:

   my @ary = split /qr{<p align="center">/}/, $_;

That would work unless I was trying to interpolate into the pattern, because
I set $/ = '' and read into memory in paragraph mode.

I believe that the solution you show allows me to act on the match as $1,
but in this case it wouldn't matter because it's only one pattern to match,
not multiple patterns or sections of a pattern. If () autoescapes the
special characters I'll just shut my mouth (or keyboard) then. :-)

Scot R.
inSite



----- Kristofer Hoch wrote: -----
split /<p align=\"center\">/, $_

instead of matching <p (space) a,l,i,g,n,=, \",c,e,n,t,e,r\">

embrace it in parenthesis...no escaping neccessary...
split /(<p align="center">)/, $_

At least I think that I am reading this book properly....hmmmm

--- Scot Robnett <[EMAIL PROTECTED]> wrote:
> I was wondering why this array that I am attempting to create at line
> 21
> seems to be empty. If I want to put chunks separated by <p
> align="center">
> into the array, how could I do this differently to make it work?
>
>
######################################################################
>
> #!C:\Perl\bin\perl.exe -w
>
> $/ = ''; # slurp in paragraph mode
> my $inputfile = 'C:\path\to\file.htm';
> my $outputfile = 'C:\path\to\OUT.html';
>
> open(INFILE,"<$inputfile") or die "Could not open IN: $! \n";
> open(OUTFILE,">$outputfile") or die "Could not open OUT: $! \n";
>
> my @sections = ();
>
> while(<INFILE>) {
>  chomp;
>  $_ =~ s/\r{3,}/\r/g; # change multiple carriage returns to single \r
>  $_ =~ s/\n{3,}/\n/g; # change multiple newlines to \n (may not be
> necessary)
>  $_ =~ s/<\/*html>//g;        # these
>  $_ =~ s/<\/*head>//g;        # are
>  $_ =~ s/<\/*title>//g;       # pretty
>  $_ =~ s/<\/*body.*?>//g;     # obvious
>  $_ =~ s/(<br wp=.*?>)+//g;   # get rid of weird WordPerfect schneck
>  @sections = split /<p align=\"center\">/, $_; # these are the chunks
> I want
>  print OUTFILE $_;
> }
>
> print OUTFILE "\n\n"; # add a couple of newlines to separate results
>
> foreach my $section(@sections) {
>  chomp($section);
>  print OUTFILE "$section \n\n\n"; # why is this printing nothing?
> }
>
> close(OUTFILE);
> close(INFILE);
> 1;
>
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


=====
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d s+:++ a C++ UL++ US+ P+++ L++
W+++ w PS PE t++ b+ G e r+++ z++++
------END GEEK CODE BLOCK------

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to