in reply to Re: How can i get a substring from a String?
in thread How can i get a substring from a String?

Close... but not quite:
use strict; use warnings; # from bloodnok's reply to 717447 # my ($qname = "_sip._udp.www.google.com") =~ s/(.*\.)(www.*)/; # typo +? Not substitution, which throws an error # ($qname, my $qname1) = ($1, $2); # error: Can't declare scalar assignment in "my" at 717447.pl line 9, +near ") =~" my $qname; $qname = ("_sip._udp.www.google.com") =~ m/(.*\.)(www.*)/; print "\$1 is: $1 \n \$2 is: $2\n";

Output

$1 is: _sip._udp. $2 is: www.google.com

Update: corrected to clarify initial commented line which has two problems

Replies are listed 'Best First'.
Re^3: How can i get a substring from a String?
by Bloodnok (Vicar) on Oct 16, 2008 at 14:33 UTC
    Bugger!!!

    TFT ww, that oughta teach me not to post from a perl-less environment !!!

    .oO(I knew my sig wasn't in vain)

    A user level that continues to overstate my experience :-))