Scott Taylor wrote:
> Hello all,
>
> I'm trying to open a file (3 separate files anyway) and iterate
> through them In this portion of my script:
>
> foreach ("dct","lfl","usa"){
> my ($co_id) = $_;
> print "$co_id\n";
> system "rcp orion:/u1/syncdata/drvdat.$co_id
> /tmp/drv.temp" || next;
>
> open(InFile, "/tmp/drv.temp") || die "No such file: $!\n";
> while(<InFile>){ chomp;
> my ($DRVID,$DRVNAME,$DRVPHONE,$DRVTRKID,$DRVLEASEOP) =
> split(/,/,$_); ...
> }
> }
>
> the "while(<InFile>){" line returns this message:
>
> Modification of a read-only value attempted
Your outer foreach() loop uses $_ as the loop variable. Inside the loop, $_
is an alias for the value being iterated. Since you're interating over a set
of literals ("dct","lfl","usa"), $_ becomes effectively read-only inside the
loop. You're trying to use $_ again as the target of the file read operation
with while (<InFile>).
Probably easiest solution is to use $co_id as the iterator, since you're
assigning it from $_ anyway:
for my $co_id (qw/dct lfl usa/) {
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]