for ( $sysDescr ) {
This line doesn't make any sense to me.
Try adding a lot debug prints to your script and then look if every variable contains what you expect and if your script walks the ways you want. For example:
foreach $hostName (@serverList) { print STDERR "--- Server: $hostName\n"; # snmpwalk as filehandle #---------------------------------- $FH_SNMPWALK = new FileHandle "$SNMPWALK $hostName $oidNbrSysDescr + 2>&1|"; die "$0: $! in Zeile: ", __LINE__ unless defined $FH_SNMPWALK; # execute snmpwalk #---------------------------------- while( $sysDescr = <$FH_SNMPWALK> ) { chomp $sysDescr; print STDERR " Desc: $sysDescr\n"; for ( $sysDescr ) { print STDERR " in_for: $_\n";
Giving the output some intend makes it easier to read when debugging nested loop/if situations. As long as you have no clue what is going wrong, up to one print in each loop or if block is a good thing. In many cases, the processing works, but the output isn't what you expect. Monitoring your $OutputLine variable may also be a good idea.

Besides of your probleme, you could shorten your code a little bit:

if (s/$prefixSysDescr/$hostName$TAB/ or s/snmpwalk:\s*/$hostN +ame$TAB/) { $OutputLine = $_; last; }; # substitute some prefixes (this one works)
...or even shorter...
if (s/($prefixSysDescr|snmpwalk:\s*)/$hostName$TAB/) { $OutputLine = $_; last; }; # substitute some prefixes

In reply to Re: His strangeness regex by Sewi
in thread His strangeness regex by o_chfa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.