here's something to get you started... 

----------------------------------------------
use Data::Dumper;

my %keep;

while(<DATA>) {
  chomp;
  if ($_ =~ s!(.*)/(.*)?!$1!g) {
      $keep{$2} = $2;
      print "$_\n";
  }
  else {
    warn "$_ did not mattch our pattern";
  }
}

warn Dumper(\%keep);


__DATA__
abc/edf/a
acb/ecf/b
ffabc/edf/e
dsa/bc/edf/xy
abc/edf/ghf/agg

----------------------------------------------


On Mon, 2003-07-28 at 10:25, Boon Chong Ang wrote:
> The scenario is like this
>   __DATA__
>   abc/edf/a
>   acb/ecf/b
>   ffabc/edf/e
>   dsa/bc/edf/xy
>   abc/edf/ghf/agg
> 
> And I want the output is like this
> 
>   abc/edf
>   acb/ecf
>   ffabc/edf
>   dsa/bc/edf
>   abc/edf/ghf
> 
> Where it delete all the character starting from the last "/" and then it use the 
> pattern to search it from other file and modify the content which is located on the 
> same line. 
> Such as 
> Mhd abc/edf 
> 
> To 
> Mhabcd abc/edf  
> 
> Thank you & best regards,
> ABC
> 
> 
> 
> -----Original Message-----
> From: Rob Dixon [mailto:[EMAIL PROTECTED] 
> Sent: Friday, July 25, 2003 7:52 PM
> To: [EMAIL PROTECTED]
> Subject: Re: search and match
> 
> 
> >
> > "Boon Chong Ang" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > ismsg03.altera.priv.altera.com...
> > Hi,
> > Just say i have a variable being assigned as follow,
> >
> > $a = abc/edf/a
> >
> > i want it to search from another file for the file that contains 
> > exactly the same words, what i do is to modify the variable a become 
> > $a = abc\/edf\/a and then print if /$a/; but it failed
> > even if i tried print if "/$a/"; it also failed. Can anyone point out
> > my mistake or show me the correct way to do this?
> >
> >
> 
> I'm not sure what your problem is here. Even without the escape characters this 
> works fine. Can you tell us more of what you're doing, and why you think it doesn't 
> work?
> 
> Rob
> 
> 
> 
>   use strict;
>   use warnings;
> 
>   my $a = 'abc/edf/a';
> 
>   while (<DATA>) {
>     print if /$a/;
>   }
> 
>   __DATA__
>   abc/edf/a
>   acb/ecf/a
>   ffabc/edf/a
>   dsa/bc/edf/a
>   abc/edf/agg
> 
> OUTPUT
> 
>   abc/edf/a
>   ffabc/edf/a
>   abc/edf/agg
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to