[25298] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 7543 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 20 18:05:48 2004

Date: Mon, 20 Dec 2004 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 20 Dec 2004     Volume: 10 Number: 7543

Today's topics:
    Re: Comparing 2 dates ? <lance-news@augustmail.com>
    Re: Comparing 2 dates ? <nospam@nospam.com>
        generating a session id ioneabu@yahoo.com
    Re: generating a session id <1usa@llenroc.ude.invalid>
    Re: generating a session id <1usa@llenroc.ude.invalid>
    Re: generating a session id <tadmc@augustmail.com>
    Re: inserting a line into the body of an eMail before f <dlr93612@yahoo.com>
    Re: inserting a line into the body of an eMail before f <tadmc@augustmail.com>
    Re: inserting a line into the body of an eMail before f <tadmc@augustmail.com>
    Re: inserting a line into the body of an eMail before f <noreply@gunnar.cc>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 20 Dec 2004 14:02:48 -0600
From: Lance Hoffmeyer <lance-news@augustmail.com>
Subject: Re: Comparing 2 dates ?
Message-Id: <pan.2004.12.20.20.02.45.570859@augustmail.com>

Birthday is n format:

2004-12-20



Lance



On Mon, 20 Dec 2004 09:53:18 -0500, Ken wrote:

> Lance Hoffmeyer wrote:
>> I modified a script I found that gets a list of birthdays.
>> I wish to compare the birthdays with the current day's date.
>> 
>> Two things I want to do:
>> 1) Print out the 3 fields if the birthday is in the current month
>> 2) Print out the 3 fields if the birthday is 2 weeks or less away
>> 
>> Any help would be appreciated
>> 
>> Lance
>> 
>> 
>> 
>> #!/usr/bin/perl -w
>> use Pg;
>> use DBI;
>> 
>> 
>> $dbh = DBI->connect ( "dbi:Pg:dbname=foobar", "foobar",
>> "foobar"); if ($dbh) {
>>    print "connected\n";
>> 
>> 
>> my $Command = "SELECT first_name, last_name, birthday FROM database";
> <snip>
> 
> We can't help you without knowing what format birthday is in. Can you 
> give an example of the returned string for birthday?
> 
> Also, it would probably be better to find the birthdays you want using 
> SQL rather than perl. But that's not a matter for a perl group. In that 
> case, look up how to find dates within a certain range using SQL.



------------------------------

Date: Mon, 20 Dec 2004 16:43:55 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: Comparing 2 dates ?
Message-Id: <1103579796.360206@nntp.acecape.com>

"Lance Hoffmeyer" <lance-news@augustmail.com> wrote in message
news:pan.2004.12.20.20.02.45.570859@augustmail.com...
> Birthday is n format:
>
> 2004-12-20


i am guessing (again, guessing) that this question belongs in the "modules"
forum.  as in "what woudl be a good module to use for date calculations?",
but hey, have been wrong before...

perldoc -q date

mentions both Date::Calc and Date::Manip.  i started with the latter, but
then further reading on cpan recommends you go with the former, so  i did.
actually if i recall, that recomendation comes from the author himself.  but
you can read it all at cpan

daniel






------------------------------

Date: 20 Dec 2004 14:17:41 -0800
From: ioneabu@yahoo.com
Subject: generating a session id
Message-Id: <1103581061.893725.116120@c13g2000cwb.googlegroups.com>

I have been using Apache:Session:MySQL for generating session ids in my
attempts at creating a secure login environment on the web where once
the users id is validated, a session id is generated which is passed
from page to page and is checked against the database at each page to
verify that it is legitimate and current.  I think this is pretty much
the standard way to do it.

I realized that I was not using the other features of
Apache:Session:MySQL, just creating a big random string to be used as a
session id.  Since I know how to insert a big random string into a
database, I thought I could skip using this module altogether and just
make up my own session id:

#!/usr/bin/perl

use strict;
use warnings;

my $count = @ARGV ? int $ARGV[0]:10;
my @array;
my $c = 'a';
for (my $i=0;$i<26;$i++)
{
push @array, $c;
$c++;
}
$c ='0';
for (my $i=0;$i<10;$i++)
{
push @array, $c;
$c++;
}
my $out;
for (my $i=0;$i<$count;$i++)
{
$out .= $array[rand(36)];
}
print "$out\n";

As you can see, this simple program just creates a random string of
letters and digits of a length defined by $ARGV[0].

1) Is there a better or more interesting or more concise way to write
the above code?

2) Is there any reason i should still use Apache:Session:MySQL if all I
am doing with it is creating session ids?

Thanks!

wana



------------------------------

Date: 20 Dec 2004 22:44:11 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: generating a session id
Message-Id: <Xns95C5B46DAD928asu1cornelledu@132.236.56.8>

ioneabu@yahoo.com wrote in news:1103581061.893725.116120
@c13g2000cwb.googlegroups.com:

> I have been using Apache:Session:MySQL for generating session ids in my

 ...

> I realized that I was not using the other features of 
> Apache:Session:MySQL, just creating a big random string to be used as a
> session id. Since I know how to insert a big random string into a
> database, I thought I could skip using this module altogether and just
> make up my own session id:


There is more to creating a hard to guess session id. If I were you, I 
would have looked at the Apache::Session module to see how it is done.
 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> my $count = @ARGV ? int $ARGV[0]:10;
> my @array;
> my $c = 'a';
> for (my $i=0;$i<26;$i++)
> {
> push @array, $c;
> $c++;
> }

Even when your code is worthless, please make the effort to present it in a 
decent format: Properly indenting your code could do wonders in eliciting 
friendlier responses at least from this particular reader.

-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



------------------------------

Date: 20 Dec 2004 22:48:54 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: generating a session id
Message-Id: <Xns95C5B539FD6E0asu1cornelledu@132.236.56.8>

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
news:Xns95C5B46DAD928asu1cornelledu@132.236.56.8: 

>> #!/usr/bin/perl
>> 
>> use strict;
>> use warnings;
>> 
>> my $count = @ARGV ? int $ARGV[0]:10;
>> my @array;
>> my $c = 'a';
>> for (my $i=0;$i<26;$i++)
>> {
>> push @array, $c;
>> $c++;
>> }
> 
> Even when your code is worthless, 

Sorry, forgot to point out why:


use warnings;
use strict;

my @array = 'a' .. 'z';
push @array, '0' .. '9';
print @array;

__END__
-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



------------------------------

Date: Mon, 20 Dec 2004 16:34:15 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: generating a session id
Message-Id: <slrncsekr7.nt0.tadmc@magna.augustmail.com>

ioneabu@yahoo.com <ioneabu@yahoo.com> wrote:

> my $c = 'a';
> for (my $i=0;$i<26;$i++)
> {
> push @array, $c;
> $c++;
> }
> $c ='0';
> for (my $i=0;$i<10;$i++)
> {
> push @array, $c;
> $c++;
> }


You can replace all of that code with this one line:

   @array = ('a' .. 'z', 0 .. 9);


> my $out;
> for (my $i=0;$i<$count;$i++)
> {
> $out .= $array[rand(36)];
> }
> print "$out\n";
> 
> As you can see, this simple program just creates a random string of
> letters and digits of a length defined by $ARGV[0].
> 
> 1) Is there a better or more interesting or more concise way to write
> the above code?


There *better* be a better way, as your approach does not
guarantee uniqueness.

How does your approach differ from simply using 1,2,3... as the ID?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 20 Dec 2004 11:28:34 -0800
From: "Lisa" <dlr93612@yahoo.com>
Subject: Re: inserting a line into the body of an eMail before forwarding
Message-Id: <1103570914.662045.223720@f14g2000cwb.googlegroups.com>

I wish it was that simple.

$pop-Body($i), returns the whole body, including the multi part boundry
strings as well as the content type, char set, and content encoding
strings. so that pre-pending the $EmailHeader{'Envelope-to') simply
puts that data infront of (outside ) body entity and therefore NOT
printed by the emial client when the message is read.

:Lisa



------------------------------

Date: Mon, 20 Dec 2004 13:51:27 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: inserting a line into the body of an eMail before forwarding
Message-Id: <slrncseb9v.nlc.tadmc@magna.augustmail.com>

Lisa <dlr93612@yahoo.com> wrote:

> Nope.


Nope to *what* ?

Please quote some context in followups.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Mon, 20 Dec 2004 13:52:01 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: inserting a line into the body of an eMail before forwarding
Message-Id: <slrncsebb1.nlc.tadmc@magna.augustmail.com>

Lisa <dlr93612@yahoo.com> wrote:

> I wish it was that simple.


You wish it was *how* simple?

Please quote some context in followups.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 21 Dec 2004 00:03:47 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: inserting a line into the body of an eMail before forwarding
Message-Id: <32p3ubF3ph70cU1@individual.net>

Lisa wrote:
> Unfortunately the only solution I can come up with invovles regex

Assuming that you have the whole message body as a string in the 
variable $body, how about this to start with:

   if ( $msg->header->{content-type} =~ /boundary=/i ) {
       my $part = '(?:;\\s*charset=\\S+)?\\s+Cont\S+Encoding: *\\S+\\n';
       my $text = qr(Content-Type:\s*text/plain$part)i;
       my $html = qr(Content-Type:\s*text/html$part)i;
       my $addr = "Original addressee: $EmailHeader{'Envelope-to'}";
       $body =~ s/($text)/$1\n$addr\n/;
       $body =~ s/($html)/$1\n<p>$addr<\/p>\n/;
   } else {
       $body = "$addr\n\n$body";
   }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

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 V10 Issue 7543
***************************************


home help back first fref pref prev next nref lref last post