Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: split one file into many on finding a new line

by spacewarp (Pilgrim)
on Sep 16, 2008 at 01:46 UTC ( #711580=note: print w/ replies, xml ) Need Help??


in reply to split one file into many on finding a new line

Another way to do it would be to examine each line, and if it's a CREATE TABLE line, close the previous file and start a new one.

if ($line =~ /CREATE TABLE/) { close (FILE) ($filename) = $line =~ /CREATE TABLE ([\S]*)/; open (FILE, >$filename); }
A similar method would also work if you have a more complicated delimiter, such as (for instance), an email address and name, but not an email and website.

Spacewarp

DISCLAIMER:
Use of this advanced computing technology does not imply an endorsement
of Western industrial civilization.


Comment on Re: split one file into many on finding a new line
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2015-07-07 01:46 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 (86 votes), past polls