3 ms·
The same shortcut syntax that people complain about does make perl really handy for one-time tasks where you're iterating on ideas. Lots of features there that
by tyingq 3y ago
The same shortcut syntax that people complain about does make perl really handy for one-time tasks where you're iterating on ideas. Lots of features there that make that easy. One example:
#!/usr/bin/perl
while (<>) {
# various processing here
# $ARGV is set to either "-" for piped input, or the current filename
# $_ is the data of the current line
}
That (<>) construct accepts data from stdin, redirection or file(s) named as arguments and iterates over the data. There's lots of things like that throughout the language.
- jandrese 3y agoAnd you can avoid even that minor boilerplate with the -n or -p flag. It even supports BEGIN and END like awk.