perl + split + pipeline

I am using the following program to get the values from the pipeline separated file

But it is not working as i expected.

input file contains :


i need a output like this :

1 : abcd
2 : efd
3 : adfa

if i replace the | (pipe symbol) with , (comma) then it works fine.

please correct the program

thanks in advance


open(LOGFILE) or die("Could not open log file.");
foreach $line (<LOGFILE>) {
    chomp($line);              # remove the newline from $line.
    # do line-by-line processing.
	 @values = split ('|',$line);
	 $count =0;
	 foreach my $val (@values) {
		 print " $count :  $val\n";

Open in new window

LVL 23
Kamaraj SubramanianApplication Support AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

split ('\|',$line)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
perldoc perlre

       The patterns used in Perl pattern matching evolved from the ones
       supplied in the Version 8 regex routines.  (The routines are derived
       (distantly) from Henry Spencer's freely redistributable
       reimplementation of the V8 routines.)  See "Version 8 Regular
       Expressions" for details.

       In particular the following metacharacters have their standard
       egrep-ish meanings:

           \   Quote the next metacharacter
           ^   Match the beginning of the line
           .   Match any character (except newline)
           $   Match the end of the line (or before newline at the end)
           |   Alternation
           ()  Grouping
           []  Character class
Kamaraj SubramanianApplication Support AnalystAuthor Commented:
When i post this quesion, i think about you only (ozo). B'cos you are master in perl.

thanks for your solution
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.