in reply to Writing unix-style filters
^C For example, the unix program cat, which is functionally pretty simple, will do exactly what you are doing, i.e. check for arguments on the command line, but it will also parse the command line for options and eliminate any of those as not being files and only if non-option syntax is found will it process it as a file rather than reading from STDIN.
^I Thus cat -b will be interpreted as an option but no file arguments and read from STDIN rather than trying to open a file called -b.
^P Fortunately, modules Getopt::Std and Getopt::Long will do the legwork of that for you (^I they handle two different styles of command line options from which you should choose in advance).
Key to hats: ^I=white ^B=black ^P=yellow ^E=red ^C=green ^M=blue - see Moron's scratchpad for fuller explanation.
^M Free your mind
|
|---|