in reply to Side effect of using undefined variable in regex

When I ran your code under Perl 5.10 with warnings enabled, I got:
C:\PerlProjects\Monks>perl regextest.pl Start Basic Standard Services: Starting $name='ONC RPC PortMapper' $last='Config' ($name=~/$last/i) +=0 Starting $name='OP Time Server' $last='Config' ($name=~/$last/i)=0 Starting $name='OP Log Server' $last='Config' ($name=~/$last/i)=0 Starting $name='OP Configuration Server' $last='Config' ($name=~/$la +st/i)=1 Start Remaining Standard Services: Use of uninitialized value $last in regexp compilation at regextest.pl + line 27. Starting $name='OP Data Server' $last=undef ($name=~/$last/i)=1 Use of uninitialized value $last in regexp compilation at regextest.pl + line 28. Start General Services: Use of uninitialized value $last in regexp compilation at regextest.pl + line 38. Starting $name='OP Monitor' $last=undef ($name=~/$last/i)=1 Use of uninitialized value $last in regexp compilation at regextest.pl + line 39. Installation completed C:\PerlProjects\Monks>perl regextest.pl asdf asdf Start Basic Standard Services: Starting $name='ONC RPC PortMapper' $last='Config' ($name=~/$last/i) +=0 Starting $name='OP Time Server' $last='Config' ($name=~/$last/i)=0 Starting $name='OP Log Server' $last='Config' ($name=~/$last/i)=0 Starting $name='OP Configuration Server' $last='Config' ($name=~/$la +st/i)=1 Start Remaining Standard Services: Use of uninitialized value $last in regexp compilation at regextest.pl + line 27. Starting $name='OP Data Server' $last=undef ($name=~/$last/i)=0 Use of uninitialized value $last in regexp compilation at regextest.pl + line 28. Use of uninitialized value $last in regexp compilation at regextest.pl + line 27. Starting $name='OP Calculation Server' $last=undef ($name=~/$last/i) +=0 Use of uninitialized value $last in regexp compilation at regextest.pl + line 28. Use of uninitialized value $last in regexp compilation at regextest.pl + line 27. Starting $name='OP OPC Client' $last=undef ($name=~/$last/i)=0 Use of uninitialized value $last in regexp compilation at regextest.pl + line 28. Start General Services: Use of uninitialized value $last in regexp compilation at regextest.pl + line 38. Starting $name='OP Monitor' $last=undef ($name=~/$last/i)=0 Use of uninitialized value $last in regexp compilation at regextest.pl + line 39. Use of uninitialized value $last in regexp compilation at regextest.pl + line 38. Starting $name='OP Mover' $last=undef ($name=~/$last/i)=0 Use of uninitialized value $last in regexp compilation at regextest.pl + line 39. Installation completed
I added:
sub startStandardServices { my $last = shift; $last //='EVERYTHING'; #ADDED sub startGeneralServices { my $last = shift; $last //='EVERYTHING'; #ADDED
And got the same results with or without command line args. I think the logic needs to be modified somewhat to get what you want. the main thing is get rid of this "undef in regex" warning.
C:\PerlProjects\Monks>perl regextest.pl Start Basic Standard Services: Starting $name='ONC RPC PortMapper' $last='Config' ($name=~/$last/i) +=0 Starting $name='OP Time Server' $last='Config' ($name=~/$last/i)=0 Starting $name='OP Log Server' $last='Config' ($name=~/$last/i)=0 Starting $name='OP Configuration Server' $last='Config' ($name=~/$la +st/i)=1 Start Remaining Standard Services: Starting $name='OP Data Server' $last='EVERYTHING' ($name=~/$last/i) +=0 Starting $name='OP Calculation Server' $last='EVERYTHING' ($name=~/$ +last/i)=0 Starting $name='OP OPC Client' $last='EVERYTHING' ($name=~/$last/i)= +0 Start General Services: Starting $name='OP Monitor' $last='EVERYTHING' ($name=~/$last/i)=0 Starting $name='OP Mover' $last='EVERYTHING' ($name=~/$last/i)=0 Installation completed <c> C:\PerlProjects\Monks>perl regextest.pl asdf asdf Start Basic Standard Services: Starting $name='ONC RPC PortMapper' $last='Config' ($name=~/$last/i) +=0 Starting $name='OP Time Server' $last='Config' ($name=~/$last/i)=0 Starting $name='OP Log Server' $last='Config' ($name=~/$last/i)=0 Starting $name='OP Configuration Server' $last='Config' ($name=~/$la +st/i)=1 Start Remaining Standard Services: Starting $name='OP Data Server' $last='EVERYTHING' ($name=~/$last/i) +=0 Starting $name='OP Calculation Server' $last='EVERYTHING' ($name=~/$ +last/i)=0 Starting $name='OP OPC Client' $last='EVERYTHING' ($name=~/$last/i)= +0 Start General Services: Starting $name='OP Monitor' $last='EVERYTHING' ($name=~/$last/i)=0 Starting $name='OP Mover' $last='EVERYTHING' ($name=~/$last/i)=0 Installation completed