#!/usr/bin/perl

$_ = <STDIN>;

if (!/camels (\d+)/) {
    print STDERR "Incorrect format--please try again!\n";
    $errors++;
}
if ($1 <= 0) {
    print STDERR "Incorrect format--please try again!\n";
    $errors++;
}
if (/pigs/) {
    print STDERR "Incorrect format--please try again!\n";
    $errors++;
}

# Alternate approach

&reproach if !/camels (\d+)/;
&reproach if $1 <= 0;
&reproach if /pigs/;

sub reproach {
    print STDERR "Incorrect format--please try again!\n";
    $errors++;
}
