Running Perl 5.6.1 on Solaris 9 SPARC No (access to) modules available other than what comes with the basic perl installation.
I have a file: ifiln.csv as such: Julian Day of the year, value 1,4144.34 2,4144.38 3,4144.38 4,4144.38 5,4144.44 6,4144.48 7,4144.48 8,4144.50 9,4144.50 10,4144.48 11,4144.50 12,4144.52 13,4144.52 14,4144.54 15,4144.54 16,4144.56 17,4144.58 18,4144.58 19,4144.60 20,4144.62 ..... 365,4147.42 366,4147.56 (Leap Year) ....OR.... This may be (as shown below) between the current date and the last day of the year or with missing data 331, 332, 333, ... 365, 366, (Leap Year) ---------------------------------- I would like to create a new file: ofiln based on the data in ifiln... Days without values (missing data or future date) would be set as null. If this is run on November 2, 2007 then all days between November 3, 2007 and December 31, 2007 would have a date and a "null value" for parameter value. Passed in as commandline arguments arg1 (ex: 201) arg2 (ex: 11) startdate (2007) - January 1, 2007 The data would be incremented as per column one value of ifiln. The output file should look something like this: insert some text1, 366, insert some text2 201, insert some text3 11, 4144.62, some text4, 2007/11/20, some text5 below is what I have... can someone assist... Thanks *** I do NOT know how to increment (and format as "2007/01/01") date so that it crosses over for each new month and know when it is a leap year. Also, Is they a better way to write this?? *------------------------ #!/usr/bin/perl use strict; use warnings; my $ifiln = 'abc.csv'; my $ofiln = 'xyz.txt'; # get start year (yyyy) from command line my($rsvr, $rdt, $dyr) = @ARGV; print "Year input argument: $ARGV[0] - $ARGV[1] - $ARGV[2]\n"; print "Year input: $dyr, $rsvr, $rdt\n"; my(@data_line, @rsvrs); # start out empty my $line = "default text"; # start with some default text my $cntr = 0; # line cntr open RDATA, $ifiln or die "can not open file: $ifiln: $!\n"; while($line = <RDATA>) { @data_line = split(/,/,$line); $rsvrs[$cntr]{jday} = $data_line[0]; $rsvrs[$cntr]{rval} = $data_line[1]; $cntr++; } close(RDATA); $cntr = 0; open(ORDATA, ">$ofiln"); foreach(@rsvrs) { print ORDATA "insert some text1,"; print ORDATA $rsvrs[$cntr]{jday}; print ORDATA "insert some text2 $rsvr,"; print ORDATA "insert some text3 $rdt,"; print ORDATA chomp($rsvrs[$cntr]{rval}); print ORDATA "some text4"; print ORDATA "Calendar Date 2007/11/20 format - How? ($dyr)"; print ORDATA "some text5\n"; $cntr++; } close(ORDATA); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/