in reply to Newbie regex question

use strict and warnings. This will show you that your $birthdate variable is out of scope Why do you think there is a problem with your regex?
use strict; use warnings; my $text = 'birthdate1234zodiac'; if ($text =~ /birthdate(.*?)zodiac/i) { my $birthdate = $1; print "$birthdate\n"; } __END__ prints: 1234
If that's not the problem, then you should show us a small sample of your input file.

You would also benefit from running your code through perltidy and perlcritic.

Replies are listed 'Best First'.
Re^2: Newbie regex question
by Anonymous Monk on Jan 15, 2011 at 17:05 UTC

    Thank you, obviously the variable was out of scope. So much for not using strict and warnings. Cheers!