[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] So, you think you know Perl?



At 09:37 AM 3/30/01 -0500, Ronald J Kimball wrote:
>On Fri, Mar 30, 2001 at 10:55:41AM +0100, Michael G Schwern wrote:
> > Ummm... the only reason this came to mind is because I saw you do
> > something similar in a JAPH.  However, I have no idea how that worked as
> > it should have turned out to be something like:
> >
> >               LINE:
> >                 while (<>) {
> >                     print q
> >                 } continue {
> >                     print or die "-p destination: $!\n";
> >                 }
> >
> > And q}{ is a syntax error... OH!  but q}} isn't!
> >
> > You frighten me.
>
>But this is a syntax error:
>
>while (<>) {
>     print q
>} continue {
>     print or die "-p destination: $!\n";
>}
>
>So there's still one piece missing...

That's because the q// delimiter isn't } ... it's ;.

I suppose it's cheating to look at the source:

             if (PL_minus_n || PL_minus_p) {
                 sv_setpv(PL_linestr,PL_minus_p ?
                          ";}continue{print or die qq(-p destination: $!\\n)" :
                          "");
                 sv_catpv(PL_linestr,";}");
                 PL_minus_n = PL_minus_p = 0;
             }
             else
                 sv_setpv(PL_linestr,";");

Thus making it equivalent to

perl -le 'while(<>){print q;}continue{print or die qq(-p destination: $!\n);}'

Clearly, the newlines in perlrun are documenter's license.

Why does perl put the semicolons in?

--
Peter Scott
Pacific Systems Design Technologies


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe