Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: multiple "newline" delimiters

by Adrade (Pilgrim)
on May 31, 2005 at 17:14 UTC ( [id://462131]=note: print w/replies, xml ) Need Help??


in reply to multiple "newline" delimiters

Well, you can read in the whole thing, and then split it - this would probably be my approach, although there are probably better out there:
my $data; $data .= $_ while (<>); my @code = split(/[;\/]/, $data); for my $line (@code) { ... }

Good luck,
  -Adam

Replies are listed 'Best First'.
Re^2: multiple "newline" delimiters
by lgordoncurtis (Initiate) on May 31, 2005 at 17:47 UTC
    That's kinda what I'm leaning towards doing right now, but it seems very memory-wasteful. A similar idea i had is to slurp in the file, replace all the '/' with ';' and then go back to parsing a new temp file. The major problem with just splitting on ';' or '/' is dealing with procedures (see sample code), which I've made a work-around for by reading in line by line.
    create or replace procedure myProc as begin select * from whatever; end;
    As you can see, those types of PL/SQL statements have multiple ';'s but are technically one statement. But I've got a messy work-around where I match up begins and ends for that. Just so people know what problem I'm working with, here's some sample data:
    delete from mytable where my_id='12345' / insert into anothertable values ('123456','somedata'); /

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-03-28 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found