in reply to Reading DIR content and printing it

The backslash is special within strings. See perlop. If you had run your code with warnings enabled, Perl would have told you so:

Unrecognized escape \A passed through at -e line 1. Unrecognized escape \D passed through at -e line 1. Unrecognized escape \S passed through at -e line 1.

Either properly escape the backslash (see perlop, or use forward slashes to separate the directories.

Replies are listed 'Best First'.
Re^2: Reading DIR content and printing it
by manishrathi (Beadle) on Jul 17, 2011 at 10:59 UTC
    Thanks, And why would I not get output, when there is no "\" ?
    open file, "< readfile.txt"; @filecontent = <file>; for $f (@filecontent){ print "$f \n" ; } close file;

      In addition to checking for errors, $f has a newline at its end. Again, if you had used warnings, Perl would have told you so:

      Unsuccessful open on filename containing newline at -e line 1.

      Also, when printing out values, always put delimiters around them so you see whitespace:

      print "[$f]\n";
      check for errors:
      open file, "< readfile.txt" or die "Unable open file: $!";