require Net::Curl; Then, the following (assume I have use strict) fails with
Bareword "Net::Curl::Easy::new" not allowed while "strict subs" in use +<?c> <c> my $c = Net::Curl::Easy::new;
while the following does not
my $c = Net::Curl::Easy->new;

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:

my $c = Net::Curl::Easy::new();

or wrap the require statement into a BEGIN block:

BEGIN { require Net::Curl::Easy }

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:

my $c = Net::Curl::Easy::new( q(Net::Curl::Easy) );

- or not. Documentation or source code should reveal that.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

In reply to Re: Why does Net::Curl::Easy->new work but Net::Curl::Easy::new does NOT? by shmem
in thread Why does Net::Curl::Easy->new work but Net::Curl::Easy::new does NOT? by YenForYang

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.