Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Sort - can't

by malaga (Pilgrim)
on Aug 31, 2005 at 05:38 UTC ( [id://488028]=note: print w/replies, xml ) Need Help??


in reply to Re: Sort - can't
in thread Sort - can't

thanks everybody. i get it now and fixed it. I did know I was doing it all wrong of course, that's why i posted. For some reason I couldn't see where the scalars and arrays were in this. everything was working till i had to add the sort - i wasn't able to back out and see where changes had to be made. i appreciate the help. hopefully people learn from my dumb posts.
#SEARCH THROUGH THE CONTENT DIRECTORY AND FIND THE FILES THAT MATCH chdir("$contentdir");#change to the content directory my $stuff = ".";#make it $_ opendir THISDIR, "$stuff";#open the content directory my @submenu = readdir THISDIR;#put the names of the files in an array closedir THISDIR; for (1..2) {shift @submenu;} my @aaa; for (@submenu) { push(@aaa,[split /\_/,$_,3]); } my @final = sort {$a->[2] <=> $b->[2] } @aaa; for (@final) { my $cat=$_->[0]; my $title=$_->[1]; my $rankk=$_->[2]; (my $rank, $tossit) = split (/\./, $rankk,2); #foreach submenu item print it if ($cat=~$main) { $counter++; if ($counter > 1) { print "<a href \= \"/cgi-bin/idx.pl?$sub1$sep$sub2$sep$sub3\">"; print "$sub2"; print "</a>"; etc., etc. i know this isn't pretty, but it is what it is.
Malaga

Replies are listed 'Best First'.
Re^3: Sort - can't
by QM (Parson) on Aug 31, 2005 at 22:14 UTC
    For some reason I couldn't see where the scalars and arrays were in this.
    Here's a tool you already have to help you with this: Perl debugger!

    Use the x command to see what a variable holds. It shows you the complete structure as if it were an array at the top level. (So hashes show up better if you escape the percent sign, as in the first example below).

    c:\perl\perl>perl -de 0 Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): 0 DB<1> %x = ( 123, [ qw(one two three) ], 456, [ qw(four five six) ], + 789, [ qw(seven eight nine) ] ) DB<2> x \%x 0 HASH(0x1d6c490) 123 => ARRAY(0x15d52a4) 0 'one' 1 'two' 2 'three' 456 => ARRAY(0x1d6c628) 0 'four' 1 'five' 2 'six' 789 => ARRAY(0x1d6c664) 0 'seven' 1 'eight' 2 'nine' DB<3> @x = ( { 1, "one", 2, "two", 3, "three" }, { 4, "four", 5, "fi +ve", 6, "six" }, { 7, "seven", 8, "eight", 9, "nine" } ) DB<4> x @x 0 HASH(0x1d70b24) 1 => 'one' 2 => 'two' 3 => 'three' 1 HASH(0x1d97a78) 4 => 'four' 5 => 'five' 6 => 'six' 2 HASH(0x1d97ab4) 7 => 'seven' 8 => 'eight' 9 => 'nine' DB<5>

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-20 13:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found