regex - Perl check for input, otherwise use default -
i perl check command line see if there input files/arguments. otherwise, utilize default file when there no arguments:
#!/usr/bin/perl -w open(input, "<", "./list2") || die "couldn't open list reading: $!\n"; while (<input>) { # print stuff; } close(input);
i've got default file (list2) opened, don't know how check input. i'm thinking of using conditional statement (if argument_exists read input command line; else open default_file). exist in library in perl, or there regular look ?
parameters script held in @argv
. therefore, check if array contains values, , add together desired logic.
you can utilize @argv
reading default file so:
#!/usr/bin/perl -w utilize strict; utilize warnings; @argv = './list2' if ! @argv; while (<>) { # print stuff }
regex perl
No comments:
Post a Comment