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 documented ...

Heh - I tested that, looked at the docs and then read the source too.
You could still break it, but only with XS I think.  And if you're doing
that sort of thing all bets are off anyway.

However, the whole construct is too ugly and confusing to live.

IMHO, of course.

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 nothing wrong with issuing an "or do {...}" especially if you
want to do multiple things on failure.

open(my $fh, '<', $somefile) or do {
log_the_error("Could not open $somefile - $!");
do_something_else();
return;
};

Kevin.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 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, and
>

I like do{...} as well but an even simpler alternative in
this case:

  open( ... )  or warn "..." and return;

--
Charles DeRykus


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 replies.

I used the above mentioned eval-$@ solution which was absolutely  working
fine.


I think Shlomi may have been over-thorough in his list of options.


I've mentioned it for completeness sake.


Yes, that is what I assumed. But some of your options are less
appropriate, and I think it would have helped to say so.


Most Perl programmers would shudder at the sight of an eval, and
inthis case it is an ugly implementation of the try/catch idiom.


Eh, why? Have you made a survey that concluded that? I agree that eval { ... }
if ($@) in Perl has its limitations but using such abstractions as
http://search.cpan.org/dist/Exception-Class/ , it is good enough. And I think in
this case, it is appropriate because errors should result in exceptions.


That is a silly comment. You make many assertions yourself Shlomi, but I
wonder how many surveys you have conducted to establish them? It is
unnecessary to turn this into a battle and certainly not what I
intended, so please stop this rivalry.


John's


open my $fh, '>', "$basedir/$userdir/$outfile" or do {
   warn "Can't write: $!\n";
   return;
};


(With or without the warning) will do all that you want, and will
enamour you to all who read your code.



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 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, and

  open my $fh, '>', "$basedir/$userdir/$outfile" or return undef;

would be fine.

Rob



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 if it exists/correct or not.
 If the path is correct, then proceed into your subrotine and if not, you
ask the user to check their input and try again! I think that will be a
better way to go!
thanks

On Tue, Jul 26, 2011 at 10:32 AM, 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 the whole script dies if e.g. the
> userdir is not available.
>
> Could you give me an advise how to just exit the subroutine if opening
> the filehandle fails, without exiting the whole script?
>
> Thanks in advance.
>
> Nikolaus
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


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.
> >
> > I used the above mentioned eval-$@ solution which was absolutely  working
> > fine.
> 
> I think Shlomi may have been over-thorough in his list of options. 

I've mentioned it for completeness sake.

> Most
> Perl programmers would shudder at the sight of an eval, and in this case
> it is an ugly implementation of the try/catch idiom.
> 

Eh, why? Have you made a survey that concluded that? I agree that eval { ... }
if ($@) in Perl has its limitations but using such abstractions as
http://search.cpan.org/dist/Exception-Class/ , it is good enough. And I think in
this case, it is appropriate because errors should result in exceptions.

> John's
> 
> > open my $fh, '>', "$basedir/$userdir/$outfile" or do {
> >   warn "Can't write: $!\n";
> >   return;
> > };
> 
> (With or without the warning) will do all that you want, and will
> enamour you to all who read your code.
> 

Well, one thing I dislike about it is that it is using "or do {...}" instead of
an "if ( ) { ... }". And I did mention something similar.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Funny Anti-Terrorism Story - http://shlom.in/enemy

bzr is slower than Subversion in combination with Sourceforge.
— Sjors, http://dazjorz.com/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 think Shlomi may have been over-thorough in his list of options. Most
Perl programmers would shudder at the sight of an eval, and in this case
it is an ugly implementation of the try/catch idiom.

John's


open my $fh, '>', "$basedir/$userdir/$outfile" or do {
  warn "Can't write: $!\n";
  return;
};


(With or without the warning) will do all that you want, and will
enamour you to all who read your code.

Rob




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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, '>', "$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 available. 
> > 
> > Could you give me an advise how to just exit the subroutine if opening
> > the filehandle fails, without exiting the whole script?
> > 
> 
> To answer your question, look at the return statement:
> 
> http://perldoc.perl.org/functions/return.html
> 
> You can do:
> 
> if (!open my $fh, '>', $path)
> {
>   return;
> }
> 
> Another option would be to use eval { ... } and $@ to trap exceptions:
> 
> http://perl-begin.org/tutorials/perl-for-newbies/part4/#page--exceptions--DIR
> 
> Now a few comments on your code:
> 
> 1. Normally, you should do: "open my $fh" instead of "open $fh" to limit its
> scope.
Done.
> 
> 2. You're interpolating several variables into a
> path: "$basedir/$userdir/$outfile", so make sure you sanitise them. If I put 
> in
> $outfile e.g: "../../../../etc/passwd", then I'll be able to write
> to /etc/passwd. See:
I added a check to verify there's no naughty stuff going on.
> 
> http://webcache.googleusercontent.com/search?q=cache:aEbtJ4YXhVkJ:shlomif-tech.livejournal.com/35301.html%3Fthread%3D29157+code+markup+injection+prevention&cd=1&hl=en&ct=clnk&source=www.google.com
> 
> (sorry - livejournal.com is down.)
> 
> You may also opt to use what Joel Spolsky describes here:
> 
> http://www.joelonsoftware.com/articles/Wrong.html
> 
> or perhaps a superior method of making the wrong code behave in an obviously
> wrong way (i.e: terminate the program with an error), which will require more
> coding in Perl.
> 
> Regards,
> 
>   Shlomi Fish
> 
> -- 
> -
> Shlomi Fish   http://www.shlomifish.org/
> My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/
> 
> Tcl is Lisp on drugs. Using strings instead of S‐expressions for closures is
> Evil with one of those gigantic E’s you can find at the beginning of chapters.
> 
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
> 

Thank you all for the replies.
I used the above mentioned eval-$@ solution which was absolutely
working fine.

Thanks again!

Nikolaus

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 available.

Could you give me an advise how to just exit the subroutine if opening
the filehandle fails, without exiting the whole script?


Yes, just exit (return) from the subroutine:

open my $fh, '>', "$basedir/$userdir/$outfile" or do {
warn "Can't write: $!\n";
return;
};



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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, which you can enable with:


use autodie;

(http://perldoc.perl.org/autodie.html)

Best regards,

--
Miquel Ruiz

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 the whole script dies if e.g. the
> userdir is not available. 
> 
> Could you give me an advise how to just exit the subroutine if opening
> the filehandle fails, without exiting the whole script?
> 

To answer your question, look at the return statement:

http://perldoc.perl.org/functions/return.html

You can do:

if (!open my $fh, '>', $path)
{
return;
}

Another option would be to use eval { ... } and $@ to trap exceptions:

http://perl-begin.org/tutorials/perl-for-newbies/part4/#page--exceptions--DIR

Now a few comments on your code:

1. Normally, you should do: "open my $fh" instead of "open $fh" to limit its
scope.

2. You're interpolating several variables into a
path: "$basedir/$userdir/$outfile", so make sure you sanitise them. If I put in
$outfile e.g: "../../../../etc/passwd", then I'll be able to write
to /etc/passwd. See:

http://webcache.googleusercontent.com/search?q=cache:aEbtJ4YXhVkJ:shlomif-tech.livejournal.com/35301.html%3Fthread%3D29157+code+markup+injection+prevention&cd=1&hl=en&ct=clnk&source=www.google.com

(sorry - livejournal.com is down.)

You may also opt to use what Joel Spolsky describes here:

http://www.joelonsoftware.com/articles/Wrong.html

or perhaps a superior method of making the wrong code behave in an obviously
wrong way (i.e: terminate the program with an error), which will require more
coding in Perl.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/

Tcl is Lisp on drugs. Using strings instead of S‐expressions for closures is
Evil with one of those gigantic E’s you can find at the beginning of chapters.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 execute.

normally we use the value of $? to know the exit status of any system call but 
in this case how shud i inform to windows batch script that the perl script 
execution / exit status is non zero and stop execution further


What you seem to be asking for seems to be about the Windows batch 
script and not Perl...   I don't recall how Windows batch files check 
the exit status of another program -- on the Perl side, just use exit 
with a non-zero value.


Ray


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 "$status";
>
> but this seems to print "0" every time whether the nslookup found the
> IP address or not.
snip

Whenever you find yourself reaching for the system function, stop and
search CPAN* first.  There is usually a module that does what you want
already.  In this case, you should probably be using Net::Ping** and
Net::Nslookup***.  Using modules is usually more efficient. more
reliable, and easier than executing an external command and parsing
its output.

* http://search.cpan.org
** http://search.cpan.org/dist/Net-Ping/lib/Net/Ping.pm
*** http://search.cpan.org/dist/Net-Nslookup/lib/Net/Nslookup.pm


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 "$status";
> 
> but this seems to print "0" every time whether the nslookup found the
> IP address or not.
> 
> 

As far as I can tell, nslookup always returns 0.  You're going to have
to determine if it works by the response.

#!/usr/bin/perl

use strict;
use warnings;

open my $ns_fh, '-|', "nslookup xxx.xxx.xxx.xxx" or die "could not open to 
nslookup: $!\n";
while( <$ns_fh> ){
  # ...
}
close $ns_fh;


-- 
Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication as it is about 
coding.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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 <[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.org/
> >
> >
> >

-- 
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

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.org/





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 got as exit value 777
>
> if(!$test){
>$failed_times =$failed_times +1;
>
>if($failed_times ==3)
>{
> exit(777);
>}
>sleep 15;
>   }# if $test
>
> but when i execute the same script with the same controlled error
situation
> I've got as exit value 9 which seems a generic error code
>
> Any idea ?

Exit statuses are stored in eight bits.

> Thanks!

You're welcome.

--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net



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)
>{
> exit(777);
>}
>sleep 15;
>   }# if $test
> 
> but when i execute the same script with the same controlled error situation
> I've got as exit value 9 which seems a generic error code
> 
> Any idea ?

Exit statuses are stored in eight bits.

> Thanks!

You're welcome.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




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 through my email address, but I have
> other, rather sad things to do. Thank you all for your
> intelligent questions and elaborations.
>
> /R

HI Rob,

I will definitely miss your input, and particularly your catches whe I fail to
check my facts carefully.  I hope that whatever issues you are dealing with will
turn out for the best.

Joseph

You are a child of the Universe
No less than the trees and stars
You have a right to be here
And whether or not it is clear to you, no doubt the Universe is unfolding as it
should
Therfore be at peace with God, whatever you conceive Him [Her] to be
And whatever your toils and aspirations
In the noisy confusion of Life
Keep peace with your Soul
For all its sham, drudgery and broken dreams, it is still a beautifuol world
Be careful
*Strive* to be happy



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




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] 
Sent: Wednesday, March 03, 2004 7:18 PM
To: [EMAIL PROTECTED]
Subject: Exit


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 through my email address, but I have
other, rather sad things to do. Thank you all for your intelligent questions and 
elaborations.

/R



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





 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [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] 
Sent: Wednesday, March 03, 2004 7:18 PM
To: [EMAIL PROTECTED]
Subject: Exit


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 through my email address, but I have
other, rather sad things to do. Thank you all for your intelligent questions and 
elaborations.

/R



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





 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [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 use it: thanks to Larry, who knew
>before we did what a programming language should have been.
>
>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.
>
>/R
>
>
>
>-- 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
> 
>
>
>
>

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




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 programming language should have been.
> 
> 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.

Thanks for your help in the past Rob.  Wish you the best.
Kent

-- 
"Efficiency is intelligent laziness."
  -David Dunham

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




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 programmer because of the help your provided to
so many on this list. Thank You and good luck.

Jim


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




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 between directories on the command line.
The problem I'm having of course is actually changing the shell's
working directory from the Perl script.  Is there anyway I can do this 
with Perl?   


Thanks all for the input.  What I've done to work around this is create
a bash function and then source it from the command line.  I know this
has nothing to do with Perl but to close this thread out for the
archives in case someone has the same question -
A very simplified version of what I'm doing:

In mycd.sh

mycd() { cd $1; }

$ . mycd.sh

$ mycd /directory

Kent

To flesh out your script you may want to have a glance at some of the 
examples of re-implementing cd using shell scripts offered in O'Reilly's 
Learning the Bash Shell book, so that you lose less of the functionality 
that the normal built-in 'cd' offers

http://www.oreilly.com/catalog/bash2/

http://danconia.org

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



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 directories on the command line.
> 
> The problem I'm having of course is actually changing the shell's
> working directory from the Perl script.  Is there anyway I can do this 
> with Perl?   

Thanks all for the input.  What I've done to work around this is create
a bash function and then source it from the command line.  I know this
has nothing to do with Perl but to close this thread out for the
archives in case someone has the same question -

A very simplified version of what I'm doing:

In mycd.sh

mycd() { cd $1; }

$ . mycd.sh

$ mycd /directory

Kent

-- 

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




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 would not solve the OP's problem of course, but I'd like to point 
out that when one wants a process to set the parent's environment, and 
the parent is a shell, one usually does this:

 $ eval `COMMAND`

An example of COMMAND would be ssh-agent, which outputs:

 SSH_AUTH_SOCK=/tmp/...
 SSH_AGENT_PID=...
The output then gets eval-ed by the shell and becomes part of the 
shell's environment.

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



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 directories on the command line.
> > 
> > The problem I'm having of course is actually changing the shell's
> > working directory from the Perl script.  Is there anyway I can do this
> > with Perl?
> 
> 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. 

He's right, out of curiousity I tried the following:

% perl -e "`cd ..`;";
% ./test 
  # where test was:
  #! /bin/bash
  cd ..

And neither worked.  However, if he wanted to he could create a script
that moved to that directory, and ran a copy of sh or bash, couldn't
he?  Then pipe commands back and forth.

It would be terribly inefficient though.

-Dan


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




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 course is actually changing the shell's
> working directory from the Perl script.  Is there anyway I can do this
> with Perl?

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.



John
-- 
use Perl;
program
fulfillment

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




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 know that...
> 
> The exit() function returns the status of your
> program upon ending -- a
> successful program exits with a status of 0, and any
> non-0 value is taken
> to indicate an error of some sort.
> 
> -- 
> Jeff "japhy" Pinyan  [EMAIL PROTECTED] 
> http://www.pobox.com/~japhy/
> RPI Acacia brother #734   http://www.perlmonks.org/ 
>  http://www.cpan.org/
> ** Look for "Regular Expressions in Perl" published
> by Manning, in 2002 **
> 


__
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

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




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 exits with a status of 0, and any non-0 value is taken
to indicate an error of some sort.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


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




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 beginning?
> It looks as though labels are only effective in the loop that you are
> currently in?
> Is that correct?

No. If there is no label used with next last or redo, it applies to the
current enclosing loop, otherwise you can move back up the hierachy.  You
should be able to do:

LOOP1: while() {

#do stuff
LOOP3: foreach $i (@array) {

  #do stuff
  next LOOP1 if $i < 3;
  next LOOP2;
}
  }
}

-- Brett

   http://www.chapelperilous.net/btfwk/

Boy, am I glad it's only 1971...


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