Databases Reference
In-Depth Information
Adding a minus (
-
) symbol immediately after the percentage symbol makes the display
left-aligned. For example the statement:
printf("\n%15s", "hello");
would display:
(ten spaces)
hello
whereas adding the minus symbol as shown here:
printf("\n%-15s", "hello");
would display:
hello
(ten spaces)
It's typical to display numbers right-aligned, and to display text left-aligned.
Resources
To learn more about Perl, we recommend these resources:
• The Perl.org page for people learning Perl (
http://learn.perl.org
)
•
Learning Perl
by Randal L. Schwartz et al. (O'Reilly)
• The Comprehensive Perl Archive Network web site (
http://www.cpan.org
)
Exercises
1. What are the strengths of Perl?
2. What is the difference between an array and a hash?
3. What does the following Perl script do?
#!/usr/bin/perl
use strict;
my $Answer;
while(@ARGV)
{
$Answer+=shift(@ARGV);
}
print "Answer: $Answer\n"