How do I pass parameters into perl through command line?
1970-01-01 00:00:00 UTC
How do I pass parameters into perl through command line?
Three answers:
?
2016-12-08 15:48:11 UTC
in case you have JDK a million.6 or later, it rather is ordinary. jar cfe growth.jar growth growth.classification In "cfe" the "c" says create an archive, "f" says shop in a document (named from the subsequent argument "growth.jar"), and the "e" (for "get admission to element") gadgets the main significant classname to the subsequent argument after than ("growth"). Following those arguments is a catalogue of sophistication archives to contain in the jar. for that reason, it rather is in basic terms "growth.classification". you additionally could make a shortcut in homestead windows that runs a java command on that classname. that's recommended to try this for GUI apps you create employing Swing to ward off the "black window". try this by potential of working "javaw" particularly of "java" with the aid of fact the command to launch the class. suitable-click on the pc (or in yet another folder the place you go with for the shortcut to be), go with New>Shortcut. in the verbal substitute, click Browse... and navigate to the folder with the class or jar document. click on the document, click okay to repeat the completed direction into the region field. Press the homestead key or click on the front of the path call and insert "java " or "java -jar " in front to run with java as a classification or jar document. Prefix with "javaw " or "javaw -jar " to run a GUI app as a classification or jar document. in the journey that your software is console based, undergo in strategies that the console window will close and disappear as quickly with the aid of fact the main significant() function returns. in case you go with for something to stay seen, you have put in a pause for keyboard enter (or a postpone, consistent with probability).
martinthurn
2011-07-05 11:46:51 UTC
I give previous answer thumbs-up for the general case, even though he forgot "use strict; use warnings;" 8-P
If you want to parse options with minus signs, the de facto standard is to use the Getopt::Long module
?
2011-07-05 10:14:20 UTC
my perl isn;t great but if i rememebr right comand line arguments are stored in the array
@ARGV
hope this helps.
Edit yep here's a simple example
#!/usr/bin/perl -w
print "argument 1 $ARGV[0] \n";
print "argument 2 $ARGV[1] \n";
or you can use this to loop through all of them
foreach $s (@ARGV) {
}
^_^
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.