[29211] in Perl-Users-Digest
Perl-Users Digest, Issue: 455 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 23 18:10:09 2007
Date: Wed, 23 May 2007 15:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 23 May 2007 Volume: 11 Number: 455
Today's topics:
Re: Catching SIGALRM in a thread <zentara@highstream.net>
CPAN Question QoS@domain.invalid
Re: CPAN Question <thepoet_nospam@arcor.de>
Re: CPAN Question QoS@domain.invalid
Date comparison.. clearguy02@gmail.com
Date comparison.. clearguy02@gmail.com
Date comparison.. clearguy02@gmail.com
Re: Date comparison.. clearguy02@gmail.com
Hashed to death... help needed. <zrogon@poczta.onet.pl>
Re: Hashed to death... help needed. <jgibson@mail.arc.nasa.gov>
Re: listing all available methods <baxter.brad@gmail.com>
Re: localtime(time()) <noreply@gunnar.cc>
Re: localtime(time()) <tony_curtis32@yahoo.com>
Re: localtime(time()) <mritty@gmail.com>
Re: Question about pack function in 64bit 2 core CPU <sisyphus1@nomail.afraid.org>
Re: Question about pack function in 64bit 2 core CPU <hjp-usenet2@hjp.at>
The Concepts and Confusions of Prefix, Infix, Postfix a <xah@xahlee.org>
Re: The Concepts and Confusions of Prefix, Infix, Postf <larry@theclapp.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 23 May 2007 21:55:13 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Catching SIGALRM in a thread
Message-Id: <nrd953t5iqlmreeum3ssl4gdov90k9ps29@4ax.com>
On 22 May 2007 15:44:28 GMT, xhoster@gmail.com wrote:
>zentara <zentara@highstream.net> wrote:
>>
>> Here is an example I have of an ALARM in a thread. It works for me,
>> but it may not be what you are looking for.
>
>What OS and what version of Perl are you using?
>Your code doesn't work for me. The main program is blown away by
>the alarm, without catching it in the SIG{ALRM} and without
>clobbering the z1 process, which just keeps on running.
>
>This is perl, v5.8.3 built for x86_64-linux-thread-multi
>
>Thanks,
>Xho
You are right, I'm totally wrong. I'll have to mark that one as
non-working too.
I may have first tested in back in the Perl5.6 days, but it dosn't
work now. :-( Maybe it never worked, but I was too dumb to
notice. :-)
Sorry for the confusion.
It seems that setting alarm in the thread will kill the main thread.
Try this, where I set the alarm callback in main, it works. So you
should be able to work around it. Of course if you want to have separate
alarms in multiple threads, you are SOL. The only thing you can do in
that case, is have secondary timer threads instead of alarm, OR use
an event loop system in your main thread, that can timeout the thread
by running it's own timer.
To be honest, I never even use alarm anymore, I setup my own timers,
since I generally use Tk, or Gtk2. (POE would work too).
Gtk2's GLib will setup timers even in non-gui programs, as will POE.
Tk has to be a GUI.
#!/usr/bin/perl
use warnings;
use strict;
use threads;
use threads::shared;
# ALARM DOSN"T WORK WELL IN THREADS
my $waitTime : shared;
my $done : shared;
my $child_pid : shared;
$waitTime = 5;
$done = 0;
my $cmd = './z1';
my $thr = threads->new(\&my_exec_thread, $cmd);
$SIG{ALRM} = sub { warn "thread timeout\n";
kill 9, "$child_pid\n";
};
while(1){
if ( $done == 1 ) {
print "Thread completed \n";
$thr->join;
last;
}elsif ( $done eq 'TIMED OUT' ) {
print "Thread Timed OUT\n";
$thr->join;
last;
}else{next}
}
print "1\n";
######################################################
sub my_exec_thread {
my $cmd = shift;
print ("In thread ".$cmd."\n");
###########################################
# will kill it all, even main thread with message ALARM CLOCK
#$SIG{ALRM} = sub { warn "thread timeout\n";
# kill 9, "$child_pid\n";
# };
############################################
eval {
alarm($waitTime);
unless ($child_pid = fork) {
exec $cmd;
die "could not exec $cmd: $!";
}
print "pid->$child_pid\n";
wait;
alarm(0);
};
print "--------- $@\n";
print "end of thread code block , main lives on\n";
}
__END__
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Wed, 23 May 2007 16:57:03 GMT
From: QoS@domain.invalid
Subject: CPAN Question
Message-Id: <zn_4i.9157$ns.5844@trndny05>
I would like to download and install a package from CPAN
but it says '** UNAUTHORIZED RELEASE **'.
What does this message mean? How did this package obtain this unfortunate
label?
Is it potentially a bad thing to use this package because of this
message?
Thanks for any insight
J
------------------------------
Date: Wed, 23 May 2007 20:55:19 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: CPAN Question
Message-Id: <46548e08$0$10190$9b4e6d93@newsspool4.arcor-online.net>
QoS@domain.invalid wrote:
> I would like to download and install a package from CPAN
> but it says '** UNAUTHORIZED RELEASE **'.
>
> What does this message mean? How did this package obtain this unfortunate
> label?
>
> Is it potentially a bad thing to use this package because of this
> message?
>
> Thanks for any insight
For which package did this occur? It usually happens when a
package that is co-maintained by a group of people gets updated
by someone who wasn't assigned all the neccessary permission bits,
as it's easy to forget passing permissions back and forth.
With some modules this has also happened when the author integrated
submodules into the distribution that were previously released
standalone by someone else and they forgot to transfer permissions,
or when he included some modules for testing purposes that stem
from another package and don't get installed, but missed to point
that out in the META.yml. I believe one of those is currently the
case with GD and Mail::SpamAssassin.
But it can also happen if someone, intentionally or by mistake,
uploads a different package into an already existing namespace.
-Chris
------------------------------
Date: Wed, 23 May 2007 19:20:36 GMT
From: QoS@domain.invalid
Subject: Re: CPAN Question
Message-Id: <8u05i.7302$YW1.471@trnddc04>
Christian Winter <thepoet_nospam@arcor.de> wrote in message-id: <46548e08$0$10190$9b4e6d93@newsspool4.arcor-online.net>
>
>QoS@domain.invalid wrote:
>> I would like to download and install a package from CPAN
>> but it says '** UNAUTHORIZED RELEASE **'.
>>
>> What does this message mean? How did this package obtain this unfortunate
>> label?
>>
>> Is it potentially a bad thing to use this package because of this
>> message?
>>
>> Thanks for any insight
>
>For which package did this occur? It usually happens when a
>package that is co-maintained by a group of people gets updated
>by someone who wasn't assigned all the neccessary permission bits,
>as it's easy to forget passing permissions back and forth.
>
>With some modules this has also happened when the author integrated
>submodules into the distribution that were previously released
>standalone by someone else and they forgot to transfer permissions,
>or when he included some modules for testing purposes that stem
>from another package and don't get installed, but missed to point
>that out in the META.yml. I believe one of those is currently the
>case with GD and Mail::SpamAssassin.
>
>But it can also happen if someone, intentionally or by mistake,
>uploads a different package into an already existing namespace.
>
>-Chris
Thank you for this information, the package is called Perl::Critic
------------------------------
Date: 23 May 2007 14:01:36 -0700
From: clearguy02@gmail.com
Subject: Date comparison..
Message-Id: <1179954095.964696.200160@h2g2000hsg.googlegroups.com>
Hi folks,
I need to convert a date from the original format 2007-05-27 00:00:00
to 5/27/2007.
>From the original date, I should strip off all the traling stuff
(00:00:00) and the months (03, 04, 05 etc) should appear as 3, 4, 5
etc.
I am trying to use the sprintf function and some truncating stuff, but
I am not getting the desired results.
Can some one tell me how I can achieve the desired result?
Thanks
-J
------------------------------
Date: 23 May 2007 14:01:45 -0700
From: clearguy02@gmail.com
Subject: Date comparison..
Message-Id: <1179954105.352910.45330@u30g2000hsc.googlegroups.com>
Hi folks,
I need to convert a date from the original format 2007-05-27 00:00:00
to 5/27/2007.
>From the original date, I should strip off all the trailing stuff
(00:00:00) and the months (03, 04, 05 etc) should appear as 3, 4, 5
etc.
I am trying to use the sprintf function and some truncating stuff, but
I am not getting the desired results.
Can some one tell me how I can achieve the desired result?
Thanks
-J
------------------------------
Date: 23 May 2007 14:01:54 -0700
From: clearguy02@gmail.com
Subject: Date comparison..
Message-Id: <1179954114.427132.150370@o5g2000hsb.googlegroups.com>
Hi folks,
I need to convert a date from the original format 2007-05-27 00:00:00
to 5/27/2007.
>From the original date, I should strip off all the trailing stuff
(00:00:00) and the months (03, 04, 05 etc) should appear as 3, 4, 5
etc.
I am trying to use the sprintf function and some truncating stuff, but
I am not getting the desired results.
Can some one tell me how I can achieve the desired result?
Thanks
-J
------------------------------
Date: 23 May 2007 14:50:58 -0700
From: clearguy02@gmail.com
Subject: Re: Date comparison..
Message-Id: <1179957058.310399.155160@p47g2000hsd.googlegroups.com>
On May 23, 2:01 pm, cleargu...@gmail.com wrote:
> Hi folks,
>
> I need to convert a date from the original format 2007-05-27 00:00:00
> to 5/27/2007.
>
> >From the original date, I should strip off all the trailing stuff
>
> (00:00:00) and the months (03, 04, 05 etc) should appear as 3, 4, 5
> etc.
>
> I am trying to use the sprintf function and some truncating stuff, but
> I am not getting the desired results.
>
> Can some one tell me how I can achieve the desired result?
>
> Thanks
> -J
Sorry for fogetting to post my code:
+++++++++++++++++++++
$date1 = "2007-05-27 00:00:00";
$date1 =~ s/(.*)\s+(.*)/($1)($2)/;
$date2 = $1;
$date2 =~ s/(.*)-(.*)-(.*)/$1$2$3/;
$year = $1;
$month = $2;
$date = $3;
$month =~ s/0//;
$date3 = "$month/$date/$year";
print "$date3\n";
++++++++++++++++++++++++++++
Is there a shorter way to do it?
Thanks
-J
------------------------------
Date: Wed, 23 May 2007 20:44:17 +0100
From: "Teq" <zrogon@poczta.onet.pl>
Subject: Hashed to death... help needed.
Message-Id: <f325k9$vmd$1@news.onet.pl>
First of all, hello!
I've been reading the group for quite a while now, but this is the first
time I really need help. This is my second attempt at posting to this
particular server, my first post has gone missing, hope it won't double it.
To summarize things: I'm building a parser which has to consolidate data
based on variables contained in an array.
The source file contains a set of tab-separated-values, and those are
parsed out into an array which contains
pdbID | resNum | resID | secstructID, these are then consolidated into a
file which should contain:
pdbID | startRes | endRes | secstructID
source array with the data for consolidation:
1b6g 1 M \N
1b6g 2 V \N
1b6g 3 N \N
1b6g 4 N H
1b6g 5 N H
1b6g 6 N \N
3hba 7 W H
2cdg 8 N H
2cdg 9 V \N
2cdg 10 M \N
2cdg 11 A B
2cdg 12 M \N
expected result after consolidation, should be:
1b6g 1 3 \N
1b6g 4 5 H
1b6g 6 6 \N
3hba 7 7 H
2cdg 5 6 H
2cdg 7 7 \N
2cdg 8 8 H
2cdg 9 10 H
2cdg 11 11 B
2cdg 12 12 \N
As you can see each pdbID is assigned a secStructuID in a sequential manner
and any interruptions are to be considered as points from which the
assignment starts new.
Each pdbID can thus have multiple occurences of for example \N in different
places of the sequence and they are differentiated by the startRes and
endRes values.
All is wonderful and I have a working code which consolidates the data,
unfortunately it doesn't recognize the occurence of the new secstructID
automatically as the end of the previous one rather it finds the last
possible in the whole sequence for one pdbID and considers that as the end.
and so my result is incorrectly displayed as:
1b6g 4 5 H
1b6g 1 6 \N ---- error here - this should be in fact two separate
"entities" because 4 and 5 do not belong to \N
3hba 7 7 H
2cdg 8 8 H
2cdg 9 12 \N ---- same here (7 and 8 should break this into two)
2cdg 11 11 B
And here's my code:
---------------------------------------------
#!/usr/bin/perl -w
use strict;
use warnings;
# --------------------------------------------------------------
# This script uses the residue.txt file generated by
# resTabmakerBatch.pl and creates a new file called
# SecStructList.txt
# each protein is described by secondary structures with a
# pdbID, 2ry structureID (char or \N'), startResidue, endResidue
# Input: residue.txt (this file is the output of resTabmakerBatch.pl)
# Output: secStructList.txt
# usage: secStructList.txt to populate the SecStructure entity
# --------------------------------------------------------------
#Read arguments, print error message if insufficient
if ($#ARGV<0)
{
die("\n\nUsage: sstruct.pl [residue_table_file.txt]\n\n");
}
my $filename = $ARGV[0];
#if either file not found return error message
if (! -e "$filename")
{
die("\n\nresidue file $filename does not exist!\n\n");
}
# Read residue.txt file, extracting the data of interest - only
# pdb id, resNum, resID, secondaryStructID
#First read file, storing each line in an array 'dssplines' splitting the
data
open (MYFILE,"$filename") or die ("\nERROR: Can't open $filename\n");
my @dssplines= split(/\r/, <MYFILE>);
my $arraySize=@dssplines;
close(MYFILE);
#read one line from the originally loaded array dssplines at a time and loop
#over it splitting the values using the tabs
my @dsspdata;
my $dsspdataSize=@dssplines;
my $n=0;
for (my $i=0; $i < $arraySize; $i++)
{
#each line from the array goes into a new dsspline variable
my $dsspline = $dssplines[$i];
for (my $j = 0; $j <=4; $j++)
{
#each time values inside are separated using the tabs
my ($pdbID, $resNo, $resID, $phi, $psi, $chi1, $chi2, $secStruct,
$activesite) = split(/\t/, $dsspline);
# now each value of interest is stored into a new array @dsspdata
$dsspdata[$n][0] = $pdbID;
$dsspdata[$n][1] = $resNo;
$dsspdata[$n][2] = $resID;
$dsspdata[$n][3] = $secStruct;
}
$n++;
}
#my @dsspdata array is now perfect to reformat into a hash analyzing the
value correlation
#initialize the hash and counter
my %dane;
my $k=0;
#loop around the dsspdata array
for (my $i=0; $i < $dsspdataSize; $i++)
{
#split each cell in a row into variables for the hash
for (my $k = 0; $k <=4; $k++)
{
my $pdb = $dsspdata[$i][0];
my $residueNum = $dsspdata[$i][1];
my $secStructure = $dsspdata[$i][3];
push @{ $dane{$pdb}->{$secStructure} }, $residueNum;
}
$k++;
}
#now for each pdbID using the hash keys
foreach my $pdbID ( keys %dane )
{
#check the secondary structure id with pdbID as a key (only if the pdbID
is the same will the values be stored)
foreach my $secID ( keys %{ $dane{$pdbID} } )
{
#finally create an array of residue numbers
my @resnums = ( $dane{$pdbID}->{$secID}->[0],
$dane{$pdbID}->{$secID}->[-1] );
#create a new file with the secondary structures list
open (SStruc, ">>secStructList.txt") || die "Can't open file: $!";
#append each line to the new file with tab separated data
print SStruc ("$pdbID \t @resnums \t $secID\n");
}
}
close(SStruc);
If anyone has an idea how to deal with this I would be very grateful for
any suggestions.
Cheers,
Matt
------------------------------
Date: Wed, 23 May 2007 14:58:27 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Hashed to death... help needed.
Message-Id: <230520071458272369%jgibson@mail.arc.nasa.gov>
In article <f325k9$vmd$1@news.onet.pl>, Teq <zrogon@poczta.onet.pl>
wrote:
> First of all, hello!
> I've been reading the group for quite a while now, but this is the first
> time I really need help. This is my second attempt at posting to this
> particular server, my first post has gone missing, hope it won't double it.
Have you taken the time to read the guidelines for posting to this
group?
>
> To summarize things: I'm building a parser which has to consolidate data
> based on variables contained in an array.
> The source file contains a set of tab-separated-values, and those are
> parsed out into an array which contains
> pdbID | resNum | resID | secstructID, these are then consolidated into a
> file which should contain:
> pdbID | startRes | endRes | secstructID
>
> source array with the data for consolidation:
> 1b6g 1 M \N
> 1b6g 2 V \N
> 1b6g 3 N \N
> 1b6g 4 N H
> 1b6g 5 N H
> 1b6g 6 N \N
> 3hba 7 W H
> 2cdg 8 N H
> 2cdg 9 V \N
> 2cdg 10 M \N
> 2cdg 11 A B
> 2cdg 12 M \N
>
[other comments snipped]
> And here's my code:
You should minimize your program as much as possible before posting
(details below).
>
> ---------------------------------------------
> #!/usr/bin/perl -w
> use strict;
> use warnings;
>
> # --------------------------------------------------------------
> # This script uses the residue.txt file generated by
> # resTabmakerBatch.pl and creates a new file called
> # SecStructList.txt
> # each protein is described by secondary structures with a
> # pdbID, 2ry structureID (char or \N'), startResidue, endResidue
> # Input: residue.txt (this file is the output of resTabmakerBatch.pl)
> # Output: secStructList.txt
> # usage: secStructList.txt to populate the SecStructure entity
> # --------------------------------------------------------------
We don't need to see these comments. Although good practice for actual
development, the people reading this post don't really care what the
program does, just how it works.
>
> #Read arguments, print error message if insufficient
> if ($#ARGV<0)
> {
> die("\n\nUsage: sstruct.pl [residue_table_file.txt]\n\n");
> }
>
> my $filename = $ARGV[0];
>
> #if either file not found return error message
> if (! -e "$filename")
> {
> die("\n\nresidue file $filename does not exist!\n\n");
> }
>
> # Read residue.txt file, extracting the data of interest - only
> # pdb id, resNum, resID, secondaryStructID
>
> #First read file, storing each line in an array 'dssplines' splitting the
> data
> open (MYFILE,"$filename") or die ("\nERROR: Can't open $filename\n");
You can eliminate all of the above lines by using the special <DATA>
filehandle (see posting guidelines).
> my @dssplines= split(/\r/, <MYFILE>);
There is no reason to read in the whole file if you are going to
process the lines one at a time.
> my $arraySize=@dssplines;
> close(MYFILE);
> #read one line from the originally loaded array dssplines at a time and loop
> #over it splitting the values using the tabs
> my @dsspdata;
> my $dsspdataSize=@dssplines;
>
> my $n=0;
> for (my $i=0; $i < $arraySize; $i++)
> {
> #each line from the array goes into a new dsspline variable
> my $dsspline = $dssplines[$i];
> for (my $j = 0; $j <=4; $j++)
> {
What is the purpose of this loop? You are doing the same things 5 times.
> #each time values inside are separated using the tabs
> my ($pdbID, $resNo, $resID, $phi, $psi, $chi1, $chi2, $secStruct,
> $activesite) = split(/\t/, $dsspline);
So your file actually contains at least 9 fields, instead of the 4 you
show above?
> # now each value of interest is stored into a new array @dsspdata
> $dsspdata[$n][0] = $pdbID;
> $dsspdata[$n][1] = $resNo;
> $dsspdata[$n][2] = $resID;
> $dsspdata[$n][3] = $secStruct;
$n will always have the same value as $i. Why didn't you just use $i
here.
You can simplify your code by not using numerical indexes, but instead
use Perl's native array manipulation functions, eg. something like
(untested):
while( <DATA> ) {
my($pdbID,$resNo,$resID,undef,undef,undef,undef,$secStruct) = split;
or
my($pdbID,$resNo,$resID,$secStruct) = (split)[0,1,2,7];
push( @dsspdata, [$pdbID,$resNo,$resID,$secStruct];
}
> }
> $n++;
> }
>
> #my @dsspdata array is now perfect to reformat into a hash analyzing the
> value correlation
>
> #initialize the hash and counter
> my %dane;
> my $k=0;
> #loop around the dsspdata array
> for (my $i=0; $i < $dsspdataSize; $i++)
> {
> #split each cell in a row into variables for the hash
> for (my $k = 0; $k <=4; $k++)
> {
Another loop that is invariant with respect to its loop variable, so
needlessly repeated 5 times.
> my $pdb = $dsspdata[$i][0];
> my $residueNum = $dsspdata[$i][1];
> my $secStructure = $dsspdata[$i][3];
> push @{ $dane{$pdb}->{$secStructure} }, $residueNum;
> }
> $k++;
> }
That is as far as I wished to analyze your program. If you fix up the
peculiarities mentioned and re-post it (albeit a shorter version that
uses <DATA>), I or someone else can probably help you.
[rest of program snipped]
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: 23 May 2007 08:20:29 -0700
From: Brad Baxter <baxter.brad@gmail.com>
Subject: Re: listing all available methods
Message-Id: <1179933629.927462.43420@g4g2000hsf.googlegroups.com>
On May 23, 10:26 am, Brad Baxter <baxter.b...@gmail.com> wrote:
> --
> Brad
Apologies for the double posts; gg is apparently lying to me.
--
Brad
------------------------------
Date: Wed, 23 May 2007 17:43:31 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: localtime(time())
Message-Id: <5bj5tuF2t7up9U1@mid.individual.net>
Tony Curtis wrote:
> Well, you've answered your own question...but simpler is:
>
> use POSIX qw( strftime );
>
> print strftime '%Y-%m-%d', localtime();
I'm not sure that using POSIX is simpler, since at least I would need to
look up the applicable conversion specifiers.
I would do:
my ($d, $m, $y) = ( localtime )[3..5];
printf '%d-%02d-%02d', $y+1900 , $m+1, $d;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 23 May 2007 12:03:25 -0400
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: localtime(time())
Message-Id: <f31oke$5i1$1@knot.queensu.ca>
Gunnar Hjalmarsson wrote:
> Tony Curtis wrote:
>> Well, you've answered your own question...but simpler is:
>>
>> use POSIX qw( strftime );
>>
>> print strftime '%Y-%m-%d', localtime();
>
> I'm not sure that using POSIX is simpler, since at least I would need to
> look up the applicable conversion specifiers.
>
> I would do:
>
> my ($d, $m, $y) = ( localtime )[3..5];
> printf '%d-%02d-%02d', $y+1900 , $m+1, $d;
"Simpler" of course depends on the metric(s) you use to measure complexity,
but I would definitely argue that strftime() is certainly much easier to
read,
especially *for other people*, and thus produces "simpler" code.
It helps you solve a problem instead of coding a problem.
hth
t
------------------------------
Date: 23 May 2007 10:00:06 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: localtime(time())
Message-Id: <1179939606.078728.249910@q75g2000hsh.googlegroups.com>
On May 23, 11:01 am, Brad Baxter <baxter.b...@gmail.com> wrote:
> On May 23, 10:29 am, Uri Guttman <u...@stemsystems.com> wrote:
>
>
>
>
>
> > >>>>> "BB" == Brad Baxter <baxter.b...@gmail.com> writes:
>
> > BB> I've used a variant of the following for years.
>
> > BB> sub now {
> > BB> for( $_[0] ) {
> > BB> defined and /(.*?)yyyy(.*?)mm(.*?)dd(.*)/i and
> > BB> return sprintf( "$1%04d$2%02d$3%02d$4",
> > BB> sub { ( $_[5] + 1900, $_[4] + 1, $_[3] )
> > BB> }->( localtime ) );
> > BB> }
> > BB> scalar localtime;
> > BB> }
>
> > bletcherific!!
>
> > what if you want a different format? days of week? use POSIX::strftime
> > and you get all you do there and much more.
>
> :-) That's true; I didn't say it was pretty. Of course, the
> ugliness is hidden behind a "use Now;", where all the other formats
> I want are defined. I personally find a format like 'yyyy' prettier
> than '%Y', but that's just me.
http://search.cpan.org/~roode/Time-Format-1.02/Format.pm
may be of interest to you.
(Of course, you may get quickly turned off by the tied hash interface,
but that's just me)
Paul Lalli
------------------------------
Date: Thu, 24 May 2007 02:01:21 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Question about pack function in 64bit 2 core CPU
Message-Id: <46546531$0$14719$afc38c87@news.optusnet.com.au>
"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote in message
news:slrnf58h9d.rq0.hjp-usenet2@zeno.hjp.at...
> On 2007-05-23 10:29, Sisyphus <sisyphus1@nomail.afraid.org> wrote:
>> "sonet" <sonet.all@msa.hinet.net> wrote in message
.
.
>>> The pack('N',$A) is 4 bytes in 32bit CPU.
>>> But, the result is still 4 bytes in 64bit 2 core CPU?
>>> Have any difference between 64bits and 32bits CPU in ActivePerl?
>>
>> 'N' is for unsigned longs - and an unsigned long is 4 bytes on both
>> 32-bit
>> and 64-bit builds.
.
.
> In C an 'unsigned long' is at least 32 bits. On 64-bit systems it is
> often (but not always) 64 bits long.
Yes - I was referring specifically to ActivePerl, where 'perl -V:longsize'
is '4' on both the 32-bit and 64-bit versions.
However, I'm not entirely sure that's the correct way to look at it. (Please
let me know if my thinking was astray :-)
Cheers,
Rob
------------------------------
Date: Wed, 23 May 2007 19:16:56 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Question about pack function in 64bit 2 core CPU
Message-Id: <slrnf58to8.sia.hjp-usenet2@zeno.hjp.at>
On 2007-05-23 16:01, Sisyphus <sisyphus1@nomail.afraid.org> wrote:
>
> "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote in message
> news:slrnf58h9d.rq0.hjp-usenet2@zeno.hjp.at...
>> On 2007-05-23 10:29, Sisyphus <sisyphus1@nomail.afraid.org> wrote:
>>> "sonet" <sonet.all@msa.hinet.net> wrote in message
>>>> The pack('N',$A) is 4 bytes in 32bit CPU.
>>>> But, the result is still 4 bytes in 64bit 2 core CPU?
>>>> Have any difference between 64bits and 32bits CPU in ActivePerl?
>>>
>>> 'N' is for unsigned longs - and an unsigned long is 4 bytes on both
>>> 32-bit
>>> and 64-bit builds.
> .
> .
>> In C an 'unsigned long' is at least 32 bits. On 64-bit systems it is
>> often (but not always) 64 bits long.
>
> Yes - I was referring specifically to ActivePerl, where 'perl -V:longsize'
> is '4' on both the 32-bit and 64-bit versions.
Yes, but my point was that size of 'N' is independent of 'perl
-V:longsize'. Even on systems where the latter is 8, pack('N', ...)
still returns 4 bytes.
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
------------------------------
Date: 23 May 2007 09:15:17 -0700
From: Xah Lee <xah@xahlee.org>
Subject: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations
Message-Id: <1179936917.652372.24780@q69g2000hsb.googlegroups.com>
The Concepts and Confusions of Prefix, Infix, Postfix and Fully
Functional Notations
Xah Lee, 2006-03-15
[This articles explains away the confusion of common terms for
notation systems used in computer languages: prefix, infix, postfix,
algebraic, functional. These notation's relation to the concept of
operators. These are explained using examples from LISP, Mathematica,
and imperative languages. Then, it discuss some problems of purely
nested notation.]
In LISP languages, they use a notation like =E2=80=9C(+ 1 2)=E2=80=9D to me=
an =E2=80=9C1+2=E2=80=9D.
Likewise, they write =E2=80=9C(if test this that)=E2=80=9D to mean =E2=80=
=9Cif (test) {this}
else {that}=E2=80=9D. LISP codes are all of the form =E2=80=9C(a b c ...)=
=E2=80=9D, where the
a b c themselves may also be of that form. There is a wide
misunderstanding that this notation being =E2=80=9Cprefix notation=E2=80=9D=
. In this
article, i'll give some general overview of the meanings of Algebraic
Notation and prefix, infix, postfix notations, and explain how LISP
notation is a Functional Notation and is not a so-called prefix
notation or algebraic notation.
The math notation we encounter in school, such as =E2=80=9C1+2=E2=80=9D, is=
called
Infix Algebraic Notation. Algebraic notations have the concept of
operators, meaning, symbols placed around arguments. In algebraic
infix notation, different symbols have different stickiness levels
defined for them. e.g. =E2=80=9C3+2*5>7=E2=80=9D means =E2=80=9C(3+(2*5))>7=
=E2=80=9D. The stickiness
of operator symbols is normally called =E2=80=9COperator Precedence=E2=80=
=9D. It is
done by giving a order specification for the symbols, or equivalently,
give each symbol a integer index, so that for example if we have
=E2=80=9Ca=E2=8A=97b=E2=8A=99c=E2=80=9D, we can unambiguously understand it=
to mean one of =E2=80=9C(a=E2=8A=97b)=E2=8A=99c=E2=80=9D
or =E2=80=9Ca=E2=8A=97(b=E2=8A=99c)=E2=80=9D.
In a algebraic postfix notation known as Polish Notation, there needs
not to have the concept of Operator Precedence. For example, the infix
notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >=
=E2=80=9D, where the
operation simply evaluates from left to right. Similarly, for a prefix
notation syntax, the evaluation goes from right to left, as in =E2=80=9C> 7=
+
* 5 2 3=E2=80=9D.
While functional notations, do not employ the concept of Operators,
because there is no operators. Everything is a syntactically a
=E2=80=9Cfunction=E2=80=9D, written as f(a,b,c...). For example, the same e=
xpression
above is written as =E2=80=9C>( +(3, *(2,5)), 7)=E2=80=9D or =E2=80=9Cgreat=
erThan( plus(3,
times(2,5)), 7)=E2=80=9D.
For lisps in particular, their fully functional notation is
historically termed sexp (short for S-Expression, where S stands for
Symbolic). It is sometimes known as Fully Parenthesized Notation. For
example, in lisp it would be (f a b c ...). In the above example it
is: =E2=80=9C(> (+ 3 (* 2 5)) 7)=E2=80=9D.
The common concepts of =E2=80=9Cprefix, postfix, infix=E2=80=9D are notions=
in
algebraic notations only. Because in Full Functional Notation, there
are no operators, therefore no positioning to talk about. A Function's
arguments are simply explicitly written out inside a pair of enclosing
delimiters.
Another way to see that lisp notation are not =E2=80=9Cpre=E2=80=9D anythin=
g, is by
realizing that the =E2=80=9Chead=E2=80=9D f in (f a b c) can be defined to =
be placed
anywhere. e.g. (a b c f) or even (a f b c), and its syntax syntactical
remains the same. In the language Mathematica, f(a b c) would be
written as f[a,b,c] where the argument enclosure symbols is the square
bracket instead of parenthesis, and argument separator is comma
instead of space, and the function symbol (aka =E2=80=9Chead=E2=80=9D) is p=
laced in
outside and in front of the argument enclosure symbols.
The reason for the misconception that lisp notations are =E2=80=9Cprefix=E2=
=80=9D is
because the =E2=80=9Chead=E2=80=9D appears as the first element in the encl=
osed
parenthesis. Such use of the term =E2=80=9Cprefix=E2=80=9D is a confusion e=
ngenderer
because the significance of the term lies in algebraic notation
systems that involves the concept of operators.
A side note: the terminology =E2=80=9CAlgebraic=E2=80=9D Notation is a misn=
omer. It
seems to imply that such notations have something to do with the
branch of math called algebra while other notation systems do not. The
reason the name Algebraic Notation is used because when the science of
algebra was young, around 1700s mathematicians are dealing with
equations using symbols like =E2=80=9C+ =C3=97 =3D=E2=80=9D written out sim=
ilar to the way we
use them today. This is before the activities of systematic
investigation into notation systems as necessitated in the studies of
logic in 1800s or computer languages in 1900s. So, when notation
systems are actually invented, the conventional way of infixing =E2=80=9C+ =
=C3=97
=3D=E2=80=9D became known as algebraic because that's what people think of =
when
seeing them.
--------
This post is part of a 3-part exposition:
=E2=80=9CThe Concepts and Confusions of Prefix, Infix, Postfix and Fully
Functional Notations=E2=80=9D,
=E2=80=9CPrefix, Infix, Postfix notations in Mathematica=E2=80=9D,
=E2=80=9CHow Purely Nested Notation Limits The Language's Utility=E2=80=9D,
available at:
http://xahlee.org/UnixResource_dir/writ/notations.html
Xah
xah@xahlee.org
=E2=88=91 http://xahlee.org/
------------------------------
Date: Wed, 23 May 2007 12:51:32 -0400
From: Larry Clapp <larry@theclapp.org>
Subject: Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations
Message-Id: <slrnf58s8k.45o.larry@theclapp.ddts.net>
["Followup-To:" header set to comp.lang.lisp.]
On 2007-05-23, Xah Lee <xah@xahlee.org> wrote:
> The Concepts and Confusions of Prefix, Infix, Postfix and Fully
> Functional Notations
>
> Xah Lee, 2006-03-15
Xah, why do you post year-old essays to newsgroups that couldn't care
less about them?
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 455
**************************************