On Tue, 18 Jan 2005 01:08:56 +0100, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> foreach my $line (<INN>) { > if ( $line =~ /^[^,]*(?:,[^,]*){10}$/) ) { > print OUT $line; > } > } > > That is check whether the full string is "something not containing > comma followed by ten times comma and something not containing > comma". This is a script for an awful system where I only have access to a certain part of the whole system. It's a web-form with 10 fields. Instead of putting the fields directly into a database, I get the fields as a comma-seperated list on email. One mail for each request(!). So, I'm basically parsing a huge mbox-file here. I have no power over the "webmaster", and he won't listen to reason. The fields may or may not be empty. So, valid format is: [EMAIL PROTECTED],bar,foo,bar,foo,bar,foo,bar,foo, bar, foo and [EMAIL PROTECTED],,,,,,,,,, and ,,,,foo,bar,,, I'm basically just checking for 10 commas, write it to it's own file and then use a mysql-import script on that file. Any lines with more than 11 commas get's flagged for manual checking. To make matters even worse, "we" are using Matt's Formmail script. I'm not sure if it's gotten better, but last time I checked it didn't have the best of track records. I ended up using tr//, even though it sports almost the same readability as s// it seems more correct. Thanks. Tor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>