tphyahoo has asked for the wisdom of the Perl Monks concerning the following question:
The error I get with the $_ variant happens at the write makefile step:use strict; use warnings; use CPAN; for ( 'Catalyst::Plugin::Authentication' ) { install ($_)} #doesn't wo +rk #for my $mod ( 'Catalyst::Plugin::Authentication' ) { install ($mod)} +#works
... blah blah blah... Removing previously used /home/thartman/.cpan/build/Catalyst-Plugin-Au +thentication-0.09 CPAN.pm: Going to build N/NU/NUFFIN/Catalyst-Plugin-Authentication-0 +.09.tar.gz Checking if your kit is complete... Looks good Writing Makefile for Catalyst::Plugin::Authentication Modification of a read-only value attempted at /home/thartman/perlroot +/perl/lib/5.8.8/CPAN.pm line 4676.
I don't understand why my $var works, but $_ from the loop doesn't. I thought $_ was automatically lexically scoped, and could be relied on to do the same thing as specifying my $var before the for list. What gives?
By the way, to test this, I had my perl root directory tarred up. Before running the script I reverted my perl root directory by
Then I ran perl -e 'use Catalyst::Plugin::Authentication'thartman@nbartertest:~/nbarter$ cat ~/perlroot-revert #!/bin/bash rm -rf perlroot tar -xzvf perlroot.tar.gz
to confirm that this produced an error because of the missing module, and then I would run the script to see if things installed ok or not.
Also, there's nothing special about Catalyst::Plugin::Authentication. This error seems to be produced regardless of what module I try to install.
Blessings to the monastery.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cpan install($_) doesn't work in loop, but normal lexical var does
by imp (Priest) on Aug 27, 2006 at 16:54 UTC | |
by xdg (Monsignor) on Aug 27, 2006 at 20:09 UTC | |
by doom (Deacon) on Aug 27, 2006 at 22:58 UTC | |
by starbolin (Hermit) on Aug 28, 2006 at 00:23 UTC | |
by doom (Deacon) on Aug 28, 2006 at 02:29 UTC | |
by starbolin (Hermit) on Aug 29, 2006 at 00:47 UTC | |
|