Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Multiple Line Data from text file to SQL

by clueless newbie (Chaplain)
on Mar 03, 2009 at 21:08 UTC ( #747897=note: print w/replies, xml ) Need Help??

in reply to Multiple Line Data from text file to SQL

# Slurp the file my $Text=do { local $/; <DATA> }; # Assuming that a question begins with a number followed by a period: # Then a question is a question number followed by lines which are not + question numbers. #while ($Text =~ m{(\d+\.\n([^\n\r\f]*[a-zA-Z]+[^\n\r\f]*\n)+)}s) { while ($Text =~ m{((\d+)\.\n(([^\n\r\f]*[a-zA-Z]+[^\n\r\f]*\n)+)(A\)([ +^\n\r\f]*[a-zA-Z]+[^\n\r\f]*\n)+?)(B\)([^\n\r\f]*[a-zA-Z]+[^\n\r\f]*\ +n)+?)(C\)([^\n\r\f]*[a-zA-Z]+[^\n\r\f]*\n)+?)(D\)([^\n\r\f]*[a-zA-Z]+ +[^\n\r\f]*\n)+))}gs) { ### question number :$2 ### question :$3 ### A) :$5 ### B) :$7 ### C) :$9 ### D) :$11 #using g so #$Text=$'; };
works but assumes that a question number of the form \d+\. begins each question, the answers must be A, B, C and D and of the form x) ..., and none of the answers are split so that the trailing portion resembles a question number.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://747897]
[shmem]: more garbage in, more garbage out that would be
[stevieb]: I found that win10 broke a C# library I was using for one project while enhancing tests for a Perl dist, which breaks other Perl dists, and I'm about to throw my hands up on berrybrew. win2k12 broke one thing, win10 breaks something...
[stevieb]: ...unrelated which requires replacing a lot of code and a whole lib. I'm about to go nix only ffs
[shmem]: stevieb: what you're doing sounds afwully complex. Too much for me this evening to provide brighter insight ;-)
[stevieb]: I don't even own a Windows computer. Both my girl and I have a laptop each with Linux. I'm supporting Windows in some of my projects and I can't even guage whether it's worth it or not.
[stevieb]: shmem It's something I desired to have years ago, which is why I took over berrybrew. Cross-platform build/test automation locally, or over the network Test::BrewBuild
[shmem]: sounds good.
[shmem]: but I'm crumbling smaller stones. remember...
[stevieb]: I'm working on it to fatten it up and make it more reliant so I can finalize my Raspberry Pi automated build system for that software :) It's all well and fun, until I try to make it work with Windows lol

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2017-03-28 22:07 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (342 votes). Check out past polls.