If (open (myfile, "E: \ Perl \ code \ string. pl ")){
Print ("Success open the file \ n ");
######################################## ####
# Output all of myfile's content 1
######################################## ####
Print (<myfile> );
Print ("=========== 1 ===============\ N ");
######################################## ####
# Output all of myfile's content 2
######################################## ####
@ Array = <myfile>;
Foreach $ I (@ array ){
Print ($ I );
}
Print ("=========== 2 =================\ N ");
######################################## ####
# Output the first line of myfile's content
######################################## ####
$ Line = <myfile>;
Print ($ line );
Print ("=========== 3 ===============\ N ");
} Else {
Die ("cannot open input file E: \ Perl \ code \ string. pl \ n ");
};
# The left value of <myfile> is actually a pointer. If print (<myfile>) is run, the remaining two steps will output any one, because the pointer has reached the end of the file.
# Run @ array = <myfile>; similarly, print ($ line); no output