• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

file lines into array

in the follwing code i open a file and print it to screen
but i also want to place the contents of the file into the
array 'originalone'
but it just puts a load of "_" in there
this is obviously the wrong way to put the file lines into the array
anyone know the correct way?
thanks
paul


open FILE,'<correct.txt' or die "can't open correct.txt because $!";
     $value = 0;
                        while( <FILE> ){
print;
@originalone[$value] = _;
$value = $value +1;
}
close FILE;    
0
paulwhelan
Asked:
paulwhelan
  • 3
  • 2
1 Solution
 
binkzzCommented:
First of all, you don't want to say
@originalone[$value] = _;

But you want to say
$originalone[$value] = $_;


To get it all in an array, the best way really is to do:

open FILE, "<correct.txt";
  @originalone = <FILE>;
close FILE;

print @originalone;

Hope this helps,

McB
0
 
binkzzCommented:
Very weak to withdraw the question to save points, Paul.
0
 
paulwhelanAuthor Commented:
what are u talking about?
i accepted your answer!
0
 
binkzzCommented:
You put a $variable question up which you withdrew seconds after I gave you the chop $variable comment... !
0
 
paulwhelanAuthor Commented:
i never got that answer!
i worked it out myself
i wasnt sure if it was chop or splice and i found it on the web

i can assure u that i didnt see your answer
i have plenty of points and dont need to save them
i dont appreciate being dissed on this site

if points mean that much to you...here...take another 25 for an answer i never saw
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now