in reply to Re^2: Editing a text file
in thread Editing a text file

When a script has a print command in it, how can you send that to a file?

From inside the script, you can print to any file that's been opened for output just by specifying the filehandle in the print command, before the first argument:

open SOMEFILE, '>', $filename; # Then... print SOMEFILE "Blah, blah, blah";

Alternately, from outside the script, when calling it, most operating environments provide a way to redirect the standard output of the script to a file. For instance, in a POSIX-like environment you can use tee or a shell redirection operator (usually > in most Unix-style shells, and also in DOS, OS/2, and NT, among others). If you need more specific information about this, you'll have to specify more details about your operating environment.


Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. You can just call me "Mister Sanity". Why, I've got so much sanity it's driving me crazy.

Replies are listed 'Best First'.
Re^2: Editing a text file
by appletag (Initiate) on Nov 21, 2006 at 12:19 UTC
    Thanks, The code everyone is submitting, some Google, and maybe a book and I think I'm closer to understanding perl. I'm really looking forward to all the cool things I should be able to do with some "Perl Wisdom".