I'm new to perl, and I wonder what this line of code mean?
($q,$dummy, $d,$v) = split;
I search through google, but i found no explanation of using split without argument, does this kind of use related to the "while" block?
And the full code fragment is:
open(T,"$opt_judgments") || die "can't open judgment file: $opt_judgments\n";
while (<T>) {
if ($opt_trec) {
($q,$dummy, $d,$v) = split;
} else {
($q,$d,$v) = split;
}
$dict{$q ."=".$d} =$v;
if ($v != 0) {
$totalRels{$q} ++;
}
}
Perl | split() Function. split() is a string function in Perl which is used to split or you can say to cut a string into smaller sections or pieces. There are different criteria to split a string, like on a single character, a regular expression(pattern), a group of characters or on undefined value etc..
Dummy-spit definition Filters. (idiomatic) The act of overreacting (as an adult) to a situation childishly, in an angry or frustrated manner.
Split (Split function is used to split a string into substring) /pattern/ (Pattern is used to split string into substring.) Split (Using split function divide string into substring) /pattern/ (We have used pattern to split string into substring.), Expression (Expression name used to split string.)
How can we split a string in Perl on whitespace? The simplest way of doing this is to use the split() function, supplying a regular expression that matches whitespace as the first argument.
It splits the current line ($_
) on whitespace. Quoting the manual:
If EXPR is omitted, splits the $_ string. If PATTERN is also omitted, splits on whitespace (after skipping any leading whitespace).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With