in reply to Re^7: Clear the contents of the text file
in thread Clear the contents of the text file

Hi Poj, Thanks a lot for the refined code, It looks prettier. Just need to know the purpose of the below part of the code. But your code is working very well.
my @nodes = (); while (<SRV>){ # skip blank lines s/\s+$//; s/^\s+//; next if /^$/; # validate records if (/.+/){ # change to suit push @nodes,$_; } else { printLog("ERROR Invalid record '$_'"); } }

Replies are listed 'Best First'.
Re^9: Clear the contents of the text file
by poj (Abbot) on Jul 22, 2015 at 18:45 UTC

    Do you mean the validate records ?

    Since you said in an earlier post This file is updated manually I thought you might like to do some validation on the values and assumed that server names would have some structure that you could check i.e. only [A-Za-z0-9_] characters perhaps ?

    I used /.+/ as a placeholder for your own regex.

    poj