Re: Right regex to match -- comments or blank line?

From: jan (jan_at_ossifrage.net)
Date: 03/05/04


Date: 5 Mar 2004 07:35:49 -0800

chomp(); is removing the \n;

try:
unless ($insert =~ /^--|^\s?$/)

Cheers,
Jan

"Dave Sisk" <dsisk@nc.rr.com.0nospam0> wrote in message news:<0QT1c.45536$%d3.4130346@twister.southeast.rr.com>...
> Hi Folks:
>
> I need the right regex to match either a comment line (--) or a blank line.
> What I've got below doesn't seem to be working like I'd expect. I've posted
> a snippet of what I have below...would anyone be kind enough to point me in
> the right direction? I also apparently need to strip the ';' off the end
> of the INSERT statement...
>
> TIA,
> Dave
>
> -----------------------------------------------------------
> while(<SCRIPT>) {
>
> chomp;
>
> $insert = $_;
>
> unless ($insert =~ /^--|^\s+$\n/) {
>
> $rv = $dbh->do($insert);
>
> }
>
> }
>
>
>
> The script I'm reading in looks like this:
>
> -- Some comments on this line, the next line is a blank line, then the next
> lines are inserts.
>
>
>
> insert into sometable values('whatever1');
>
> insert into sometable values('whatever2');
>
> etc.