May 21, 2003 #1 Flipster MIS Jun 25, 2001 38 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 Apr 27, 2001 488 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 Oct 25, 2001 231 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 Jun 25, 2001 38 US Oh, I chomp with the best of 'em. Thanks, though. Upvote 0 Downvote