Re: Warnings when sorting by hashref

2017-04-11 Thread Chris Fedde
I like to define a value subroutine. sub myvalue { return uc($options{$_[0]}->{type} // "") } This particular one returns the empty string ("") if $options{$_[0]}->{type} is undefined. Now the sort becomes: sort {myvalue($a) cmp myvalue($b)} keys %options This code is unteste

Re: Warnings when sorting by hashref

2017-04-11 Thread Jim Gibson
> On Apr 11, 2017, at 6:13 AM, Mike Martin wrote: > > Hi > > I have the following code as an example against a hash of hashes, to sort by > hashrf key > > foreach my $opt (sort {uc($options{$b}->{type}) cmp uc($options{$a}->{type})} > keys %options){ >my $type=$options{$opt}->{vt

Warnings when sorting by hashref

2017-04-11 Thread Mike Martin
Hi I have the following code as an example against a hash of hashes, to sort by hashrf key foreach my $opt (sort {uc($options{$b}->{type}) cmp uc($options{$a}->{type})} keys %options){ my $type=$options{$opt}->{vtype}; $video_type->append_text($type) if defined($type)

Re: hash of arrays sorting

2012-08-23 Thread Salvador Fandino
$type, ref(code): " . ref($code); +next TEST; +} +} +} +my $sub = eval "sub { $init (" . join(", ", @code) . ") }"; + my $sorter = Sort::Key::multi

Re: hash of arrays sorting

2012-08-23 Thread Salvador Fandino
han Sort::Maker and also Sort::Key::Radix, even >> faster when sorting by numeric keys but not available in Debian. >> >>use Sort::Key qw(ukeysort); >> >>my @sorted = ukeysort { /^(\d+)-(\d+)/ >> or die "bad key $_&quo

Re: hash of arrays sorting

2012-08-23 Thread Rob Coops
usually faster than Sort::Maker and also Sort::Key::Radix, even >> faster when sorting by numeric keys but not available in Debian. >> >>use Sort::Key qw(ukeysort); >> >>my @sorted = ukeysort { /^(\d+)-(\d+)/ >> or die "b

Re: hash of arrays sorting

2012-08-23 Thread Uri Guttman
On 08/23/2012 02:54 AM, Salvador Fandino wrote: It's a pity Sort::Maker not in Debian There is also Sort::Key, available in Debian testing and unstable, and which is usually faster than Sort::Maker and also Sort::Key::Radix, even faster when sorting by numeric keys but not availab

Re: hash of arrays sorting

2012-08-22 Thread Salvador Fandino
de up how you extract each key from >> the data set and how it gets sorted (number vs string, etc.). it makes >> sorting into a declarative problem instead of a coding problem. >> >> uri > > do'nt worry, that's what I'm > > Thanks a lot for

Re: hash of arrays sorting

2012-08-22 Thread Eduardo
and how it gets sorted (number vs string, etc.). it makes > sorting into a declarative problem instead of a coding problem. > > uri do'nt worry, that's what I'm Thanks a lot for forcing me to study sorting in perl. This morning I read sort_paper[*] apparently written by some

Re: hash of arrays sorting

2012-08-21 Thread Uri Guttman
cleaner looking. all you need to do is code up how you extract each key from the data set and how it gets sorted (number vs string, etc.). it makes sorting into a declarative problem instead of a coding problem. uri -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional comman

Re: hash of arrays sorting

2012-08-21 Thread Eduardo
On 22/08/12 00:35, Uri Guttman wrote: > On 08/21/2012 05:33 PM, Eduardo wrote: >> On 21/08/12 22:05, Chris Stinemetz wrote: >>> Hello List, >>> >>> I am trying to sort a hash of arrays ( example below: ) >>> >>> I would the sort to sort in ascending order the first index of the >>> array >>> then

Re: hash of arrays sorting

2012-08-21 Thread Uri Guttman
On 08/21/2012 05:33 PM, Eduardo wrote: On 21/08/12 22:05, Chris Stinemetz wrote: Hello List, I am trying to sort a hash of arrays ( example below: ) I would the sort to sort in ascending order the first index of the array then the second index of the array. So in this example the arrays wou

Re: hash of arrays sorting

2012-08-21 Thread Eduardo
On 21/08/12 22:05, Chris Stinemetz wrote: > Hello List, > > I am trying to sort a hash of arrays ( example below: ) > > I would the sort to sort in ascending order the first index of the array > then the second index of the array. > > So in this example the arrays would sort to: > > 97,2,120,65 >

Re: hash of arrays sorting

2012-08-21 Thread Chris Stinemetz
I will leave it to you to write an actual program incorporating these > ideas. > > Thank you Jim for the excelent explanation. This seems to do the trick. foreach my $cellNo ( sort { $hash{$a}->[0] <=> $hash{$b}->[0] || $hash{$a}->[1] <=> $hash{$b}->[1] } keys %hash ) { print join( "\0", @{

Re: hash of arrays sorting

2012-08-21 Thread Jim Gibson
e array >> then the second index of the array. > > I believe you mean "first element" rather than "first index". The first index > of your array is 0, and sorting by the indices is a no-operation. > > What you want to do is sort the list of keys returned b

Re: hash of arrays sorting

2012-08-21 Thread Jim Gibson
st element" rather than "first index". The first index of your array is 0, and sorting by the indices is a no-operation. What you want to do is sort the list of keys returned by the keys() function. You do this by supplying a subroutine reference to the sort function that returns a neg

Re: hash of arrays sorting

2012-08-21 Thread Chris Stinemetz
On Tue, Aug 21, 2012 at 3:11 PM, Shawn H Corey wrote: > On Tue, 21 Aug 2012 15:05:33 -0500 > Chris Stinemetz wrote: > > > I am trying to sort a hash of arrays ( example below: ) > > > > I would the sort to sort in ascending order the first index of the > > array then the second index of the array

Re: hash of arrays sorting

2012-08-21 Thread Shawn H Corey
On Tue, 21 Aug 2012 15:05:33 -0500 Chris Stinemetz wrote: > I am trying to sort a hash of arrays ( example below: ) > > I would the sort to sort in ascending order the first index of the > array then the second index of the array. What have you tried so far? Can we see the code? -- Just my 0

hash of arrays sorting

2012-08-21 Thread Chris Stinemetz
Hello List, I am trying to sort a hash of arrays ( example below: ) I would the sort to sort in ascending order the first index of the array then the second index of the array. So in this example the arrays would sort to: 97,2,120,65 219,1,30,33 280,3,230,90 462,2,270,65 $VAR1 = { '

Re: array sorting

2012-05-18 Thread Rob Dixon
On 17/05/2012 23:19, Shawn H Corey wrote: > On 12-05-17 05:24 PM, Chris Stinemetz wrote: >> >> push(@fields, $Icell,$Isect,$Ichan,$cfc,$cfcq,$rtd); > > # push an anonymous array for each record > push @fields, [ $Icell,$Isect,$Ichan,$cfc,$cfcq,$rtd ]; > >> } >> } >> >> >> my @sorted_fields = sort

Re: array sorting

2012-05-17 Thread Shawn H Corey
On 12-05-17 05:24 PM, Chris Stinemetz wrote: Thank you Uri and Shawn. I am getting the following error and not sure how to resolve: I will also checkout the great suggestions Uri made. Can't use string ("3") as an ARRAY ref while "strict refs" in use at ./DBSRtest.pl line 51,<> line 999. #!/

Re: array sorting

2012-05-17 Thread Chris Stinemetz
Thank you Uri and Shawn. I am getting the following error and not sure how to resolve: I will also checkout the great suggestions Uri made. Can't use string ("3") as an ARRAY ref while "strict refs" in use at ./DBSRtest.pl line 51, <> line 999. #!/usr/bin/perl use warnings; use strict; use POSI

Re: array sorting

2012-05-17 Thread Uri Guttman
On 05/17/2012 04:52 PM, Shawn H Corey wrote: On 12-05-17 03:36 PM, Chris Stinemetz wrote: I would like to sort the array by $fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5] in ascending order starting witht he first element before I print the array. Do you want the fields sort

Re: array sorting

2012-05-17 Thread Shawn H Corey
On 12-05-17 03:36 PM, Chris Stinemetz wrote: I would like to sort the array by $fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5] in ascending order starting witht he first element before I print the array. Do you want the fields sorted or do you want records sorted? If you want

array sorting

2012-05-17 Thread Chris Stinemetz
I have an array "@fields" that contains 6 elements. I would like to sort the array by $fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5] in ascending order starting witht he first element before I print the array. I haven't been able to figure this out. Any help is greatly apprecia

Re: need guidance on encode JSON and sorting

2012-02-06 Thread Igor Dovgiy
That's what the documentation says: ... $json = $json->canonical([$enable]) "If $enable is true (or missing), then the encode method will output JSON objects by sorting their keys. This is adding a comparatively high overhead". ... So I guess you'd have to use something l

Re: need guidance on encode JSON and sorting

2012-02-05 Thread Rajeev Prasad
d e.g.: 2012-01-20 22:24:36   value is some text - Original Message - From: Rajeev Prasad To: perl list Cc: Sent: Sunday, February 5, 2012 10:20 PM Subject: Re: need guidance on encode JSON and sorting I tried below but getting err:     my $json = JSON::XS->new;     $json

Re: need guidance on encode JSON and sorting

2012-02-05 Thread Rajeev Prasad
Prasad To: perl list Cc: Sent: Sunday, February 5, 2012 10:04 PM Subject: need guidance on encode JSON and sorting in the script this is all i am using JSON as: ... use JSON::XS; ... $return_json_text = encode_json $tmp_hash; this variable ($return_json_text) is then used to display valu

need guidance on encode JSON and sorting

2012-02-05 Thread Rajeev Prasad
in the script this is all i am using JSON as: ... use JSON::XS; ... $return_json_text = encode_json $tmp_hash; this variable ($return_json_text) is then used to display values. I need this to be orderd, but not able to figure how to order the outcome??? I read about $enabled = $json->get_c

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-30 Thread Rob Dixon
On 30/10/2011 13:20, newbie01 perl wrote: Hi Rob, Thanks for your response and to everyone else who had given their thoughts, especially John. This whole exercise is turning out to be a "fun" way of learning arrays and print formatting. I tried the script that you suggested and it is giving som

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-30 Thread newbie01 perl
Hi Rob, Thanks for your response and to everyone else who had given their thoughts, especially John. This whole exercise is turning out to be a "fun" way of learning arrays and print formatting. I tried the script that you suggested and it is giving some error and not sure how to get around it. F

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-25 Thread Rob Dixon
On 24/10/2011 21:35, John W. Krahn wrote: > > You forgot the part where the OP wants to sort the output. :-) I thought I didn't have enough information to know how the OP wanted the report sorted, but I see from the attacked shell script that the original lines from the df output are sorted befor

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-24 Thread John W. Krahn
Rob Dixon wrote: **OUTPUT** FilesystemMBytes UsedAvail Capacity Mount -- - - - /dev/md/dsk/d1 3027-MB 2424-MB 542-MB 82% / /proc

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-24 Thread Rob Dixon
m wanting to convert it to Perl 'coz I have a server that has 30+ lines > of df output and it takes ages to run using Korn shell. I am hoping that > it will run faster in Perl, John W. Krahn had proven that to be case > lots of times, thanks John :-) > > Plus it is a good

Re: HELP on Perl array / sorting - trying to convert Korn ShellScript to Perl

2011-10-23 Thread Dr.Ruud
On 2011-10-22 17:37, timothy adigun wrote: my($filesys,$mbytes,$used,$avail,$capacity,$mount)=("","","","","",""); Alternative: $_ = "" for my ( $p, $q, $r, $s ); -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org htt

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-22 Thread GRAEME F ST CLAIR
"Learning Perl" turns out to be the 6th edition. Oh my! I thought to myself, perhaps mine might be about the 4th or 5th edition - alas, it is the 2nd. Start saving... Tx & rgds, GFStC. On Fri, 21 Oct 2011 22:37:14 -0700 David Christensen wrote: The canonical book for learning Perl i

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-22 Thread Brandon McCaig
On Sat, Oct 22, 2011 at 7:13 PM, Brian Fraser wrote: > I say this without a bit of sarcasm: Feel blessed in your ignorance of > formats. The declarations on top are unfortunately needed (If it helps, > think of formats using lexical variables as closures). > But you shouldn't be using formats. So

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-22 Thread Brian Fraser
On Sat, Oct 22, 2011 at 4:57 PM, Brandon McCaig wrote: > On Sat, Oct 22, 2011 at 11:37 AM, timothy adigun <2teezp...@gmail.com> > wrote: > > my($filesys,$mbytes,$used,$avail,$capacity,$mount)=("","","","","",""); > > Declaring these variables here is useless (and initializing them > here is even

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-22 Thread Brandon McCaig
On Sat, Oct 22, 2011 at 3:00 PM, Brandon McCaig wrote: > http://search.cpan.org/~abarclay/Filesys-DiskFree-0.06/DiskFree.pm I guess the proper way to post a CPAN link is with the 'permalink': http://search.cpan.org/perldoc?Filesys::DiskFree Regards, -- Brandon McCaig Castopulence Software

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-22 Thread Brandon McCaig
On Fri, Oct 21, 2011 at 10:18 PM, newbie01 perl wrote: > At the moment am using > > system("df -k > /tmp/df_tmp.00"); > > To re-direct the df output. Am using df -k because some of the Solaris and > HP servers does not have df -h, by using df -k, am sure it will work on all > of them. Apparently

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-22 Thread Brandon McCaig
On Sat, Oct 22, 2011 at 11:37 AM, timothy adigun <2teezp...@gmail.com> wrote: > my($filesys,$mbytes,$used,$avail,$capacity,$mount)=("","","","","",""); Declaring these variables here is useless (and initializing them here is even more useless). :-/ The lack of whitespace is also useless and makes

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-22 Thread timothy adigun
Hi newbie01 perl, Try the code below and see if it works for you, it works well on my Ultimate Ubuntu OS. Assumptions in the code below: 1. you must pass df to the perl script on the Command Line Interface *e.g perl mydf.pl df*, 2. you don't have Perl6::Form installed, though you can get here h

Re: HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-21 Thread David Christensen
On 10/21/2011 07:18 PM, newbie01 perl wrote: Am trying to write/convert a customized df script... > I've attached a version of the script in Korn shell. ... ... [input] Filesystemkbytesused avail capacity Mounted on /dev/md/dsk/d1 3099287 2482045 55525782%/ /pr

HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

2011-10-21 Thread newbie01 perl
rl 'coz I have a server that has 30+ lines of df output and it takes ages to run using Korn shell. I am hoping that it will run faster in Perl, John W. Krahn had proven that to be case lots of times, thanks John :-) Plus it is a good exercise to learn Perl arrays and sorting too. Any advise/

Re: File sorting question

2011-08-18 Thread ERIC KRAUSE
Brandon and Jim, Thank you for the replies. They were very helpful. I have gotten past my blockage. Eric On Aug 17, 2011, at 5:22 PM, Brandon McCaig wrote: > On Wed, Aug 17, 2011 at 5:59 PM, ERIC KRAUSE wrote: >> The problem for me is the line endings I think. When I open the >> file and read

Re: Sorting a String

2011-08-17 Thread John W. Krahn
Shlomi Fish wrote: "Wagner, David --- Sr Programmer Analyst --- CFS" wrote: Since a \n is at end, then could use split like: for my $dtl ( sort {$a<=> $b} split(/\n/, $a_string) ) { One can also do split(/^/m, $a_string) to split into lines while preserving the newlines. It wi

Re: File sorting question

2011-08-17 Thread Brandon McCaig
On Wed, Aug 17, 2011 at 5:59 PM, ERIC KRAUSE wrote: > The problem for me is the line endings I think. When I open the > file and read in one line, I get the whole file. I think the > line endings are ^p (MS paragraph markers), but I can't open > the file to view them. The files are huge, 150M or b

Re: File sorting question

2011-08-17 Thread Jim Gibson
On 8/17/11 Wed Aug 17, 2011 2:59 PM, "ERIC KRAUSE" scribbled: > Hello all, > I am beating my head against the wall, any help would be appreciated. > > I have a file: > / // / m / cvfbcbf/ A123/ / / /// > / // / m / cvfbcbf/ A234/ / / /// > / /

File sorting question

2011-08-17 Thread ERIC KRAUSE
Hello all, I am beating my head against the wall, any help would be appreciated. I have a file: / // / m / cvfbcbf/ A123/ / / /// / // / m / cvfbcbf/ A234/ / / /// / // / m / cvfbcbf/ B123/ / / /// There is spaces in the b

Re: Sorting a String

2011-08-17 Thread Shlomi Fish
Hi, On Tue, 16 Aug 2011 11:09:35 -0500 "Wagner, David --- Sr Programmer Analyst --- CFS" wrote: > >-Original Message- > >From: Matt [mailto:lm7...@gmail.com] > >Sent: Tuesday, August 16, 2011 10:04 > >To: beginners@perl.org > >Subject: Sorting a

RE: Sorting a String

2011-08-17 Thread Wagner, David --- Sr Programmer Analyst --- CFS
>-Original Message- >From: Matt [mailto:lm7...@gmail.com] >Sent: Tuesday, August 16, 2011 10:04 >To: beginners@perl.org >Subject: Sorting a String > >I believe you can sort an array like so: > >sort @my_array; > >I need to sort a string though. > >

Re: Sorting a String

2011-08-16 Thread John W. Krahn
Matt wrote: I believe you can sort an array like so: sort @my_array; That should be: @my_array = sort @my_array; I need to sort a string though. I have $a_string that contains: 4565 line1 2345 line2 500 line3 etc. Obviously \n is at end of every line in the string. I need it sorted.

Re: Sorting a String

2011-08-16 Thread Brandon McCaig
On Tue, Aug 16, 2011 at 12:04 PM, Matt wrote: > I believe you can sort an array like so: > > sort @my_array; > > I need to sort a string though. > > I have $a_string that contains: > > 4565 line1 > 2345 line2 > 500 line3 > etc. > > Obviously \n is at end of every line in the string.  I need it sor

Re: Sorting a String

2011-08-16 Thread marcos rebelo
sort like string or like numbers? On Tue, Aug 16, 2011 at 18:04, Matt wrote: > I believe you can sort an array like so: > > sort @my_array; > > I need to sort a string though. > > I have $a_string that contains: > > 4565 line1 > 2345 line2 > 500 line3 > etc. > > Obviously \n is at end of every li

Sorting a String

2011-08-16 Thread Matt
I believe you can sort an array like so: sort @my_array; I need to sort a string though. I have $a_string that contains: 4565 line1 2345 line2 500 line3 etc. Obviously \n is at end of every line in the string. I need it sorted. How would I approach this? -- To unsubscribe, e-mail: beginner

Re: Sorting an extremely LARGE file

2011-08-08 Thread shawn wilson
On Mon, Aug 8, 2011 at 10:10, Paul Johnson wrote: > On Mon, Aug 08, 2011 at 09:25:48AM -0400, shawn wilson wrote: >> On Aug 8, 2011 12:11 AM, "Ramprasad Prasad" wrote: >> > >> > Using the system linux sort ... Does not help. >> > On my dual quad core machine , (8 gb ram) sort -n file takes 10 >>

Re: Sorting an extremely LARGE file

2011-08-08 Thread Shawn H Corey
On 11-08-08 10:23 AM, Shlomi Fish wrote: I suggest splitting the files into bins. Each bin will contain the records with the batch numbers in a certain range (say 0-999,999 ; 1,000,000-1,999,999, etc.). You should select the bins so the numbers are spread more or less evenly. Then you sort each b

Re: Sorting an extremely LARGE file

2011-08-08 Thread Shlomi Fish
Hi Ramprasad, On Sun, 7 Aug 2011 20:58:14 +0530 Ramprasad Prasad wrote: > I have a file that contains records of customer interaction > The first column of the file is the batch number(INT) , and other columns > are date time , close time etc etc > > I have to sort the entire file in order of t

Re: Sorting an extremely LARGE file

2011-08-08 Thread Paul Johnson
On Mon, Aug 08, 2011 at 09:25:48AM -0400, shawn wilson wrote: > On Aug 8, 2011 12:11 AM, "Ramprasad Prasad" wrote: > > > > Using the system linux sort ... Does not help. > > On my dual quad core machine , (8 gb ram) sort -n file takes 10 > > minutes and in the end produces no output. > > I had a

Re: Sorting an extremely LARGE file

2011-08-08 Thread shawn wilson
On Aug 8, 2011 12:11 AM, "Ramprasad Prasad" wrote: > > Using the system linux sort ... Does not help. > On my dual quad core machine , (8 gb ram) sort -n file takes 10 > minutes and in the end produces no output. > I had a smaller file and 32g to play with on a dual quad core (dl320). Sort just c

Re: Sorting an extremely LARGE file

2011-08-08 Thread Paul Johnson
On Mon, Aug 08, 2011 at 10:40:12AM +0530, Ramprasad Prasad wrote: > Using the system linux sort ... Does not help. > On my dual quad core machine , (8 gb ram) sort -n file takes 10 > minutes and in the end produces no output. Did you set any other options? At a minimum you should set -T to tell

Re: Sorting an extremely LARGE file

2011-08-07 Thread Kenneth Wolcott
On Sun, Aug 7, 2011 at 22:10, Ramprasad Prasad wrote: > [snip] > I guess there is a serious need for re-architecting , rather than > create such monstrous files, but when people work with legacy systems > which worked fine when there was lower usage and now you tell then you > need a overhaul be

Re: Sorting an extremely LARGE file

2011-08-07 Thread Ramprasad Prasad
Using the system linux sort ... Does not help. On my dual quad core machine , (8 gb ram) sort -n file takes 10 minutes and in the end produces no output. when I put this data in mysql , there is an index on the order by field ... But I guess keys don't help when you are selecting the entire table.

Re: Sorting an extremely LARGE file

2011-08-07 Thread Uri Guttman
> "RP" == Rajeev Prasad writes: RP> hi, you can try this: first get only that field (sed/awk/perl) RP> whihc you want to sort on in a file. sort that file which i assume RP> would be lot less in size then your current file/table. then run a RP> loop on the main file using sorted file

Re: Sorting an extremely LARGE file

2011-08-07 Thread shawn wilson
On Sun, Aug 7, 2011 at 15:58, Rob Dixon wrote: > On 07/08/2011 20:30, Shawn H Corey wrote: >> >> On 11-08-07 03:20 PM, shawn wilson wrote: >>> >>> It can be sped up (slightly) with an index. >> >> Indexes in SQL don't normally speed up sorti

Re: Sorting an extremely LARGE file

2011-08-07 Thread Rob Dixon
On 07/08/2011 20:30, Shawn H Corey wrote: On 11-08-07 03:20 PM, shawn wilson wrote: It can be sped up (slightly) with an index. Indexes in SQL don't normally speed up sorting. What they're best at is selecting a limited number of records, usually less than 10% of the total. Other

Re: Sorting an extremely LARGE file

2011-08-07 Thread Shawn H Corey
On 11-08-07 03:20 PM, shawn wilson wrote: It can be sped up (slightly) with an index. Indexes in SQL don't normally speed up sorting. What they're best at is selecting a limited number of records, usually less than 10% of the total. Otherwise, they just get in the way. The be

Re: Sorting an extremely LARGE file

2011-08-07 Thread shawn wilson
On Aug 7, 2011 1:15 PM, "Paul Johnson" wrote: > > On Sun, Aug 07, 2011 at 08:58:14PM +0530, Ramprasad Prasad wrote: > > > I have a file that contains records of customer interaction > > The first column of the file is the batch number(INT) , and other columns > > are date time , close time etc etc

Re: Sorting an extremely LARGE file

2011-08-07 Thread Paul Johnson
On Sun, Aug 07, 2011 at 08:58:14PM +0530, Ramprasad Prasad wrote: > I have a file that contains records of customer interaction > The first column of the file is the batch number(INT) , and other columns > are date time , close time etc etc > > I have to sort the entire file in order of the first

Re: Sorting an extremely LARGE file

2011-08-07 Thread Rajeev Prasad
print $}' > tmp-file   sort   for id in `cat `;do grep $id >> sorted-large-file;done From: Ramprasad Prasad To: Shawn H Corey Cc: Perl Beginners Sent: Sunday, August 7, 2011 11:01 AM Subject: Re: Sorting an extremely LARGE file On 7 August 2011 21:24, Shawn H Corey wrote: >

Re: Sorting an extremely LARGE file

2011-08-07 Thread Dr.Ruud
On 2011-08-07 17:28, Ramprasad Prasad wrote: I have a file that contains records of customer interaction The first column of the file is the batch number(INT) , and other columns are date time , close time etc etc I have to sort the entire file in order of the first column .. but the problem is

Re: Sorting an extremely LARGE file

2011-08-07 Thread Ramprasad Prasad
On 7 August 2011 21:24, Shawn H Corey wrote: > On 11-08-07 11:46 AM, Ramprasad Prasad wrote: > >> I used a mysql database , but the order by clause used to hang the >> process indefinitely >> If I sort files in smaller chunks how can I merge them back ?? >> >> > Please use "Reply All" when respon

Re: Sorting an extremely LARGE file

2011-08-07 Thread Shawn H Corey
On 11-08-07 11:46 AM, Ramprasad Prasad wrote: I used a mysql database , but the order by clause used to hang the process indefinitely If I sort files in smaller chunks how can I merge them back ?? Please use "Reply All" when responding to a message on this list. You need two temporary files a

Re: Sorting an extremely LARGE file

2011-08-07 Thread Shawn H Corey
On 11-08-07 11:28 AM, Ramprasad Prasad wrote: I have a file that contains records of customer interaction The first column of the file is the batch number(INT) , and other columns are date time , close time etc etc I have to sort the entire file in order of the first column .. but the problem is

Sorting an extremely LARGE file

2011-08-07 Thread Ramprasad Prasad
I have a file that contains records of customer interaction The first column of the file is the batch number(INT) , and other columns are date time , close time etc etc I have to sort the entire file in order of the first column .. but the problem is that the file is extremely huge. For the large

Re: sorting report

2011-02-01 Thread Rob Dixon
On 01/02/2011 14:02, Chris Stinemetz wrote: #!/usr/bin/perl use warnings; use strict; use IO::Handle; RAW->format_lines_per_page(100); # I will change this once I get strict pragma to work. format RAW_TOP = @|||

RE: sorting report

2011-02-01 Thread Chris Stinemetz
I bottom posted. Any help is greatly appreciated. Chris -Original Message- From: Chris Stinemetz [mailto:cstinem...@cricketcommunications.com] Sent: Tuesday, February 01, 2011 8:03 AM To: Shlomi Fish; beginners@perl.org Subject: RE: sorting report Shlomi, See far bottom for my

RE: sorting report

2011-02-01 Thread Chris Stinemetz
Shlomi, See far bottom for my updated code. Chris Stinemetz -Original Message- From: Shlomi Fish [mailto:shlo...@iglu.org.il] Sent: Tuesday, February 01, 2011 4:18 AM To: beginners@perl.org Cc: Chris Stinemetz Subject: Re: sorting report Hi Chris, a few comments on your code: On

Re: sorting report

2011-02-01 Thread Shlomi Fish
Hi Chris, a few comments on your code: On Tuesday 01 Feb 2011 06:43:43 Chris Stinemetz wrote: > I would like to sort my final report in the following order: > > $data[31],$data[32],$data[38] > > How would I add this into my following program to get the report sorted > this way? > > Thanks in a

sorting report

2011-01-31 Thread Chris Stinemetz
I would like to sort my final report in the following order: $data[31],$data[32],$data[38] How would I add this into my following program to get the report sorted this way? Thanks in advance. Chris #!/usr/bin/perl use warnings; #use strict; use FileHandle; use IO::Handle; RAW->format_lines_

Re: Sorting files in a directory, without using any OS specific command, ordered by modified timestamp

2010-12-01 Thread Mark
> On Dec 1, 7:31 am, jwkr...@shaw.ca ("John W. Krahn") wrote: > > Correction: > > my @sorted_files_in_directory = >      map $_->[ 1 ], >      sort { $a->[ 0 ] <=> $b->[ 0 ] } >      map { ( stat "$directory_name/$_" )[ 9 ], $_ } map { [ ( stat "$directory_name/$_" )[ 9 ], $_ ] } >    

Re: Sorting files in a directory, without using any OS specific command, ordered by modified timestamp

2010-12-01 Thread Shlomi Fish
On Wednesday 01 December 2010 16:57:07 John W. Krahn wrote: > Amit Saxena wrote: > > Hi all, > > { > > > > next if ( ( $filename eq "." ) or ( $filename eq ".." ) ); > > > > push ( @files_in_directory, $filename ); > > > > } > > Since all you are doing is populating t

Re: Sorting files in a directory, without using any OS specific command, ordered by modified timestamp

2010-12-01 Thread Shawn H Corey
On 10-12-01 09:57 AM, John W. Krahn wrote: Or just: print map( "$_\n", @files_in_directory ), "\n"; print map( "$_\n", @sorted_files_in_directory ), "\n"; -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding.

Re: Sorting files in a directory, without using any OS specific command, ordered by modified timestamp

2010-12-01 Thread John W. Krahn
John W. Krahn wrote: Amit Saxena wrote: my @sorted_files_in_directory; @sorted_files_in_directory = sort { (stat($a))[9]<=> (stat($b))[9] } If you read the documentation for readdir you will see where it says: If you're planning to filetest the return values out of a "readdir", you'd better

Re: Sorting files in a directory, without using any OS specific command, ordered by modified timestamp

2010-12-01 Thread John W. Krahn
Amit Saxena wrote: Hi all, Hello, The following perl program, for sorting files in a directory, without using any OS specific command, ordered by modified timestamp is not working. Please help. *Perl Program* #!perl.exe use strict; use warnings; my $directory_name; print "This pr

Re: Sorting files in a directory, without using any OS specific command, ordered by modified timestamp

2010-12-01 Thread Shawn H Corey
On 10-12-01 07:19 AM, Amit Saxena wrote: print "Sorted listing of files in<$directory_name> directory are as follows :-\n"; my $j; foreach $j ( @files_in_directory ) foreach $j ( @sorted_files_in_directory ) { print $j . "\n"; } print "\n"; -- Just my 0.0002 million dollars w

Sorting files in a directory, without using any OS specific command, ordered by modified timestamp

2010-12-01 Thread Amit Saxena
Hi all, The following perl program, for sorting files in a directory, without using any OS specific command, ordered by modified timestamp is not working. Please help. *Perl Program* #!perl.exe use strict; use warnings; my $directory_name; print "This program print the files in asce

Re: sorting DB_File hash data

2010-06-21 Thread C.DeRykus
On Jun 20, 1:39 am, philg...@yahoo.com (philge philip) wrote: > hi > > can someone tell me how i can sort by keys from a hash (huge data) stored in > a DB_File? > You might try a merge-sort - check CPAN. Another possibility: re-write the existing DB_File to use a DB_Tree format which by default

sorting DB_File hash data

2010-06-20 Thread philge philip
hi can someone tell me how i can sort by keys from a hash (huge data) stored in a DB_File? thanking you philge

Re: Sorting mixed alphanumerics

2009-10-18 Thread Rick Triplett
Many thanks to Scott, Shawn, Paul, Jenda, and Uri. I've learned something from each of you, and appreciate your taking the time to help! Rick -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Sorting mixed alphanumerics

2009-10-14 Thread Jenda Krynicky
From: Shawn H Corey > Jenda Krynicky wrote: > > ST is an overkill if the extraction is simple. > > > > Especially if the number of items is fairly small. > > > > Actually if the extraction is really simple and the extracted key is > > not so small, than ST may perform worse than an ordinary so

RE: Sorting mixed alphanumerics

2009-10-14 Thread Hall, Scott
>-Original Message- >From: Rick Triplett [mailto:r...@reason.net] >Sent: Tuesday, October 13, 2009 12:09 PM >To: Perl Beginners >Subject: Sorting mixed alphanumerics > >I need to sort the keys in a hash. The keys are the question number >and the values are the stu

Re: Sorting mixed alphanumerics

2009-10-14 Thread Uri Guttman
SHC> that changes if the sort-field-extraction functions and whether a '<=>' SHC> or 'cmp' appears in the sort. All the rest is just copy & paste. and if you can't generate an ST easily enough, try Sort::Maker. it can do that and 3 other sort styles.

Re: Sorting mixed alphanumerics

2009-10-14 Thread Shawn H Corey
Jenda Krynicky wrote: > ST is an overkill if the extraction is simple. > > Especially if the number of items is fairly small. > > Actually if the extraction is really simple and the extracted key is > not so small, than ST may perform worse than an ordinary sort doing > the extraction within t

Re: Sorting mixed alphanumerics

2009-10-14 Thread Jenda Krynicky
Date sent: Wed, 14 Oct 2009 11:03:13 -0400 From: Shawn H Corey To: Rick Triplett Copies to: Perl Beginners Subject:Re: Sorting mixed alphanumerics > Rick Triplett wrote: > > I need to sort the keys in a

Re: Sorting mixed alphanumerics

2009-10-14 Thread Paul Johnson
On Tue, Oct 13, 2009 at 11:09:09AM -0500, Rick Triplett wrote: > I need to sort the keys in a hash. The keys are the question number and > the values are the student's answer. A numeric sort with <=> won't work > since retaking a missed question (say, 2) produces the new key, 2h with > its new a

Re: Sorting mixed alphanumerics

2009-10-14 Thread Shawn H Corey
Rick Triplett wrote: > I need to sort the keys in a hash. The keys are the question number and > the values are the student's answer. A numeric sort with <=> won't work > since retaking a missed question (say, 2) produces the new key, 2h with > its new answer. A representative hash might look like

Sorting mixed alphanumerics

2009-10-14 Thread Rick Triplett
I need to sort the keys in a hash. The keys are the question number and the values are the student's answer. A numeric sort with <=> won't work since retaking a missed question (say, 2) produces the new key, 2h with its new answer. A representative hash might look like this 1 => b 2h => c 3

Re: Sorting a hash to user needs

2009-07-08 Thread Chas. Owens
On Wed, Jul 8, 2009 at 15:09, "Alexander Müller" wrote: > Hi, > > I need an order for hash by user preferences. Because the criterion to order > the hash entries a not numerical and not should sorted alphabetical, I tried > following > > >   3 %hashToSort = ( >   4 "a" => "one", >   5 "b"

Sorting a hash to user needs

2009-07-08 Thread Alexander Müller
Hi, I need an order for hash by user preferences. Because the criterion to order the hash entries a not numerical and not should sorted alphabetical, I tried following   3 %hashToSort = (   4 "a" => "one",   5 "b" => "two",   6 "c" => "three",   7 ); @keys = sort { qw(a, b, c) } (

  1   2   3   4   5   6   7   8   >