Perl save stdin to file




















Strangely, the OPs code worked fine for me unmodified. That was my guess too, an omission that MillerH's code handles neatly. How do you signal EOF? Ctrl-D on a blank line. It doesn't, the Ctrl-D is supplied by the user entering the data. Ohhh ok I understand now!!!

Thank you so much for this nuance I did not know. For completeness, we should mention that this is true on Unix-like systems. Though the! Red Flag This Post Please let us know here why this post is inappropriate.

Read on. Before you launch your favourite text editor and start hacking Perl code, you may just need to redirect the program output in the terminal. If a terminal redirect is not specific enough for your needs, you can use one of the following Perl solutions. This makes it easy to globally redirect and restore standard output. The local function creates a lexically-scoped copy of any variable passed to it. This copy can then be restored when required. Scalar context operator will read the line which was entered from the keyboard along with the new line character in perl.

We have taken input as age from the user. We have removed new line character by using chomp. Chomp function removes the new line character from the code. The STDIN will read the line entered from the keyboard along with the new line character and special character corresponding with the enter key which we have pressed after input. It is very useful in perl. Sign up using Facebook. Sign up using Email and Password.

Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked



0コメント

  • 1000 / 1000