Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Learning Exercise

by atcroft (Abbot)
on Jul 18, 2002 at 12:52 UTC ( [id://182785]=note: print w/replies, xml ) Need Help??


in reply to Learning Exercise

If this is a single-user program, one way you could handle the delete is to rename the file containing your addresses (addybase.adb) to something else (say, addybase.old), then open it for read, dumping all but those you are wishing to delete back to addybase.adb. (This also saves having to read all of the addresses into memory at the same time.)

Later on, you might also want to look at tie or some of the Tie::* modules on CPAN, or the perl DBI, for easier ways to handle the address. Some of the examples I have seen for tie seem to treat the file access similar to a hash, making it easy to reach an entry quickly. Likewise, using the perl DBI with a database and SQL statements also makes access fairly easy.

Hope that helps somewhat.

Replies are listed 'Best First'.
Re: Re: Learning Exercise
by Foncé (Scribe) on Jul 18, 2002 at 13:02 UTC
    I'd really prefer not to make another file, but that does sound feasible. I'll look into that stuff when I learn a little more.

    In the meantime...*scours the Llama for ideas*

    <idea>I'm basically trying to delete a line (which I will be loading into an array, thus, giving it an index with which to remove it by) and then shifting the entries thereafter, but not the ones before the entry I'm removing...

    Any ideas on doing that?
      You might want to read the perldoc for grep() for a way to remove an entry from an array based on known content.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-24 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found