Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Re: easiest way to set $1 $2 $3...

Thread Tools

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

Posts: n/a
In our last episode, the evil Dr. Lacto had captured our hero, Removed), 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! (E-Mail Removed)
It's not Perl's fault if you don't know how to program. --Ronald J Kimball
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: easiest way to set $1 $2 $3... Jürgen Exner Perl Misc 1 07-18-2012 04:16 PM
Re: easiest way to set $1 $2 $3... Wolf Behrenhoff Perl Misc 0 07-18-2012 09:58 AM
Easiest way in Ruby to express "given this, set target to this if nilor undefined, else increment by this" RichardOnRails Ruby 4 01-23-2011 07:17 PM
Searching easiest way to convert/copy a (Hash)Set<--->List Gianni Galore Java 0 01-12-2011 02:19 PM
easiest way to set future date enspired Ruby 1 10-30-2005 03:18 PM