http://qs1969.pair.com?node_id=1166670


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

Ok, I've been trying to break things down with the info you have provided, intially with a simpler problem so I can work out whats going on. I'm trying to print the year from the title in a file called csv3 (which contains 1989 in the title) using the following code but it isn't printing anything, what am I doing wrong?
#!/bin/perl open CSV3, "<csv3" or die; while (<CSV3>) { chomp; my ($title) = $_ =~ /^.+?,\s*([^,]+?),/; #/ match the title my %words; $words{$_}++ for split /\s+/, $title; #/ get words ## Collect unique words #+ # my @titlewords = keys(%words); + my @titlewords = keys(%words); #print "$title" } sub find_year { my( $str ) = @_; my $year; $year = $1 if( $str =~ /\b((?:19|20)\d\d)\b/ ); return $year } &find_year ($title);
I would have thought the   &find_year ($title); would have taken the title and applied the subroutine to this string, picking out the 1989?