STDIN in list context

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • varaprasad yadav
    New Member
    • Apr 2007
    • 1

    STDIN in list context

    i have created an array
    print "Enter a string";
    @list = <STDIN>;
    print @list;
    when i excute this it is always in input mode even though i go to new line by pressing enter or if i try bypressing ctrl z
  • theJade
    New Member
    • Apr 2007
    • 5

    #2
    Are you using Linux or Windows? In Linux, I believe the EOF character is indicated by Ctrl-D. In Windows, it's Ctrl-Z.

    If you want the print to return upon pressing enter. Store the input into a scalar as such:

    Code:
    my $temp = <STDIN>;
    print "$temp";

    Comment

    • savanm
      New Member
      • Oct 2006
      • 85

      #3
      Hi,

      The array size is not mentioned so that it doesn't know which element
      is last, so that it doesn't print anything. So u must give Ctrl+Z to terminate,
      then it wl show the result..
      Thanks

      Comment

      Working...