in reply to Re: His strangeness regex
in thread His strangeness regex

With youre shorting it works now as I wanted it to do.

for ( $sysDescr ) { s/$prefixSysDescr|$prefixSnmpWalk/$hostName$TAB/ && do { $OutputLine = $_; last; }; # substitute some prefixes $OutputLine = $OutputLine . $SPACE . $_; } # process output

If I run the script with 3 hostnames, it produces now the following output (the IBM machine produces normally an output over a couple of lines):

$ perl -w getSysDescr.pl 82 >>omServer1 Sun SNMP Agent, Ultra-80 Pause in (main). Go [y|Y]; Quit [q|Q]: y 82 >> omServer2 IBM PowerPC CHRP Computer Machine Type: 0x0800004c Pr +ocessor id: 00C9FC8A4C00 Base Operating System Runtime AIX version: 0 +5.03.0000.0060 TCP/IP Client Support version: 05.03.0000.0063 Pause in (main). Go[y|Y]; Quit [q|Q]: y 82 >>omServer3 No response arrived before timeout. Pause in (main). Go [y|Y]; Quit [q|Q]:q

Nevertheless I'm still interested why now the use of the variable $prefixSnmpWalk works.

Beside:never mind my avoiding the if-clause. In this case I try to avoid an if-then-elseif-elseif .... I prefer select-case-else-endselect and substitute it with the for-loop

Replies are listed 'Best First'.
Re^3: His strangeness regex
by Anonymous Monk on Sep 04, 2009 at 08:41 UTC
    Nevertheless I'm still interested why now the use of the variable $prefixSnmpWalk works.

    In the code you showed it always worked, your problem was always the input

    # some declarations in the beginnings my $TAB = "\t"; my $SPACE = " "; my $oidNbrSysDescr = ".1.3.6.1.2.1.1.1"; my $prefixSysDescr = quotemeta 'system.sysDescr.0 : DISPLAY S +TRING- (ascii): '; my $prefixSnmpWalk = 'snmpwalk:\s*'; # no use ?? my $sysDescr = q~ snmpwalk: yeah ~; for ( $sysDescr ) { /$prefixSysDescr/ && do { s/$prefixSysDescr/$hostName$TAB/; $OutputLine = $_; last; }; # substitute some prefixes (this one works) # /snmpwalk:\s*/ /$prefixSnmpWalk/ && do { s/snmpwalk:\s*/$hostName$TAB/; $OutputLine = $_; last; }; # error messages starting with "snmpwalk: " # here is the problem. All of a sudden I coudln't # use $prefixSnmpWalk anymore. Even quotemeta # failed $OutputLine = $OutputLine . $SPACE . $_; } # process output die "$OutputLine "; __END__ yeah at - line 36.

      I'm sorry - but it's not the input. The line you marked out was the workaround. Still I don't got any idea why I had to do the dirty way instead of using the variabel. I know the variabel to work normally - I'm used to it to see it running this very way. But I was perplexed that all of a sudden it didn't worked properly anymore.

      And astonihing is the fact that the nice short term worked as expected. For this very fact I'm interested in.

        I'm sorry - but it's not the input.

        Why don't you provide some input?

        The line you marked out was the workaround. Still I don't got any idea why I had to do the dirty way instead of using the variabel.

        Thanks, I knew that. I was demonstrating that the variable way was working.

        I know the variabel to work normally - I'm used to it to see it running this very way. But I was perplexed that all of a sudden it didn't worked properly anymore.

        I'm not saying I don't believe you, but prove it or it didn't happen :)

Re^3: His strangeness regex
by biohisham (Priest) on Sep 04, 2009 at 11:05 UTC
    Sometimes I stumble upon these sorts of hitches, something works just to stops working without prior warning, so my friend, I advice you to really dig into finding out how that shortening worked and where your problem resided in order to be able to avoid falling in the same pit over and over.

    Take care and have a happy Perl Programming :)


    Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.