Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Re: perl -s is evil?

by blakem (Monsignor)
on Nov 15, 2001 at 14:50 UTC ( #125546=note: print w/ replies, xml ) Need Help??

in reply to Re: perl -s is evil?
in thread perl -s is evil?

Here's a one liner that exhibits this oddity... 5.6.1 and 5.00503 on linux:

perl -sle 'print $1' -- -1=foo foo /usr/local/bin/perl5.6.1 -sle 'print $1' -- -1=foo foo /usr/local/bin/perl5.00503 -sle 'print $1' -- -1=foo foo
Can you replicate this?


Comment on Re: Re: perl -s is evil?
Download Code
Replies are listed 'Best First'.
Re: Re: Re: perl -s is evil?
by buckaduck (Chaplain) on Nov 16, 2001 at 01:56 UTC
    I can replicate that. But more to the point, I also get the following result which is closer to the original post:

    (using both Perl 5.6.0 on Win95 and Perl 5.005_02 on Solaris)

    % perl -sle '"Hello" =~ /(\w+)/; print $1' -- -1=foo foo
    It's just plain wrong. Not only can $1 be assigned to, but afterward it refuses to take the pattern from the regex.


      Well, just some fooling around with the last statement Re: Re: Re: perl -s is evil? on my linux box runing Perl 5.005_03, I decided to see what taint checking would do to this example. Wwll here's the results:
      $ perl -sleT 'use diagnostics; use strict; "Hello" =~ /(\w+)/; print $ +1' -- -1=foo $
      While T in any other position returns
      $ perl -sleT 'use diagnostics; use strict; "Hello" =~ /(\w+)/; print $ +1' -- -1=foo foo $
      Clovs aka jclovs
        ummm... You've got a bit of a command like goof there.... The following one-liner illustrates it. Can you figure it out?
        perl -weT 'print "I like jellybeans"' Useless use of a constant in void context at -e line 1.
        consult perlrun for hints. ;-)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://125546]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2015-11-30 07:33 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (764 votes), past polls