You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
744 B
Perl

$string= "ABC:11/12/2009:10 St.:CA, value:012345";
@line=split(":", $string); # The string delimiter is a colon
print @line,"\n";
print "The guy's name is $line[0].\n";
print "The birthday is $line[1].\n\n";
@str=split(":", $string, 2);
print $str[0],"\n"; # The first element of the array
print $str[1],"\n"; # The rest of the array because limit is 2
print $str[2],"\n"; # Nothing is printed
@str=split(":", $string); # Limit not stated will be one more than total number of fields
print $str[0],"\n";
print $str[1],"\n";
print $str[2],"\n";
print $str[3],"\n";
print $str[4],"\n";
print $str[5],"\n";
( $name, $birth, $address )=split(":", $string);
print $name , "\n";
print $birth,"\n";
print $address,"\n";