Re: easiest way to set $1 $2 $3...

Discussion in 'Perl Misc' started by hymie!, Jul 18, 2012.

  1. hymie!

    hymie! Guest

    In our last episode, the evil Dr. Lacto had captured our hero,
    , who said:
    >In /bin/sh it merely takes a
    >$ set a b c
    >to set $1 $2 $3.
    >
    >So what is the easiest way to do the same in perl?


    Um... you *do* understand that "the shell" and "a perl program" are
    two completely different things, right? I mean, $1 $2 $3 in the context
    of the shell, and $1 $2 $3 in the context of a running perl program
    have no relation to each other beyond the fact that they are composed of
    two characters, a dollar sign and a number.

    >Yes in perl they are related to regexps. No don't ask me why I want to
    >set them, Just pretend I need to use them on the next line and want to
    >try some different values.


    You could (and probably should) use $q $w $e . Set them like they were
    normal variables (which they are). They take no more keystrokes than
    $1 $2 $3 do.

    >If it takes more than just a one-liner, then perl has problems.


    I would like perl to mow my lawn. The fact that it can't doesn't mean
    that "perl has problems".

    This is funny -- my sig generater is random, and this is the one it picked.

    --hymie! http://lactose.homelinux.net/~hymie
    -------------------------------------------------------------------------------
    It's not Perl's fault if you don't know how to program. --Ronald J Kimball
    -------------------------------------------------------------------------------
    hymie!, Jul 18, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gianni Galore
    Replies:
    0
    Views:
    339
    Gianni Galore
    Jan 12, 2011
  2. enspired

    easiest way to set future date

    enspired, Oct 30, 2005, in forum: Ruby
    Replies:
    1
    Views:
    93
    Gene Tani
    Oct 30, 2005
  3. RichardOnRails
    Replies:
    4
    Views:
    128
    RichardOnRails
    Jan 23, 2011
  4. Wolf Behrenhoff

    Re: easiest way to set $1 $2 $3...

    Wolf Behrenhoff, Jul 18, 2012, in forum: Perl Misc
    Replies:
    0
    Views:
    432
    Wolf Behrenhoff
    Jul 18, 2012
  5. Jürgen Exner

    Re: easiest way to set $1 $2 $3...

    Jürgen Exner, Jul 18, 2012, in forum: Perl Misc
    Replies:
    1
    Views:
    510
    Tim McDaniel
    Jul 18, 2012
Loading...

Share This Page