Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Help to improving my code please?

by moxliukas (Curate)
on May 30, 2003 at 12:02 UTC ( #261817=note: print w/ replies, xml ) Need Help??


in reply to Help to improving my code please?

A first thought that comes into my mind would be to construct a hash of arrays (HoA) to get rid of those 26 arrays that you have (and what if the filename doesn't start with a letter at all?)

here is some code:

$hash{$_} = [] for ('A'..'Z'); # prepare some empty arrayrefs $file_name =~ /^(.)/; # Mmm... It would be better to use a substr here + :/ push @{$hash{uc($1)}}, $infoline; # push an $infoline, first by upper +casing the key

I am no Perl guru, so others will probably point to a better direction.


Comment on Re: Help to improving my code please?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2015-07-06 15:28 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 (77 votes), past polls