SPUG: running script with the variables on the same line
Tim Maher
tim at consultix-inc.com
Mon May 30 09:53:08 PDT 2005
On Mon, May 30, 2005 at 10:37:18AM -0600, Medrano-Zaldivar, L E wrote:
> I really appreciate all your mails and actually I found code example
> of what I was looking for:
Here are some additional tips: always use the -w invocation option,
so you'll get free warnings about your mistakes:
> #!/usr/bin/perl
#!/usr/bin/perl -w
and if you want to avoid typing \n at the end of every print statement
for the rest of your Perl career 8-{, and doing manual "chomp"ing,
add the -l option too:
#!/usr/bin/perl -wl
> print "My name is $0\n";
Now this will work just like the one above:
print "My name is $0";
With -l in effect, if you don't want a carriage return at the end of
an output string, such as a prompt, you can use printf rather than print:
printf "Please enter your name: "; # no carriage return emitted
-Tim
*--------------------------------------------------------------------------*
| Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX |
| tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
| Watch for my Summer, 2005 book: "Minimal Perl for UNIX/Linux People" |
| See http://manning.com/Maher for details, and email notification signup |
*--------------------------------------------------------------------------*
More information about the spug-list
mailing list