1. Single Line (large file processing ):
Copy codeThe Code is as follows: my $ oneline = <$ FL> or
While ($ line = <H>)
{}
2. Read all (small File Processing ):
Copy codeThe Code is as follows: open (my $ in, "path") or die "open error: $! ";
My @ lines = <$ in>;
3. Read 3 rows (large files and special processing needs ):
Copy codeThe Code is as follows: open (my $ in, "path") or die "open error: $! ";
My @ lines;
Push (@ lines, scalar <$ in>) for (1 .. 3 );
4. read three rows by condition each time and output two rows by condition. Or modify the settings as required.
Copy codeThe Code is as follows: while (<TEST> ){
If (index ($ _, "=")>-1 ){
My $ position = tell (TEST );
My $ keyword_line =$ _;
My $ line_1 = <TEST>;
My $ line_2 = <TEST>;
# @ A = split //, $ keyword_line; check whether their elements are equal.
# @ B = split //, $ line_1; use if ($ a [0] eq $ a [0]) to determine
# @ C = split //, $ line_2;
If ($ line_2) & (index ($ line_2, "=")>-1) {# Or if ($ line_2 = ~ // = /)
Print OUTFILE "$ _ $ line_1 ";
}
If (! ($ Line_2) {print OUTFILE "$ _ $ line_1"; last ;}
Seek (TEST, $ position, 0 );
}
}