Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: system & shell metacharacters

by snax (Hermit)
on Jul 23, 2003 at 00:46 UTC ( [id://276980]=note: print w/replies, xml ) Need Help??


in reply to Re: system & shell metacharacters
in thread system & shell metacharacters

I'm with you. I'd use something like
open BAR, '|bar.pl' || die qq(Useful msg: $!); print BAR $xmldata;
and let bar.pl read from STDIN. No shell at all. OP might want a glance at perlipc.

Replies are listed 'Best First'.
Re: Re: Re: system & shell metacharacters
by bunnyman (Hermit) on Jul 23, 2003 at 15:58 UTC
    open BAR, '|bar.pl' || die qq(Useful msg: $!);

    ... is wrong, because it is interpreted as:

    open BAR, ('|bar.pl' || die qq(Useful msg: $!));

    ... so remember to use "or die" rather than "|| die".

      Really? Ya learn something new every day :) I have a great number of scripts to modify, it would seem....
        Using || die is fine as long as parens are used.
        open(FOO, $file) || die "Couldn't open $file - $!\n";

        When no parens are present, you should use or die instead.

        Personally, I always use parens everywhere so my code is littered with || dies.

        -- vek --

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://276980]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 21:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found