Stuart Clark wrote:
>
> Hi All,
Hello,
> I'm having trouble with this regular expression
> I have data file with colon separated delimiters
> The data below has 6 colon delimiters
> I want to check to make sure that none of the lines of data has more or less
> than 6 colons in it (EG: Lets say David enters his phone number as
> 9876:4342)
> The rest of my file works ok, its just matching the 6 colons.
>
> # File
> David:smith:21 lake drv::98764342::
> John:Jones:44 ratfink st:west mouseville:8432321::
> ##
>
> I have tried this
>
> if ($_ =~ m/:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:/) {
>
> and
>
> if ($_ = ~ m/:{6}/) {
Assuming the current line in in $_:
if ( tr/:// == 6 ) {
print "$_ has six colons.\n";
}
else {
print "ERROR: wrong number of colons!\n";
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]