Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: perl not going to error path

by choroba (Archbishop)
on Jan 23, 2016 at 18:24 UTC ( #1153480=note: print w/replies, xml ) Need Help??


in reply to perl not going to error path

I can't replicate the behaviour with "non numeric" equal to string, reference, or object:
#!/usr/bin/perl use warnings; use strict; my $filename = __FILE__; my %offset_type = ( number => 1, string => 'abc', reference => { a => 23 }, object => bless do { \ my $object }, 'Class' ); for my $type (keys %offset_type) { my $offset = $offset_type{$type}; open my $FH, '<', $filename or die $!; eval { warn "$type without quotes\n"; seek $FH, $offset, 0 or die "Report error - $!"; warn "quoted $type\n"; seek "$FH", $offset, 0 or die "Report error - $!"; 1 } or warn $@; }

Update: Adding output:

number without quotes quoted number seek() on unopened filehandle at ./1.pl line 21. Report error - Bad file descriptor at ./1.pl line 21. reference without quotes quoted reference seek() on unopened filehandle at ./1.pl line 21. Report error - Bad file descriptor at ./1.pl line 21. string without quotes Argument "abc" isn't numeric in seek at ./1.pl line 19. quoted string seek() on unopened filehandle at ./1.pl line 21. Report error - Bad file descriptor at ./1.pl line 21. object without quotes quoted object seek() on unopened filehandle at ./1.pl line 21. Report error - Bad file descriptor at ./1.pl line 21.

Please, read Short, Self Contained, Correct Example on how to post helpful code.

If you need to check whether something is a number, use Scalar::Util's looks_like_number.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: perl not going to error path
by stevieb (Canon) on Jan 23, 2016 at 18:34 UTC

    On 5.10 and 5.22, I get Argument "abc" isn't numeric in seek at ./off.pl line 20., but not with the ref or object though.

      References are converted to their addresses so you can check object identity:
      if ($obj1 == $obj2) { print "The same object.\n"; }
      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1153480]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2022-05-18 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (71 votes). Check out past polls.

    Notices?