Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-20-2004, 01:43 AM   #1 (permalink)
Draqos
Registered User
 
Draqos's Avatar
 
Join Date: Aug 2004
Posts: 2
Draqos is on a distinguished road
PERL to C#

Hi. I had to translate a PERL program to C# and I almost did it, though i'm having trouble understanding these lines bellow.
If someone could give me a pseudocode or point to a link where I can find explanation of the keywords used, I'd be eteranally gratefull

---------------- PERL CODE ------------

my @results = sort { $results{$a} <=> $results{$b} } keys %results;

print join("\n",map { "$_\t $results{$_}"; } @results),"\n" if $opt_v;

my $a = $results{$results[0]};
my @answers=(shift(@results));
while (@results && $results{$results[0]} < ($opt_u *$a)) {
@answers=(@answers,shift(@results));
}

---------------------------------------

To be more specific, I don't understand the sort, shift (these ones are really giving me headaches) and join statements.
Once again, if could spare 5 minutes, i'd very much apreciate it
Draqos is offline   Reply With Quote
Old 08-20-2004, 04:11 AM   #2 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
Sort - does just that. Sorts (numerically in this case) your hash keys.

Shift - Removes and returns the first slice (or first key) of an array.

Join - Joins array values together. In this case it separates them by "\n" so its printing values on each line.

-r
idx is offline   Reply With Quote
Old 08-20-2004, 04:45 AM   #3 (permalink)
Draqos
Registered User
 
Draqos's Avatar
 
Join Date: Aug 2004
Posts: 2
Draqos is on a distinguished road
Thanx. Shift was the dilematic one and also the sorting criteria
Draqos is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
edit? anon Lounge 10 11-21-2002 03:02 PM


All times are GMT -8. The time now is 09:39 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting