On 12-02-17 10:32 AM, lina wrote:
#!/usr/bin/perl

use warnings;
use strict;

open FILE, "<try.xpm" or die $!;

my @line =<FILE>;

while (<FILE>) {
        print $_;
}

strangely it print me nothing out,

Try:

#!/usr/bin/perl

use warnings;
use strict;

# place the file name in a variable
# so that it can be easier changed later
my $file = "try.xpm";

# open with a lexically-scoped file handle
# to avoid name collisions with other file handles
open my $fh, '<', $file or die "could not open $file: $!\n";

# read each line into a appropriately named variable
while( my $xpm_line = <$fh> ){

    # for demo purposes; this will be replaced later with more code
    print $xpm_line;

} # end while <$fh>

__END__

--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

It's Mutual Aid, not fierce competition, that's the dominate
force of evolution.  Of course, anyone who has worked in
open source already knows this.

--
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