
mhx
Enthusiast
/ Moderator
Nov 13, 2002, 1:32 PM
Post #7 of 12
(898 views)
|
|
Re: [chrisdeffer] Adding to array...
[In reply to]
|
Can't Post
|
|
Hi Chris, indeed, you explained the problem to the best of your knowledge. But, as RedRum already said, there's no problem with thodi's code. However, you seem to get a "wrong" result. I think the problem is that your input strings in the @natsources array are already not the way you think they are. Whenever you expect some data to be in a certain way, but you're not sure, use the Data::Dumper module. It's part of standard Perl, and it's invalueable for debugging. Try this script, it should do exactly what you want:
#!/usr/bin/perl -w use strict; use Data::Dumper; my @natsources = ( 'ip nat inside source static 167.125.250.193 10.76.250.193', 'ip nat inside source static 167.125.250.194 10.76.250.194', 'ip nat inside source static 167.125.250.195 10.76.250.195', 'ip nat inside source static 167.125.250.196 10.76.250.196', 'ip nat inside source static 167.125.250.197 10.76.250.197', 'ip nat inside source static 167.125.250.198 10.76.250.198', 'ip nat inside source static 167.125.250.199 10.76.250.199', ); print Dumper( \@natsources ); $_ = "no $_" for @natsources; print Dumper( \@natsources ); Now, put in the code you're using to acquire @natsources:
#!/usr/bin/perl -w use strict; use Data::Dumper; my @natsources = ... ; # your code print Dumper( \@natsources ); $_ = "no $_" for @natsources; print Dumper( \@natsources ); Run the script again and if it does not work the way you expect it, please copy and paste the exact output in your reply. -- mhx
At last with an effort he spoke, and wondered to hear his own words, as if some other will was using his small voice. "I will take the Ring," he said, "though I do not know the way."-- Frodo
|