david <[EMAIL PROTECTED]> writes:
> Harry Putnam wrote:
>
>> david <[EMAIL PROTECTED]> writes:
>>
>> Won't is still quite even with the eval, in the above case?
>>> passing it to Perl
>>
>> Can you give an example of this?
>
> no it doesn't. if you put it inside an eval{}, it won't quit. consider:
>
> #!/usr/bin/perl -w
> use strict;
>
> my $reg = shift;
>
> while(<STDIN>){
> chomp;
> eval{
> print "$_\n" if(/$reg/o);
> }
> print "ERROR: $@\n" if($@);
> }
>
> __END__
I must be a real dunce, but I still don't get the point.
If a bad regex is given, I want the program to stop.
Your script above doesn't spit an error, it just fails and gives some
other error.
cat chop2.pl
#!/usr/local/bin/perl -w
use strict;
my $reg = shift;
while(<STDIN>){
chomp;
eval{
print "$_\n" if(/$reg/o);
}
print "ERROR: $@\n" if($@);
}
../chop2.pl '\' Mail/xfce/*
$ ./chop2.pl '\' ~/Mail/xfce/*
syntax error at ./chop2.pl line 12, near "print"
Execution of ./chop2.pl aborted due to compilation errors.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]