RE: Writing to file
From: Rob Hanson (rhanson_at_aptegrity.com)
Date: 02/01/04
- Next message: Jeff 'Japhy' Pinyan: "Re: Writing to file"
- Previous message: R. Joseph Newton: "Re: I did it!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: 'Support' <support@emlgroup.co.nz>, beginners@perl.org Date: Sun, 1 Feb 2004 15:24:25 -0500
> but I can not retrieve the data into $newline with join. Is this bit wrong
Yes, it is a little off.
> $member_array[$count]
This *isn't* an array, it is an *array reference*
> [@edit_array]
Same with this.
Join takes a list of scalars, not a list of references. So you need to
dereference them. I think this is what you are after.
join("\:",@{$member_array[$count]});
Rob
-----Original Message-----
From: Support [mailto:support@emlgroup.co.nz]
Sent: Sunday, February 01, 2004 2:31 PM
To: beginners@perl.org
Subject: Writing to file
Hi all
I have a little bit of code you may be able to help with. I load a file into
an array with
foreach $lines(@database_array) {
@edit_array = split(/\:/,$lines);
push(@member_array,[@edit_array]);
$x++;
} #loop
and then play around with the array a bit, then I would like to load it back
into the file with
while($count<$x){
$newline = join("\:",$member_array[$count],[@edit_array]);
chomp($newline);
print DAT "$newline\n";
$count++;
}
but I can not retrieve the data into $newline with join. Is this bit wrong
$member_array[$count],[@edit_array])
or am I missing the point completely or is there another way of doing it.
I am currently loading direct from the file working on that line and them
loading back to file, but I can only change one line at a time. Doing it
with as above I can alter the entire array and then load back to file.
Any help is appreciated and please excuse if I'm in the wrong forum.
Cheers
Colin
----------------------------------------------------------------------------
-------------------
www.rentmyplace.co.nz
The ultimate in that holiday spot away from the maddening crowd
Join as a member today its FREE
List your holiday accommodation for FREE
----------------------------------------------------------------------------
--------------------
- Next message: Jeff 'Japhy' Pinyan: "Re: Writing to file"
- Previous message: R. Joseph Newton: "Re: I did it!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|