in reply to Newbie Script

Try this:
#!/usr/bin/perl -w use strict; my $filename = shift || "Fav_mov.txt"; open (FILE, ">>$filename") or die "can't open $filename: $!\n"; print "Your favorite movie: "; my $line = <>; print FILE "$line"; print "Thank you!\n"; close(FILE);
Comments:
use strict and warnings, is safer.
To append to any file, use ">>$filename"
If you want to write to a filehandle, you have to specify it; if you don't do it, you'll be writting to STDOUT (or select it).
Remember that if you select FILE, you should specify STDOUT to print "Thank you!\n".
Hope this helps


Hopes
$_=$,=q,\,@4O,,s,^$,$\,,s,s,^,b9,s, $_^=q,$\^-]!,,print

Replies are listed 'Best First'.
Re: Re: Newbie Script
by apocrates (Initiate) on Nov 21, 2001 at 22:15 UTC
    Thank you for all your help! :)