easiest way to set $1 $2 $3...
- From: jidanni@xxxxxxxxxxx
- Date: Wed, 18 Jul 2012 17:25:03 +0800
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?
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.
If it takes more than just a one-liner, then perl has problems.
$ perl -wle '"abc" =~ /(.)(.)(.)/; print $1, $2, $3;'
So we see on perlvar there is no array that can give us even read-only
$<digits> ($1, $2, ...)
not of course even to think of an easy way to set them by all directly by hand
if we need to.
Well maybe perlvar should mention what the best way so-far to access
them all (like /bin/sh's $@, $*), and set them all (like /bin/sh's set) is!
- Prev by Date: Re: Regex: match double OR single quote
- Next by Date: Re: easiest way to set $1 $2 $3...
- Previous by thread: Stupid regex problem, s/// catching extra letter
- Next by thread: Re: easiest way to set $1 $2 $3...