If you call, return the remaining records in the file. If you are at the end of the file, an empty table is returned:
@records=;
if(@records){
PRint"Therewere",scalar(@records),"recordsread.n";
}
at In the next step, assignment and testing are performed:
if(@records=){
print"Therewere",scalar(@records),"recordsread.n";
}
chomp() also Applicable array operations:
@records=;
chomp(@records);
For any expression, chomp operation can be performed, so you can write like this in the next step:
chomp(@records =);
What is a record?
The default definition of a record is: "row".
The definition of the record is controlled by the $/ variable, which stores the separator of the entered record. Because the newline character (by definition!) is used to separate lines, its default value is the string "n".
For example, you can replace "n" with any symbol you want to replace.
$/=";";
$record=;#Read the next record separated by semicolon
$/ can take on two other interesting values: empty string ("") and undef
above This is the classic usage of Perl: reading the contents of multiple records. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!