Question could also be asked, how to compare data between two arrays and perform an action (print cmd) everytime there is a match?
The problem I'm having with the code below is that the comparison in the conditional IF statement is only happening against the first value --$link-- in the array --@route--
I want the comparison between the two arrays to repeat for every value in the first array @route.
...
User Profile
Collapse
-
hutch75 started a topic How to search values in an array & if it matches data in a file, perform an action?in PerlHow to search values in an array & if it matches data in a file, perform an action?
-
hutch75 replied to Extract and compile a list of IP addresses after doing a system call of traceroutein PerlThanks for the Response Kevin,
The Unix Sys Admin showed me the error of my ways. I thought I couldn't run traceroute from the command line because of a permissions issue, when in fact it just needed to be called differently.
EG, instead of typing: traceroute 72.14.207.99
I needed to type: /usr/sbin/traceroute 72.14.207.99
With that being said, was able to design a script to do what... -
hutch75 started a topic Extract and compile a list of IP addresses after doing a system call of traceroutein PerlExtract and compile a list of IP addresses after doing a system call of traceroute
Hi All - chasing down a means to initiate a traceroute, record results, and extract IP addresses in an (array?)
Here's what I'm thinking about so far, wonder if anyone's been down this road before and can offer advice if I'm going the right direction or not.
untested - pending permissions to initiate traceroute from server
...Code:#!/usr/bin/perl -w use strict; use warnings; use CGI
-
Thanks KevinADC and SpecialKay.
Kay, your idea re; using the commas is what sparked the solution.
In essence...
[CODE=perl]
# GPS variable name represents pair of GPS coordinates of unknown and uncontrollable lengths
$GPS = (-xx.xxxx, xxx.xxxxxxxx)
# retain GPS variable for use elsewhere, use newGPS variable
# original GPS format has parantheses ( ) and blank space...Leave a comment:
-
Hi all,
Correction to the last, the correct IF logic is as follows:
[CODE=perl]if (($fields[0] - $lat <= 0.20 && $fields[0] - $lat >= -0.20) && ($fields[1] - $long <= 0.20 && $fields[1] - $long >= -0.20)) {
Action, print, etc.
} # close if bracket[/CODE]
---
Would be of much great assist if anyone can lend an idea to my last query in the above...Leave a comment:
-
Thanks for the feedback folks.
Quick Update on progress and a different question at bottom:
Update:
Eventually got the syntax right, and here is the current working view:
[code=perl]
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI qw(:standard);
# GPS value derived from web-based javascript query to google's geocoder api. #...Leave a comment:
-
Best to use If and conditions? or some other form of logic for this example
Hi Folks,
Wondering if my logic is bringing me down the right path..was hoping for some feedback before I spend too much time creating the source document / database to test it out.
At a high level, what I'm trying to do is read through a database (CSV file) of GPS coordinates and general descriptions for devices that are deployed throughout a national geography. Rather than have every device in the database formatted... -
hutch75 replied to is there a perl mechanism to ping a network element before issuing SNMP commands?in PerlThanks Mate, I was trying to steer clear of any modules. The SA won't allow any use of XYZ beyond basic perl functionality. Don't ask my=[me]-edit why. I'm just wearing the development hat as a one-off here.
Just looking for basic perl functionality to do the task at hand.
Cheers,
HutchLeave a comment:
-
hutch75 started a topic is there a perl mechanism to ping a network element before issuing SNMP commands?in Perlis there a perl mechanism to ping a network element before issuing SNMP commands?
Since I found the site by googling, I will post a new question in addition to my follow-on response, with belief it will aid others. And increased crossing of fingers it will aid in receiving a response.
Cutting to the chase.....
i can use a system call to issue a ping to network element easily enough
Ie, system("/directory1/directory2/command like i was in CLI");
how can i harvest... -
Hate to be redundant or insignificant in my response, yet here is my take.
Based on my limited understanding and personal roadblocks.
1) Reading/Looping Through an XLS file to extract data with perl is a $bear = killer koala
2) My path of least resistance to overcome said $bear, has been to require the XLS file to be converted (via save as) to a CSV format.
O.K -- I too am almost sick at...Leave a comment:
-
hutch75 replied to CSV to XML works o.k - having prob taking a field from the CSV to name the XML filein PerlMany thanks, the input twas not ignored despite my latency in responding.
Helped a great deal... I will in turn follow up with posting the complete script when complete. Which, i trust, may help others along the way!
The present enhancement I'm trying to integrate is a means to ping (query) a remote host before SNMPSET commands are issued to it. Have already integrated a mechanism to time-out based on number of attempts...Leave a comment:
-
hutch75 started a topic CSV to XML works o.k - having prob taking a field from the CSV to name the XML filein PerlCSV to XML works o.k - having prob taking a field from the CSV to name the XML file
Hi folks,
I've been dead-ending on this issue, and I'm dusting off my brain to re-engage with Perl, so pls bear with me.
Here's an example of what I'm trying to accomplish, have tried several variants to resolve; but am getting error mssgs to the effect of: Global symbol "@site" requires explicit package name at csvconvert-BETA.pl line 16.
Overview is I'm uploading a .CSV file to a tmp directory...
No activity results to display
Show More
Leave a comment: