Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: List::MoreUtils and require

by Sidhekin (Priest)
on Jun 27, 2006 at 23:50 UTC ( [id://557900]=note: print w/replies, xml ) Need Help??


in reply to List::MoreUtils and require

Prototype and late loading don't run well together. Add XS into the mix, and you get a segfault instead of an error message. Bug? Anyway, workarounds for the original problem:

(1) Bypass prototype (ugly):

my $ea = &List::MoreUtils::each_array(\@v1, \@v2);

(2) Late compilation w/string eval (somewhat ugly, unnecessary compilation):

my $ea = eval q{ use List::MoreUtils; List::MoreUtils::each_array(@v1, @v2) };

(3) Declare the prototype yourself (might break(?) if List::MoreUtils upgrades behind your back):

sub List::MoreUtils::each_array(\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\ +@\@\@\@\@\@\@); my $ea = List::MoreUtils::each_array(@v1, @v2);

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Replies are listed 'Best First'.
Re^2: List::MoreUtils and require
by leriksen (Curate) on Jun 28, 2006 at 02:43 UTC
    Could you also call import() after the require as a workaround ?
    require List::MoreUtils; List::MoreUtils::import(); # or List::MoreUtils->import() ?

    ...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann

      Could you also call import() after the require as a workaround ?

      Not as such, since import just aliases the symbols in your own namespace. Doing that at runtime means it is too late to get the prototype checking. But ... ouch ... you could use that as a way to implicitly bypass prototype checking:

      List::MoreUtils->import('each_array'); my $ea = each_array(\@v1, \@v2);

      I prefer being explicit when bypassing prototype checking though -- the flip side to not using that '&' sigil unless you mean it, is to make sure you do use it when you finally do mean it!

      print "Just another Perl ${\(trickster and hacker)},"
      The Sidhekin proves Sidhe did it!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found