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

my ($qname = "_sip._udp.www.google.com") =~ s/(.*\.)(www.*)/; ($qname, my $qname1) = ($1, $2);

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

Replies are listed 'Best First'.
Re^2: How can i get a substring from a String?
by ww (Archbishop) on Oct 16, 2008 at 12:06 UTC
    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

      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 :-))