Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Record Separator affecting Regex

by insensate (Hermit)
on Nov 07, 2002 at 19:11 UTC ( #211188=note: print w/ replies, xml ) Need Help??


in reply to Record Separator affecting Regex

Would something like this suffice? The \m modifier lets the ^ metacharacter match next to a newline in your multiline $line value.

#!/usr/bin/perl $/ = ";\n"; while (my $line = <DATA> ){ $line =~ s/^#.*[\n\r]*//gm; print "Query: $line" unless $line=~/^\s+$/; } __DATA__ # one comment # two comment # another comment insert into table_name values(1, 'testing 1 2 3'); # more comments insert into table_name values (2, 'test &#149;')
OUTPUT:
Query: insert into table_name values(1, 'testing 1 2 3'); Query: insert into table_name values (2, 'test &#149;');


Comment on Re: Record Separator affecting Regex
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://211188]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2015-07-06 07:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls