Patricia E Gorden-Ozgul wrote: > I need help with my $date var. I want it to print at the sixth printf > position. Can someone help? > > Pat Gorden-Ozgul > [EMAIL PROTECTED] > > Input: > > 18033|18033|89.00|1|182682|20021011|89.00|1|0|0000070001|19724|FIRM| > 03046|03046|135.93|1|67579558|20020927|135.93|1|0|0000070097|90081|FIRM| > 08830|08830|88.38|1|182824|20021017|154.26|2|0|0000070001|12435|FIRM| > 03121|03121|558.81|1|182985|20021022|558.81|1|0|0000070001|15139|FIRM| > 04500|04500|61.89|1|182988|20021023|61.89|1|0|0000070001|17893|FIRM| > > Code: > > #!/usr/bin/perl -w > # > # Parse input from invoice file and split into three output files > # PGO March 2003 > # must run inv_sed against datafile (file9.final) to remove $ > > # my $date = `date +%Y%m%d`; > my $datafile = "invshrt"; > open DATA, "< $datafile" || die "Can't open data file: $datafile"; > > while(<DATA>) { > chomp; > my $date = `date +%Y%m%d`; > my @data = split('\|'); > printf "%-2s%-16s%-8s%-10s%-10s%-7s%-11s%-154s%-7s\n", > "", $data[4], $data[5], $data[9], "", "", $date, "", $data[6]; > } > close DATA; > > exit 1;
Hi Patricia. Rather than use the system command 'date' (which I can't help you with anyway!) how about the following, which uses the Perl built-in 'time' to get the current date. my $date = do { my @ymd = (localtime(time))[5,4,3]; $ymd[0] += 1900; $ymd[1] += 1; sprintf "%04d%042%02d", @ymd; }; which currently gives a value of '20030314'. But do you mean that want it to print at the sixth field of your printf format? This is '%-7s' which is only seven characters wide, while the seventh field (where your $date appears in the parameter list) is formatted as '%-11s'. What exactly is it that you want? Come back if you need any more help. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]