> Hi,
>
> This is embarrassing.
>
> All I want to do is read the content of a simple 10 line .txt file
> into an array
> and print out the lines, and I just can't seem to get it to work!
> /*
> $target = "D:\testfile.txt";
> open NEWBIE, "<"$target";
> @arr = <WAWA>;
> foreach $line (@arr) {
> print "$line\n";
> }
> close(NEWBIE)
> */


You have an "@arr = <WAWA>" above???? Anyway, try this, (not tested on
Windows)



#========================================

#/use/bin/perl

use strict;      # always use strict
use warnings;    # helps in debugging

my $target = "D:\testfile.txt";

open (my $NEWBIE, '<', "$target") or die "can't open $target $!\n";

my @arr = <$NEWBIE>;
foreach my $line (@arr){
    print "$line"; # no need for a new line here
 }


#========================================
-- 



Owen


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to