in reply to Re: System and a question of style
in thread System and a question of style
Good idea steves++ , I suppose it depends on one's perl version and personal preference, but being able to call system with list syntax (bypassing the shell hence no jiggery-pokery with escaping things) is IMHO so groovy it hurts doing it the old way!. I'd make a small modification to your subroutine.
sub run_command { # invoke system(@list) if more than one arg passed. ($#_) ? system(@_) : system($_[0]); if ($?) { my $rc = $? >> 8; die "Failed to run '$command': exit code $rc\n"; } } # Easy arg passing with a list; run_command('blah' , '-v' , '-q'); # Pass as scalar for shell interpretation of metachars run_command('tar cvf /dev/null /tmp/*.sock');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: System and a question of style
by bsb (Priest) on Feb 07, 2003 at 06:42 UTC | |
|
Re: Re: Re: System and a question of style
by bronto (Priest) on Feb 07, 2003 at 11:24 UTC |