Re: Exit subroutine on filehandle error

2011-07-29 Thread Paul Johnson
On Fri, Jul 29, 2011 at 04:05:26PM +0200, Dr.Ruud wrote: > On 2011-07-28 00:45, C.DeRykus wrote: > > > open( ... ) or warn "..." and return; > > Here you are assuming that warn always returns true. It actually > does, even if the device that it write to is full, but I don't think > that is

Re: Exit subroutine on filehandle error

2011-07-29 Thread Dr.Ruud
On 2011-07-28 00:45, C.DeRykus wrote: open( ... ) or warn "..." and return; Here you are assuming that warn always returns true. It actually does, even if the device that it write to is full, but I don't think that is documented ... -- Ruud -- To unsubscribe, e-mail: beginners-uns

Re: Exit subroutine on filehandle error

2011-07-28 Thread Kevin Spencer
On Wed, Jul 27, 2011 at 9:30 AM, Rob Dixon wrote: > What exactly is wrong with "or do {...}"? > > I believe it is the best option simply because is is comparable to the > common "open ... or die $!" idiom. The do is there only so that a > warning can be issued as well as the return There's nothin

Re: Exit subroutine on filehandle error

2011-07-27 Thread C.DeRykus
On Jul 27, 9:30 am, rob.di...@gmx.com (Rob Dixon) wrote: > ... > > Well, one thing I dislike about it is that it is using "or do {...}" > > instead of > > an "if ( ) { ... }". And I did mention something similar. > > What exactly is wrong with "or do {...}"? > > I believe it is the best option sim

Re: Exit subroutine on filehandle error

2011-07-27 Thread Rob Dixon
On 27/07/2011 08:51, Shlomi Fish wrote: On Tue, 26 Jul 2011 16:58:47 +0100 Rob Dixon wrote: On 26/07/2011 16:39, Nikolaus Brandt wrote: On Tue, Jul 26, 2011 at 01:01:54PM +0300, Shlomi Fish wrote: Another option would be to use eval { ... } and $@ to trap exceptions: Thank you all for the

Re: Exit subroutine on filehandle error

2011-07-27 Thread timothy adigun
Hello Nikolaus Brand, You can try these: 1. ) Instead of "die" in your code use "warn", then return from the subroutine, 2.) Intstead of hard coding the path and file in your program i.e ["$basedir/$userdir/$outfile" ], ask the user to input the path and file, assign the input to a scalar and check

Re: Exit subroutine on filehandle error

2011-07-27 Thread Shlomi Fish
Hi Rob, On Tue, 26 Jul 2011 16:58:47 +0100 Rob Dixon wrote: > On 26/07/2011 16:39, Nikolaus Brandt wrote: > > On Tue, Jul 26, 2011 at 01:01:54PM +0300, Shlomi Fish wrote: > >> > >> Another option would be to use eval { ... } and $@ to trap exceptions: > > > > Thank you all for the replies. > > >

Re: Exit subroutine on filehandle error

2011-07-26 Thread Rob Dixon
On 26/07/2011 16:39, Nikolaus Brandt wrote: On Tue, Jul 26, 2011 at 01:01:54PM +0300, Shlomi Fish wrote: Another option would be to use eval { ... } and $@ to trap exceptions: Thank you all for the replies. I used the above mentioned eval-$@ solution which was absolutely working fine. I t

Re: Exit subroutine on filehandle error

2011-07-26 Thread Nikolaus Brandt
Hi, On Tue, Jul 26, 2011 at 01:01:54PM +0300, Shlomi Fish wrote: > Hi Nikolaus, > > On Tue, 26 Jul 2011 11:32:19 +0200 > Nikolaus Brandt wrote: > > > Hi, > > > > I'm currently writing a script which contains a subroutine to write > > data to files. > > Currently I use > > open $fh, '>', "$base

Re: Exit subroutine on filehandle error

2011-07-26 Thread John W. Krahn
Nikolaus Brandt wrote: Hi, Hello, I'm currently writing a script which contains a subroutine to write data to files. Currently I use open $fh, '>', "$basedir/$userdir/$outfile" or die "Can't write: $!\n"; which has the disadvantage, that the whole script dies if e.g. the userdir is not availa

Re: Exit subroutine on filehandle error

2011-07-26 Thread Miquel Ruiz
El 26/07/2011 12:01, Shlomi Fish escribió: Another option would be to use eval { ... } and $@ to trap exceptions: http://perl-begin.org/tutorials/perl-for-newbies/part4/#page--exceptions--DIR Important to remember that "open" won't raise an exception if you are not using the "autodie" pragma

Re: Exit subroutine on filehandle error

2011-07-26 Thread Shlomi Fish
Hi Nikolaus, On Tue, 26 Jul 2011 11:32:19 +0200 Nikolaus Brandt wrote: > Hi, > > I'm currently writing a script which contains a subroutine to write > data to files. > Currently I use > open $fh, '>', "$basedir/$userdir/$outfile" or die "Can't write: $!\n"; > which has the disadvantage, that th

Re: exit status

2009-06-30 Thread Raymond Wan
Hi Irfan, Irfan Sayed wrote: I have one windows batch script in which i am calling one perl script. now what i want to do is if the exit status of that perl script is non zero then batch script should not continue executing further and if the exit status is zero then only it shud further ex

Re: Exit status of system commands

2009-01-01 Thread Chas. Owens
On Thu, Jan 1, 2009 at 07:38, Duck wrote: > I am writing a script to ping several systems and then to run nslookup > on those that fail the ping test. How do I capture the exit status of > the system commands. I tried something like: > > $status = system("nslookup xxx.xxx.xxx.xxx"); > print "$st

Re: Exit status of system commands

2009-01-01 Thread Mr. Shawn H. Corey
On Thu, 2009-01-01 at 04:38 -0800, Duck wrote: > I am writing a script to ping several systems and then to run nslookup > on those that fail the ping test. How do I capture the exit status of > the system commands. I tried something like: > > $status = system("nslookup xxx.xxx.xxx.xxx"); > print

Re: exit code

2007-06-29 Thread Martin Barth
I just googled a bit: http://www.hiteksoftware.com/knowledge/articles/049.htm it seems that windows has more exit codes than linux. On Fri, 29 Jun 2007 13:15:18 +0200 "Tatiana Lloret Iglesias" <[EMAIL PROTECTED]> wrote: > And why i windows I get exit value 777? > > On 6/29/07, Martin Barth <[

Re: exit code

2007-06-29 Thread Tatiana Lloret Iglesias
And why i windows I get exit value 777? On 6/29/07, Martin Barth <[EMAIL PROTECTED]> wrote: exit codes are stored in 1 byte. so you can only exit with 2^8 == 256 different values. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl

Re: exit code

2007-06-29 Thread Martin Barth
exit codes are stored in 1 byte. so you can only exit with 2^8 == 256 different values. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: exit code

2007-06-29 Thread Tatiana Lloret Iglesias
Sorry.. but I don't understand what do you mean ... On 6/29/07, Paul Johnson <[EMAIL PROTECTED]> wrote: On Fri, Jun 29, 2007 at 11:08:19AM +0200, Tatiana Lloret Iglesias wrote: > Hi all, > > when I execute my perl script in my local machine and I get to a controlled > error situation i've go

Re: exit code

2007-06-29 Thread Paul Johnson
On Fri, Jun 29, 2007 at 11:08:19AM +0200, Tatiana Lloret Iglesias wrote: > Hi all, > > when I execute my perl script in my local machine and I get to a controlled > error situation i've got as exit value 777 > > if(!$test){ >$failed_times =$failed_times +1; > >if($failed_times ==3) >

Re: Exit

2004-03-04 Thread R. Joseph Newton
Rob Dixon wrote: > I hope, and think, that I've helped several people to > be more eloquent in Perl. > > The language fascinates me in the way that nearly all > who can speak can use it: thanks to Larry, who knew > before we did what a programming language should have been. > > I remain available

Re: Exit

2004-03-04 Thread Gabor Urban
We'll miss you, shure Gabaux Linux is like a wigwam: no gates, no windows, and an apache inside! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Exit

2004-03-04 Thread NYIMI Jose (BMB)
Thanks Rob for your great help in this list. I was always impressed by your elegant coding. You are one the best Perl Programmer I have seen. And I learned a lot from you, thanks ! Wish you all the best for the future ... José. -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED]

RE: Exit

2004-03-04 Thread NYIMI Jose (BMB)
Thanks Rod for your great help in this list. I was always impressed by your elegant coding. You are one the best Perl Programmer I have seen. And I learned a lot from you, thanks ! Wish you all the best for the future ... José. -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED]

Re: Exit

2004-03-03 Thread Michael C. Davis
Thanks for all the insights, Rob. You've helped a *ton* of people. Good luck for the future. At 06:17 PM 3/3/04 -, Rob Dixon wrote: >I hope, and think, that I've helped several people to >be more eloquent in Perl. > >The language fascinates me in the way that nearly all >who can speak can us

Re: Exit

2004-03-03 Thread Kenton Brede
On Wed, Mar 03, 2004 at 06:17:36PM -, Rob Dixon ([EMAIL PROTECTED]) wrote: > I hope, and think, that I've helped several people to > be more eloquent in Perl. > > The language fascinates me in the way that nearly all > who can speak can use it: thanks to Larry, who knew > before we did what a

RE: Exit

2004-03-03 Thread Kipp, James
> I hope, and think, that I've helped several people to > be more eloquent in Perl. Absolutely ! > > I remain available through my email address, but I have > other, rather sad things to do. Thank you all for your > intelligent questions and elaborations. > I, for one, am a better perl progra

OT: Re: exit perl script and cd in bash?

2004-01-20 Thread Wiggins d'Anconia
Kenton Brede wrote: On Sun, Jan 18, 2004 at 05:44:25PM -0600, Kenton Brede ([EMAIL PROTECTED]) wrote: I've been searching the archives and google for an answer. I suspect it can't be done but thought I'd ask. What I'm trying to do is create a tool such as "cdargs", in perl, to simplify moving

Re: exit perl script and cd in bash?

2004-01-20 Thread Kenton Brede
On Sun, Jan 18, 2004 at 05:44:25PM -0600, Kenton Brede ([EMAIL PROTECTED]) wrote: > I've been searching the archives and google for an answer. I suspect it > can't be done but thought I'd ask. > > What I'm trying to do is create a tool such as "cdargs", in perl, to > simplify moving between dir

Re: exit perl script and cd in bash?

2004-01-20 Thread David Garamond
John W. Krahn wrote: It is very easy to change the directory from inside a Perl program however as soon as the program exits the changes will be lost. This is true of Perl or C or Bash or anything that runs as a child of the shell. A child process cannot change its parent's environment. This woul

Re: exit perl script and cd in bash?

2004-01-19 Thread Dan Anderson
On Mon, 2004-01-19 at 02:05, John W. Krahn wrote: > Kenton Brede wrote: > > > > I've been searching the archives and google for an answer. I suspect it > > can't be done but thought I'd ask. > > > > What I'm trying to do is create a tool such as "cdargs", in perl, to > > simplify moving between

Re: exit perl script and cd in bash?

2004-01-19 Thread John W. Krahn
Kenton Brede wrote: > > I've been searching the archives and google for an answer. I suspect it > can't be done but thought I'd ask. > > What I'm trying to do is create a tool such as "cdargs", in perl, to > simplify moving between directories on the command line. > > The problem I'm having of

Re: exit 0 or exit 1

2001-10-23 Thread Joe Echavarria
Those it also apply to shell scripts ? --- Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote: > On Oct 23, Joe Echavarria said: > > > What is the diference when you write a subroutine > >and you type > > Well, exit() doesn't return from a subroutine -- it > stops the program. So > long as you k

Re: exit 0 or exit 1

2001-10-23 Thread Jeff 'japhy' Pinyan
On Oct 23, Joe Echavarria said: > What is the diference when you write a subroutine >and you type Well, exit() doesn't return from a subroutine -- it stops the program. So long as you know that... The exit() function returns the status of your program upon ending -- a successful program exit

Re: exit to the start of the outermost while loop

2001-07-18 Thread Brett W. McCoy
On Wed, 18 Jul 2001, Craig S Monroe wrote: > I basically a have a series of nested while loops that prompts the user > down a particular decision tree to a result. > What I was wondering, is there a way to exit an inner loop directly to the > initial while loop to start the program from the begin