From: "Bruno Negrao" <[EMAIL PROTECTED]>
> Hi all, today I discovered a module, the Shell.pm module, which gives
> you the possibility to run shell commands directly from perl. to use
> it, you should try:
> 
> use Shell;
> sub ls;
> print ls('/etc');
> 
> What is the advantage of using all this syntax instead of simply use
> a:`ls /etc`; ? I mean, I don't know why should I use Shell.pm...

Nicer syntax. Plus it's a bit safer.
Suppose you do this:

        $list = `program $dir`; #assuming $dir was checked to be safe!

Now what happens is the $dir contains spaces? (File and directory 
names MAY contain spaces on all current OSes!)

OK, so you may think this will be safe:

        $list = `program '$dir'`;

well ... while this will be fine under Unix, it will not work under 
Windows. You are supposed to use doublequotes there.

So you might end up having different code, different escaping and 
quoting for different OSes ....

Shell.pm will take care of all this for you.
Or at least that's what is it supposed to do. I think the module 
would need to be rethought and rewritten. Currently it kind-of is 
supposed to quote the params, but let the shell do the globbing and 
it's all a little foggy. IMHO of course.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to