Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: script not working

by Anonymous Monk
on Dec 27, 2012 at 11:59 UTC ( [id://1010505]=note: print w/replies, xml ) Need Help??


in reply to script not working

add use autodie;

Replies are listed 'Best First'.
Re^2: script not working
by samwyse (Scribe) on Dec 27, 2012 at 12:15 UTC
    Or even better, use strict; as shown here:
    #! perl -w use strict; my @lines1= <DATA>; print "number of lines = $#lines1\n"; my $fivefirstfile1= substr($lines1[2], 0, 5); print "Five first characters are: $fivefprot1\n"; __DATA__ First line of the file. Second line of the file. Third line of the file. Fourth line of the file. Fifth line of the file. Sixth line of the file.

      That will still not work, except this line print "Five first characters are: $fivefprot1\n";is changed to print "Five first characters are: $fivefirstfile1\n";
      variable $fivefprot1 requires explicit package name.

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me

        I think that was the anonymous poster and samwyse's point, that it still wouldn't work but then the OPer would be able to find the problem from the messages.

        samwyse's version using test lines in DATA would also demonstrate to the OPer that there was an off by one error in the array index.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1010505]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-29 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found