Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: can't read the 2nd input file;12 new versions of PORT-STATE-SERVICE+IP;14 in all;3 disk,11 memory (part 1)

by perl_boy (Novice)
on Apr 04, 2022 at 16:32 UTC ( [id://11142674]=note: print w/replies, xml ) Need Help??


in reply to can't read the 2nd input file

I have made 12 new versions/programs from port-state-service+IP-mem.pl (now renamed port-state-service+IP-mem-array.pl) and port-state-service+IP-disk.pl now renamed port-state-service+IP-disk-sub.pl
3 versions/programs work from disk
port-state-service+IP-disk-goto.pl port-state-service+IP-disk-sub.pl port-state-service+IP-disk-while.pl

11 versions/programs work from memory
port-state-service+IP-mem-list-direct.pl port-state-service+IP-mem-hash-direct.pl port-state-service+IP-mem-array.pl port-state-service+IP-mem-array-delete.pl port-state-service+IP-mem-array-delete-xtra.pl port-state-service+IP-mem-hash-direct-delete.pl port-state-service+IP-mem-hash-direct-delete-xtra.pl port-state-service+IP-mem-hash-indirect.pl port-state-service+IP-mem-list-indirect.pl port-state-service+IP-mem-list-splice.pl port-state-service+IP-mem-list-splice-xtra.pl

The ones operating from disk is in the case where the list is IPs taken from IP.txt file, which may be very big will not fit in a computers memory (some legacy computers from the 70/80 have only 64K!) in which case will work much slower due to frequent disk access
Those are goto, sub and while.
The goto version is a bit contreversial and the black sheep since it uses a goto to jump in goto get_IP (line 13) and out goto CONT (line 20) of the outter while (line 7) loop and I was a bit hesitant of including it here,but I did EVERYTHING I could, but could not find any instruction/statement/command to return from a goto (see below) and decided to post it anyway for completeness
The sub version uses a subroutine calling &get_IP (line 13) defined below (lines 18 .. 28)
The while version uses an inner while loop (lines 13 .. 15)
I did the port-state-service+IP-disk-while.pl from port-state-service+IP-disk-goto.pl replacing goto get_IP with the code of that label , indented and deleted the labals get_IP CONT END
All 3 versions (subroutine calling &get_IP, while loop, goto get_IP label) read the IP.txt file upto the line number 1st column ($1 as in awk) of port.txt file and prints the IP associated with the nth,that is, that number
The ones operating from memory are much faster since IPs are fetched directly from memory. They use 3 different data structures (array, list, hash) from perl to store IPs read from IP.txt
list and hash both have a direct and indirect version. The direct version port-state-service+IP-mem-list-direct.pl and port-state-service+IP-mem-hash-direct.pl read from the data structure (list, hash) itself without passing by a subroutine, while the indirect version port-state-service+IP-mem-hash-indirect.pl and port-state-service+IP-mem-list-indirect.pl uses the idx subroutine
The array and hash both have 2 delete versions
port-state-service+IP-mem-array-delete.pl port-state-service+IP-mem-array-delete-xtra.pl port-state-service+IP-mem-hash-direct-delete.pl port-state-service+IP-mem-hash-direct-delete-xtra.pl

the delete ONLY versions port-state-service+IP-mem-array-delete.pl and port-state-service+IP-mem-hash-direct-delete.pl delete ONLY the index item while port-state-service+IP-mem-array-delete-xtra.pl and port-state-service+IP-mem-hash-direct-delete-xtra.pl delete items between interveining line numbers from the port.txt file

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-03-28 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found