in reply to How to read the file from stdin using perl?

The file handle associated with standard input is STDIN. You need not open it. You can read from this filehandle as you do with your filehandle F.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: How to read the file from stdin using perl?
by gopikavi (Initiate) on May 09, 2017 at 09:44 UTC
    are you suggesting me to pass STDIN instead of filename.

      No. I am suggesting to read the filehandle STDIN as you do with your filehandle F - via the diamond operator "<>" or readline. No need to pass STDIN anywhere.

      $| = 1; # turn on autoflush print "Enter file name: "; my $answer = <STDIN>; chomp $answer; # remove newline char from answer print "file name is '$answer'\n";
      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
        But this wont help my query