At 14:01 21/02/2004, you wrote:
>Hi.
Hello again and thank you
>I recently questioned whether a rewrite was an appropriate response
>to a question on this group. Now I'm going to do it anyway!
after seeing you code i have cleaned up mine,
amassing how much eazy'er it make it to read.
>First of all, the warnings are there to help you. Don't 'fix' warnings by commenting
>out the 'use warnings' line. From this code, I get
i did this because when i got home perl kept saying "Can't locate warnings.pm in @INC"
i just relised this is because i installed Solaris8, and have not updated the perl
hence the -w now in code
> Useless use of a constant in void context at E:\Perl\source\xx.pl line 21.
>Line 21 is:
>
> $foundElements[$i] = qw($segmentFields{segment} ... );
>
>and you're getting this error because you're assigning a list of strings to a scalar
>value. All but one of the values will be thrown away, so they are 'useless'. What you
>probably mean is
>
> $foundElements[$i] = qq($segmentFields{segment} ... );
/me need to read his perl book more (might of helped if it wasnt at work.
but i have "removed" this from the code.
> $segmentFields { $segmentFieldKey => $segmentFieldValue };
What does => do then im shore i saw it a lot in the learning perl book
my $siteIPAdd = shift;
is this doing a shift $_ , and because no other functions have run then $_ is the
command line vars?
would this still work if this was a sub and run like " checkResults("$siteIP"); " ?
my($NH_HOME, $i)=("","0"); #setup main vars
what wrong with setting up variables like this ? note $NH_HOME will have a value
"/path/to/files"
well in fact $NH_HOME is a environmental variables on the system its there a way i
can inport system environmental variables ?
me new code is below...
i now get the error
Use of uninitialized value at ./poller.cfg.search.pl line 22, <POLLER> chunk 5.
which is happening on the last line of each section which is "[TAB] } \n" or after i
have " s/["}{]//g; " i guess it would be "[TAB] /n"
how can ignore this last line?
thank you for all you help
RichT
------------------
_start_
#!/usr/bin/perl -w
use strict;
#use warnings;
my $NH_HOME;
my($segmentFieldKey, $segmentFieldValue, %segmentFields, $nullVar);
my($siteIPAdd)=$ARGV[0];
local $/ = "}\n";
open(DISCOVERLOG, ">found.test.csv") || die "can not open : $!";
open(POLLER, "<poller.cfg") || die "can not open : $!";
while(<POLLER>) {
next unless /\s+segment/;
next unless /$siteIPAdd/;
s/["}{]//g;
foreach (split(/\n/)) {
($nullVar,$segmentFieldKey,$segmentFieldValue)=split(/\s+/,$_,3);
$segmentFields { $segmentFieldKey } = $segmentFieldValue ;
print "$segmentFields{$segmentFieldKey} like $segmentFieldKey \n"; # just for testing
}
print DISCOVERLOG "$segmentFields{segment}, $segmentFields{deviceSpeed2},
$segmentFields{sysName}, $segmentFields{aliasName},
$segmentFields{mibTranslationFile}\n" ;
}
close POLLER;
close DISCOVERLOG;
_end_
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.581 / Virus Database: 368 - Release Date: 09/02/2004
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>