#!/usr/bin/perl use strict; use warnings; my @array = qw(a123 abc abc1 123a 123_1 abc_1); for my $element (@array){ print "before: $element\n"; $element++; print "after: $element\n"; print "\n"; } __DATA__ output (with comments) # these "do what you want" before: a123 after: a124 before: abc after: abd before: abc1 after: abc2 # and these don't :-( # if the string starts with a number # Perl treats it as number before: 123a after: 124 # the _ always breaks the magic before: 123_1 after: 124 # not at all sure what's happening here! before: abc_1 after: 1