in reply to SOLVED:how to assign 'system' to a value, and eval it.
#!/usr/bin/perl -w use strict; use warnings; my $condition = 0; sub RunProg # Run program only if it exists { my $CMD = join(' ', @_); my $PRG = ($CMD =~ m/^([a-zA-Z0-9_\/\-.~!]+)/) ? $1 : ''; if (length(`which $PRG`)) { return system("$CMD"); } return -1; } my @args = ('yad --help'); my $RET = eval(($condition ? 'system' : 'RunProg') . '(@args);' ); print "\nRETURN VALUE = $RET\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to assign 'system' to a value, and eval it.
by Anonymous Monk on Jun 10, 2024 at 01:06 UTC | |
by vincentaxhe (Scribe) on Jun 10, 2024 at 01:59 UTC | |
|
Re^2: how to assign 'system' to a value, and eval it.
by vincentaxhe (Scribe) on Jun 10, 2024 at 01:53 UTC |