Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Need help appending to a user defined file

by toolic (Bishop)
on Sep 19, 2012 at 20:06 UTC ( #994521=note: print w/ replies, xml ) Need Help??


in reply to Need help appending to a user defined file

You want to open a filehandle, not an array of file names. You should print to a file handle, not to STDOUT.

use warnings; use strict; my $file2 = '/tmp/foo'; print "Enter filename to search\n"; chomp( my $file = <STDIN> ); if ( -e $file ) { die "File already Exists!\n"; } unless ( -e $file ) { my @appfiles = glob "*"; open my $fh, '>>', $file2 or die $!; print $fh "List of all the files in the directory:\n"; print $fh "@appfiles\n"; close $fh; }

See also the Basic debugging checklist


Comment on Re: Need help appending to a user defined file
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994521]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (14)
As of 2015-07-06 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls