[plug] [OT]how to do this in perl?
Michael Collard
quadfour at iinet.net.au
Thu Aug 12 10:17:26 WST 2004
On Thu, 2004-08-12 at 09:55, simon at plumtek.com wrote:
> Hi all
>
> just a quick question - If I have a for loop in perl, how do I affect the
> 'parent' $_ variable from within it? Within the loop the $_ variable is equal
> to the counter.... but I want to append a string to $_ variable outside the
> loop....
>
> Any clues?
Why not do whatever you want to $_ and then add it to an array or string
that you can use outside the loop. And depending on the type of loop, $_
is not always the counter. Eg:
foreach (@fudd) {
# $_ is equal to the current item in the array.
push (@duff, $_ . 'hello');
}
Regards
Michael Collard
More information about the plug
mailing list