RE: How to use command-line switches...
No problem, glad to help. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 1:56 PM To: Miller, Joseph S; [EMAIL PROTECTED] Subject: RE: How to use command-line switches... Thank you! This is exactly what I need. The 17 pages in the PERLDOC lib info on Getopt::Long were a bit daunting/intimidating and for me like driving a nail with a shotgun This sample code gives me a really good example that shows the concept! Thank you for sharing it! -Original Message- From: Miller, Joseph S [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 2:48 PM To: Copits Richard; [EMAIL PROTECTED] Subject: RE: How to use command-line switches... Richard here is an example of code that gets the switch variables from the command line and checks it before continuing with the script. The shift function is operating on the @_ array and the @_ array contains the parameters passed to that subroutine from the command line(reference perlvar). my $switch = shift; if($switch eq "" or $switch =~ /-u/i) { print "$usagestring"; exit 1; } elsif ($switch =~ /-p/i) { $portnum = shift; } elsif ($switch =~ /-d/i) { $dbalias = shift; } else { print "Invalid argument passed. Try again.\n$usagestring"; exit 1; } Hope it helps. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 1:04 PM To: [EMAIL PROTECTED] Subject: How to use command-line switches... I have a case where I need to use a command-line switch such as -X or /x Could anyone help me with information as to how I read this into a perl script and test it - along the lines of "if "/x" then..." ?? I've searched but can't seem to find any concrete example that a newbie like me can use as a sample. Thank you!! Portions of this message may be confidential under an exemption to Ohio's public records law or under a legal privilege. If you have received this message in error or due to an unauthorized transmission or interception, please delete all copies from your system without disclosing, copying, or transmitting this message. Portions of this message may be confidential under an exemption to Ohio's public records law or under a legal privilege. If you have received this message in error or due to an unauthorized transmission or interception, please delete all copies from your system without disclosing, copying, or transmitting this message. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to use command-line switches...
Richard here is an example of code that gets the switch variables from the command line and checks it before continuing with the script. The shift function is operating on the @_ array and the @_ array contains the parameters passed to that subroutine from the command line(reference perlvar). my $switch = shift; if($switch eq "" or $switch =~ /-u/i) { print "$usagestring"; exit 1; } elsif ($switch =~ /-p/i) { $portnum = shift; } elsif ($switch =~ /-d/i) { $dbalias = shift; } else { print "Invalid argument passed. Try again.\n$usagestring"; exit 1; } Hope it helps. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 1:04 PM To: [EMAIL PROTECTED] Subject: How to use command-line switches... I have a case where I need to use a command-line switch such as -X or /x Could anyone help me with information as to how I read this into a perl script and test it - along the lines of "if "/x" then..." ?? I've searched but can't seem to find any concrete example that a newbie like me can use as a sample. Thank you!! Portions of this message may be confidential under an exemption to Ohio's public records law or under a legal privilege. If you have received this message in error or due to an unauthorized transmission or interception, please delete all copies from your system without disclosing, copying, or transmitting this message. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: slash
Susan, Try: $dir = '//ITC/home/techs'; Your first example should have worked. You didn't need to put additional set of quotes around the string like you did in the latter examples. -Original Message- From: Susan Aurand [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 25, 2003 9:34 AM To: beginners Subject: slash If I want the following field to contain forwarded slashes - this is for a linux box, as follows. $dir="//ITC/home/techs"; How do I get the forward slashes in there? I have tried: $dir ="'//ITC'"; $dir ='"//ITC"'; $dir =`"//ITC"`; Nothing works. Help. Thank you - Susan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: system function
What happens when you include the path? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, June 16, 2003 11:27 AM To: [EMAIL PROTECTED] Subject: system function I'm trying to execute a perl script with system("sendscript.pl"); I also tried exec("sendscript.pl"); Both of these return Error: No such file or directory The sendscript.pl is in the same directory as the script. What am I doing wrong? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl -w odd error
You need to do a loop of some sort and extract the data from the file try: open (CNTFILE, "${OUTPUTFILE}") or die "Can't open ${OUTPUTFILE} : $!"; for ($i= 0; ; $i++){ $file_date = $_; $FILE[$i]= $file_data; } close(CNTFILE); -Original Message- From: Yacketta, Ronald [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2003 12:05 PM To: [EMAIL PROTECTED] Subject: Perl -w odd error Folks, I have the following block of code: open (CNTFILE, "${OUTPUTFILE}") or die "Can't open ${OUTPUTFILE} : $!"; @FILE=; close(CNTFILE); Which reports this warning: Name "main::CNTFILE" used only once: possible typo at ./OrderTakingTree.pl line 151. I am just opening the file, slurping it in and closing it. Whats the prob? -Ron -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]