3 ms·
It's not a Perl thing. In Perl, that would set argv[1] to undef. It would not delete or left-shift @ARGV. There is a delete() function that acts similarly, b
by tyingq 6y ago
It's not a Perl thing. In Perl, that would set argv[1] to undef. It would not delete or left-shift @ARGV. There is a delete() function that acts similarly, but is discouraged to use on regular arrays. Shift() would be more appropriate in this case.
Given the context, in little-lang, it appears to delete argv[1] and shift all of the right of that down, such that argv[2] becomes argv[1] and so on. That's so that the the "while (buf = <>)" construct used right below it doesn't process the regex as if it were a file to "grep" through.
In Perl, you would typically do it this way...
if (!defined(my $regex=shift(@ARGV))) {
die("usage: grep regexp [files]");
}