#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my @strings = qw( He_is_super_hero_Spiderman He_was_a_super_actor_Tom ); for my $string (@strings) { my ($spiderman_or_tom) = $string =~ /Spiderman|Tom/g; say $spiderman_or_tom; my ($last_word) = (split /_/, $string)[-1]; say $last_word; my ($last_capitalized) = $string =~ /.*([[:upper:]][^_]+)/; say $last_capitalized; }