Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Addional "year" matching functionality in word matching script

by Corion (Patriarch)
on Jun 27, 2016 at 14:42 UTC ( [id://1166663] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $str = 'this is some text 1989 blah';
    my $year;
    $year = $1
        if( $str =~ /\b((?:19|20)\d\d)\b/ );
    
  2. or download this
    sub find_year {
        my( $str ) = @_;
    ...
            if( $str =~ /\b((?:19|20)\d\d)\b/ );
        return $year
    }