develooper Front page | perl.beginners | Postings from March 2002

Since when is $_ a read-only variable?

Thread Next
From:
KEVIN ZEMBOWER
Date:
March 20, 2002 09:59
Subject:
Since when is $_ a read-only variable?
Message ID:
sc988795.035@ccp2.jhuccp.org
I'm trying to process a list like so:
 foreach ("photoshare", "mmc", "popline", "popline/www", "popline/db",
"netlinks") {
          $aoutpath = "/usr/local/httpd/htdocs/webstats/$_/$YYYY$MM";
         mkdir("$aoutpath") unless (-e "$aoutpath");
         print "Can't write $aoutpath.\n" unless (-w $aoutpath);
         print "\$_ is <" . $_ . ">\n"; #for troubleshooting only
         s#/#.#g;       #Substitute "." for "/" in the magic variable,
to match analog.cfg filenam
es
          system("$apath/analog -m +g${acfgpath}/${_}.analog.cfg
+F$YY${MM}01 +T$YY${MM}31 +O${aout
path}/index.html"); 
      } #end for each subject area

In the fourth iteration, the directory to be generated should be
"/usr/local/httpd/htdocs/webstats/popline/www/200203", but the +g option
to the command "analog" should be "popline.www.analog.cfg". In other
words, I want to substitute "." for "/" in the magic variable $_ in each
foreach loop.

When I try to run this, I get "Modification of a read-only value
attempted at ./2001.analogall.pl line 81." The print statement in line
80, just above the substitution statement, shows the contents of $_ to
be "photoshare" like I expected.

I'm really puzzled, why it seems to be indicating that $_ is a
read-only variable. Can anyone enlighten me?

Thanks for your help.

-Kevin Zembower

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About