Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

RE: Re: Remote Pipe

by mdillon (Priest)
on May 31, 2000 at 05:57 UTC ( [id://15553]=note: print w/replies, xml ) Need Help??


in reply to Re: Remote Pipe
in thread Remote Pipe

[ if you are using the latest version of Perl (5.6) ] try opening TMP like this: open(TMP, '>', $tmp) || die "Couldn't open $tmp: $!"; note, die adds a line break on its own so it is not necessary to put one in your message.

p.s. a pox upon the houses of those who would unduly censure me with their '--' votes. was it because my sub-par code didn't work in your version of Perl? or because i do not fully grasp the intricacies of 'die'? die $haters if $haters->dont_know_jack();

Replies are listed 'Best First'.
RE: RE: Re: Remote Pipe
by mikfire (Deacon) on May 31, 2000 at 06:13 UTC
    Umm ,actually not really. See, die is pretty funky and looks at the end of the message. If there is no newline, it adds the new line along with a whole bunch of other stuff ( like the line number, etc ).

    Sometimes, though, that information is not desired. Especially when it may confuse the poor end user. So, if you do add the newline, the only thing that shows up is the message you sent.

    Mik - probably going on far longer than anybody really needs
    mikfire

      i see. i guess my die statements are executed so rarely that i never notice the difference. 8^)
RE: RE: Re: Remote Pipe
by btrott (Parson) on May 31, 2000 at 06:40 UTC
    Probably just a typo on your part, but I think this is what threw the OP when he tried your code. The second comma: you probably meant that to be a concatenation operator, yes?

    You want

    open TMP, ">" . $tmp or die "Couldn't open $tmp: $!";
      actually, i got confused by the fact that i have Perl 5.6.0 installed and it has a new variant of open with the following signature: open HANDLE, MODE, LIST sorry that i didn't notice it was Perl 5.6 only, but i don't use files too often. i figured the other signature was there to avoid cross platform problems easier.
Re: Remote Pipe
by Robert (Initiate) on May 31, 2000 at 06:15 UTC
    This is what I've got: Too many arguments for open at test1.pl line 5, near "$tmp) " Execution of test1.pl aborted due to compilation errors.
      I cannot reproduce that locally, but it still looks like a precendence problem to me.

      Try changing your open statements and stop mixing, ie, do this

      open( TMP, ">$tmp" ) || die( "A grim and horrible death" );
      or do it like this
      open TMP, ">$tmp" or die "A grim and horrible death";
      I believe the second method is considered more Perlish.

      Mik
      mikfire

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-28 20:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found