Link to home
Start Free TrialLog in
Avatar of blnukem
blnukem

asked on

print # sign with alphabet array

Hi All

I use this code to dynamically print the alphabet:

my @Alphabet = ("A".."Z");

foreach my $Letter (@Alphabet) {
print "$Letter ";
}


RESULT: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


How do I add the # in the array in front of the "A"


DESIRED RESULT:  # A B C D E F G H I J K L M N O P Q R S T U V W X Y Z




ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Adam314
Adam314

Or if you don't want to change @Alphabet (in case it's used elsewhere)

my @Alphabet = ("A".."Z");
 
print "# ";
foreach my $Letter (@Alphabet) {
print "$Letter ";
}

Open in new window

or
 print "$_ " foreach ('#',@Alphabet);
or
print "# @Alphabet ";