Re: Inappropriate ioctl for device
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Sun, 30 Mar 2008 19:56:32 -0700
PekinSOFT@xxxxxxxxx wrote:
On Mar 30, 6:54 am, kra...@xxxxxxxxx (John W. Krahn) wrote:Yes, I understand that die() exits the program. My question was are
die() exits the program.
you able to process more than one line of code in a die() context?
die(), like print() and warn(), prints a list of strings. To do what I think you are trying to do:
open my $FH, '<', 'somefile' or do {
# some statement here;
# and another statement;
# and finally;
die "some string here";
};
Since I didn't know the answer to that, I set my $ExitStatus varialbe
to $EX_NOINPUT so that I would be able to process more than one line
of code before `die`ing.
[ SNIP ]
You are using the $! variable six statements away from the open()Yes, but I'm doing nothing between the open() and where I use it that
statement which means that there is no guarantee that its value will be
related to what open() may have set it to.
should cause it to be changed.
You have print() six times, any one of which could change the value of $!.
Plus, if you look at the output from
the run of my script, you can see that it is reporting the correct
error. However, you bring up a good point regarding the distance, so
I am going to make the next line after the open() statement an
assignment to a variable to hold that exit error, just in case.
What does `shift` do?
Pass the exit code to your subroutine:
my $ExitStatus = shift;
With no arguments, in file scope it removes an element from the beginning of the @ARGV array, in subroutine scope it removes an element from the beginning of the @_ array. The @_ array holds the list of scalars that was passed to the subroutine.
perldoc -f shift
perldoc perlsub
And, how does the line `my $ExitStatus = shift;`
pass the exit code to my subroutine?
If you call the subroutine with the exit code as the first argument, for example:
ExitScript( $EX_USAGE );
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.
- Follow-Ups:
- Re: Inappropriate ioctl for device
- From: Chas. Owens
- Re: Inappropriate ioctl for device
- References:
- Inappropriate ioctl for device
- From: PekinSOFT
- Re: Inappropriate ioctl for device
- From: John W. Krahn
- Re: Inappropriate ioctl for device
- From: PekinSOFT
- Inappropriate ioctl for device
- Prev by Date: Re: commify_series script in cookbook page 94
- Next by Date: parse x.500 DN and change order displayed
- Previous by thread: Re: Inappropriate ioctl for device
- Next by thread: Re: Inappropriate ioctl for device
- Index(es):
Relevant Pages
|
|