in reply to Re: Input validation
in thread Input validation

hi thanks Matija,Castaway & CountZero ..

The line should comprise the said number of fields(in
the eg case - 4).So what I am also checking for,is the
number of fields returned on the 'split' & yeah I am
taking care of the possibility of receiving an empty
$line and/or empty field/fields. I think the two checks
1.Fields returned & 2. delimiter presence should be good
enough method to determine if the $line is fine,right?

Replies are listed 'Best First'.
Re: Re: Re: Input validation
by ysth (Canon) on Mar 23, 2004 at 10:25 UTC
    Sounds like you are concerned that you may have bad data, and asking us how bad it could be, which of course we have no way of telling.

    If you want to check that split returns the number of fields you expect, just check it:

    my @split_line = split(m"\|",$line); if (@split_line != 4) { warn "something gang aft"; } else { print "valid data!"; }