Hi Shlomi,

Thanks for the quick response, appreciate it.

I modified the code as below and it works.

foreach $fa(@falist) {
my @parts = $fa =~m/(..)/g;
my $with_colons = join (':',  @parts);
push @newfa,$with_colons;
}
print @newfa;

I have one more query, please help

i have an @newfa with 50:00:00:08:44:9a:fb:79:90 50:00:00:90:44:9a:fb:30:90
50:00:00:55:44:9a:fb:79:66 and a file as below. now i want check if the
@newfa entry present in the file if it exists then i need to print the
matching zone: name


zone:            tstdetdr_B_AARA_30767_CL45
                     10:00:00:00:c7:d5:cd:16:c6
                      50:00:00:08:44:9a:fb:79:90
zone:            artdetdr_B_AARA_30767_CL45
                     10:00:00:00:c7:d5:cd:16:c9
                      50:00:00:08:44:9a:fb:64:90
zone:            dbtdetdr_B_AARA_30767_CL45
                     10:00:00:00:c7:d5:cd:16:ca
                      50:00:00:08:44:9a:fb:74:90


Thanks
Sj

On Tue, Aug 14, 2012 at 11:04 AM, Shlomi Fish <shlo...@shlomifish.org>wrote:

> Hi Sj,
>
> On Tue, 14 Aug 2012 10:55:13 +0100
> jet speed <speedj...@googlemail.com> wrote:
>
> > Hi All,
> >
> > I have a file as below
> >
> > file.txt
> > 50000008449AFB7494
> > 50000008449AFB749C
> > 50000008449AFB779D
> >
> > now i want to introduce : inbetween  as below for each of these
> > entries in the file
> >
> > 50:00:00:08:44:9A:FB:74:90
> >
> > i did come across join function in perl, not sure how to apply
> > inbetween each entries as above.
> >
> > any help would be much appreciated.
> >
>
> You can do something like this:
>
> [CODE]
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $s = '50000008449AFB749C';
>
> my @parts = $s =~ m/(..)/g;
>
> my $with_colons = join(':', @parts);
>
> print "With colons = <<$with_colons>>\n";
>
> [/CODE]
>
> Regards,
>
>         Shlomi Fish
>
> --
> -----------------------------------------------------------------
> Shlomi Fish       http://www.shlomifish.org/
> Freecell Solver - http://fc-solve.shlomifish.org/
>
> How many “one-liners” do I actually write? I don’t know; maybe a couple
> dozen
> a day. But I guess I must be unusual, because as we all know, AWK was a
> complete failure and vanished into obscurity since it didn’t address
> anyone’s
> real needs. (That was sarcasm.) — “Twelve Views of Mark Jason Dominus”
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
>

Reply via email to