pacman has asked for the wisdom of the Perl Monks concerning the following question:
Description: Suppose that the variable $line holds a line from some file.The '|' delimited line looks like this ..
$line = man|woman|child|family
If I wanted to seperate the fields into an array, I'd do
something like this
so far so good..right?my @split_line = split(m"\|",$line)
Problem:What If my line in $line, for some reason, didn't look
like it was supposed to(!).So I just checked for the
presence of the delimiter '|' in the line.
Just wonder if this is going to be robust enough ?if(!$line =~ m"|"g){die " Not Compatible\n";}
Edited by Chady -- fixed code tags.
20040323 Edit by BazB: Changed title from 'simple one'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Input validation
by castaway (Parson) on Mar 23, 2004 at 08:09 UTC | |
|
Re: Input validation
by matija (Priest) on Mar 23, 2004 at 08:06 UTC | |
by pacman (Initiate) on Mar 23, 2004 at 09:01 UTC | |
by ysth (Canon) on Mar 23, 2004 at 10:25 UTC | |
|
Re: Input validation
by CountZero (Bishop) on Mar 23, 2004 at 08:15 UTC |