Can someone explain what this does? Is this some Perl or Tcl thing? Unfortunately I've never used either :)
Can someone explain what this does? Is this some Perl or Tcl thing? Unfortunately I've never used either :)
undef is both a function and a (non) value. It is the main reason Little never got pushed back into tcl, the tcl crowd hates the idea that there can be a value for a variable that is undefined. I found that very useful, for example, undef is the error return from any function. Just made sense to me, didn't make sense to the Tcl people.
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]");
}