open (IN, "< $file") or warn ("Can't open $file: $!\n"), die; while () { # loop through the file, print ("$file ==> $_"); # read one line at a time } close(IN); #### open (IN, "< $file") or warn ("Can't open $file: $!\n"), die; chomp(my @data = ); # read all lines into array of lines # and get rid of trailing \n's print "$_\n" for @data; close(IN); #### open (IN, "< $file") or warn ("Can't open $file: $!\n"), die; my $data = do { local $/; }; # file slurping print ("$file ==> $data\n"); close(IN);