May 21, 2003 #1 Flipster MIS Joined Jun 25, 2001 Messages 38 Location US If I have a file containing a single string on each line, how would I load all of the strings into an array? I was mistaken in believing that you can just ... @array = file but that only loads the name of the file. Any help would be appreciated.
If I have a file containing a single string on each line, how would I load all of the strings into an array? I was mistaken in believing that you can just ... @array = file but that only loads the name of the file. Any help would be appreciated.
May 21, 2003 #2 raider2001 Technical User Joined Apr 27, 2001 Messages 488 Location US You have to open the file like this: open(F, $File) or die "Can't open $File: $!\n"; @Array = <F>; close(F); Upvote 0 Downvote
You have to open the file like this: open(F, $File) or die "Can't open $File: $!\n"; @Array = <F>; close(F);
May 22, 2003 #3 greadey Technical User Joined Oct 25, 2001 Messages 231 Location GB You would also do well to remember that you'll have "\n" at the end of each string so remeber to chomp!!! Upvote 0 Downvote
You would also do well to remember that you'll have "\n" at the end of each string so remeber to chomp!!!
May 22, 2003 Thread starter #4 Flipster MIS Joined Jun 25, 2001 Messages 38 Location US Oh, I chomp with the best of 'em. Thanks, though. Upvote 0 Downvote