Perl serach string that starts with a pattern

Example: MAIN1*PA*1231*ASDFSDF*ARWTFGADF****BDFBV*140056546

I want to extract ID from the above string which is nothing but the string after 9th '*' and the line should always start with "MAIN1*PA*1231" so the ID in the above case is '140056546'

I asked a similar question couple of days back - so from that answer I adjusted my perl script as below but it has compilation errors which i am not able to fix...
so can some one tell me what's wrong with my script...

#!/usr/bin/perl

use 5.006;
use strict;
use warnings;


  my $str = 'KAYAK*21312*123*12312*123$BROAD*P*18*SDFGASDF******ASDF$MAIN1*PA*1231*ASDFSDF*ARWTFGADF****BDFBV*140056546$ASDF*ASDF8*112157409*ASDF';
  my @lines = split /\$/, $str;
  my $mID;
  my @emps = ();
  for my $i (2..@lines-1) {
  if ($lines[$i] =~ /^MAIN1*PA*1231\*/) {
    $mID = (split /\*/, $lines[$i])[9];
    push(@emps, $mID);
    }
  }
 
  foreach(@emps) {
    print "$_";
  }
shragiAsked:
Who is Participating?
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.

nemws1Database AdministratorCommented:
You need to backslash the asterisks in your search:

if ($lines[$i] =~ /^MAIN1\*PA\*1231\*/) {

Open in new window

0

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
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
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.