abigail at abigail.be
Sun Jul 20 00:43:18 BST 2008
On Sat, Jul 19, 2008 at 07:16:40PM +0100, A Smith wrote:
> I was trying the Perl one liner below but it complains about an *unrecognized
> switch*. despite this the value is passed into the code. I was trying to
> avoid a full script file with a getopts and its baggage.
> perl -s -e "print $oldage;" -oldage=abc
The value isn't passed to the code when I try it. In fact, it doesn't
$ perl -s -le 'print $oldage' -oldage=abc
Unrecognized switch: -oldage=abc (-h will show valid options).
> Anyone got an idea what will work.
The problem here is that it's perl that will process the -oldage=abc switch,
not the Perl program. To have it work, you first have to tell perl to stop
looking for switches, using the standard -- trick:
$ perl -s -le 'print $oldage' -- -oldage=abc
More information about the london.pm