in reply to Re: regex/perl question about uninitialized value
in thread regex/perl question about uninitialized value

This is an interesting hipothetic situation:

#!/usr/bin/perl -w use strict; open <ID>, '<', 'textfile.txt'; # a lot of lines later... my $mystring = "ABC<ID>blahblah</ID>DEF"; if ( $mystring =~ /<ID>(.*?)<\/ID>/) { my $ID = $1; print "$ID\n"; # OOOPS.... }

The moral of the history is... always check the ""

Replies are listed 'Best First'.
Re^3: regex/perl question about uninitialized value
by JavaFan (Canon) on Nov 03, 2011 at 21:46 UTC
    I've no idea what problem you're describing here. Well, except that
    open <ID>, '<', 'textfile.txt';
    looks very strange. But that doesn't seem related to the line with the OOOPS.

      Oh, well... I see now, I'm stupid

      You're right, I'm over a false problem. The error message I had was for the over ID, extra "<>" stuff... I was thinking that I had another type of problem here, that in fact is not a problem at all to Perl; not unless you wrote:

      my $mystring = "ABC".<ID>."blahblah</ID>DEF";

      That is a very different situation to...

      my $mystring = "ABC<ID>blahblah</ID>DEF";

      So I was in the clouds again (what a zurprize)