I need to accept command line arguments from my user who is executing my script (I Do not like to use GetOptions ()
).
I have two variables,
my ($ port_name, $ report); $ Port_name = $ ARGV [0]; $ Report = $ ARGV [1]; If (defined $ port_name) {....} if (defined $ report) {....}
if not as the $ report
flag Given the argument of a command line I do not wish to run the second agar block, how can this be done without PRL give me an error?
Thank you for helping.
Your code should work as expected .....
< Code> hi [root @ matthewharris cpanel] # perl blah.pl 1 en [root @ matthewharris cpanel] # perl blah.pl 1 2 Hino [root @ matthewharris cpanel] # [root @ matthewharris cpanel] # cat blah.pl #! Use / usr / bin / perl strict; Use warnings; Mine ($ port, $ report) = @ARGV; If ($ Port) {Print 'Hi'; } If ($ report) {print 'no'; }
Comments
Post a Comment