As far as I can see, the prints for output are going to the console, not a
file.  The statement you're referring to:

__END__
flat2rdb.pl sitelist.str.fo

has very little to do with the perl script.  The __END__ tells the perl
interpreter to not compile/run anything after the __END__ line.  So the
"flat2rdb.pl sitelist.str.fo" has no affect on how the program runs.  It may
be a veiled attempt at a comment?  

>From my brief review of the code, I see that the commented out portion near
the top would have used the command line parameter to open the input file
rather than how it is currently running -- using STDIN to capture a user
entered filename.   

(I'm guessing that the part that choked was that `date '+%Y%m%d%H%M%S'`
shells out to the operating system to call a date program.  This probably
didn't work under windows NT since there isn't a date program under a
standard system.)

I'm assuming that you want the prints that are going to a console to go to a
flat file?  If so you could just use a redirect STDOUT to a file under
windows NT

flat2rdb.pl > myresultfile.dat

??

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 31, 2001 5:42 PM
To: [EMAIL PROTECTED]
Subject: Output to a file.


I've never written a line of perl before ... and I've only been lurking on
the list for three hours or so. But I've been presented some code which was
written for Unix and I'm trying to run on NT using ActiveState Perl.  It
converts a flat file from the USGS to a format we can get into our SQL
database.

It's running right now -- and I'm hoping that it will generate an output
file -- however I see no indication that an output file is being generated
as the program loops (it's been running for three hours or so -- see the
connection?)

the very end of the program are these lines:

__END__
flat2rdb.pl sitelist.str.fo

flat2rdb.pl is the name of the perl code.  When this is done running will it
generate a file called sitelist.str.fo ?  Entire code at end of message.

TYIA

Rob Clayton
WRE-Data/Modeling
City of Austin

ps. I must apologize for the rtf email.  wish that I could deactivate it;
but there are restrictions on that sort of thing here.

#! /usr/bin/perl5
# Program for Chris Herrington
# Convert flatout files to RDB files
# with the format:
# STAID   DATES   TIMES   PARAMETER_CODE   VALUE

#-----------------------------------------------------------
# This command caused program to choke on NT: RC <begin edit>
# Get the date
#chomp($DTAG = (`date '+%Y%m%d%H%M%S'`));

# Get flatfile filename from command line
#chomp($QWFLAT = $ARGV[0]);
# </end edit> Edited out Unix Commands by RC
#-----------------------------------------------------------

# If flatfile filename not on command line prompt for it
if($QWFLAT eq '')
{
    print "Enter QW flatfile file name -> ";
    chomp($QWFLAT = <STDIN>);
}

# Check to make sure file exists
if(! -r $QWFLAT)
{
    print "The file \"$QWFLAT\" not found\?\n";
    exit;
}

open(FLAT, "< $QWFLAT") or die "Can\'t open $QWFLAT file.\n";

while(<FLAT>)
{
#    print "$parmcount\n";
    $line = $_;
    $parmcount='';
    $COL=40;
    $STAID = substr($_, 0,20);
    $STAID=~(s/^\s*(.*?)\s*$/$1/);

    $DATE = substr($_, 20,10);
    $DATE=~(s/^\s*(.*?)\s*$/$1/);
    $TIME = substr($_,30,10);
    $TIME=~(s/^\s*(.*?)\s*$/$1/);
    $VALUE = substr($_,40,10);
    $VALUE=~(s/^\s*(.*?)\s*$/$1/);
    $COL=($COL+10);
#    $crap=<STDIN>;

    print "# $STAID Station Number\n" if($OLDSTNUM != $STAID);
    print "DATE\tTIME\tSTORET\tRESULT\n8D\t4s\t5s\t10n\n" if($OLDSTNUM !=
$STAID);
    open(PARMS, "<${QWFLAT}.parnames") or die "Can\'t open
${QWFLAT}.parnames file.\n";
    while(<PARMS>)
    {
        next if(/^STAID|^DATES|^TIMES/);
        ($PARM, $junk)=split(/\s+/);
        print "$DATE\t$TIME\t$PARM\t$VALUE\n" if(($VALUE !=
-999999)and($VALUE ne ''));
        
        while($VALUE ne '')
        {
            
            while(<PARMS>)
            {
                ($PARM, $junk)=split(/\s+/);
                last;
            }
            $VALUE = substr($line,$COL,10);
            $VALUE=~(s/^\s*(.*?)\s*$/$1/);
            print "$DATE\t$TIME\t$PARM\t$VALUE\n" if(($VALUE !=
-999999)and($VALUE ne ''));
            $COL=($COL+10);
        }
    }
    $OLDSTNUM = $STAID;
}

__END__
flat2rdb.pl sitelist.str.fo

Reply via email to