Next | Tricks of the Wizards | 117 |
One final hack:
sub AUTOLOAD { my ($pack, $func) = ($AUTOLOAD =~ /(.*)::(.*)/); qx{$func @_}; }
Now you can write Perl programs that look like shell scripts:
$passwd = cat("</etc/passwd"); print $passwd;
sub ps; print ps -ww;
cp("/etc/passwd", "/tmp/passwd");
This is due to Larry Wall
I omitted a lot of details here
See Shell.pm for the actual implementation
Next | Copyright © 2003 M. J. Dominus |