On Monday 10 December 2007 21:50, John Jack wrote:
>
> Hi Group

Hello,

> I'm new to perl and haven't used it before. I'm still practising and
> trying my best to know it. Anyway, I wanted to print the list of
> files in a directory with their full pathnames. This script below
> worked fine but I want to write it to a file. Can someone help me,
> please? I know it must be very simple but as I said I very new to
> programming and perl is my new programming language to learn.


#!/bin/perl
use warnings;
use strict;

use File::Find;

my $ByteCount = 0;

open OUTFILE, '>', 'c:/perl/output.txt'
    or die "Can't open output.txt: $!";

find( \&pits, 'W:/Users/PACLAWMAT/PACIFIC TREATIES' );

print "Files are using $ByteCount bytes\n";

# Subroutine that determines whether we matched the file extensions.
sub pits {
    if ( /\.doc$/ ) {
        print OUTFILE "$File::Find::name\n";
        $ByteCount += -s;
        }
    }

close OUTFILE;

__END__



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to