RE: Writing to file

From: Rob Hanson (rhanson_at_aptegrity.com)
Date: 02/01/04


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
----------------------------------------------------------------------------
--------------------



Relevant Pages

  • Re: Get name and create date of files in a directory
    ... I want to retrieve a list of files AND the file create date and load them ... DirectoryInfo.GetFiles - it returns an array of FileInfo objects, ... DirectoryInfo directory = new DirectoryInfo; ...
    (microsoft.public.dotnet.languages.csharp)
  • Problem formatting text
    ... I am trying to format some text that I retrieve from a DB. ... I load the converted (to string) values in an array and then use the following statement: ...
    (microsoft.public.dotnet.languages.vb)
  • Problem formatting text in a ListBox
    ... I am trying to format some text that I retrieve from a DB. ... I load the converted (to string) values in an array and then use the following statement: ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Get name and create date of files in a directory
    ... Long time developer / total newbie @ C#. ... I want to retrieve a list of files AND the file create date and load them ... into an array for further processing… ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Getting a (non-radio) buttons index number from array
    ... index in the Comment array of the button that was fired. ... you don't need js if you print out the full DOM ... There needs to be some unique way to identify the row in the database. ... Then it's easy to retrieve the ...
    (comp.lang.php)