;
212.120.32.0|19;
212.120.64.0|18;
212.120.192.0|19;
213.3.12.120|29;
116.212.120.0|24;
12.120.24.0|21;
Now I need to map C_IP to list with longest prefix match. (As u can
there are many IP address with 12.120. but I need to map to one with
longest prefix match)
--
To unsubscribe, e-mail
Hi,
I want to implement longest prefix match in my code in perl, but am not able
to get started with it. I am sure, it can be easily achieved with the help
of regex in perl, but I haven't worked on it. Following is what I want to
do:-
If the phone number is
+852 ---> The country is H
; 12.120.96.0|20;
> 12.120.40.0|21;
> 12.120.0.0|21;
> 12.120.192.0|19;
> 12.120.16.0|22;
> 12.120.36.0|22;
> 12.120.80.0|20;
> 194.212.120.0|21;
> 212.120.32.0|19;
> 212.120.64.0|18;
> 212.120.192.0|19;
> 213.3.12.120|29;
> 116.212.120.0|24;
> 12.120.24.0|21
194.212.120.0|21;
>> 212.120.32.0|19;
>> 212.120.64.0|18;
>> 212.120.192.0|19;
>> 213.3.12.120|29;
>> 116.212.120.0|24;
>> 12.120.24.0|21;
>>
>>
>> Now I need to map C_IP to list with longest prefix match. (As u can
>> there are many
On Thu, Nov 27, 2008 at 00:02, Chas. Owens <[EMAIL PROTECTED]> wrote:
snip
>>> Now I need to map C_IP to list with longest prefix match. (As u can
>>> there are many IP address with 12.120. but I need to map to one with
>>> longest prefix match)
>>
>>
On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to implement longest prefix match in my code in perl, but am not able
> to get started with it. I am sure, it can be easily achieved with the help
> of regex in perl, but I haven't worked on it. Follow
.
my $country = $countries{$prefix};
2007/8/27, Mihir Kamdar <[EMAIL PROTECTED]>:
> Hi,
>
> I want to implement longest prefix match in my code in perl, but am not able
> to get started with it. I am sure, it can be easily achieved with the help
> of regex in perl, but I haven
Mihir Kamdar wrote:
I want to implement longest prefix match in my code in perl, but am not able
to get started with it. I am sure, it can be easily achieved with the help
of regex in perl, but I haven't worked on it.
perldoc perlrequick
perldoc perlretut
perldoc perlre
Good
sorry, I forgot to send my mail to the list:
Jeff Pang schrieb:
> > then use regex or other ways (I prefer substr) to get the prefix.
> > my $prefix = substr($string,1,3);
I think the problem is that some countrycodes are only 2 digits some are 3
( or more ? )
So you dont know how long your pre
The sample code below on executing gives result as:-
Macau
Hong Kong
But there are 0 keys in the hash. I expected the result to be
Hong Kong
Macau
Why is the hash getting empty here?
#!/usr/bin/perl
my %countries = ('+852' => 'Hong Kong', '+853' => 'Macau' );
my @string = {'+8521235567','+853
2007/8/27, Mihir Kamdar <[EMAIL PROTECTED]>:
> The sample code below on executing gives result as:-
> Macau
> Hong Kong
>
> But there are 0 keys in the hash. I expected the result to be
> Hong Kong
> Macau
>
> Why is the hash getting empty here?
>
>
> #!/usr/bin/perl
>
> my %countries = ('+852' =>
hat CPAN module for doing
> this.
> Because countries's tel prefixes length are not the same.
>
thanks,
But i have a list of 65 countries, and I only want to implement for them.
Also, as you said, definitely for some, prefix length is only 1 digit, while
for others, it is 2 or 3 digits.
or 3 digits. So, I was thinking to
> build a hash and then implement this.
> Also, my aim is not actually to get the country name.
> On the basis of the prefix, I have the corresponding callrate/sec.
> Foe ex,
>
> Country_Name Country_Code Rate/sec
> Argentina 5
On 8/27/07, Martin Barth <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> do you understand my pseudo code, i think it should work for your hash?
>
> Regards
> Martin
Hi Martin,
Yes, I guess I understood yr code...if I am correct, i just need to know the
longest country code digits and store them in $pref
a hash and then
> implement this.
> Also, my aim is not actually to get the country name.
> On the basis of the prefix, I have the corresponding callrate/sec. Foe ex,
>
> Country_Name Country_Code Rate/sec
> Argentina 54 RM0.99
> So, if the longest prefix match of the 6th f
i never worked with CSV so far but
http://search.cpan.org/~danboo/Tie-Handle-CSV-0.09/lib/Tie/Handle/CSV.pm
sounds quite good. (hope it can handle if you're writing something to the
hash too. I didn't read the code... if not there are a lot of CSV modules
at cpan. )
Country_Name Country_
I can't recommend reinventing the wheel, I would use the module to
> lookup the country name and the use hash where the country name is the
> key and the rate is the value to get the value, but if you are dead
> set on not using the module your best bet is something like this:
>
> #!/usr/bin/perl
>
On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
>
>
>
> I can't recommend reinventing the wheel, I would use the module to
> > lookup the country name and the use hash where the country name is the
> > key and the rate is the value to get the value, but if you are dead
> > set on not using the
On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
snip
> > > my %prefix_to_rate = (
> > > 12 => 0.30,
> > > 1234 => 0.35,
> > > 134 => 0.50,
> > > 44 => 0.70
> > > );
snip
> my %prefix_to_rate = (
>'+12' =>0.30,
>'+1234' =>0.35,
>'+13
On 8/27/07, Chas Owens <[EMAIL PROTECTED]> wrote:
>
> On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
> snip
> > > > my %prefix_to_rate = (
> > > > 12 => 0.30,
> > > > 1234 => 0.35,
> > > > 134 => 0.50,
> > > > 44 => 0.70
> > > > );
> snip
> > my %prefix_to_
On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
snip
> Even if my $cdr[3] field in few of the records matches with the keys in the
> hash, it is still not going to the if part at all.
> It just takes one of the not matching records and printing the else part in
> the $OUT_FILE.
>
> OUT_FILE con
>
> Not a one. Can you provide some test data?
>
Sure Chas...
Following is some sample records:-
2006/09/01 00:19:30,999,+60132868382,+126312437,,1,253,2006/09/01
00:15:17,350370010515510,515111061171520,00043,3,1,0.0
,7,1,1,1,,0,8,+60132868382,Normal,,TELMT,Alcatel,,,
2006/09/01 00:21:13,999,+6
On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
> > Not a one. Can you provide some test data?
> >
> Sure Chas...
>
> Following is some sample records:-
snip
Seems to be working for me (with substr $cdr[3], 0, $len;). I get the output
the rate for +126312437 is 0.3: 3.795
the rate for +123
Hi Chas,
Look at the following code. It does not change the $cdr[13] value after
processing as is desired.
#!/usr/bin/perl
use strict;
use warnings;
my $file_path =
'/home/user71/RangerDatasource/Customization/TelekomMalaysia/Scripts/Tests/cprogs/files/ratetest';
my $write_path =
'/home/user71/
On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
snip
> for my $len (reverse $shortest .. $longest) {
> my $key = substr $cdr[3],0,$len;
> last if $rate = $prefix_to_rate{$key};
>
On 8/27/07, Chas Owens <[EMAIL PROTECTED]> wrote:
>
> On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
> snip
> > for my $len (reverse $shortest ..
> $longest) {
> > my $key = substr $cdr[3],0,$len;
> >
On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
>
>
> On 8/27/07, Chas Owens <[EMAIL PROTECTED]> wrote:
> > On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
> > snip
> > > for my $len (reverse
> $shortest .. $longest) {
> > > my
Hi Chas,
It works...but the problem I have is that some of the records are totally
lost. And also the output file keeps on writing multiple times and grows
into a huge size. almost 10 times, it keeps on growing until I kill the
script.
I checked few of the records which have calculated properly a
Hi,
if you open your outputfile like
open(FH, ">>", $file)
you will append all the stuff to the file. Probably you want to
replace your file if you run your script again.
open(FH, ">", $file)
HTH, Martin
On Mon, 27 Aug 2007 22:53:16 +0530
"Mihir Kamdar" <[EMAIL PROTECTED]> wrote:
> Hi Chas,
On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
> Hi Chas,
>
> It works...but the problem I have is that some of the records are totally
> lost. And also the output file keeps on writing multiple times and grows
> into a huge size. almost 10 times, it keeps on growing until I kill the
> script.
30 matches
Mail list logo