#!/usr/bin/perl use strict; use warnings; use Data::Dumper qw(Dumper); # Test cases: my $string_a = "Joe Dolly"; # It should split and print JD. my $string_b = "perl.pl"; # It should match on the regular expression and nothing prints. my $string_c = "States"; # It should match on the regular expression and nothing prints. my @got = $search_c =~ /^(?!\w)|(\.[^.]+)$/ig ? [] : split //, $string_c; print Dumper $got[0]; print Dumper $got[1];