in reply to Splitting a string, Just want to Keep Half

Also note that since you're not actually looking to split the string, this might better be expressed as a pattern match: "I want the part after the @ sign" rather than "I want the second of the string parts delimited by an @ sign".
my ($domain) = ($email =~ /@(.*)/); print "Domain is $domain\n";

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Splitting a string, Just want to Keep Half
by choocroot (Friar) on Jul 07, 2003 at 09:05 UTC
    I would also recommend to use a regex instead of a split as it allows you to check for valid domain name characters :
    my ($domain) = ($email =~ /@([a-zA-Z0-9.-]+)$/); if( defined $domain ) { print "Domain is $domain\n"; } else { print "Invalid or missing domain name ...\n"; }