use strict; use warnings; use 5.010; my $string = "HELLO\nWORLD\nGOODBYE"; my @patterns = ( '\A (.)', #Match start of entire string followed by any char '^ (.)', #Match start of every line followed by any char '(.) \z', #Match any char followed by end of the entire string '(.) $', #Match any char followed by end of a line ); for my $pattern (@patterns) { my @matches = $string =~ /$pattern/gxms; say "@matches"; say '*' x 20; } --output:-- H ******************** H W G ******************** E ******************** O D E ******************** #### use strict; use warnings; use 5.010; sub do_stuff { my @x = shift; my @y = shift; say "@x"; say "@y"; } my @arr1 = (10, 20); my @arr2 = ('a', 'b'); do_stuff(@arr1, @arr2); #### do_stuff(10, 20, 'a', 'b'); #### my @x = 10; #### my @x = (10);