[11318] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4919 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 17 13:07:34 1999

Date: Wed, 17 Feb 99 10:05:00 -0800
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, 17 Feb 1999     Volume: 8 Number: 4919

Today's topics:
    Re: How do you calculate $yday if already know $mday, $ <wmwilson1@go.com>
        How to replace a string by another <vbezard@atos-group.com>
        MASS EMAIL <curweb@cur.org>
        Need perl programmer <charman@clark.net>
    Re: none (Abigail)
    Re: none <revjack@radix.net>
        Perl Book <stephenz@nortelnetworks.com>
    Re: Perl evangelism <camerond@mail.uca.edu>
        perlexe.pl problems? <abeer@hplb.hpl.hp.com>
    Re: PFR: UTC_to_Epoch <garethr@cre.canon.co.uk>
    Re: pos() and $1, $2, $3... (Peter Palfrader)
        print: location not working? (Curtiss Hammock)
    Re: regex poll (Chris Nandor)
        Socket communication nightinj@my-dejanews.com
    Re: Speed Up Perl <ludlow@us.ibm.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 17 Feb 1999 15:47:15 GMT
From: wil <wmwilson1@go.com>
Subject: Re: How do you calculate $yday if already know $mday, $mon and $year?
Message-Id: <7aeoa0$58e$1@nnrp1.dejanews.com>

In article <7aa5ak$9rj$1@ionews.ionet.net>,
  "Bvis" <bvis@mtv.com> wrote:
> All,
>
> I'm having trouble trying to figure out the day of the year if I already
> know the date(month,day,year). I've heard of an external module called
> Date::Manip , but I can't use external modules and need a built-in function
> or some code to do the calculation. Anybody have any ideas? Any help is
> greatly appreciated. Thanks.
>
> P.S. Just adding up the days is not an option either. :)
>
> Tommy
>
>

Not to do your homework for you, but if you're trying to figure out
yesterday's date (which from your subject seems correct, but not so much from
the body), try this script, it uses all standard Perl Modules and well...I'm
sure you'll figure it out

#!/usr/bin/perl -w

#
#  Program Name:        date-tool
#  Date Created:        02/15/99
#  Creator:             Mike Wilson
#
#  Usage & Description:
#       date-tool [-i or -d] -n (number of days) -f <format>
#
#       see usage for a complete explanation of the formatting.
#       Basically, -i for increment or -d for decrement, -n for
#       the number of days you'd like to look ahead or back, and
#       -f and your format choice, the format is sent directly to
#       the strftime function which takes care of all that crap.
#

#
#  Some pragmas and module inclusion.  Strict is always a nice
#  choice, we need 'use vars..' for getopts, we need Getopt::Std
#  for the command line options, and from the POSIX module we'll
#  grab the strftime function for formatting.
#
use strict;
use vars qw($opt_i $opt_d $opt_n $opt_f);
use Getopt::Std;
use POSIX qw(strftime);

#
#  getopts automagically fills $opt_(option letter) as
#  seen below
#
getopts('idn:f:');

#
#  We won't worry whether opt_i or opt_d are filled, we'll
#  use decrement as the default, but we'll wine about it of course ;)
#
die "Expecting more options" && &usage
     unless(defined($opt_n) && $opt_f);

#
#  Fill current_date with the Epoch seconds.  Also, we'll only
#  work with full days, so the interval is easy to determine, whatever
#  opt_n's argument was times 60 (equals n minutes) times 60 (equals
#  n hours) times 24 (equals n days)....simple enough
#
my $yesterday;
my $current_date = time;
my $interval = $opt_n * 60 * 60 * 24;

if($opt_d) {

$yesterday = $current_date - $interval;

} elsif($opt_i) {

$yesterday = $current_date + $interval;

} else {

#
#  Wine and complain...but do it anyway.
#
print "You should specify -i(ncrement) or -d(ecrement)!!";
print "\nusing decrement as the default\n\n";

$yesterday = $current_date - $interval;

}

#
#  Just print the answer because I doubt anyone will use
#  this "interactively", just for scripts and such
#
print strftime($opt_f, localtime($yesterday)), "\n";

sub usage {

#
#  basename $0, strip everything to the last / (greedy)
#
(my $progname = $0) =~ s|^.*/||g;

print <<End_Of_Usage;

Usage: $progname [-i or -d] -n N -f <format>

where:
-i means increment
-d means decrement
-n is the number of days to increment/decrement -f <format> is:

%a  The abbreviated weekday name according to the current locale. %A  The
full weekday name according to the current locale. %b  The abbreviated month
name according to the current locale. %B  The full month name according to
the current locale. %c	The  preferred date and time representation for the
current locale. %d  The day of the month as a decimal number (range 01 to
31). %H  The hour as a decimal number using a 24-hour  clock (range  00  to
23). %I  The  hour  as	a  decimal number using a 12-hour clock (range 01 to
12). %j  The day of the year as a decimal number (range 001 to 366). %m  The
month as a decimal number (range 01 to 12). %M	The minute as a decimal
number. %p  Either `am' or `pm' according to the given time value, or the 
cor-responding strings for the current locale. %S  The second as a decimal
number. %U  The  week  number of the current year as a decimal number,
starting with the first Sunday as the first day of the first week. %W  The
week number of the current year as a decimal number,  starting with the first
Monday as the first day of the first week. %w  The day of the week as a
decimal, Sunday being 0. %x  The  preferred  date  representation for the
current locale without the time. %X  The preferred time representation for
the  current locale without the date. %y  The year as a decimal number
without a century (range 00 to 99). %Y	The year as a decimal number
including the century. %Z  The time zone or name or abbreviation. %%  A
literal `%' character.

End_Of_Usage

}

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 17 Feb 1999 18:08:11 +0100
From: "Vincent BEZARD" <vbezard@atos-group.com>
Subject: How to replace a string by another
Message-Id: <7aet1l$856$1@jaydee.iway.fr>

Hello,

I would like to replace a string by another in a variable. For example, I've
got the string named A$, witch containe "cats:dogs", and I would like to
have "cats hats dogs".
Thanks in advance.




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

Date: Wed, 17 Feb 1999 12:33:53 -0500
From: "Christopher Pieper" <curweb@cur.org>
Subject: MASS EMAIL
Message-Id: <7aeuca$g8e$1@news1.Radix.Net>

Ok so I have a task of send 3000 or so people one email. Now I have found
that my best bet is to use a perl script and the sendmail function. is this
sound?

Chris




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

Date: Wed, 17 Feb 1999 10:57:37 -0500
From: Chip Harman <charman@clark.net>
Subject: Need perl programmer
Message-Id: <36CAE6F1.67BE175D@clark.net>

Can anyone give me a suggestion for finding a perl script programmer to
do some short-term file 'fixing' in the U.S.?

Chip Harman
charman@clark.net



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

Date: 17 Feb 1999 16:58:17 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: none
Message-Id: <7aesf9$12k$1@client2.news.psi.net>

Fernando Tanzania (revjack@radix.net) wrote on MCMXCVI September MCMXCIII
in <URL:news:7aej48$rrl$1@news1.Radix.Net>:
__ Abigail explains it all:
__ 
__ :perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'
                                     ^^^^^
__ 
__ Use of uninitialized value at -e line 1.



Abigail
-- 
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'


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

Date: 17 Feb 1999 17:14:14 GMT
From: Calder Pandora <revjack@radix.net>
Subject: Re: none
Message-Id: <7aetd6$dqv$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight

Abigail explains it all:
:Fernando Tanzania (revjack@radix.net) wrote on MCMXCVI September MCMXCIII
:in <URL:news:7aej48$rrl$1@news1.Radix.Net>:
:__ Abigail explains it all:
:__ 
:__ :perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'
:                                     ^^^^^

Stop making me think.

:perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'

Sometimes you frighten me, Abigail.

-- 
  /~\  Turkish formula Wiggins take Montgomery amygdaloid Haitian glin
 C oo  pneumatic deerstalker spacious gullet comparison Alberich monox
 _( ^) 1 , 0 0 0 , 0 0 0   m o n k e y s   c a n ' t   b e   w r o n g
/___~\ http://3509641275/~revjack  02/17/99 12:12:40 revjack@radix.net


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

Date: Wed, 17 Feb 1999 12:32:30 -0500
From: Stephen ZHANG <stephenz@nortelnetworks.com>
Subject: Perl Book
Message-Id: <36CAFD2E.233911A7@nortelnetworks.com>

Hi Folks,

I am looking for a free e-format Perl Book on the Internet. If someone
the Web Site, please let me know. Thanks a lot!

MfG
ZHANG


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

Date: Wed, 17 Feb 1999 09:40:02 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: brian d foy <comdog@computerdog.com>
Subject: Re: Perl evangelism
Message-Id: <36CAE2D2.91B64740@mail.uca.edu>

[cc'd to bdf]


brian d foy wrote:
> 
> In article <36C9F49C.341C90EA@mail.uca.edu>, Cameron Dorey <camerond@mail.uca.edu> posted:
> [snip]
> > http://www.microsoft.com/sitebuilder/magazine/clinick_perl.asp
> 
> from that page:
> 
>    Sometimes, those shortcuts can be a little
>    counterproductive, though. Perl is famous for its ability to
>    create programs that are entirely illegible to everyone but
>    the developer who wrote them. The Perl community even has
>    obfuscation contests to see who can write the most
>    unintelligible Perl code.
> 
> it's almost depressing to think that someone might actually
> beleive this.  Programmers, not languages, write obfuscated code; and
> Perl certainly didn't invent the concept.
> 
> more mis-informed crap from an MS marketing droid posing as
> a technology consultant.

Well, yep, he says this, but in the next section:

"I can't talk for all of Microsoft, but certainly the script
technologies group and a bunch of people in the Windows and BackOffice
group think it's a fine language and certainly deserves a place in
Windows Scripting. [snip] 

Perl does have some very powerful features -- both in the language and
from the myriads of modules that are available (modules are extensions
to the core Perl language). One of Perl's key features as a language is
regular expressions; in fact, Perl has probably done more to evolve
regular expressions than any other language. If you are not familiar
with regular expressions, think of them as the ultimate string
manipulation tool for serious string processing. Regular expressions are
to strings what math is to numbers. In addition to the language
features, modules are a great asset to Perl; there is probably a module
out there that will do what you need. For example, there are modules to
talk to sockets, HTTP, and SMTP e-mail -- making Perl a very useful
language for Web server development. 

We also recognize that a lot of people moving from UNIX to Windows have
considerable investment in Perl -- both code and expertise. As a result,
it's very important that we have a great Perl implementation on Windows,
and that you can use Perl everywhere you can use a Microsoft scripting
language. This eases some of the pain of migration to Windows, since you
can at least keep using a language that is familiar to you."

Sorry about the long quote, but I think this sounds pretty positive from
a MS employee standpoint. And, the original poster said he had been
using Perl, this page pretty much says, "Go ahead, we're giving you no
reason to change." It even gives a couple of (trivial) examples which
show how you can use Perl in the place of VB with no loss of
functionality. IMHO, this page should help him, even if he has to use
NT.

Cameron
camerond@mail.uca.edu


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

Date: Wed, 17 Feb 1999 17:39:44 GMT
From: Andrew Beer <abeer@hplb.hpl.hp.com>
Subject: perlexe.pl problems?
Message-Id: <36CAFEE0.A5C60C32@hplb.hpl.hp.com>

Hi All,

I'm trying to create a standalone executable from a perl script I have
written but keep coming across the same error regardless of what perl
module I use to send mail. The compilation error messages are as
follows.

Failed to Load Net::SMTP Failed to Load Socket
BEGIN failed--compilation aborted (in cleanup) Failed to Load Socket
BEGIN failed--compilation aborted at (eval 4) line 13.

BEGIN failed--compilation aborted at (eval 2) line 10.

Any help would be much appreciated.

Cheers,

Andy Beer - HP Labs




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

Date: Wed, 17 Feb 1999 15:39:13 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: PFR: UTC_to_Epoch
Message-Id: <sid839rqe6.fsf@cre.canon.co.uk>

Tom McGlynn <tam@silk.gsfc.nasa.gov> wrote:
> I do have applications where the leap seconds matter.

If leap seconds matter to your application you may be better off using
something other than UTC for your time.  TAI (International Atomic Time)
has no leap seconds.

-- 
Gareth Rees


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

Date: Wed, 17 Feb 1999 16:41:20 GMT
From: palfrader@usa.net (Peter Palfrader)
Subject: Re: pos() and $1, $2, $3...
Message-Id: <36caf04b.96803@news.uibk.ac.at>

On 16 Feb 1999 20:37:53 GMT, ilya@math.ohio-state.edu (Ilya
Zakharevich) wrote:

>[A complimentary Cc of this posting was sent to Peter Palfrader
><palfrader@usa.net>],
>who wrote in article <36c9d306.6731604@news.uibk.ac.at>:
>
>>     Is there a function similar to pos() to find out, where these
>> substrings start/end in the "big" string ($src)?
>
>I answered it just yesterday.  Use @+, @-.

If you did, I'm very sorry for my repost, but I did not get any reply,
neither per mail nor per news :(


I'm sorry to be a nuisance but I did not find them in the man pages.
How are they supposed to work? I tried:

    #!/usr/bin/perl -w -T
    use strict;

    my $tst = "Hello, go to hell";
    $tst =~ s/(Hel.*?)(he)//g;

    print $&."yy\n";
    for (@+) { print $_."xx\n"; };
    for (@-) { print $_."zz\n"; };

But all I get is an output from the first print: "Hello, go to heyy\n"
the prints in the loops are never executed. Did I do something wrong?

TIA


--
Weasel                               mailto:palfrader@writeme.com
-----------------------------------------------------------------
             "With a rubber duck, one's never alone"
             -- The Hitchhiker's Guide to the Galaxy


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

Date: Wed, 17 Feb 1999 17:57:25 GMT
From: curtiss@desertisle.com (Curtiss Hammock)
Subject: print: location not working?
Message-Id: <36cb0192.14958390@nntp4.mindspring.com>

I'm trying to do a redirect, randomly sending one of four web pages. I
think I've got the random part right, but the print: location thing
isn't working right (unless I'm just misunderstanding it). I've
searched high and low, and found lots of examples of why this should
work. I must be missing something.

Here's the page (index.shtml)  from which I call the script:

<html>
<head>
<title>Testing...testing...</title>
</head>
<body>
<!--#exec cgi = "/cgi-bin/randhom2_flash.pl" -->
</body>
</html>


And here's my script (a simplified version without the randomization):

#!/usr/bin/perl
print "Location:
http://www.webserver.com/flash/cgi_test/index1.shtml\n\n";
exit 0;

Am I wrong in thinking that this should load "index1.shtml"? Right
now, it just loads a page with a *link* to the page in question.

Any hints would be greatly appreciated.

Curtiss


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

Date: Wed, 17 Feb 1999 10:04:05 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: regex poll
Message-Id: <pudge-1702991004050001@192.168.0.77>

In article <39soc6ufbq.fsf@ibnets.com>, Uri Guttman <uri@ibnets.com> wrote:

>as ilya and i are having another war over MRE and versions of perl, i am
>posting this poll. i want to know what regex features people use and how
>often. i have listed all features i found in the desktop reference which
>covers 5.005. if you see some that i have missed, add them. this is both
>for s/// and m//.

Uri, as this poll is being conducted in an entirely unscientific manner,
the results will be useless for arguing for either position, whatever the
positions are.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Wed, 17 Feb 1999 16:52:22 GMT
From: nightinj@my-dejanews.com
Subject: Socket communication
Message-Id: <7aes41$8qv$1@nnrp1.dejanews.com>

I've been using the Socket module to transfer data between a server and a
client program/process using TCP.

Does anybody know if it possible to send information to the server from the
client and give an example of how this could be done (or some other hint).

Regards,

John N.

Code extracts:

SERVER
for ( ;$paddr = accept(Client,Server);close Client) {

   my ($port,$iaddr,$name);
   ($port,$iaddr) = sockaddr_in($paddr);
   $name = gethostbyaddr($iaddr,AF_INET);

   logmsg "connection from $name [", inet_ntoa($iaddr), "] at port $port";

# want to display detail from client, here

  for ($i = 1; $i <= 2; $i++) {  print Client "$i: Hello there, $name, it's
now ", scalar localtime, "\n";	sleep 5;  } }

CLIENT
connect(SOCK,$paddr) or die "connect: $!\n";

# want to send detail for display on server, here

while ($line = <SOCK>)
{
   print "$line";
}

close (SOCK) or die "close: $!\n";

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 17 Feb 1999 10:02:20 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Speed Up Perl
Message-Id: <36CAE80C.C29828DF@us.ibm.com>

pvdkamer@inter.NL.net wrote:
 
> Does anyone have a sulution to speed up perl scripts ?
> i've got several perl scripts wich are all comparing substrings in 2
> textfiles.

You might want to post some pieces of your code.  My first instinct
isn't to blame perl, but rather the Perl script itself.  You may simply
be using an inefficient algorithm.  Without ruling that possibility out,
it's impossible to tell you how to speed up your program.

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4919
**************************************

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