We don't bite newbies here... much | |
PerlMonks |
Re: Why does Net::Curl::Easy->new work but Net::Curl::Easy::new does NOT?by shmem (Chancellor) |
on May 07, 2018 at 23:39 UTC ( [id://1214176]=note: print w/replies, xml ) | Need Help?? |
require Net::Curl; Then, the following (assume I have use strict) fails withwhile the following does not That's because require is a runtime directive, and strict is compile time. During the parse of the script it is not distinguishable whether Net::Curl::Easy::new is a subroutine call or a bareword. Add parens to disambiguate:
or wrap the require statement into a BEGIN block:
which loads, compiles and executes Net/Curl/Easy.pm during the parse, and thus makes known Net::Curl::Easy::new as being a subroutine in perl's symbol table. But then, if Net::Curl::Easy::new is not insentitive to be called as a class method or a function, (i.e. it takes arguments and doesn't validate them proper), you may have to pass the classname, as LanX noted:
- or not. Documentation or source code should reveal that.
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
In Section
Seekers of Perl Wisdom
|
|