Why is my Perl program not reading from the input file? -


i'm trying read in file:

oranges apples bananas mangos 

using this:

open (fl, "fruits"); @fruits  while(<fl>){ chomp($_); push(@fruits,$_); }  print @fruits; 

but i'm not getting output. missing here? i'm trying store lines in file array, , printing out contents on single line. why isn't chomp removing newlines file, it's supposed to?

i'm guessing have dos-style newlines (i.e., \r\n) in fruits file. chomp command works on unix-style (i.e., \n.)


Comments

Popular posts from this blog

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -

Java - Returning an array from a method to main -