Ron Grabowski wrote:
> I think this works too:
>
> use strict;
> use constant T => 'TelephoneNumber';
> use constant F => 'FaxNumber';
> use Data::Dumper;
>
> my @customers = ( { T,'555-555-5555',F,'555-555-5555'},
> { T,'912-289-5555',F,'912-259-5555'},
> { T,'555-555-5555',F,'555-555-5555'} );
>
> # http://search.cpan.org/doc/JHI/Regex-PreSuf-1.15/PreSuf.pm
Clever! The things you find on CPAN....
Or use a hash. Stealing stuff from your code:
use strict;
use constant T => 'TelephoneNumber';
use constant F => 'FaxNumber';
use Data::Dumper;
my @customers = ( { T,'555-555-5555',F,'555-555-5555'},
{ T,'912-289-5555',F,'912-259-5555'},
{ T,'555-555-5555',F,'555-555-5555'} );
my %prefix = map { ; $_ => 1 } (
208, 209, 215, 216, 217, 219, 220, 221, 224, 225,
227, 228, 241, 242, 243, 244, 245, 246, 247, 248,
249, 250, 251, 253, 254, 259, 263, 268, 271, 273,
276, 291, 292, 293, 294, 295, 297, 298, 300, 304,
307, 312, 316, 317, 323, 324, 331, 333, 334, 336,
343, 344, 346, 347, 349, 362, 365, 371, 372, 377,
378, 382, 385, 386, 387, 388, 391, 392, 400, 401,
402, 403, 406, 407, 409, 413, 415, 416, 417, 418,
420, 423, 424, 425, 426, 428, 430, 431, 432, 434,
435, 436, 438, 439, 444, 446, 455, 460, 465, 467,
468, 482, 483, 493, 498, 502, 503, 504, 505, 509,
513, 514, 515, 516, 518, 519, 520, 522, 524, 528,
532, 533, 535, 540, 543, 546, 548, 549, 551, 556,
558, 559, 560, 561, 563, 566, 567, 574, 581, 582,
584, 593, 603, 605, 613, 616, 622, 623, 624, 630,
639, 641, 642, 643, 645, 648, 649, 662, 679, 683,
686, 698, 723, 724, 725, 726, 732, 734, 735, 758,
759, 762, 768, 769, 774, 775, 776, 777, 782, 787,
792, 793, 794, 817, 824, 828, 831, 833, 835, 838,
846, 849, 853, 854, 859, 860, 861, 868, 869, 870,
872, 873, 874, 878, 879, 881, 883, 886, 887, 888,
889, 890, 891, 894, 895, 896, 899, 924, 928, 931,
937, 938, 939, 941, 942, 977, 985, 991, 995
);
foreach my $customer ( @customers ) {
foreach ( $customer->{+T}, $customer->{+F} ) {
if ( /^912-(\d\d\d)/ && $prefix{$1} ) {
s/^912/229/;
}
}
}
print Dumper \@customers;
Cheers,
Philip
--
Philip Newton <[EMAIL PROTECTED]>
All opinions are my own, not my employer's.
If you're not part of the solution, you're part of the precipitate.
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users