in reply to Re^2: The day before a specific date
in thread The day before a specific date

Good grief, not again! tybalt89 kindly provided you with sample code (doing your job for you, you ought to have posted sample code in your original question). Now, instead of posting code based on tybalt89's superb code, you again post a short paragraph of text!

You should have taken the time to post a reply showing the exact program you ran (based on tybalt89's code), the exact output you saw (which you say "doesn't work"), and the exact output you need for it to "work".

For more background on where I'm coming from, please read:

Replies are listed 'Best First'.
Re^4: The day before a specific date
by jpys (Novice) on Jun 01, 2023 at 11:26 UTC
    Sorry tybalt89 and others. Here is the table that this will fit into. $dsrd = the date the script will provide.
    print "<tr><td colspan=12 class=\" f-width td-border0\"><label name=\" +Rep_name\" size=\"45\" class=\"font-large font-faceA\">REPORT NAME: & +nbsp; <B>$Rep_name</label></B></td></tr>\n"; #print "<td class=\"s-width td-border0\"><span name=\"Rep_name\" type= +\"text\" value=\"$Rep_name\" size=\"10\" class=\"font-large align-cen +ter\" /></td></tr>\n"; print "<tr><td colspan=12 class=\"l-width td-border0\"><label name=\"D +srd\" size=\"35\" class=\"font-large font-faceA\">DAILY SALES REPORT +DATE: <font face=arial size=2><B>(Enter date as \"MM/DD/YYYY\")</B></ +font></label></td>\n"; print "<td class=\"l-width td-border0\"><input type=\"text\" name=\"Ds +rd\" value=\"$Dsrd\" size=\"10\" class=\"font-large align-center\" /> +</td></tr>\n"; print "<tr><td colspan=12 class=\"m-width td-border0\"><label name=\"D +sr_notes\" size=\"25\" class=\"font-large font-faceA\">DAILY SALES RE +PORT NOTES: &nbsp; &nbsp; <input type=\"text\" class=\"font-large fon +t-faceA\" name=\"Dsr_notes\" size=\"20\" value=\"$Dsr_notes\"></td>< +/tr>\n"; &get_yesterday; open(RPTDET, "<reports/amdsrdet.txt") or die "Cannot open amdsrdet.txt +"; flock RPTDET,2; seek(RPTDET,0,0); @rptdet = <RPTDET>; close(RPTDET); foreach $line (@rptdet) { $r_line = split(/\n/,$line); ($rpt_dt,$dsrd,$rpt_nts,$dsr_notes,$repcr_dt,$repcr_date,$rpt_cd,$ +rep,$sess_nbr,$session,$rpt_usr,$user,$tdy_pre_coh,$pre_coh,$td_sls_d +,$td_sls,$tot_exp_d,$tot_exp,$fin_coh_d,$fin_coh,$tdy_grpft_d,$tdy_gr +pft,$cash_xfr_desc,$cash_xfr_d,$cash_xfr_v,$tdy_cscnt_d,$tdy_custcnt, +$groc_d,$groc,$meats_desc,$meats_d,$meats_v,$fish_desc,$fish_d,$fish_ +v,$rice_d,$rice,$trans_d,$trans,$phwf_d,$phwf,$elec_d,$elec,$wtr_bill +_d,$wtr_bill,$loan_d,$loan,$pyrlA_desc,$pyrlA_d,$pyrlA_v,$van_desc,$v +an_d,$van_v,$legal2_desc,$legal2_d,$legal2_v,$legal3_desc,$legal3_d,$ +legal3_v,$misc1_desc,$misc1_d,$misc1_v,$misc2_desc,$misc2_d,$misc2_v) + = split(/\,/,$r_line); if($dsrd eq $yesterday) { $Lcoh = $pre_coh; }else { next; } } print "<tr><td colspan=12 class=\"l-width td-border0\"><label name=\"L +coh\" size=\"35\" class=\"font-large font-faceA\"> LAST CASH ON HAND: + </label></td>\n"; print "<td class=\"s-width td-border0 font-faceA font-large align-cent +er font-bold\" name=\"Lcoh\" type=\"text\" value=\"$Lcoh\" size=\"10\ +">$Lcoh</td></tr>\n"; print "<tr><td colspan=12 class=\"l-width td-border0\"><label name=\"P +re_coh\" size=\"35\" class=\"font-large font-faceA\"> CURRENT CASH ON + HAND: <font face=arial size=3><B>(Enter as 000.00)</B></font></label +></td>\n"; print "<td class=\"s-width td-border0\"><input name=\"Pre_coh\" type=\ +"text\" value=\"$Pre_coh\" size=\"10\" class=\"font-large align-right +\" /></td></tr>\n"; print "<tr><td colspan=12 class=\"f-width font-medium2 td-border0 font +-faceT font-red font-bold\">Enter \"Current Cash on Hand\" Amount or +you will have to start over!</td></tr>\n"; print "<P><tr><td colspan=12 class=\"l-width td-border0\"><label name= +\"User\" size=\"35\" class=\"font-large font-faceA\">REPORT WRITER:</ +label></td>\n"; print "<td class=\"s-width td-border0 font-faceA font-large align-cent +er font-bold\" name=\"User\" type=\"text\" value=\"$User\" size=\"10\ +">$User</td></tr></table>\n";
    The $yesterday I am seeking will allow me to go back into data file and find what I need to provide for the report created by the table here. Thanks.

      Thank you for posting your code.

      A good first step is to reduce the code to the minimum code needed for reproducing the problem. This helps us understand the code quicker, and likely it also helps you to understand the structure of your code better.

      Can you please post the code without the HTML generation as a new reply, to your node? The generation of an output file is likely also not relevant to the problem.

        Hello Corion, Earlier I received a piece of code in part like this:

        #!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11152433 use warnings; use Time::Piece; use Time::Seconds; { print "MONTH is first, then DAY. That is: MM/DD/YYYY\n"; @ARGV = '05/01/2023'; # MONTH comes first my $t = Time::Piece->strptime("$ARGV[0] 12", "%m/%d/%Y %H"); my $daybefore = ($t - ONE_DAY)->mdy("/"); printf <<END, $ARGV[0], $daybefore; Date as supplied: %s Date minus one day: %s END }
        download Outputs: MONTH is first, then DAY. That is: MM/DD/YYYY Date as supplied: 05/01/2023 Date minus one day: 04/30/2023

        As I attempted to comment before, this works perfectly but I don't have the luxury of manually entering the date as shown. (@ARGV = '05/01/2023';) My script provides the date in a string. From there I need the script to provide "the day before" in a different string. (At least that is the plan) When I attempt to use the string within the above code I cannot get it to work, I guess primarily because I don't understand Time::Piece well at all.

      Hi jpys, you wrote
      $dsrd = the date the script will provide.
      I think you could avoid some of the confusion by showing us, what
      print chr(39) . $dsrd . chr(39);
      really gives you. Just put that in your script, and paste your output between <code> and </code> in a post.