I hope this node isn't a harbinger of things to come this year ... just when I thought I was beginning to understand something, along comes the fickle finger of fate to point out the following (AFAICT) anomaly: running this one-liner doesn't produce the expected fatal not an object error....
Deparse shows, AFAICT, that there's nothing untoward going on from a parsing POV...pointo1d@unforgiven:~/workspace/SVC-ArgsParser$ perl -Mstrict -we 'sub + can_it { $_[0]->can(qw/can/) } my $f = qw/fred/; $f->can(qw/isa/); c +an_it(qw/fred/)' pointo1d@unforgiven:~/workspace/SVC-ArgsParser$
Question is, am I, once again, missing something obvious ? I was expecting a fatal error, at the very least, from the $f->can(qw/isa/) statement - but self-evidently didn't get one ... from either of the potential sources !!perl -MO=Deparse -we 'use strict ; sub can_it { $_[0]->can(qw/can/) } +my $f = qw/fred/; $f->can(qw/isa/); can_it(qw/fred/)' BEGIN { $^W = 1; } sub can_it { use strict 'refs'; $_[0]->can('can'); } use strict 'refs'; my $f = 'fred'; $f->can('isa'); can_it 'fred'; -e syntax OK
FWIW, I'm running 5.8.8 on Ubuntu.
In reply to Arrgh, can() appears to work for non-object !! by Bloodnok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |