Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This code works (that is, the print executes) for me, and should work for you:
$dm='08/14/04'; $_='There is an 08/14/04 in here'; if ($_ =~ m/$dm/) { print "Matched on <$_>\n"; }
The code you've included so far hasn't been the kind of test code we'd most like to see, which is an actual program that we can run that demonstrates the problem.

In this last excerpt, you're quoting your subroutine calls, which results in the subroutines not being called. Also, you're putting a newline in your date_manip, which may not be what you want. Here's a test-code modification that may help you out:

#!perl sub date_manip { my ($month, $day, $year) = (localtime)[4,3,5]; sprintf ("%02d/%02d/%02d\n", $month+1,$day,($year % 100)); } my $dm = &date_manip; sub date_manip1 { my $days = (shift); my ($d, $m, $y) = (localtime($time - $days * 86400)) [3..5]; sprintf ("%02d/%02d/%02d", $m+1,$d,($y % 100)); } my $dmm = &date_manip1(1); print ("{$dm} {$dmm}\n"); ############################################################ ## Gather data for scratch tapes; open file, create list, then print i +t. ## ############################################################ while (<DATA>) { print "-- Checking <$_>\n"; print "Found 9840\n" if /9840S/; print "Found ebexpire\n" if /ebexpire, ebexpire/; print "Found $dm\n" if /$dm/; print "Found $dmm\n" if /$dmm/; } __DATA__ 9840S ebexpire, ebexpire 12/30/69 08/18/04 9840S ebexpire, ebeXpire 12/30/69 08/18/04 9840S ebexpire, ebexpire XX/30/69 08/18/04

Caution: Contents may have been coded under pressure.

In reply to Re^3: regex match with interpolated pattern by Roy Johnson
in thread regex match with interpolated pattern by drock

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2024-04-18 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found