Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Question concerning the get method.

$data = get($HomePage);
How do I then extract a certain word from the $data variable?? I tried many ways but can't seem to fetch a specific word with different 5th and 6th characters.

if ($data =~ /1234\d{2}\abcd/) { print "Fetch successful\n"; } else { print "Not found\n"; }

Replies are listed 'Best First'.
Re: Fetching data
by broquaint (Abbot) on Apr 25, 2002 at 12:07 UTC
    You'll need to put parentheses around the word you want to capture if you want to save it to a variable
    my $data = "this is a character array"; my($str) = $data =~ /(char.{2}ter)/;
    Also you shouldn't be escaping non-meta characters as they'll be confused for something else e.g when you escaped 'a' character it was interpreted as an ASCII BEL characer (which emits a bleep on the command line when printed).
    Check out the perl regex man page for more info on regular expressions.
    HTH

    _________
    broquaint

      Thank you broquaint. Your answer helped me correct my problem!