sorting in perl..part2?
396369
Firstly, sorting a hash isn't exactly the most ideal situation, it would be better if each item was a hashref in an array:\n\n@books = (\n    { id => 1, title => 'foo', price => '2.99' },\n    # etc...\n);\n\nhowever, it can be done by using the key to look up the title in the hash via a custom sort routine (e.g $books{ $a }->{ title }).\n---\n\nuse strict;\nuse warnings;\nuse CGI qw( :all );\n\nmy %books = (\n    4 => {\n        'price' => '44.95',\n        'title' => 'Java Servlet & JSP Cookbook'\n    },\n    1 => {\n        'price' => '103.00',\n        'title' => 'Operating Systems Design and Implementation, 3/E'\n    },\n    25 => {\n        'price' => '45.00',\n        'title' => 'asdasdasd'\n    }\n);\n\nmy( %labels, @values );\nmy @items = sort { lc $books{ $a }->{ title } cmp lc $books{ $b }->{ title } } keys %books;\n\nforeach my $key ( @items ) {\n    my $item = $books{ $key };\n    push @values, $key;\n    $labels{ $key } = sprintf( '%s ($%s)', $item->{ title }, $item->{ price } );\n}\n\nprint popup_menu( {\n    name       => 'id',\n    values     => &#92;@values,\n    labels     => &#92;%labels,\n    ononchange => 'submit()'\n} );
711352
get -e http://www.example.com/page \n\n('get' is part of the perl lwp library) can show the headers \n\nyou can include the If-Modified-Since header and just check the result code!\n\nit's a great little util (simple command line), but you need perl!
346407
I think it is order(N squared), so not very good. It's a variant of bubble sort, which you can google. Plus you never know when you're done!
828194
You have to remember that computers don't see letters, they see numerics that represent letters. They compare values against one another numerically and based on the type of sorting algorithm used (yes there are many of them and different software can use various forms of sorting) can sort the list appropriately.\n\nI am not one for whipping out many wikipedia answers, but wikipedia has a good article that shows you the various sorts that software often uses. Many of them are described in detail and you can get an idea of how they work.\n\nAs for windows I believe it uses a sorting style known as "Natural sorting" which to us isn't exactly straight forward, but to the computer it is perfectly reasonable. I have including a link to a small quick little article about how it works. If you want more info on this part, just do a search for the keywords "natural sorting"\n\nHope this is what you were looking for. Enjoy!
907405
There is a quicksort algorithem built into one of the standard C functions that comes with C++.\n\nIt is called qsort.\n\nYou could also use one of the standard C++ templates. The standard templates have functions to do all sorts of operations.\n\n\nIf you want to program the sort yourself, just write a bubble sort.  See the Wikipedia link for instructions.\n\nIt is not the fastest sort for big datasets but it is more than adequate for even more than 4 numbers at a time.
395965
The bubble sort is the simplest, easiest sort algorithm. It basically goes like this:\n\nfor(x = 0; x < ARRAY_SIZE; x++)\n{\n   for(y = 0; y < ARRAY_SIZE-1; y++)\n   {\n      if(iarray[y] > iarray[y+1])\n      {\n         swap = iarray[y+1];\n         iarray[y+1] = iarray[y];\n         iarray[y] = swap;\n      }\n   }\n}\n\nPieces of cake!
20218
go to http://www.emule-project.net/home/perl/help.cgi?l=1&rm=show_entries&cat_id=245 .\nYou can find a lot of information about The Preferences.
212340
Actually, this is Perl code.  Perl has support for regular expressions built into the language.  There are tools out there (such as "The Regulator") which can take regular expression strings and break them down into english statements that make it easier to understand them.\n\nHowever, from this code, it looks like it is storing a several regular expression strings into a collection.  From first glance, it appear that the strings look for certain text, most specifically for questions that probably appear on Yahoo! Answers.  For example, it looks like "quick and easy 10 point" or "an easy ten points" may be a match.\n\nThis is probably a script used to search for a pattern of questions and provide stock answers in an attempt to automate "point gaming".  I would strongly recommend against using it, especially after posting details about it here.
1059802
well that is an easy one.....\n\nIt is in alphabetical order
2509
Here's a java solution that uses recursion.  The permute function takes two arguments: a done portion and a todo portion.   The basic idea is that each of the characters in the todo portion could be the next character.  So, at each step, n recursive calls are made, where n is the length of todo.  Each call chooses a different character as the next character to go into the done portion.  So, the first time the number of recursive calls will equal the number of characters in the initial string.  Each of these calls will make further recursive calls equal to the number of characters in the initial string minus one.  And so on.  Thus, the number of solutions will be n! = n*n-1*n-2*...*1, where n is the number of characters in the initial string.\n\nThe program below was tested with java's sun compiler 1.4.2.\npublic class perm\n{\n  public perm(String S)\n  {     \n    permute("", S);\n  }     \n  public void permute(String done, String todo) \n  {     \n    if ((todo.length()==0)||\n        (todo.equals("")))\n      System.out.println(done);\n    else        \n    {           \n      for (int i=0; i<todo.length(); i++)\n      {                 \n        String c = todo.substring(0,1);\n        todo = todo.substring(1);\n        permute(done+c, todo);  \n        todo = todo + c;        \n      }                 \n    }           \n  }     \n  public static void main(String args[])\n  {     \n    if ((args.length==0)||\n        (args[0].length()==0)||\n        (args[0].equals("")))\n      return;           \n    perm p = new perm(args[0]);\n  }     \n}
555196
Before you attempt to sort, make sure you select ALL of the columns that you want sorted. Make sure you turn off Header Row if you don't have one.  If you sort by column, it should keep all the rows together.\n\nIf it doesn't, then something is wrong with your setup.\n\nBe careful when trying to sort columns of formulas, if you don't have the formula placeholders correct, it might mess them up.
299985
#!/usr/bin/perl -w\n\nuse strict;\n\nopen( INPUTFILE, "input.txt" ) ;\nmy $startCaptureLine = 10;\nmy $numLinesToCapture = 10;\nmy $curLine = 1;\nmy $capturedLines = "";\nforeach (<INPUTFILE>) {\nif( $curLine >= $startCaptureLine \n     and $curLine <= $startCaptureLine + $numLinesToCapture - 1 ) {\n$capturedLines .= $_ ;\n}\n++$curLine;\n\n}\nprint "$capturedLines";\n\nexit 0;
402471
http://www.mycinnamontoast.com/perl/results.cgi?surname=ARDIS
801228
I'm using Excel 2003. This solution should work for any recent version of Excel. \n\n1. Select the entire worksheet. You do this by either 1) clicking on the "select all" button, which is located between the labels for row 1 and column A (the very top left corner), or 2) press "Ctrl+A".\n\n2. On the top bar menu, choose Data/Sort. Choose the column on which you want to sort. (It almost doesn't matter for your purpose, but if you have a preferred order you might as well choose it now.) \n\nBe sure that the order is Ascending for now, even if you want it to be Descending in your final sort.\n\nIf your worksheet has a header row, you'll want to select the "Header row" radio button. If you choose this option, your header row (row labels) will stay at the top of your sort. If you choose "No header row," the header row labels will sort with the rest of your data.\n\n3. Click "OK." If the sort order is Ascending, your blank rows should be at the bottom of your list. If you had chosen to sort in Descending order, the blank rows would be at the top and you'd have to do a follow-up step of selecting the blank rows and deleting them. \n\nHope that helps.
626282
Here's one way:\n\n#!perl\n\nwhile(<>) {\nif($_ =~ m/abxy$/) {\nchop;\nprintf("$_ -- $.&#92;n");\n}\n}\n\nTurn this into a perl file (say findinline.pl) then run\nPerl findinline.pl somefile\n\nAny qualifying line will print out followed by the line number.
55365
1. You can: IrfanView (http://www.download.com/IrfanView/3000-2192_4-10387524.html?tag=lst-0-5)\n2. A short script (depends on your OS) will do the work as well.\nFor example:\n#!/usr/local/bin/perl\n#\n# Usage: rename perlexpr [files]\n\n($regexp = shift @ARGV) || die "Usage:  rename perlexpr [filenames]&#92;n";\n\nif (!@ARGV) {\n   @ARGV = <STDIN>;\n   chomp(@ARGV);\n}\n\n\nforeach $_ (@ARGV) {\n   $old_name = $_;\n   eval $regexp;\n   die $@ if $@;\n   rename($old_name, $_) unless $old_name eq $_;\n}\n\nexit(0);
784795
numbering pages beginning from 1 in ascending order