On 04/16/2012 01:58 AM, Shekar wrote:
if( exists $hash_val{$dom} ) {
my $val=$hash_val{$dom};
$val++;
$hash_val{$dom}=$val;
} else {
$hash_val{$dom}=1;
}
all that code can be replaced with this one line:
$hash_val{$dom}++ ;
pe
On 15/04/2012 18:44, Вячеслав Агапов wrote:
Hello all.
I have a file with logs
2012-04-13 17:06:10,881 test:dom1 CRIT home
2012-04-13 17:06:10,882 work:dom1 CRIT home
2012-04-13 17:06:10,882 my:dom1 CRIT home
2012-04-13 17:06:10,881 test:dom2 CRIT home
2012-04-13 17:06:10,882 work:dom2 CRIT home
Thanks Uri, and Ruud for lightening up :)
Cheers,
Shekar
On Mon, Apr 16, 2012 at 12:25 PM, Dr.Ruud wrote:
> On 2012-04-16 07:58, Shekar wrote:
>
> next if (/^\s$/);
>>
>
> You probably meant:
>
> next if /^\s*$/; # skip blank lines
>
> --
> Ruud
>
>
> --
> To unsubscribe, e-mail: begin
On 2012-04-16 07:58, Shekar wrote:
next if (/^\s$/);
You probably meant:
next if /^\s*$/; # skip blank lines
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 04/16/2012 01:58 AM, Shekar wrote:
if( exists $hash_val{$dom} ) {
my $val=$hash_val{$dom};
$val++;
$hash_val{$dom}=$val;
} else {
$hash_val{$dom}=1;
}
all that code can be replaced with this one line:
$hash_val{$dom}++ ;
pe
Below code might be helpful...
Assuming you are passing log file as argument 1, and your values in log
file are space delimited,
use Data::Dumper;
open my $fd, "<", "$ARGV[0]" or die $!;
while(<$fd>) {
next if (/^\s$/);
my ($some_date, $some_time, $dom, $crt, $home)=split;
i
Вячеслав Агапов wrote:
Hello all.
Hello,
I have a file with logs
2012-04-13 17:06:10,881 test:dom1 CRIT home
2012-04-13 17:06:10,882 work:dom1 CRIT home
2012-04-13 17:06:10,882 my:dom1 CRIT home
2012-04-13 17:06:10,881 test:dom2 CRIT home
2012-04-13 17:06:10,882 work:dom2 CRIT home
2012-04-1
On 12-04-15 01:44 PM, Вячеслав Агапов wrote:
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
use 5.010;
use IO::Compress::Gzip;
use IO::Uncompress::Gunzip;
my %count = ();
my $file = "log.gz";
my $ungzip = new IO::Uncompress::Gunzip($file);
@arr = grep/work/,<$ungzip>;
foreach
thanks rob. it worked
From: Rob Dixon
To: beginners@perl.org
Cc: Irfan Sayed
Sent: Thursday, June 23, 2011 3:37 PM
Subject: Re: sort hash
On 23/06/2011 10:36, Irfan Sayed wrote:
> Hi,
>
> i need to sort hash in descending order.
> but the issue
On 2011-06-23 11:36, Irfan Sayed wrote:
[I need to sort a hash, but my keys are integers]
Realize that all hash keys are strings.
sort { $hash_fin{$b} <=> $hash_fin{$a} } keys %hash_fin
You were almost there:
sort { $b <=> $a } keys %hash_fin
The <=> operator is numeric, so casts it
On 23/06/2011 10:36, Irfan Sayed wrote:
> Hi,
>
> i need to sort hash in descending order.
> but the issue is , in hash, i have key as integer value and the value
> associated with that key is string
>
> so when i do sort it does not really sort the hash on the key level
>
>
> i used follwoing
> "RD" == Rob Dixon writes:
RD> On 17/03/2011 17:22, Shawn H Corey wrote:
>> On 11-03-17 01:05 PM, Rob Dixon wrote:
>>>
>>> If you are uncomfortable with arrays of hash references
>>
>> Sooner or later every Perl programmer has to become comfortable with
>> complex data struct
On 11-03-17 03:23 PM, Rob Dixon wrote:
We have established that Chris's data is numeric. Your code is overkill.
No, it's not. Just because this case does not have the join character
in the data, does mean it will never happen. What the novice programmer
is going to do is decide that this te
On 17/03/2011 18:43, Shawn H Corey wrote:
On 11-03-17 02:04 PM, Rob Dixon wrote:
A beginners list isn't the place to introduce arbitrarily complex Perl
constructs. Replies have to be sensitive to the ability of the OP or
they may co
On the other hand, telling them to use a kluge to get the re
On 11-03-17 02:04 PM, Rob Dixon wrote:
A beginners list isn't the place to introduce arbitrarily complex Perl
constructs. Replies have to be sensitive to the ability of the OP or
they may co
On the other hand, telling them to use a kluge to get the results they
want is very bad advice. Tell t
On 17/03/2011 17:22, Shawn H Corey wrote:
On 11-03-17 01:05 PM, Rob Dixon wrote:
If you are uncomfortable with arrays of hash references
Sooner or later every Perl programmer has to become comfortable with
complex data structures. Why not start now?
A beginners list isn't the place to intro
On 17/03/2011 17:22, Chris Stinemetz wrote:
From: Rob Dixon [mailto:rob.di...@gmx.com]
If you are uncomfortable with arrays of hash references, it may be
better for you to create an array of records containing just the four
fields you are interested in, and then sort that. Such a program is
sho
On 11-03-17 01:05 PM, Rob Dixon wrote:
If you are uncomfortable with arrays of hash references
Sooner or later every Perl programmer has to become comfortable with
complex data structures. Why not start now?
--
Just my 0.0002 million dollars worth,
Shawn
Confusion is the first step
On 16/03/2011 14:58, Chris Stinemetz wrote:
> Shawn H Corey wrote:
>> On 11-03-16 09:26 AM, Chris Stinemetz wrote:
>>>
>>> I would like to print results in ascending order starting with $cell,
>>> $sect, and finally $carr.
>>
>> You would need to store the data in a large array, then sort it.
>>
On Thu, Mar 17, 2011 at 11:04, Chris Stinemetz
wrote:
snip
> For some reason I am not getting the sorted list in my output file. Instead I
> am getting the following:
>
> bc8) HASH(0x100d0d78) HASH(0x100d15e8) HASH(0x100d0f28) HASH(0x100d0c58)
> HASH(0x100d1168) HASH(0x100d1678)
snip
You are g
On 11-03-17 11:04 AM, Chris Stinemetz wrote:
print OUTFILE "@sorted:\n";
for my $tuple ( @sorted ){
print "$tuple->{cell} $tuple->{sect} $tuple->{carr} $tuple->{RTD}\n";
}
--
Just my 0.0002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Pr
Good day,
Your help is greatly appreciated. Thanks
For some reason I am not getting the sorted list in my output file. Instead I
am getting the following:
bc8) HASH(0x100d0d78) HASH(0x100d15e8) HASH(0x100d0f28) HASH(0x100d0c58)
HASH(0x100d1168) HASH(0x100d1678) HASH(0x100d21
70) HASH(0x100d0ce
On 11-03-16 10:58 AM, Chris Stinemetz wrote:
Where would I place print to see the results for validation?
Since @sorted contains the sorted data, anywhere after it gets the
sorted data.
--
Just my 0.0002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Prog
Thanks,
Where would I place print to see the results for validation?
On 11-03-16 09:26 AM, Chris Stinemetz wrote:
> I would like to print results in ascending order starting with $cell, $sect,
> and finally $carr.
You would need to store the data in a large array, then sort it.
# untested du
On 11-03-16 09:26 AM, Chris Stinemetz wrote:
I would like to print results in ascending order starting with $cell, $sect,
and finally $carr.
You would need to store the data in a large array, then sort it.
# untested due lack of data
my @array = ();
while (<>)
{
chomp;
if (/;/)
{
On Sun, Jun 20, 2010 at 04:41, philge philip wrote:
> hi
>
> can someone tell me how i can sort by keys from a hash (huge data) stored
> using Data::Dumper?
snip
Data::Dumper can be configured through the use of its package
variables (or methods if you are using the OO version). For instance:
On Sunday 20 Jun 2010 11:41:42 philge philip wrote:
> hi
>
> can someone tell me how i can sort by keys from a hash (huge data) stored
> using Data::Dumper?
>
You need to do:
[code]
my @keys = sort { $a cmp $b } keys(%hash);
[/code]
Is it causing a memory overflow?
Regards,
Shlomi Fi
Hi Owen,
On Tuesday 11 May 2010 14:10:49 Owen wrote:
> I have this statement;
>
> foreach my $key ( keys %filehash ) {
> print "$key $filehash{$key}->[0]\t\t\t$filehash{$key}->[3]\t
> $filehash{$key}->[2]\t $filehash{$key}->[1]\n";
> }
>
> but wish to sort the output by $filehash{$key}->[0].
Robert Wohlfarth wrote:
> On Mon, Dec 7, 2009 at 10:29 PM, wrote:
>
>> I'm fairly new to perl but loving it. I've run into some trouble though...
>> Trying to sort a hash by it's key value, which is not a problem by itself;
>>
>> foreach(my $key (sort keys %channels)) {
>>print $key;
>> }
On Mon, Dec 7, 2009 at 10:29 PM, wrote:
> I'm fairly new to perl but loving it. I've run into some trouble though...
> Trying to sort a hash by it's key value, which is not a problem by itself;
>
> foreach(my $key (sort keys %channels)) {
>print $key;
> }
>
> What I've been struggling wit
On Fri, Jul 24, 2009 at 11:01, Jo for lists and
groups wrote:
> How about this? Jo
>
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my @list = qw/dog is a there/;
> my @sortOrder = (3,1,2,0);
> my @sorted;
> foreach (@sortOrder) { push(@sorted,$list[$_]); }
>
> print "@sorted";
> exit;
s
Steve Bertrand wrote:
> Jo for lists and groups wrote:
>> How about this? Jo
>
>> #!/usr/bin/perl
>>
>> use strict;
>> use warnings;
>>
>> my @list = qw/dog is a there/;
>> my @sortOrder = (3,1,2,0);
>> my @sorted;
>> foreach (@sortOrder) { push(@sorted,$list[$_]); }
>>
>> print "@sorted";
>> exit
Jo for lists and groups wrote:
> How about this? Jo
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my @list = qw/dog is a there/;
> my @sortOrder = (3,1,2,0);
> my @sorted;
> foreach (@sortOrder) { push(@sorted,$list[$_]); }
>
> print "@sorted";
> exit;
...or this:
#!/usr/bin/perl
use
How about this? Jo
#!/usr/bin/perl
use strict;
use warnings;
my @list = qw/dog is a there/;
my @sortOrder = (3,1,2,0);
my @sorted;
foreach (@sortOrder) { push(@sorted,$list[$_]); }
print "@sorted";
exit;
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands
On Fri, Jul 24, 2009 at 00:14, sys adm wrote:
> Hi,
>
> When I got a word list, I want it to be sorted with special order.
> for example, I got this array:
>
> ("dog","is","a","there");
>
> I want the sorted result is:
>
> ("there","is","a","dog");
>
> How to code it? Thank you.
snip
You need to s
Chas. Owens wrote:
On Tue, May 12, 2009 at 00:08, Rick wrote:
snip
It's very weird. I did verify that it is numeric values that I am
comparing... also i am using warnings and strict as well and i get no
warnings.
can't figure out what's wrong.
snip
In cases like this it is best to try
On Tue, May 12, 2009 at 00:08, Rick wrote:
snip
> It's very weird. I did verify that it is numeric values that I am
> comparing... also i am using warnings and strict as well and i get no
> warnings.
> can't figure out what's wrong.
snip
In cases like this it is best to try to reproduce your prob
John W. Krahn wrote:
Rick wrote:
John W. Krahn wrote:
Rick wrote:
should this not work?
Based upon the code presented, it looks like the code it correct.
I am finding out that Length is *NOT* being sorted correctly
numerically...
Of course we don't know the data stored in %in_array and %
Rick wrote:
John W. Krahn wrote:
Rick wrote:
should this not work?
Based upon the code presented, it looks like the code it correct.
I am finding out that Length is *NOT* being sorted correctly
numerically...
Of course we don't know the data stored in %in_array and %in_array_c
so it is h
John W. Krahn wrote:
Rick wrote:
should this not work?
Based upon the code presented, it looks like the code it correct.
I am finding out that Length is *NOT* being sorted correctly
numerically...
Of course we don't know the data stored in %in_array and %in_array_c
so it is hard to say wh
Rick wrote:
should this not work?
Based upon the code presented, it looks like the code it correct.
I am finding out that Length is *NOT* being sorted correctly numerically...
Of course we don't know the data stored in %in_array and %in_array_c so
it is hard to say why it is not working th
On Apr 2, 9:04 am, [EMAIL PROTECTED] (Matthew Whipple) wrote:
> LC_ALL=C sort echo.txt
>
>
>
> [EMAIL PROTECTED] wrote:
> > On Mar 29, 3:19 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
>
> >> [EMAIL PROTECTED] wrote:
>
> >>> When I do string comparisons in perl the strings seem to ignore the
> >>>
LC_ALL=C sort echo.txt
[EMAIL PROTECTED] wrote:
On Mar 29, 3:19 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
[EMAIL PROTECTED] wrote:
When I do string comparisons in perl the strings seem to ignore the
embedded hyphens.
I want to sort strings assuming the 'dictionary' order of the char
On Mar 29, 3:19 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> [EMAIL PROTECTED] wrote:
> > When I do string comparisons in perl the strings seem to ignore the
> > embedded hyphens.
> > I want to sort strings assuming the 'dictionary' order of the chars is
> > ASCII order: hypen, 0-9, A-Z.
> > It a
[EMAIL PROTECTED] schreef:
> John W. Krahn:
>> It appears to work in Perl:
>>
>> $ perl -le'@x = qw[22 2-2 2-3 23 21]; print for sort @x'
>> 2-2
>> 2-3
>> 21
>> 22
>> 23
>
> I'm looking for the perl way of comparing strings.
>
> Your posted code 'diff says memory exhausted need help with perl
>
[EMAIL PROTECTED] wrote:
On Mar 30, 10:57 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
It appears to work in Perl:
$ perl -le'@x = qw[22 2-2 2-3 23 21]; print for sort @x'
2-2
2-3
21
22
23
I'm looking for the perl way of comparing strings.
Your posted code 'diff says memory exhausted need h
On Mar 31, 11:44 am, [EMAIL PROTECTED] (Dr.Ruud) wrote:
> [EMAIL PROTECTED] schreef:
>
> > unsorted:
> > 22
> > 2-2
> > 2-3
> > 23
> > 21
>
> > linux sort produces:
> > 21
> > 22
> > 2-2
> > 23
> > 2-3
>
> $ echo '
> 21
> 22
> 2-4
> 2-2
> 23
> 2-3
> ' |sort -n
>
> 2-2
> 2-3
> 2-4
> 21
> 22
> 23
>
>
On Mar 30, 10:57 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> [EMAIL PROTECTED] wrote:
>
> > On Mar 29, 4:19 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
>
> >> [EMAIL PROTECTED] wrote:
>
> >>> When I do string comparisons in perl the strings seem to ignore the
> >>> embedded hyphens.
> >>> I wan
[EMAIL PROTECTED] schreef:
> unsorted:
> 22
> 2-2
> 2-3
> 23
> 21
>
> linux sort produces:
> 21
> 22
> 2-2
> 23
> 2-3
$ echo '
21
22
2-4
2-2
23
2-3
' |sort -n
2-2
2-3
2-4
21
22
23
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands,
[EMAIL PROTECTED] wrote:
On Mar 29, 4:19 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
[EMAIL PROTECTED] wrote:
When I do string comparisons in perl the strings seem to ignore the
embedded hyphens.
I want to sort strings assuming the 'dictionary' order of the chars is
ASCII order: hypen, 0-9,
On Mar 29, 4:19 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> [EMAIL PROTECTED] wrote:
> > When I do string comparisons in perl the strings seem to ignore the
> > embedded hyphens.
> > I want to sort strings assuming the 'dictionary' order of the chars is
> > ASCII order: hypen, 0-9, A-Z.
> > It a
[EMAIL PROTECTED] wrote:
When I do string comparisons in perl the strings seem to ignore the
embedded hyphens.
I want to sort strings assuming the 'dictionary' order of the chars is
ASCII order: hypen, 0-9, A-Z.
It appears linux sort also has the problem (LC_ALL is blank).
Any ideas? I want to av
[EMAIL PROTECTED] wrote:
>
When I do string comparisons in perl the strings seem to ignore the
embedded hyphens.
>
I want to sort strings assuming the 'dictionary' order of the chars is
ASCII order: hypen, 0-9, A-Z.
>
It appears linux sort also has the problem (LC_ALL is blank).
>
Any ideas?
yitzle wrote:
P.S. What's HTH?
Hope This Helps :)
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
In that case just create a list of the keys with a defined VAL value
before you do the sort:
my @keys = grep defined $dHash{$_}{VAL}, keys %dHash;
foreach (sort { $dHash{$b}{VAL} <=> $dHash{$a}{VAL} } @keys) {
print $_, "\n";
}
HTH,
Rob
This solution appeals to me. I'll use it. Tha
yitzle wrote:
Inside the loop I check if the value is defined, so I don't care where
in the order the undefined one shows up in. I don't want to delete
undefined ones or anything...
On 4/25/07, Chas Owens <[EMAIL PROTECTED]> wrote:
On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote:
> Warning messag
yitzle wrote:
On 4/25/07, Chas Owens <[EMAIL PROTECTED]> wrote:
On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote:
Warning message:
Use of uninitialized value in numeric comparison (<=>) at ...
Code:
foreach (sort { $dHash{$b}{'VAL} <=> $dHash{$a}{'VAL'} } keys %dHash) {
How do I fix? Should my
On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote:
Inside the loop I check if the value is defined, so I don't care where
in the order the undefined one shows up in. I don't want to delete
undefined ones or anything...
Then you can either turn off the warnings for that section (not
advised), ignore
On 4/24/07, yitzle <[EMAIL PROTECTED]> wrote:
Warning message:
Use of uninitialized value in numeric comparison (<=>) at ...
Code:
foreach (sort { $dHash{$b}{'VAL} <=> $dHash{$a}{'VAL'} } keys %dHash) {
How do I fix?
Give it an initialized value. Maybe like this?
sort { ($dHash{$b}{VAL} ||
Inside the loop I check if the value is defined, so I don't care where
in the order the undefined one shows up in. I don't want to delete
undefined ones or anything...
On 4/25/07, Chas Owens <[EMAIL PROTECTED]> wrote:
On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote:
> Warning message:
> Use of uni
On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote:
Warning message:
Use of uninitialized value in numeric comparison (<=>) at ...
Code:
foreach (sort { $dHash{$b}{'VAL} <=> $dHash{$a}{'VAL'} } keys %dHash) {
How do I fix? Should my sort function be checking for variable
defined? What do I return on
On Wed, Apr 25, 2007 at 01:37:24AM -0400, yitzle wrote:
> Warning message:
> Use of uninitialized value in numeric comparison (<=>) at ...
>
> Code:
> foreach (sort { $dHash{$b}{'VAL} <=> $dHash{$a}{'VAL'} } keys %dHash) {
perhaps
foreach (sort { $dHash{$b}{'VAL'} <=> $dHash{$a
>>
>> Data file below is just made up but illustrates the structure
>>
>> line1^FC12345^IQ
>> line1^FC12345^LD
>> line1^FC2345^pq
>> line2^FC12345^IQ
>> line2^FC12345^LD
>> line2^FC2345^pq
>> line3^FC12345^IQ
>> line3^FC12345^LD
>> line3^FC2345^pq
>>
>> WHEN FINISHED
>> line1
>> line2
>> line3
>>
Ok, for those interested the threshold for shuffling is 256 elements.
Though I'm still confused on shuffling vs. random quicksort, I imagine
thats a question only the person who implemented it can answer. And
thanks for the clarification on lists vs arrays.
On 12/13/06, John W. Krahn <[EMAIL PRO
Jason Roth wrote:
> I was reading the perldoc for the sort function and I had a few
> questions. http://perldoc.perl.org/sort.html says that large arrays
> will be shuffled to ensure nlgn runtime. What is the cutoff for
> "large arrays" and is there a reason that it isn't simply using a
> randomi
Rob Dixon schreef:
> $uniq{$_} = 1 foreach @holdArr;
I prefer "foreach" to "for", mainly because it is shorter.
Alternative:
@[EMAIL PROTECTED] = (1) x @holdArr;
Test-1:
perl -MData::Dumper -wle'
@keys = qw(a b c) ;
@hash{ @keys } = (1) x @keys ;
print Dumper \%hash
'
$VAR1 = {
Shiping Wang wrote:
At 02:04 PM 10/18/2006, Johnson, Reginald (GTI) wrote:
I am trying to understand this sort and uniq code that a came across in
the archive. This works, but I thought the %uniq would have the sort
and uniqed values. What is needed if I didn't want to print the values
out imme
On Wed, Oct 18, 2006 at 03:04:32PM -0400, Johnson, Reginald (GTI) wrote:
> I am trying to understand this sort and uniq code that a came across in
> the archive.
I don't see anything to do with sort in this code.
> This works, but I thought the %uniq would have the sort
> and uniqe
At 02:04 PM 10/18/2006, Johnson, Reginald (GTI) wrote:
I am trying to understand this sort and uniq code that a came across in
the archive. This works, but I thought the %uniq would have the sort
and uniqed values. What is needed if I didn't want to print the values
out immediatedly but put them
Tom Phoenix wrote:
On 4/25/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote:
sort {
$a->value() cmp $b->value()
||
$a->part('Name')->value() cmp $b->part('Name')->value()
}
grep { defined } @objects
But sometimes $a->part('Name') returns undef, so the sort
On 4/25/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote:
> sort {
> $a->value() cmp $b->value()
> ||
> $a->part('Name')->value() cmp $b->part('Name')->value()
> }
> grep { defined } @objects
But sometimes $a->part('Name') returns undef, so the sort fails.
Jay Savage wrote:
On 4/25/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote:
for my $obj(
sort {
$a->value() cmp $b->value()
||
$a->part('Name')->value() cmp $b->part('Name')->value()
}
grep { defined } @objects
) {
...
$a/$b->value() always works since if $
Timothy Johnson wrote:
Just a thought, but couldn't you put the logic in your grep statement?
Something like this:
grep {defined($_->value()) or defined($_->part('Name')->value())}
@objects;
The only problem is then that the object woudl be completely skipped.
I need all objects regardles
Just a thought, but couldn't you put the logic in your grep statement?
Something like this:
grep {defined($_->value()) or defined($_->part('Name')->value())}
@objects;
-Original Message-
From: JupiterHost.Net [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 25, 2006 12:22 PM
To: beginne
On 4/25/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote:
> for my $obj(
> sort {
> $a->value() cmp $b->value()
> ||
> $a->part('Name')->value() cmp $b->part('Name')->value()
> }
> grep { defined } @objects
> ) {
>
> ...
>
> $a/$b->value() always works since i
Randal L. Schwartz wrote:
"Jeff" == Jeff Pang <[EMAIL PROTECTED]> writes:
Jeff> and we can use the _ handle to avoid stat'ing twice.
Jeff> Sorry,I don't know what is _ handle.Who help explain with it
please,thanks.
It's documented. I refuse to retype the docs for a thing. :)
Specifically
> "Jeff" == Jeff Pang <[EMAIL PROTECTED]> writes:
Jeff> and we can use the _ handle to avoid stat'ing twice.
Jeff> Sorry,I don't know what is _ handle.Who help explain with it
please,thanks.
It's documented. I refuse to retype the docs for a thing. :)
--
Randal L. Schwartz - Stonehenge Co
and we can use the _ handle to avoid stat'ing twice.
Sorry,I don't know what is _ handle.Who help explain with it please,thanks.
-Original Message-
From: "Randal L. Schwartz"
Sent: Dec 14, 2005 11:56 PM
To: beginners@perl.org
Subject: Re: sort files by creati
> "Todd" == Todd W <[EMAIL PROTECTED]> writes:
Todd> my @files = map $_->[0],
Todd> sort { $b->[1] <=> $a->[1] }
Todd> map [ $_, -M ],
Todd> grep -f, # get only plain files
Todd> glob("/mnt/qdls/MSDSIN/*");
Since the map can also serve as a grep, and we can
OXx wrote:
Hello all,
I try to launch my perl application as a windows service.
I compile it with PAR so I have mysoft.exe
Then i installed win32::daemon, no problem.
I try this script so:
use Win32::Daemon;
a) always always always:
use strict;
use warnings;
on code you post to this lis
Hello all,
I try to launch my perl application as a windows service.
I compile it with PAR so I have mysoft.exe
Then i installed win32::daemon, no problem.
I try this script so:
use Win32::Daemon;
%Hash = (
machine => '',
name=> 'PerlTest',
display => 'Oh m
-Original Message-
From: Brian Volk
Sent: Tuesday, December 13, 2005 8:10 AM
To: 'Brian Franco'
Subject: RE: sort files by creation time
-Original Message-
From: Brian Franco [mailto:[EMAIL PROTECTED]
Sent: Monday, December 12, 2005 7:34 PM
To: Brian Volk
Subject
Brian Volk wrote:
Of course I
have one more rookie question and a reference to a perldoc is just
fine. :~) If I use the following code, why do I not need to declare
the $a and the $b w/ my?
Correct. This is explained in perldoc perlvar:
$a
$b Special package variables when using sor
Todd W wrote:
"Brian Volk" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
After running a few tests... :~) I think I might be able to sort on the
inode... ? Does this make sense?
my @files = glob("/mnt/qdls/MSDSIN/*");
foreach my $file (@files) {
print "$file\n";
my $in
-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED]
Sent: Monday, December 12, 2005 4:44 PM
To: Brian Volk
Cc: 'beginners@perl.org'
Subject: Re: sort files by creation time
Brian Volk wrote:
> Hi All~
>
>
>
> I'm using the glob function to
Brian Volk wrote:
> Hi All~
>
>
>
> I'm using the glob function to grab all the files in a given
> directory and then using crontab to check it every 5 minutes. Once I
> have the files I'm using the diamond operator to read every line in
> every file and *do something* if the line matches. He
"Brian Volk" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> After running a few tests... :~) I think I might be able to sort on the
> inode... ? Does this make sense?
>
> my @files = glob("/mnt/qdls/MSDSIN/*");
>
> foreach my $file (@files) {
>
>print "$file\n";
>my $ino =
> -Original Message-
> From: Brian Volk [mailto:[EMAIL PROTECTED]
> Sent: Monday, December 12, 2005 4:47 PM
> To: beginners@perl.org
> Subject: RE: sort files by creation time
>
> After running a few tests... :~) I think I might be able to sort on
the
> inode...
You could try something along these lines, where I create an array
prepending the date in Perl time format and then sort the array. There
is probably a better way, but this would work.
Note: (stat $file)[9] is a list slice that represents only the 9th
element of the list returned by 'stat $file
After running a few tests... :~) I think I might be able to sort on the
inode... ? Does this make sense?
my @files = glob("/mnt/qdls/MSDSIN/*");
foreach my $file (@files) {
Brian Volk wrote:
Hi All~
I'm using the glob function to grab all the files in a given directory
and
then using crontab to check it every 5 minutes. Once I have the files
I'm
using the diamond operator to read every line in every file and *do
something* if the line matches. Here's my ques
[sorry, PINE has become very confused about who said what]
On Oct 3, Jay Savage said:
On 10/3/05, Bakken, Luke <[EMAIL PROTECTED]> wrote:
JupiterHost.Net wrote:
>> On Oct 3, JupiterHost.Net said:
>>
>>> I have a list of strings that start with an uppercase B, Q, or Z
>>>
>>> I need to sort them
Bakken, Luke wrote:
> JupiterHost.Net wrote:
>>>On Oct 3, JupiterHost.Net said:
>>>
I have a list of strings that start with an uppercase B, Q, or Z
I need to sort them so they are in order of Q, B , then Z
Any ideas or input on how to efficiently do that with sort() or even
>
On 10/3/05, Bakken, Luke <[EMAIL PROTECTED]> wrote:
> JupiterHost.Net wrote:
> >> On Oct 3, JupiterHost.Net said:
> >>
> >>> I have a list of strings that start with an uppercase B, Q, or Z
> >>>
> >>> I need to sort them so they are in order of Q, B , then Z
> >>>
> >>> Any ideas or input on how t
JupiterHost.Net wrote:
>> On Oct 3, JupiterHost.Net said:
>>
>>> I have a list of strings that start with an uppercase B, Q, or Z
>>>
>>> I need to sort them so they are in order of Q, B , then Z
>>>
>>> Any ideas or input on how to efficiently do that with sort() or even
>>> map() is most appre
On Oct 3, Xavier Noria said:
On Oct 3, 2005, at 18:16, Jeff 'japhy' Pinyan wrote:
my @sorted =
map { tr/123/QBZ/; $_ }
sort
map { tr/QBZ/123/; $_ }
@data;
There's a potential gotcha there: since all Qs and Bs are being swapped
lexicographic order after the first character
On Oct 3, JupiterHost.Net said:
I have a list of strings that start with an uppercase B, Q, or Z
I need to sort them so they are in order of Q, B , then Z
Any ideas or input on how to efficiently do that with sort() or even
map() is most appreciated :) perldoc -f sort|-f map didn't appear to
On Oct 3, 2005, at 18:16, Jeff 'japhy' Pinyan wrote:
On Oct 3, JupiterHost.Net said:
I have a list of strings that start with an uppercase B, Q, or Z
I need to sort them so they are in order of Q, B , then Z
Any ideas or input on how to efficiently do that with sort() or
even map() is mos
On Oct 3, JupiterHost.Net said:
I have a list of strings that start with an uppercase B, Q, or Z
I need to sort them so they are in order of Q, B , then Z
Any ideas or input on how to efficiently do that with sort() or even map() is
most appreciated :) perldoc -f sort|-f map didn't appear to
On Oct 3, 2005, at 17:35, JupiterHost.Net wrote:
I need to sort them so they are in order of Q, B , then Z
The real array will have between 1 to 100 items, just FYI
They all go in ASCII relative order except B <-> Q, thus a way to get
it is to handle that special case and delegate to cmp
1 - 100 of 267 matches
Mail list logo