Re: More advanced list

2003-01-05 Thread Jerry Rocteur
Hi,

Thanks.. I would not unsubscribe from this list, it is great and it has 
its place, there's quite a bit of advanced stuff on this list and 
whilst Randal subscribes to it, I'll stay subscribed ;-))

I was just interested in what other Perl lists you more advanced guys 
also subscribed to that's all..

Thanks again!

Jerry

It is just that I did want to have a list that was not made for 
beginners
On Sunday, Jan 5, 2003, at 00:49 Europe/Brussels, Timothy Johnson wrote:


Check out http://lists.perl.org.  There are quite a few lists, and 
probably
a few of them are close to what you want, although it seems there 
might be
quite a large gap in the expected comptetency level.  In the meantime, 
you
can always post any moderately advanced questions here, and someone can
probably help you, but if you're looking to filter out the beginner
questions then I would look at one of the more advanced lists.

-Original Message-
From: Jerry Rocteur [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 04, 2003 3:43 PM
To: [EMAIL PROTECTED]
Subject: More advanced list


Hi,

I'm looking for a Perl list a bit more advanced that this one, you
know, not beginners questions..

I love this list and I'm learning a lot from it but I'm wondering if
there is another list with less "hello world" or Visual basic is better
than Perl type comments, preferably NO WINDOWS but I guess
unfortunately that is impossible ??

Any ideas ???

Thanks guys,

Jerry




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Crypt::PGPSimple ???

2003-01-05 Thread Mark Goland
I have installed pgp 6.5.8 , and am testing on winXP. I can encrypt and
decrypt from cmd just fine. Have  anyone used this pack, I am having a hard
time Can any make something of it ??

use Crypt::PGPSimple;
{
open my $RD_FH,"< $ARGV[0]" || die "cant open $ARGV[0]: $!";
local @TMP=<$RD_FH>;
$_= join '',@TMP;
}

my ($objPGP)= new Crypt::PGPSimple;

$objPGP->PgpExePath("c:\\progra~1\\networ~1\\PGPcmdln\\PGP.exe -h ");
$objPGP->PgpTempDir("c:\\temp\\Fcrypt");
$objPGP->PublicKey("public.pgp");
$objPGP->PlainText("$_");
$objPGP->Encrypt;

$rint=$objPGP->EncryptedText;

print $rint || print $objPGP->ErrDescription . "\n" . $objPGP->Result;


Thanx in Advance,
Mark


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: byte count

2003-01-05 Thread zentara
On Sat, 04 Jan 2003 17:32:22 -0500, [EMAIL PROTECTED] (Mark Goland)
wrote:

>no, I want to use one of Crypt modules which expacts to be passed strings of
>n*16 bytes. How do I go about genereting such blocks ??



#this sub makes all data blocksize of 16 bytes.
sub get16 {
my $data = shift;
print "data=$data\n";
  return "\0" x ( 16 - length($data)%16 ) . $data;
  }
  
exit;

#You can also use this to get data that is in a multiple of 16 bytes:
# this requires $username < 16 bytes and prefix packs with spaces
#sprintf '%16s', $username;
#or you can xor it
# $filecrypted = $cipher->encrypt($file^("\0"x16));

#To strip any padding after decryption:
#my $plaintext = $cipher->decrypt($secret_stuff);
#   $plaintext =~ s/^\0+//;  
# remove leading null bytes, use \s (not \0) for spaces
  

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: More advanced list

2003-01-05 Thread zentara
On Sun, 5 Jan 2003 00:43:07 +0100, [EMAIL PROTECTED] (Jerry Rocteur)
wrote:

>Hi,
>
>I'm looking for a Perl list a bit more advanced that this one, you 
>know, not beginners questions..
>
>I love this list and I'm learning a lot from it but I'm wondering if 
>there is another list with less "hello world" or Visual basic is better 
>than Perl type comments, preferably NO WINDOWS but I guess 
>unfortunately that is impossible ??
>
>Any ideas ???

Go to http://perlmonks.org  

Become a monk, and go thru the "newest nodes" everyday.
The high monks there are the "best", and you can always
count on them for "deep insight" into Perl.




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Why Perl kicks but!

2003-01-05 Thread Jonathan Daugherty
# > As for me I don't like visual basic so I don't use it and I don't
# > post to mailing lists for it explaining that all of these 1000's of users
# > are dumb to use such a language.
# 
# do you know how many VB developers are in the US alone?

Of course, numbers do say a lot; in this case, you're probably implying
that there are quite a few VB developers in the US alone.  If that's true,
it's just as profound as saying that there are many windows users in the
world; it doesn't take much to do anything in windows just like it doesn't
take much to write anything in VB.

There may be millions of VB developers in the US, but that just tells me
that there are millions of people out there that would rather write code
quickly and easily and without care, rather than putting forth a bit of
effort to write programs in an efficient, respectable, compiled, and
standard language like C (for those of you who may be so audacious as
to think that C is "antequated", etc).  VB is arguably inefficient,
by virtue of being made by Microsoft it is unrespectable, and is most
certainly nonstandard.  I don't have to like VB, nor must you like or
use C, Perl, or anything else; just don't think that by presenting
statistics you may make a case for VB at all.

-- 

  Jonathan Daugherty
  http://www.cprogrammer.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Looking for a perl benchmark suite

2003-01-05 Thread Bob X
"Beau E. Cox" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi -
>
> I can't seem to find a good benchmark suite for perl.
> I looked through CPAN and found benchmarking tools, but
> not a ready-to-go suite.
>
> I don't need anything too fancy. I have compiled perl
> 5.8 on windows with the MS free VC7 std. compiler (which
> doesn't have optimization) and am wondering what the
> performance hit is compared to AS's bininary and my
> Linux versions.
>
> Any help would be appreciated.
>
> Aloha => Beau.
>

perldoc Benchmark

I use it to time scripts...easy to do.

Bob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: parsing a program's output as its running (in perl)

2003-01-05 Thread Mark Price
> ahh yes, thank you.  but i ran into a little problem.  consider the code:
>
> open PIPE, "| /usr/bin/mplayer args" or die "failed to open pipe, $!"
> while (  ) {
>   if ($condition) {
>   close(PIPE);
>   }
>   else{
>   # process line
>   }
> }
>
> it seems that when i close the pipe before EOF, whatever i type in the
> terminal that started the perl script is no longer echoed onto the screen.
> i.e. the script ends and whatever i type into the console isn't echoed on the
> screen (but its there).  what gives?  =/
>
Well, I typed up a similar program and didn't see the same symptoms
although I have seen this type of thing before.  But my guess is that
even so the program is not doing what you think it is.

A.   open FILE, "| $command"
opens a file pointer for writing to $command's stdin.
I.e.
print FILE "stuff\n";
while:
B.   open FILE, " $command | ";
opens a file pointer for reading $command's stdout.

You probably want to try the second version.
There are plenty of possible reasons why your program is
behaving this way, such as giving an empty stdin to
$command, trying to read from a write pipe, or the fact that
$command is printing to screen instead of  and possibly
printing invisible characters that foul up your terminal.

The part about $command printing to screen is the important
part.  If you use type A, there will be no text to process.

--
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Mark Price
SysAdmin and Operations Manager, The JIMINI Project,
Applied Global Systems Lab, University of North Florida
Phone (Office): 904-620-3880 (Mobile): 904-626-8172
mailto: [EMAIL PROTECTED]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




3 questions about Perl

2003-01-05 Thread Gary Fung

Hi,

  I am the beginner of using Perl. I am facing 2 problems when I am doing my Academic 
Project. My project is to build a system for Webmining.

1. Can Perl 5 build a .EXE (executable) file from a program source. How?

2. Since my project Webmining include the technique of data-mining (Apriori algorithm 
for Association Rule and Sequential Pattern) , I need to use "Set" operations such as 
Union, Intersaction...etc.. Does Perl have any module to handle such Set operations? 

My questions may be silly as I am the beginner of Perl. Hope you can give help to me. 

Thank you very much!

Regards,

Gary,from HK

Lonely Christmas(³¯«³¨³)¡A­·ºå»P­·(Twins)¡AµL¶¡¹D(¹q¼v)...
¦ÜIn¤â¾÷¹aÁn ³­§A¹L¥V¤Ñ



How to write hex values into a file

2003-01-05 Thread Alex Demmler
Hi folks!

How do I write hex Values direct into a file (like a hex editor does)?
I have tested some stuff with "printf" but it did not worked (as I expected
or I did wrong).

Example: I need to write "C9D0D3C6" as header in front of my files.

Thanks a lot
Alex


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Clear command in perl?

2003-01-05 Thread Alex Demmler
in Beitrag [EMAIL PROTECTED]
schrieb Jensen Kenneth B Sra Afpc/Dpdmpq unter
[EMAIL PROTECTED] am 02.01.2003 15:25 Uhr:

> Is there a perl command equivalent to:
> system ("clear");
> ?
> 
> Thanks,
> Ken
> 
> 
Simple write it as a system call

#!/usr/bin/perl -w

system("clear"); on UNIX
system("cls"); on Windows

Now the terminal will be cleared.

;-) Alex

PS: Find attached an sample


#!/usr/bin/perl -w

print ("hello\n");
print("clear screen in 5 sec!\n");
sleep(5);
system("clear");
exit 0;
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: 3 questions about Perl

2003-01-05 Thread Paul Johnson
On Sun, Jan 05, 2003 at 09:00:03PM +0800, Gary Fung wrote:

>   I am the beginner of using Perl. I am facing 2 problems when I am
>   doing my Academic Project. My project is to build a system for
>   Webmining.
> 
> 1. Can Perl 5 build a .EXE (executable) file from a program source.

If you are a beginner, the answer is probably no.  Of course it all
depends what you want your executable to do, but if you want to do the
same as a C compiler for example, then you are pretty much out of luck.
There was an experimental project to do this, but it doesn't work
completely and is basically dead.

> How?

No doubt someone will suggest something like perl2exe.  For an academic
project I doubt this is what you want.

> 2. Since my project Webmining include the technique of data-mining
> (Apriori algorithm for Association Rule and Sequential Pattern) , I
> need to use "Set" operations such as Union, Intersaction...etc.. Does
> Perl have any module to handle such Set operations? 

Get to know cpan.  Go to search.cpan.org and type in set.

Now you just have to decide what to use.  I'm not familiar with all these
modules, but the author of Set::Scalar has a reasonable pedigree :-)

Depending on your needs, bitstrings may suffice.

> My questions may be silly as I am the beginner of Perl.

It was only the third one I found a little silly ;-)

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: How to write hex values into a file

2003-01-05 Thread Wagner, David --- Senior Programmer Analyst --- WGO
If you use the following:

printf "%x\n", $_;

where $_ equals 3385906118 it will print C9D0D3C6 or are you needing the
data to be in true binary form, then pack may be what you need.

Wags ;)
-Original Message-
From: Alex Demmler [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 05, 2003 05:34
To: [EMAIL PROTECTED]
Subject: How to write hex values into a file


Hi folks!

How do I write hex Values direct into a file (like a hex editor does)?
I have tested some stuff with "printf" but it did not worked (as I expected
or I did wrong).

Example: I need to write "C9D0D3C6" as header in front of my files.

Thanks a lot
Alex


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




How to extract a atachment from a email

2003-01-05 Thread LRMK
How to extract a atcahment from a email to save in harddrive Im using Net::POP3




Re: More advanced list

2003-01-05 Thread Jenda Krynicky
From: Jerry Rocteur <[EMAIL PROTECTED]>
> Thanks.. I would not unsubscribe from this list, it is great and it
> has its place, there's quite a bit of advanced stuff on this list and
> whilst Randal subscribes to it, I'll stay subscribed ;-))
> 
> I was just interested in what other Perl lists you more advanced guys
> also subscribed to that's all..

Well ... pretty much all Perl related lists @ActiveState.com ;-)
And PerlMonks.
 
> > -Original Message-
> > From: Jerry Rocteur [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, January 04, 2003 3:43 PM
> > To: [EMAIL PROTECTED]
> > Subject: More advanced list
> >
> >
> > Hi,
> >
> > I'm looking for a Perl list a bit more advanced that this one, you
> > know, not beginners questions..
> >
> > I love this list and I'm learning a lot from it but I'm wondering if
> > there is another list with less "hello world" or Visual basic is
> > better than Perl type comments, preferably NO WINDOWS but I guess
> > unfortunately that is impossible ??

I do not remember any "VB is better" message here. There were a few 
"how do you translate this VB to Perl" and "how do I interface VB 
with Perl", but that's a different issue. And something that 
definitely belongs here.

Jenda
P.S.: VB(Script) is better.
For those script kiddies that do the interface layer here in TMP.
IMHO, if you need some graphical interface with very little logic 
inside VB is quite a good option. Especialy since it's easier (at 
least in Czech Republic) to find someone who knows enough VB that 
someone who knows enough Perl.
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Sent time in a Net::SMTP mail

2003-01-05 Thread Jenda Krynicky
From: "John W. Krahn" <[EMAIL PROTECTED]>
> Or, you could do it the "correct" way.  :-)
> 
> use POSIX 'strftime';
> 
> my $date = strftime '%a, %d %b %Y %H:%M:%S %z', localtime;
> $smtp->datasend( "Date: $date\n" );

I'm not sure this is the correct way.
This prints
Sun, 05 Jan 2003 18:42:54 Central Europe Standard Time
on my computer (Win2k, ActivePerl 5.5.1 build 631 as well as 
ActivePerl 5.8.0 build 804).
Which is NOT understood properly by my mailer (Pegasus Mail 4.02a).

My way prints
Sun, 5 Jan 2003 18:47:11 +0100
which is understood.

According to the RFC 822 : http://www.faqs.org/rfcs/rfc822.html
(STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES)

zone=  "UT"  / "GMT"; Universal Time
 ; North American : 
UT
 /  "EST" / "EDT";  Eastern:  - 5/ - 
4
 /  "CST" / "CDT";  Central:  - 6/ - 
5
 /  "MST" / "MDT";  Mountain: - 7/ - 
6
 /  "PST" / "PDT";  Pacific:  - 8/ - 
7
 /  1ALPHA   ; Military: Z = UT;
 ;  A:-1; (J not 
used)
 ;  M:-12; N:+1; 
Y:+12
 / ( ("+" / "-") 4DIGIT ); Local differential
 ;  hours+min. (HHMM)

And according to RFC 2822 : http://www.faqs.org/rfcs/rfc2822.html
(Internet Message Format) 

zone =   (( "+" / "-" ) 4DIGIT) ; obs-zone

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Why Perl kicks but!

2003-01-05 Thread Rob Dixon
Group, this isn't about beginners or Perl, it's about whether or not VB,
Perl etc is the best language in the world and doesn't belong here. People
are as protective of their favourite languages as they are of their mothers,
and I don't want to read a list of list members' relatives either.

Please let's keep this to alt.religion.programming.

Cheers,

Rob


"Dan Muey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
To me Visual Basic is retarded , not even a last resort.
At best a good tool to use to learn some basic concepts of
programming to move on to a better one like C or a variant.
But that's just me.
If you don't like perl don't use it and go join a visual basic mailing list.
As for me I don't like visual basic so I don't use it and I don't post to
mailing lists for it
explaining that all of these 1000's of users are dumb to use such a
language.

I personally like perl very much for plenty of reasons.
But why get into a big fight over 'my daddy can beat up your daddy';

It's not 'hell' trying to use data structures more complicated than a hash.
It's quite elegant and simple once you do it a bit.
Unless you've never done it then it may be, just as riding a bike or tieing
your shoes or not crapping in your pants was 'like hell' at one time or
another in your life.

Sorry, enough ranting I've had quite a day with no one to take it out on.

I apologize.

Dan


-Original Message-
From: Rob Richardson [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 3:43 PM
To: [EMAIL PROTECTED]
Subject: Re: Why Perl kicks but!


David and everybody else,

To me, Perl is a tool to be used when other tools don't fit.  It's great to
be able to write a program that will run on just about every Windows and
Unix box ever made, but it's hell trying to use structures more complicated
than a hash.

Give me Visual Basic first, and then C++.  Perl is a last resort.

Rob



__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




LWP and HTTP::Cookies Trouble

2003-01-05 Thread Superkuh

I've been having a bit of trouble getting LWP and HTTP::Cookies to play
nice in a little script I've been making. Basically it's just a simple
get client that retrieves a series of URLs defined by 2 for loops. But
to achieve it's goal the client has too both impersonate a browser
(which was quite easy thanks to LWP) and accept cookies, which I thought
HTTP cookies working in concert with LWP could handle. But for some odd
reason I can't get the silly little script to work. No cookies are
recieved by the client, and thus the server I'm playing around with does
not perform the action I wanted.

So why doesn't this accept cookies?
---

use LWP::UserAgent;
use HTTP::Request::Common qw(GET);
use HTTP::Cookies;

$line = "";
$agtname = q[Mozilla/5.0 (compatible; Konqueror/3.0.0-10; Linux)];
@headers = (
   'Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*',
   'Accept-Charset' => 'iso-8859-1,*,utf-8',
   'Accept-Language' => 'en-US',
   'Referer' => "http:\/\/www.superkuh.com\/"
  );

system ("cls");
print "Operation ChunkBuster Commencing\n";
print "\n\n";

for ($x = 200; $x <= 320; $x++) {   
for ($y = 22; $y <= 47; $y++) {
$line = 'http://drunkmenworkhere.org/189.php?x=' . "$x" . '&y=' . "$y";
$url = "$line";

$ua = LWP::UserAgent->new('agent' => $agtname);
$ua->cookie_jar(HTTP::Cookies->new(file => "cookies.txt", autosave => 1));  

# $ua->cookie_jar({});
push(@{ $ua->requests_redirectable }, 'POST');

$req = GET ($url, @headers);
print $ua->request($req)->as_string;
print "\n\n";
sleep 1.2;
   }
}

-- 
Superkuh <[EMAIL PROTECTED]>
http://www.superkuh.com/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Perl Help

2003-01-05 Thread Adam Southerland
Hi all...

I have worked for about 6 hours on one bit of code and to be honest, I
am bum-fuzzeled. I don't know who to ask or where to look for help..
Chat rooms seem to be of no use..

I have values - 14.95 and 28.00 and 0.00

I want this code to say, if equal 0.00 then don't display html, else
display it.

My Var = @fieldprice

If (@fieldprice > 0) { #show HTML; }
Or
If (@fieldprice gt "0") { #show HTML; }

Here is the true problem:
 In the comparison the Variable is jacked up and returns only '.##' (Ex.
'.95'  '.00'  '.00')

So any even number priced doesn't get shown.

Someone said do a 'RegExp' (Regular Expresion) like this /\d+\.\d+/
\d+  = numeric number
\. =  '.'
/ is beginning and end.

I have tried  
  @fieldprice = /\d+\.\d+/;
but it still fails to work right.

If you don't know, perhaps you know someone who does?

Any help is grateful =)

Adam Southerland





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Perl Help

2003-01-05 Thread simran
Adam, 

Not sure exactly what you are trying to do, but from what i gather...
you don't want to say:

  @fieldprice > 0

as that will put the "array" fieldprice in scalar contect, and give you
back the number of elements in that array... 

Now Assuming:

  $fieldprice = 14.95

You should be able to say:

  if ($fieldprice != 0) { # aka, if $fieldprice does not 
  # equal 0 (in numerical context)
&showHTML();
  }
  else {
# do something else... 
  }
  


On Mon, 2003-01-06 at 12:17, Adam Southerland wrote:
> Hi all...
> 
> I have worked for about 6 hours on one bit of code and to be honest, I
> am bum-fuzzeled. I don't know who to ask or where to look for help..
> Chat rooms seem to be of no use..
> 
> I have values - 14.95 and 28.00 and 0.00
> 
> I want this code to say, if equal 0.00 then don't display html, else
> display it.
> 
> My Var = @fieldprice
> 
> If (@fieldprice > 0) { #show HTML; }
> Or
> If (@fieldprice gt "0") { #show HTML; }
> 
> Here is the true problem:
>  In the comparison the Variable is jacked up and returns only '.##' (Ex.
> '.95'  '.00'  '.00')
> 
> So any even number priced doesn't get shown.
> 
> Someone said do a 'RegExp' (Regular Expresion) like this /\d+\.\d+/
> \d+  = numeric number
> \. =  '.'
> / is beginning and end.
> 
> I have tried  
>   @fieldprice = /\d+\.\d+/;
> but it still fails to work right.
> 
> If you don't know, perhaps you know someone who does?
> 
> Any help is grateful =)
> 
> Adam Southerland
> 
> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Sent time in a Net::SMTP mail

2003-01-05 Thread John W. Krahn
Jenda Krynicky wrote:
> 
> From: "John W. Krahn" <[EMAIL PROTECTED]>
> > Or, you could do it the "correct" way.  :-)
> >
> > use POSIX 'strftime';
> >
> > my $date = strftime '%a, %d %b %Y %H:%M:%S %z', localtime;
> > $smtp->datasend( "Date: $date\n" );
> 
> I'm not sure this is the correct way.
> This prints
> Sun, 05 Jan 2003 18:42:54 Central Europe Standard Time
> on my computer (Win2k, ActivePerl 5.5.1 build 631 as well as
> ActivePerl 5.8.0 build 804).
> Which is NOT understood properly by my mailer (Pegasus Mail 4.02a).

On my system the manpage for strftime says:

man 3 strftime
[snip]
   %z The time-zone as hour offset from GMT.  Required to
  emit RFC822-conformant dates (using "%a, %d  %b  %Y
  %H:%M:%S %z"). (GNU)

As I don't have a Windows system to test this on I'm not sure why this
is happening.
However the POSIX manpage states:

man 3pm POSIX
[snip]
   If
   you want your code to be portable, your format
   (`fmt') argument should use only the conversion
   specifiers defined by the ANSI C standard.  These
   are `aAbBcdHIjmMpSUwWxXyYZ%'.

So it looks like the %z format is not portable.
If it doesn't work on your machine you can calculate it like this:

$ perl -MPOSIX -MTime::Local -e'
$local = time;
$gm = timelocal( gmtime $local );
$sign = qw( + + - )[ $local <=> $gm ];
$calc = sprintf "%s%02d%02d", $sign, (gmtime abs( $local - $gm ))[2,1];

print "Calculated: $calc\n", strftime( "strftime: %z\n", localtime );
'
Calculated: -0800
strftime: -0800




John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]