in reply to script not working

Hi mate please check the following, just change the path since I work on Windows.
#!/usr/bin/perl use strict; use warnings; open (file1, "file1.txt"); my @lines1= <file1>; my $fivefirstfile1= substr($lines1[2], 0, 5); print "Five first characters are:", $fivefirstfile1, "\n"; # print "Five first characters are: $fivefprot1\n";

Replies are listed 'Best First'.
Re^2: script not working
by Anonymous Monk on Dec 27, 2012 at 16:50 UTC

    just change the path since I work on Windows.

    forward slashes work even on windows

      thanks. Didnīt know.
Re^2: script not working
by ww (Archbishop) on Dec 27, 2012 at 20:36 UTC

    Wrong, wrong, wrong! You still have the original error in the array_element's index... and your reply duplicates what's offered (one hopes, "with good intent," but with the same mistake) above.

    Please, test your answers. Any other approach runs a serious chance that you'll be providing bad guidance to future readers.

    <rant> ... especially when XP-whoring leads the careless to upvote your node.
    aaaAAARGH!</rant> &cv():#r$!!

      the code was tested, and the index should be 1 instead of 2, since start with 0 and the outcome is Line#2. In that you are right. But, the code works!!!

      Happy new year.

      Take lots of deep breaths, not everyone plays XP :)