in reply to Re: how to assign 'system' to a value, and eval it.
in thread SOLVED:how to assign 'system' to a value, and eval it.
It's using prepared hash to switch run command, that's the logical way instead of using 'if ($run eq 'x'){system ...}', the ugly way I tried to avoid.my %run = (x => \&system, X => \&myrun); my ($run, @args); foreach(@ARGV){ if (/^-([xX])$/){ $run = $run{$1} }elsif (/^-/){ push @args, $_ } $run->(@args)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to assign 'system' to a value, and eval it.
by Corion (Patriarch) on Jun 09, 2024 at 17:54 UTC | |
by vincentaxhe (Scribe) on Jun 10, 2024 at 01:41 UTC |