|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
Re: [PLUG] question re: perl diamond operator
|
#! /usr/bin/perl -w
if (! -f $ARGV[0]) {
print "$ARGV[0] does not exist\n";
exit 1;
}
while (<>) {
chomp;
print $_;
}
-morgan
On Jun 25, 2009, at 12:24 PM, Mark M. Hoffman wrote:
> Hi all:
>
> Given the following trivial script:
>
>>> #! /usr/bin/perl -w
>>>
>>> while (<>) {
>>> chomp;
>>> print $_;
>>> }
>
> $ ./example.pl foo
> Can't open foo: No such file or directory at ./example.pl line 3.
>
> So far so good; the file foo really does not exist.
>
> $ echo $?
> 0
>
> Really? I want the exit status to be non-zero here. I've looked
> through the
> perl documentation; I can't see any way to get the diamond operator
> to do what
> I want in this case. I would appreciate any suggestions from perl
> experts.
>
> Thanks & regards,
>
> --
> Mark M. Hoffman
> mhoffman@lightlink.com
>
> ___________________________________________________________________________
> Philadelphia Linux Users Group -- http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|