Add letters

I want to add letters A,B,C,� in front of every line of input while printing them out using PERL.
eg
A file is parsed as a cmd line arg and its context will be displayed as
A line1...
B line 2..

I tried this..but I want better and perfect solution!

!perl -p
my $counter;
BEGIN { $counter = q{A}; }
print $counter++;

Source(s):
The -p will make it print every input line automatically.

are you trying like this?

file a.txt

1 Line ...
2 Line ...
3 Line ...
4 Line ...
5 Line ...
6 Line ...
7 Line ...
8 Line ...
9 Line ...
10Line ...

For adding Letters A,B.C to each line see the following perl Example code.

open(MY,"txt.1");


for( (A..J) )
{
            my $Line = <MY>;
        print "$_ ";
                print $Line;
                print "\n";

}

Output:

A 1 Line ...

B 2 Line ...

C 3 Line ...

D 4 Line ...

E 5 Line ...

F 6 Line ...

G 7 Line ...

H 8 Line ...

I 9 Line ...

J 10Line ...

First question: if it works, why do you want to change it?
Second question: when you hit line numbers > 26, how should it progress? As AA, AB, AC, ... or just stop?

@ungalnanban: Your solution only works if you know the number of lines beforehand.

aadi_uni Code is works. But I gave one more solution for achieve that.

For Example Only I gave the Example.

we need to find the number of line in the file then based up on the line we can expand the characters like.

A..Z
A..ZZ
A..ZZZZ

for example : if your total line number has 3 digits use based on the "ZZZ"

the characters will add after A..Z, AA,AB....ZZZ.

Thanks. pludi.

If you don't know the number of lines in your file,then use the following script.It will print the desired format for you.

open (MY,"inputfile");

my $ind='A';
while( $ind)
{
            my $Line=<MY>;
            last unless $Line;
            print "$ind ";
            print $Line if($Line);
            $ind++;
}