Re: Standard input errors



elite elite am Dienstag, 26. September 2006 20:16:
Here are my error:

Instead of the line

use warnings;

you can use

use diagnostics;

which gives you a more verbose explanation of errors!

The documentation for both you can get by (from the cmdline prompt):

perldoc warnings;
perldoc diagnostics;

(after "perldoc" you can put anything that you use after a

use ...

line.


[syntax@localhost ~]$ perl hello.pl
String found where operator expected at hello.pl line
15, near "print ""
(Might be a runaway multi-line "" string starting on
line 11)
(Missing semicolon on previous line?)
Backslash found where operator expected at hello.pl
line 15, near "print "\"
(Do you need to predeclare print?)
Backslash found where operator expected at hello.pl
line 15, near "address\"
String found where operator expected at hello.pl line
15, at end of line
(Missing semicolon on previous line?)
syntax error at hello.pl line 15, near "print ""
Global symbol "$address" requires explicit package

This error is a result of the

use strict;

line in your program. But *don't* eliminate it from the script, it forces you
to declare all variables that you use. Most of the time, a variable is
declared with a "my " preceeding the variable at the point it is introduced
(mentioned the first time).

name at hello.pl line 11.
Global symbol "$name" requires explicit package name
at hello.pl line 11.
Can't find string terminator '"' anywhere before EOF
at hello.pl line 15.

Sometimes the error *is* not at the line mentioned in the error message; it
tells you at which line perl has *detected* the error, this may be some or
even many lines below :-)

Go trough the error messages from top to bottom, and correct the errors from
top to bottom (not the other way round - generally).

here my code.I not sure what i did wroung here.

#!/usr/bin/perl

use strict;
use warnings;

my $street='Wright';
print "$street\n";
$street='Washington';
print "$street\n";
print "One major street in madison is Washington\n";

or, since you created a variable for the street:

print "One major street in madison is '$street'\n";

(I'm not from there, but isn't there a Madison street in Washington? ;-)

print "enter your address"/n";
my $address

$name =<>;

The above lines are a bit messy, arne't they?
You ask for the address and save it in a variable which most people expect to
contain a name...

print "\nPerl has received your address\n";

Give a feedback:

print "\nPerl has received your address:\n$address";

:-)

Dani
.



Relevant Pages