Printing to a file

From: Kevin Old (kevinold_at_gmail.com)
Date: 10/26/04


Date: Tue, 26 Oct 2004 11:38:25 -0400
To: beginners@perl.org

Hello everyone,

First, this is a basic problem, but I have looked at it for over an
hour and wasted time. Now, I'm asking for help.

For some reason nothing is being printed to the MY filehandle. Can
someone see what I'm doing wrong?

#!/usr/bin/perl
                                                                      
+
use warnings;
use strict;
use File::Find;

find sub {
    return unless -f;
    return unless $_ =~ /.\d+$/;
    print "$_\n";
    #print "$File::Find::name\n";
                                                                      
+
        open(SD, "$_") or die "can't open $_ $!\n";
        #my $fh = IO::File->new("> /tmp/savedata/new/$_") or die "Coul
+dn't open new for writing: $! \n";
        open(MY, "> /tmp/savedata/new/$_") or die "can't open new $_ $
+!\n";
                                                                      
+
                my @sd = <SD>;
                foreach (@sd) {
                        if ( $_ =~ /40187378|40187233|40187230|4018722
+9|40187234|40187232|40186526/ ) {
                                #print "match: $_\n";
                                my $line = $_;
                                print MY $line;
                        }
                }
                                                                      
+
        close MY;
        close SD;
}, ".";

Thanks,
Kevin

-- 
Kevin Old
kevinold@gmail.com


Relevant Pages

  • Re: Printing to a file
    ... Kevin Old wrote: ... > First, this is a basic problem, but I have looked at it for over an ... > hour and wasted time. ... > For some reason nothing is being printed to the MY filehandle. ...
    (perl.beginners)
  • Re: Printing to a file
    ... Kevin Old wrote: ... > First, this is a basic problem, but I have looked at it for over an ... > hour and wasted time. ... Gunnar Hjalmarsson ...
    (perl.beginners)
  • Re: apache 1.3.28-4 on unstable
    ... >>The basic problem is that the modules are inserted into modules.conf in ... >>reverse order. ... For some reason I never saw this message from ??. ... * For God so loved the world that He gave his only begotten Son, ...
    (Debian-User)
  • Re: Driverless vehicle project
    ... >is preparing a HMMWV ... The basic problem with all the designs thus far - and the reason all ...
    (comp.arch.embedded)
  • Re: Driverless vehicle project
    ... >>is preparing a HMMWV ... > The basic problem with all the designs thus far - and the reason all ...
    (comp.arch.embedded)