Yet another great explanation... thank you! But I still need to know how
to print each specific element # along with its data?
Is this the right way to go for storing each line in its own element???
while $line < FILEHANDLE >
my @tsm = < FILEHANDLE >
foreach $_ (@tsm)
print $_ , "\n";
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
[EMAIL PROTECTED]
04/01/2004 06:02 PM
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
cc:
Subject: Re: using strict
In a message dated 4/1/2004 5:03:40 PM Eastern Standard Time,
[EMAIL PROTECTED] writes:
People of the Perl,
>from my understanding strict disallows soft references, ensures that all
>variables are declared before usage and disallows barewords except for
>subroutines.
>
>what is a soft reference?
A soft reference is a symbolic reference. For example:
$hello = "Hey, what's up?";
$var = "hello";
print $$var; #or, if it helps you see it better 'print ${$var}'
This may be what you want, but may not be (usually you want hard
references), hence use strict 'refs'
>what is a bareword?
A bareword is...a bare...word? Really its just a word not expicitly
denoted to be something. For example:
sub foo { 1 }
foo;
foo is a barewords. In the above case, strict doesn't freak out because
the subroutine is predeclared. But if you just throw around words whenever
you want, it will freak out. For example,
@array = (String, String, String, String);
String is a bareword. strict will throw up an exception so fast.
2 exceptions to the bareword throw-up: left side of '=>' and inside curly
braces. For Example:
%hash = (
left => 'right'
)
print $hash{left};
>why is strict disallowing a compile here.... When I comment out strict
the
>syntax checks outs as ok!???
>how do I display each element # with its corresponding data line, b/c I
>only want certain elements printed out?
People already answered these. On an aside, Your code may compile dandy,
that's not what strict is for. If perl could catch the errors like the
ones you stated, there would be no need for strict. Strict is basically
just so you don't screw up. You don't want barewords because you might
think it means something else. You don't want soft references when you
think you're using hard references. You don't want your code to screw up
and you not to know why cause you used $var on 10,000 of the 20,000 lines
and $Var on the other 10,000.
-will
(the above message is double rot13 encoded for security reasons)
Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone (a Godsend)
-Perl::Tidy
-Beautifier