X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlfaq4.pod;h=ecbd65243e5ff28a3966b50bc16c180cb0e5be43;hb=40b568c93a31cb8feae8a14551365dff7e76b624;hp=7a342719f7d79eab1d3f9649bc6f1f5607c618d6;hpb=6cecdcac8975bfe2a12272798634919e91b189db;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlfaq4.pod b/pod/perlfaq4.pod index 7a34271..ecbd652 100644 --- a/pod/perlfaq4.pod +++ b/pod/perlfaq4.pod @@ -444,11 +444,9 @@ nested patterns, nor can they. For that you'll have to write a parser. If you are serious about writing a parser, there are a number of -modules or oddities that will make your life a lot easier. There is -the CPAN module Parse::RecDescent, the standard module Text::Balanced, -the byacc program, the CPAN module Parse::Yapp, and Mark-Jason -Dominus's excellent I tool at http://www.plover.com/%7Emjd/perl/py/ -. +modules or oddities that will make your life a lot easier. There are +the CPAN modules Parse::RecDescent, Parse::Yapp, and Text::Balanced; +and the byacc program. One simple destructive, inside-out approach that you might try is to pull out the smallest nesting parts one at a time: @@ -465,7 +463,7 @@ really does work: # $_ contains the string to parse # BEGIN and END are the opening and closing markers for the # nested text. - + @( = ('(',''); @) = (')',''); ($re=$_)=~s/((BEGIN)|(END)|.)/$)[!$3]\Q$1\E$([!$2]/gs; @@ -821,7 +819,7 @@ Stringification also destroys arrays. print "@lines"; # WRONG - extra blanks print @lines; # right -=head2 Why don't my EEHERE documents work? +=head2 Why don't my < flag will warn you about these matters. +The C pragma and the B<-w> flag will warn you about these +matters. =head2 How can I remove duplicate elements from a list or array? @@ -1070,7 +1069,7 @@ strings. Modify if you have other needs. sub compare_arrays { my ($first, $second) = @_; - local $^W = 0; # silence spurious -w undef complaints + no warnings; # silence spurious -w undef complaints return 0 unless @$first == @$second; for (my $i = 0; $i < @$first; $i++) { return 0 if $first->[$i] ne $second->[$i]; @@ -1282,7 +1281,7 @@ Supply a comparison function to sort() (described in L): @list = sort { $a <=> $b } @list; The default sort function is cmp, string comparison, which would -sort C<(1, 2, 10)> into C<(1, 10, 2)>. C=E>, used above, is +sort C<(1, 2, 10)> into C<(1, 10, 2)>. C<< <=> >>, used above, is the numerical comparison operator. If you have a complicated function needed to pull out the part you @@ -1747,7 +1746,7 @@ if you just want to say, ``Is this a float?'' Or you could check out the String::Scanf module on CPAN instead. The POSIX module (part of the standard Perl distribution) provides the -C and C for converting strings to double and longs, +C and C for converting strings to double and longs, respectively. =head2 How do I keep persistent data across program calls?