I am comparing 2 dates and then I need to empty a field if I have it matching and all that, I just cant seem to remove the text I want to remove.
#!/usr/local/bin/perl5 # create a date+time string $shortdate = `date +"%D"`; chop ($shortdate); print "$shortdate\n"; $inhouse = "Open House Information"; open(FILE, "dbase1.exm") || die "I can't open that because: $!\n"; while(<FILE>) { chop; @all = split(/\n/); foreach $line (@all) { local($AA, $BB, $CC, $DD, $EE, $FF, $GG, $HH, $II, $JJ, $KK, $LL, +$MM, $NN, $OO, $PP, $QQ, $RR, $SS, $TT, $UU, $VV, $WW, $XX) = split(/ +","/, $line); $date = $shortdate; $date_from_db = $XX; $date1 = "$date"; @newdate = split(/\//,$date1); $formate_date1 = "$newdate[2]" . "$newdate[1]" . "$newdate[0]"; $date2 = "$date_from_db"; @newdate = split(/\//,$date2); $formate_date2 = "$newdate[2]" . "$newdate[1]" . "$newdate[0]"; if ($formate_date1 > $formate_date2) { $kill = "yes"; } else { $kill = "no"; } if ($inhouse eq "$WW" && $kill eq "yes") { print "$line\n"; print "$XX\n"; print "$formate_date1\n"; print "$formate_date2\n"; print "$kill\n"; print "$WW\n"; # this is the problem need the text removed from $WW field $WW =~ s/Open House Information//g; } } } close(FILE, "dbase1.exm")

20070801 Janitored by Corion: Changed PRE tags to code tags, as per Writeup Formatting Tips


In reply to replace in lines by pglinx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.