LPM: hlp with h2ph :) sorry
Rich Bowen
rbowen at rcbowen.com
Sat Apr 1 19:56:50 CST 2000
repett0 at sac.uky.edu wrote:
>
> I have been a lurker for a long time on this list and need some help. I
> had to run a program for a class using anykind of scripting and I choose
> perl so I can start getting some skillz... However, Im having problems on
> finding the best way to get a syscall to work. In solaris(at least most
> shells) you can type 'clear' to clear the screen or 'ls' to list files.
> How do you make these calls in a perl script without exiting the script.
The first part I can answer for you. And there are two answers, sort of.
OK, three.
To call system calls, use the `` notation. Those are "backticks" which
are on the key at the top left with the tilde (~), also known to Math
majors as a twiddle.
So, to call ls, do ...
@results = `ls`;
OR
You can use the system() function, which behaves rather differently.
system(ls);
Might not do what you want.
Finally, there's a Perl module called Shell.pm so that you can do stuff
like
use Shell;
cp("/etc/passwd", "/tmp/passwd");
By the way, don't do that
Rich
--
http://www.ApacheUnleashed.com/
Lexington Perl Mongers - http://lexington.pm.org/
PGP Key - http://www.rcbowen.com/pgp.txt
More information about the Lexington-pm
mailing list