Perl one-liner: how to skip to the next file in @ARGV -


i thinking how "short circuit" reading file within perl -ne loop. if hit condition, want abandon current file , proceed next 1 in @argv. similar gnu awk's handy nextfile command.

something this:

perl -ne 'do_something(); next_file if some_condition()' files ... 

playing around, found close argv achieves "go next file" goal.

are there other, less magical, ways accomplish this?

nope, close argv right way this.

as noted glenn jackman, has side effect of resetting $. line counter (which continues incrementing across several files when using argv), may want save , restore it:

my $line = $.; close argv; $. = $line; 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -