Split a string by using the regular expression
#!/usr/bin/perl -w use strict; my $passwd = "A:B:C:D::/value1/value2:/value3"; my @fields = split /:/, $passwd; print " $fields[0]\n"; print " $fields[2]\n"; print " $fields[5]\n";