On Dec 20, Beauty said:
>I figure if I never ask anything, I'll never learn...
>So here's my first post to the list. What is strict?
Perl is a good language for laziness. What I mean by this is, unlike
languages like C and Java, you can just use a variable whenever you want,
and it will come into being. Compare:
# perl
print "Enter two numbers: ";
($x, $y) = <STDIN> =~ /(\d+)\D+(\d+)/;
$z = $x + $y;
with
/* C */
int x, y, z;
printf("Enter two numbers: ");
scanf("%d %d", &x, &y);
z = x + y;
That's just a minor example.
Anyway, Perl lets you make variables up whenever you need them -- no
declaration necessary.
However, you can make Perl a little more wary of your code by telling it
to
use strict;
The behavior is three-fold, and is documented in 'perldoc strict'. The
primary purpose is to require all variables be declared (most often with
'my') so that their scope is known. By scope, I mean the lifetime of a
variable, the area where that variable exists.
use strict;
my $x = 10;
my $y = 20;
{
my $x = 30;
$y = 40;
}
# $x is back to 10 now
# but $y is still 40
That's a very brief description. I'm sure there's a wealth of information
in this mailing list's archives.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]