Mailing List Archive

Catalog Building Tutorial - perl question
This isn't an Interchange specific question but if any of you Perl guru's
out there can answer this for me I would be very grateful.

In the Catalog-Building Tutorial on page 34 there is some code that looks
like so:

for ($year .. $year + 7) {

What does the '..' do. I could ot find it in any of my perl books (or maybe
i keep missing it). Is it just short hand?

for ($year; $year <= $year + 7; $year++)

thanks
mike k.
Catalog Building Tutorial - perl question [ In reply to ]
Today around 10:32pm, kenshin hammered out this masterpiece:

: This isn't an Interchange specific question but if any of you Perl guru's
: out there can answer this for me I would be very grateful.
:
: In the Catalog-Building Tutorial on page 34 there is some code that looks
: like so:
:
: for ($year .. $year + 7) {
:
: What does the '..' do. I could ot find it in any of my perl books (or maybe
: i keep missing it). Is it just short hand?
:
: for ($year; $year <= $year + 7; $year++)

You got it right.

C<..> is a range operator. You can read about it by typing

perldoc perlop

at the command prompt. It's under the section titled ``Range
Operators''

Replace C<..> with the word ``to'' and you have an english
representation:

foreach ( 1 .. 10 ) {
# code
}

foreach ( 1 to 10 ) {
# code
}

HTH



--
print(join(' ', qw(Casey R. Tweten)));my $sig={mail=>'crt@kiski.net',site=>
'http://home.kiski.net/~crt'};print "\n",'.'x(length($sig->{site})+6),"\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys%{$sig};
my $VERSION = '0.01'; #'patched' by Jerrad Pierce <belg4mit at MIT dot EDU>