Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Sorting Files with Numbers

by dragonchild (Archbishop)
on Dec 30, 2002 at 15:47 UTC ( [id://223051]=note: print w/replies, xml ) Need Help??


in reply to Sorting Files with Numbers

You need to make your own custom sorting routine. Try something along the lines of:
# Note that $a and $b are special globals. DO NOT my THEM!!! sub my_sort { my ($a_word, $a_num) = $a =~ /^(\w+)(\d+)$/; my ($b_word, $b_num) = $b =~ /^(\w+)(\d+)$/; return $a_word cmp $b_word || $a_num <=> $b_num; } foreach my $file (sort my_sort keys %hash) { print $key, $/; }

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-25 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found