Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: best way to read and save long list of words

by roboticus (Chancellor)
on Apr 19, 2020 at 00:15 UTC ( #11115757=note: print w/replies, xml ) Need Help??


in reply to best way to read and save long list of words

Anonymous Monk:

So long as the time spent reading it and writing it is insignificant, I'd suggest leaving the file as it is. It's nice to be able to be able to edit the file without worrying about breaking a serialization format.

If reading and writing the file costs enough time to be worth looking at serialization, then I'd use serialization. But in that event, if it's a file you read often but edit infrequently, then I'd keep the text file as the 'master' so you can edit it and then run your serializer against it to generate the file you'd read frequently.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re: best way to read and save long list of words

Replies are listed 'Best First'.
Re^2: best way to read and save long list of words
by GrandFather (Saint) on Apr 19, 2020 at 00:24 UTC

    or if time becomes significant maybe the OP needs to rethink and start using a database instead? The rethink part may mean replacing the regex with some other technique of course.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

      I had considered earlier mentioning that if there's a list of words that may need to have additions once in awhile, DBD::SQLite isn't a bad alternative.

      But then I couldn't put my finger on what problem we're solving for here. Optimizing disk usage? Optimizing read speed? I understand he's constructing a big regex out of the words, but is that even the best approach at solving whatever the problem is that's being solved? Maybe a SELECT would be useful? It's just a little hard to recommend an approach without understanding the objective.


      Dave

        Indeed. That is why I suggested a "rethink". I strongly suspect we are helping to solve the wrong problem, but with the information we have even that is not clear.

        Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
Re^2: best way to read and save long list of words
by BillKSmith (Prior) on Apr 19, 2020 at 15:43 UTC
    I agree. I also have a long list of English words sorted alphabetically. I received the original file in .zip format and keep that as backup. I keep the working copy in plain text, one word per line. On average, I add one new word every few months. It is convenient to do this with my editor (gvim). I originally planed to develop a library of functions to access the list so I could change the format without changing my applications. My 'lazy' approach worked so well that I could never justify the effort.
    Bill

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2021-01-27 21:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?