20090410 more stupid perl tricks - plembo/onemoretech GitHub Wiki
title: more stupid perl tricks link: https://onemoretech.wordpress.com/2009/04/10/more-stupid-perl-tricks/ author: lembobro description: post_id: 340 created: 2009/04/10 16:18:48 created_gmt: 2009/04/10 16:18:48 comment_status: open post_name: more-stupid-perl-tricks status: publish post_type: post
more stupid perl tricks
I wanted to install YAML on my machine, but kept getting an error:
me@test:~$ sudo perl -MCPAN -e "install YAML" Can't locate object method "install" via package "YAML" at -e line 1.
The answer came, as usual, from an obscure mail list:
You’re running into the ambiguity surrounding indirect object syntax, has
nothing to do with CPAN.pm.$ perl -wle ‘foo Bar’
Can’t locate object method “foo” via package “Bar” (perhaps you forgot to load
“Bar”?) at -e line 1.Perl thinks you’re saying Bar->foo(). Use a + to disambiguate:
$ perl -MCPAN -e ‘install +YAML’
CPAN: File::HomeDir loaded ok (v0.69)
…Or use the cpan script:
$ cpan YAML
CPAN: File::HomeDir loaded ok (v0.69)
Thanks to Michael Schwern for being one of those generous souls who respond to questions like this.
Copyright 2004-2019 Phil Lembo