[18118] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 278 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 12 21:10:37 2001

Date: Mon, 12 Feb 2001 18:10:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982030212-v10-i278@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 12 Feb 2001     Volume: 10 Number: 278

Today's topics:
        Help Running  Perl Scripts from a web-page (Falc2199)
    Re: Help Running  Perl Scripts from a web-page <tlav1@mediaone.net>
    Re: Help Running  Perl Scripts from a web-page <newuser@nospam.slip.net>
    Re: Help Running  Perl Scripts from a web-page <gaverth@home.com>
        Help with a perl/cgi script <newuser@nospam.slip.net>
    Re: Help with form code egwong@netcom.com
        Help with MIME-tools <kent@erix.ericsson.se>
        Looking For A Good Sockets Tutorial <jeff_nokes@yahoo.com>
        Looking for a simple output script.... <shaolin@montereybay.com>
    Re: Looking for alternative to Google (was deja) newsgr (Si Ballenger)
    Re: Need help with an array (Abigail)
    Re: Perl FAQ: Stripping blank space <jeffno@denali.ccs.neu.edu>
    Re: Perl FAQ: Stripping blank space (Chris Fedde)
    Re: Perl FAQ: Stripping blank space (Abigail)
    Re: Perl FAQ: Stripping blank space egwong@netcom.com
    Re: Perl FAQ: Stripping blank space <joe+usenet@sunstarsys.com>
    Re: Re: A Question on OLE and EXCEL- help please (Abigail)
    Re: reload blocking (Gwyn Judd)
    Re: reload blocking <c.gersch@team.isneurope.com>
    Re: Replacing single-letter words doesn't work (Abigail)
    Re: Sending email from Perl Script on NT <gaverth@home.com>
    Re: Timezones <ddunham@redwood.taos.com>
    Re: Two dimensional arrays <abe@ztreet.demon.nl>
    Re: Two dimensional arrays (Mahesh A)
    Re: Two dimensional arrays (Gwyn Judd)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 13 Feb 2001 00:40:31 GMT
From: falc2199@aol.comNOJUNK (Falc2199)
Subject: Help Running  Perl Scripts from a web-page
Message-Id: <20010212194031.17694.00000748@ng-cm1.aol.com>

Here is a simple script that I wrote in Perl. It works fine when I run it from
the Perl Interpreter on my machine, but when I upload it to the net it doesn't.

#!\usr\bin\perl
print "Content-type: text/html\n\n";
print "\n\n";

print "Hello World";

I uploaded the file into the cgi-bin given to me by my web-host, but everytime
I go to the file either by typing the exact loc into my browser or thorough
another HTML form, it gives me a 500 Internal Server error.

Here is a link to the problem script...

 <A HREF = "http://odin.prohosting.com/falc/cgi-bin/test1.cgi"> Problem Script
</A>


Can anyone help?

Thank in advance,
Falc


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

Date: Tue, 13 Feb 2001 00:52:23 GMT
From: ted <tlav1@mediaone.net>
Subject: Re: Help Running  Perl Scripts from a web-page
Message-Id: <3A88B000.ABB80CDC@mediaone.net>

Hi there,

These are the first things I can think of...

1) Did you upload your perl program as ASCII text?
2) Did you change permissions ( chmod ) on your perl program to 755 after you
uploaded it?
3) Make sure perl is where the shebang line says it is
4) You're missing the basic minimum HTML tags to create an HTML page (
<HTML><HEAD> etc )

These are just guesses as I don't know all of the details.  Try these and please
let me know if any work for you.

ted




Falc2199 wrote:

> Here is a simple script that I wrote in Perl. It works fine when I run it from
> the Perl Interpreter on my machine, but when I upload it to the net it doesn't.
>
> #!\usr\bin\perl
> print "Content-type: text/html\n\n";
> print "\n\n";
>
> print "Hello World";
>
> I uploaded the file into the cgi-bin given to me by my web-host, but everytime
> I go to the file either by typing the exact loc into my browser or thorough
> another HTML form, it gives me a 500 Internal Server error.
>
> Here is a link to the problem script...
>
>  <A HREF = "http://odin.prohosting.com/falc/cgi-bin/test1.cgi"> Problem Script
> </A>
>
> Can anyone help?
>
> Thank in advance,
> Falc



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

Date: Mon, 12 Feb 2001 16:56:49 -0800
From: "newuser" <newuser@nospam.slip.net>
Subject: Re: Help Running  Perl Scripts from a web-page
Message-Id: <t8h1i4m4ceuede@corp.supernews.com>

Do you have a server error log file? If so what does this error say.
hth
newuser
Falc2199 wrote in message <20010212194031.17694.00000748@ng-cm1.aol.com>...
>Here is a simple script that I wrote in Perl. It works fine when I run it
from
>the Perl Interpreter on my machine, but when I upload it to the net it
doesn't.
>
>#!\usr\bin\perl
>print "Content-type: text/html\n\n";
>print "\n\n";
>
>print "Hello World";
>
>I uploaded the file into the cgi-bin given to me by my web-host, but
everytime
>I go to the file either by typing the exact loc into my browser or thorough
>another HTML form, it gives me a 500 Internal Server error.
>
>Here is a link to the problem script...
>
> <A HREF = "http://odin.prohosting.com/falc/cgi-bin/test1.cgi"> Problem
Script
></A>
>
>
>Can anyone help?
>
>Thank in advance,
>Falc




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

Date: Tue, 13 Feb 2001 01:21:51 GMT
From: "Tim Gaverth" <gaverth@home.com>
Subject: Re: Help Running  Perl Scripts from a web-page
Message-Id: <P_%h6.89627$B6.21643593@news1.rdc1.md.home.com>


Falc2199 <falc2199@aol.comNOJUNK> wrote in message
news:20010212194031.17694.00000748@ng-cm1.aol.com...
> Here is a simple script that I wrote in Perl. It works fine when I run it
from
> the Perl Interpreter on my machine, but when I upload it to the net it
doesn't.
>
> #!\usr\bin\perl

I kind of doubt that's the real location of perl. Maybe #!/usr/bin/perl ?
Maybe #!c:\some\ms\path\perl.exe ?

> print "Content-type: text/html\n\n";
> print "\n\n";
>
> print "Hello World";
>
> I uploaded the file into the cgi-bin given to me by my web-host, but
everytime
> I go to the file either by typing the exact loc into my browser or
thorough
> another HTML form, it gives me a 500 Internal Server error.
>
> Here is a link to the problem script...
>
>  <A HREF = "http://odin.prohosting.com/falc/cgi-bin/test1.cgi"> Problem
Script
> </A>
>
>
> Can anyone help?
>
> Thank in advance,
> Falc




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

Date: Mon, 12 Feb 2001 15:53:17 -0800
From: "newuser" <newuser@nospam.slip.net>
Subject: Help with a perl/cgi script
Message-Id: <t8gtqv4eq7k6ef@corp.supernews.com>

Hello,
    I am having some problems where to insert a part of a perl/cgi script
into a master perl script and was wondering what is the correct way to post
the script here for help.
    Is it ok to post the whole script or just a snippet of it here for help.
thanks




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

Date: Tue, 13 Feb 2001 00:08:12 GMT
From: egwong@netcom.com
Subject: Re: Help with form code
Message-Id: <MV_h6.6823$y03.449850@news.flash.net>

jmd <jdthelen@worldnet.att.net> wrote:
> Thanks but I think that your instructions are over my head (not into
> programming). I've d/l'd the module and looked over the instructions but I
> am sure I will f**k it up totally if I try to do this. Is there a cgi script
> that you know of that is already available somewhere?  Thanks.

No.  You might ask on comp.infosystems.www.authoring.cgi

Followups set.


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

Date: 13 Feb 2001 03:03:57 +0100
From: Kent Boortz <kent@erix.ericsson.se>
Subject: Help with MIME-tools
Message-Id: <d23ddjcp9u.fsf@erix.ericsson.se>


I'm writing a script that take incoming mails, many of them MIME
encoded, and split them up like

   $mail-id/body.txt
   $mail-id/attachments/....

From what I understand the body is really just one of the parts.
Mail readers try to be cleaver and guess what part is the "body"
and it calls the other parts "attachments".

  Q1  Is it the first part that is handled by most mail readers
      like the "body" of the mail? Or should I take the first
      part ending in ".txt" or with the type "text/plain"?
      I tried parsing lots of old mail and sometimes even a single-
      part mail resulted in a file ending in ".dat" so I'm
      not sure how this is supposed to work.

  Q2  Do I have to handle finding the "body" part myself, i.e. first
      use $parser->output_dir("$mail-id/attachments") and decode
      the mail, then find out what file was the first part and
      rename the first part to "$mail-id/body.txt"?

  Q3  How do I find out the file name and type of the first part?  I
      can find the "suggested" name (I think), but I don't know the
      name that was used when the parser stored the file on disk.

I have found out how to read the header fields but is a bit puzzled
about how to handle them. Q4 is maybe not a Perl question but
maybe you can help me anyway

  Q4  Can I expect several fields with the same key? Multiple
      "Cc" fields, multiple "From" fields?

  Q5  Is there another module how to handle the content inside
      a field. If I get a "Cc" like

        "'foo@bar.com'" <foo@bar>, A Name <zap@bar>, zip@zoom.com (Name)

      how do I safely split it up to something like the Perl data

        [["foo@bar",""],["zap@bar","A Name"],["zip@zoom.com","Name"]]

  Q6  Some mails are in Sun MailTool multipart format, i.e. not MIME.
      Is there a module to handle this format?

  Q7  Can I trust the date format used in a "Date" field to be parsable
      by Date::Parse::str2time($date_string)? Should I use
      Mail::Field::Date instead (undocumented?!) and if so, how to I
      use it? Is it inherited from MIME::Head or another MIME module
      and if so, how do I call it? Or do I just create the object and
      use it on the string?

I wish there where more examples with MIME-tools. It seem to be very
powerful but I have a hard time to understand the usage. Also examples
when the inherited methods from MailTools are used would be helpful.
As I said before, part of my trouble is probably because I'm not a OO
person. Yes, one last question

  Q8  Is there a class/object browser or something? If I create an
      object, say MIME::Parser, how do I find out all the methods I
      can call including the inherited ones?

I'm very thankful for any help or pointers you can give me,

kent


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

Date: Mon, 12 Feb 2001 16:47:20 -0800
From: "Jeffry A. Nokes" <jeff_nokes@yahoo.com>
Subject: Looking For A Good Sockets Tutorial
Message-Id: <3A888418.585FA531@yahoo.com>

Greetings,
Anyone know a good link(s) or book(s) that have a very laymens tutorial
on socket/network programming in Perl?  I would really like to start
with understanding the lower layers of what a socket connection is, and
then get into the API.

Thanks in advance,
 - Jeff



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

Date: Mon, 12 Feb 2001 15:53:14 -0800
From: "Gabriel" <shaolin@montereybay.com>
Subject: Looking for a simple output script....
Message-Id: <_H_h6.34$E2m1.13041828@news.randori.com>

I am looking for a perl script that will take my form submission output and
write it to a static web page.  Ideally a script that would overwrite the
previous text output when submitted.

    Thanks for the help,

--
Gabriel





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

Date: Tue, 13 Feb 2001 00:10:11 GMT
From: shb@vnet.net (Si Ballenger)
Subject: Re: Looking for alternative to Google (was deja) newsgroup search
Message-Id: <3a887b24.116461899@166.82.1.9>

On Mon, 12 Feb 2001 16:28:41 -0500, Keith Harrison
<harriso2@pilot.msu.edu> wrote:

>Google has taken over the newsgroup search site www.deja.com and changed 
>the format to, in my opinion, an inferior one. Does anyone know of 
>another site that's comparable to the old deja?

Goto the below site and let them know how  *successful*  their
new interface is. ;-)

http://groups.google.com/intl/en_extra/contact/success.html


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

Date: 12 Feb 2001 23:39:12 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Need help with an array
Message-Id: <slrn98gt10.tas.abigail@tsathoggua.rlyeh.net>

Janet Schlueb (jgs2283@MailAndNews.com) wrote on MMDCCXXII September
MCMXCIII in <URL:news:3A8A58E4@MailAndNews.com>:
** Hello, I know that this isn't too difficult of a question, but I was 
** wondering 
** if anyone could tell me how to do this in one statement rather than 22:
** 
** $rqst = HTTP::Request->new('GET', $PageUrl);
** $rqst = HTTP::Request->new('GET', $PageUrl2);
** $rqst = HTTP::Request->new('GET', $PageUrl3);
   ...
** $rqst = HTTP::Request->new('GET', $PageUrl21);
** $rqst = HTTP::Request->new('GET', $PageUrl22);


Since they all assign to the same variable, you could delete the first 21
lines. ;-)

But, it's better to put the URLs in an array, say @PageUrl and loop
over the array:

    foreach my $PageUrl (@PageUrl) {
	$rqst = HTTP::Request->new('GET', $PageUrl)
    }


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: 12 Feb 2001 18:27:11 -0500
From: Jeffrey Nowakowski <jeffno@denali.ccs.neu.edu>
Subject: Re: Perl FAQ: Stripping blank space
Message-Id: <wzdu25zscs0.fsf@denali.ccs.neu.edu>

Joe Schaefer <joe+usenet@sunstarsys.com> writes:

> Jeffrey Nowakowski <jeffno@denali.ccs.neu.edu> writes:
> 
> > There exists in the Perl FAQ the question "How do I strip blank space
> > from the beginning/end of a string?"
> > 
> > Could the FAQ maintainer please add the question "Why doesn't Perl
> > include a built in function to do this?" 
> 
> What do you suggest the answer should be?
> 
> A : Perl has a regexp engine that can do this trivially.
>     Hence, Perl doesn't need an extremely specialized function
>     (Perl already has it's fair share of those.) If you really 
>     want to, you could always write your own:

I'd prefer the answer: It was an oversight and will be added in.

The operation is so common that to not include it is just silly.
Defining a subroutine yourself is nowhere near as convenient as having
a built-in API.

Also notice that the FAQ starts out with:

"Although the simplest approach would seem to be:"
    (unintelligble regexp follows)
"Not only is this unnecessarily slow and destructive, it also fails
with embedded newlines."

Nice trap for the unwary.  Now tell me again why such a universal and
common operation isn't predefined, but chop/chomp is?

-Jeff


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

Date: Tue, 13 Feb 2001 00:05:46 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl FAQ: Stripping blank space
Message-Id: <uT_h6.68$zN2.188320768@news.frii.net>

In article <wzdu25zscs0.fsf@denali.ccs.neu.edu>,
Jeffrey Nowakowski  <jeffno@denali.ccs.neu.edu> wrote:
>Joe Schaefer <joe+usenet@sunstarsys.com> writes:
>
>> Jeffrey Nowakowski <jeffno@denali.ccs.neu.edu> writes:
>> 
>> > There exists in the Perl FAQ the question "How do I strip blank space
>> > from the beginning/end of a string?"
>> > 
>
>Nice trap for the unwary.  Now tell me again why such a universal and
>common operation isn't predefined, but chop/chomp is?
>
>-Jeff

Chop is there because when Larry invented the language perl was
working on a lot of datafiles with one record per line format.
Chomp is a refinement to this added around the beginning of version 5. 

If you want to see this feature added to the perl core functions
then I'd recommend lobbying on the perl5-porters mailing list.
But be sure to put on your flame retardent Dr Dentons when you make
that post.  The current thinking in the development community is
to make the core smaller by migrating stuff out of the executable
and into external modules.

Also note that code speeks louder than words.

thanks
chris
-- 
    This space intentionally left blank


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

Date: 13 Feb 2001 00:10:06 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl FAQ: Stripping blank space
Message-Id: <slrn98guqu.tas.abigail@tsathoggua.rlyeh.net>

Jeffrey Nowakowski (jeffno@denali.ccs.neu.edu) wrote on MMDCCXXII
September MCMXCIII in <URL:news:wzdu25zscs0.fsf@denali.ccs.neu.edu>:
%% Joe Schaefer <joe+usenet@sunstarsys.com> writes:
%% 
%% > Jeffrey Nowakowski <jeffno@denali.ccs.neu.edu> writes:
%% > 
%% > > There exists in the Perl FAQ the question "How do I strip blank space
%% > > from the beginning/end of a string?"
%% > > 
%% > > Could the FAQ maintainer please add the question "Why doesn't Perl
%% > > include a built in function to do this?" 
%% > 
%% > What do you suggest the answer should be?
%% > 
%% > A : Perl has a regexp engine that can do this trivially.
%% >     Hence, Perl doesn't need an extremely specialized function
%% >     (Perl already has it's fair share of those.) If you really 
%% >     want to, you could always write your own:
%% 
%% I'd prefer the answer: It was an oversight and will be added in.
%% 
%% The operation is so common that to not include it is just silly.
%% Defining a subroutine yourself is nowhere near as convenient as having
%% a built-in API.

Nothing prevents you from writing your own library with your own API.
Write once, use always.

%% Also notice that the FAQ starts out with:
%% 
%% "Although the simplest approach would seem to be:"
%%     (unintelligble regexp follows)
%% "Not only is this unnecessarily slow and destructive, it also fails
%% with embedded newlines."
%% 
%% Nice trap for the unwary.  Now tell me again why such a universal and
%% common operation isn't predefined, but chop/chomp is?

Because stripping all whitespace at the beginning/end isn't that common.
There are specialized functions to add one to a scalar. There isn't a
dedicated function to add 3 to a scalar - you'll have to use the general
addition operator.

Plus that chop/chomp works on lists - it's more than just stripping $/
from a scalar.


Abigail
-- 
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
 |perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
 |perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
 |perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;


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

Date: Tue, 13 Feb 2001 00:22:38 GMT
From: egwong@netcom.com
Subject: Re: Perl FAQ: Stripping blank space
Message-Id: <i7%h6.6833$y03.449850@news.flash.net>

Jeffrey Nowakowski <jeffno@denali.ccs.neu.edu> wrote:
> I'd prefer the answer: It was an oversight and will be added in.
>
> The operation is so common that to not include it is just silly.
> Defining a subroutine yourself is nowhere near as convenient as having
> a built-in API.
>
> Also notice that the FAQ starts out with:
>
> "Although the simplest approach would seem to be:"
>     (unintelligble regexp follows)
> "Not only is this unnecessarily slow and destructive, it also fails
> with embedded newlines."
>
> Nice trap for the unwary.  Now tell me again why such a universal and
> common operation isn't predefined, but chop/chomp is?

You forgot to mention that after the so-called "unintelligble [sic]
regexp", the faq lists the preferred solution.

I can't speak for Larry Wall, but my guess is that removing leading/
trailing space isn't as universal or common as you think.  Furthermore,
it's a poorly defined problem without a general solution.  What
constitutes a space to be removed?  Should leading tabs be removed?
How about newlines?  How about a combination of tabs, newlines and "space"
(\x20)?  I think that there are enough slightly different answers to
these questions to make a builtin practically useless.  Contrast this
with chomp, whose *specific* job is to remove trailing instances of $/.

Of course if you want to develop a patch, I'm sure the people on
p5p will be happy to look at it and give you their opinion --
perl 5.6.1-TRIAL2 is up on CPAN.

ERic


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

Date: 12 Feb 2001 19:47:09 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Perl FAQ: Stripping blank space
Message-Id: <m3ofw7jto2.fsf@mumonkan.sunstarsys.com>

Jeffrey Nowakowski <jeffno@denali.ccs.neu.edu> writes:

> I'd prefer the answer: It was an oversight and will be added in.

I kindly suggest you submit a documentation/source patch to p5p,
and see if it's well-received there.

> The operation is so common that to not include it is just silly.

That's odd; I've been writing perl for few years and haven't once felt
the need for such a thing.  In fact, after a quick peek, the closest 
code snippets I've written look like this:

1)      chomp, s/^\s+//;       # similar to the faq
2)      s/^\s+|\s+$//g;        # a pretty old one :)
3)      chomp, y/"\r//d;       # also old
4)      s/\s{4}.+$//s;         # 4 spaces marks the end of data

Of those 4, only (2) would be correctly handled by your suggested 
function.  The times I've actually needed to simultaneously remove
leading and trailing spaces have been so infrequent that the faq solution
is just fine with me.

> Defining a subroutine yourself is nowhere near as convenient as having
> a built-in API.

Perl does have a built-in API for this and it is extensively documented 
in perlre.

> Also notice that the FAQ starts out with:
> 
> "Although the simplest approach would seem to be:"
>     (unintelligble regexp follows)

That's meant as a warning to people trying to come up with a single
naive regexp instead of cleanly dividing the job between two.

> "Not only is this unnecessarily slow and destructive, it also fails
> with embedded newlines."
> 
> Nice trap for the unwary. 

Huh?  How could you be unwary if you've just read the warning?
It comes included right there with a correct solution.

> Now tell me again why such a universal and
> common operation isn't predefined, but chop/chomp is?

Who cares?  "sub" is a universal and common predefined operation, 
and it's there exactly for times like this.  Two wrongs don't make 
a right.

-- 
Joe Schaefer     "Hain't we got all the fools in town on our side? And hain't
                           that a big enough majority in any town?"
                                               --Mark Twain


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

Date: 13 Feb 2001 00:10:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Re: A Question on OLE and EXCEL- help please
Message-Id: <slrn98gurr.tas.abigail@tsathoggua.rlyeh.net>

hgonzalez@mindspring.com (hgonzalez@mindspring.com) wrote on MMDCCXXII
September MCMXCIII in <URL:news:2334-qx3@questionexchange.com>:
`' 
`' test


Success!  *plonk*


Abigail
-- 
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;        
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";


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

Date: Mon, 12 Feb 2001 23:07:37 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: reload blocking
Message-Id: <slrn98gr5m.6b6.tjla@thislove.dyndns.org>

I was shocked! How could Christian Gersch <c.gersch@team.isneurope.com>
say such a terrible thing:
>Hi there!
>
>The script (I found it free at the web) attatched _should_ prevent the user

>===== CODE: Start =====
>#!/usr/bin/python
            ^^^^^^

Wrong newsgroup.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)


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

Date: Tue, 13 Feb 2001 00:15:12 +0100
From: "Christian Gersch" <c.gersch@team.isneurope.com>
Subject: Re: reload blocking
Message-Id: <969qq0$u4t$05$1@news.t-online.com>

Hi!

> Wrong newsgroup.
Ooops, I sent the wrong code, sorry!

-Chris

=== CODE:START ===
#!/usr/bin/perl
########################################################
#                    Randex  1.21                      #
#               By Thomas Tsoi 12.8.99                 #
#                webmaster@cgi.com.hk                  #
########################################################
#                                                      #
# CGI.com.hk:                                          #
#   http://www.cgi.com.hk/                             #
#                                                      #
# #################################################### #
#                                                      #
# You can distribute this script and use it freely as  #
# long as this header is not edited in the script.     #
#                                                      #
########################################################

############ This is the only thing required
# chmod 644
$rand_file = "/home/astronom/public_html/perl/randex/randex.txt";

############ Advanced Options ; Ignore the following if you are not
interested
# chmod 666
$rand_data = "/home/astronom/public_html/perl/randex/data.txt";
# chmod 666
$rand_ip   = "/home/astronom/public_html/perl/randex/iplog.txt";
# number of ip to store in iplog.txt
$number_ip = 20;
########################################################
#
# That's it, setup ends.
#
########################################################

if ((-w $rand_data) && (-w $rand_ip) && $number_ip > 0) {
 $advanced = 1;
 }

open(RANDEX, $rand_file) or die("Cannot open $rand_file");
@lines = <RANDEX>;
close(RANDEX);

@codes = split(/\[\%\%BREAK\%\%\]/, join("", @lines));
srand(time);
$index = int(rand($#codes+1));

if (($advanced) && $#codes > 0) {
 ##################
 # Check IP
 open(IP, $rand_ip);
 @lines = <IP>;
 close(IP);

 foreach $line (@lines) {
  ($ip, $id) = split(/\|\|/, $line);

  if ($ip eq $ENV{'REMOTE_ADDR'}) {
   $lastid = $id;
   do {
    $index = int(rand($#codes+1));
    }
   while ($index == $lastid);
   }
  }

 open(IP, ">$rand_ip");
 print IP "$ENV{'REMOTE_ADDR'}||$index\n";
 $count = 1;
 foreach $line (@lines) {
  ($ip, $id) = split(/\|\|/, $line);
  if ($ip ne $ENV{'REMOTE_ADDR'} && $count<$number_ip) {
   print IP $line;
   $count++;
   }
  }
 close(IP);

 ##################
 # Count hits
 open(READ, $rand_data);
 @lines = <READ>;
 close(READ);

 $flag = 0;
 open(WRITE, ">$rand_data");
 foreach $line (@lines) {
  if ($line =~ /^html$index\|/g) {
   chomp($line);
   ($filename, $hits) = split(/\|/, $line);
   $hits++;
   print WRITE "html$index|$hits\n";
   $flag = 1;
   }
  else {
   print WRITE $line;
   }
  }
 if ($flag == 0) {
  print WRITE "html$index|1\n";
  }
 close(WRITE);
 }

print "Content-type: text/html\n\n";
print $codes[$index];
=== CODE:END ===

-Chris
--
Christian Gersch, chris@team.isneurope.com
:: www.neukunden.myisn.de - Geld für Ihre Startseite ::




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

Date: 12 Feb 2001 23:56:19 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Replacing single-letter words doesn't work
Message-Id: <slrn98gu13.tas.abigail@tsathoggua.rlyeh.net>

Holger Marzen (holger.marzen@sik-gmbh.de) wrote on MMDCCXXII September
MCMXCIII in <URL:news:slrn98gls7.ca6.holger.marzen@sally.sik-gmbh.de>:
__ On Mon, 12 Feb 2001 20:42:10 GMT, Uri Guttman wrote:
__ 
__ >perl -pe 's/\b\w\b/ /g'
__ 
__ Thanks. This does the job. Where can I find some information about
__ \b, \w and so on?


In the manual about Perl regular expressions of course. The manual 
comes with any non-b0rken installation of Perl. "man perlre", or
whatever it is in your OS.


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Tue, 13 Feb 2001 00:22:18 GMT
From: "Tim Gaverth" <gaverth@home.com>
Subject: Re: Sending email from Perl Script on NT
Message-Id: <_6%h6.89610$B6.21602708@news1.rdc1.md.home.com>


Jason Baumbach <baumbach@bellatlantic.net> wrote in message
news:3A856CF0.3ACF4A14@bellatlantic.net...
> I agree that LWP may be a dead end.  Unfortunately, this still leaves me
> without email capabilities from within my Perl programs.
>
> I only need to send (not receive) simple email messages.  I tried both
> examples given in this mail thread but neither worked.  They both just
> completed successfully and did not complain nor did I ever see any email
> arrive from them

Did you by chance just cut and paste the Net::SMTP example posted my
Franziskus?
That really should do it for you, as it pretty much just opens a tcp
connection to
the smtp port (25 unless modified) on a valid mailserver and sends your data
in smtp format.
So, you have to substitute his "mailhost" with the name of your mail server,
and postmaster
with a valid recipient email address.

Since you have a win2k server, you can enable the smtp server in IIS5 and
use that as your
mail server. Since email is such a dangerous service, you'll want to
configure that to only accept/relay
for localhost, as you don't need to recieve mail.

> Any and all reply will be appreciated.
>
> Maggert wrote:
>
> > On Fri, 09 Feb 2001 15:40:04 GMT, jgunnip@my-deja.com wrote:
> >
> > >Hi,
> > >
> > >Does anyone know why the following code to send email works perfectly
> > >on Linux but not on Windows NT?  It doesn't complain (i.e. die()) when
> > >I use it on NT.  I just never receive the email.
> > >
> >
> >         I would hazard a guess that since Windoze systems have no
> > native emailing facilities that posting it without mentioning an smtp
> > server would just send it off to no mans land. Of course I could be
> > wrong. I've never seen anyone use LWP to send an email.
>
>




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

Date: Tue, 13 Feb 2001 01:55:06 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Timezones
Message-Id: <_t0i6.89455$Wq1.37638726@nnrp5-w.sbc.net>

Rob Donovan <rob@robdon.com> wrote:
> Hi,
> I know about localtime & gmtime routines, but does anyone know how to
> convert from GMT to anyother timezone without having to know the hours
> difference.  IE just give the routines the country code or something...

If your computer has a timezone database (most UNIX do, I don't know
about Win32), then set $ENV{'TZ'} and call localtime...

> cat /tmp/perl
#!/usr/bin/perl -w
$t = time;
print $ENV{'TZ'}, "\n";
print scalar localtime $t, "\n";
$ENV{'TZ'} = "US/Eastern";
print $ENV{'TZ'}, "\n";
print scalar localtime $t, "\n";
> perl /tmp/perl
US/Pacific
Mon Feb 12 17:48:15 2001
US/Eastern
Mon Feb 12 20:48:15 2001
>

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
      < Please move on, ...nothing to see here,  please disperse >


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

Date: Tue, 13 Feb 2001 00:50:42 +0100
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Two dimensional arrays
Message-Id: <49sg8t44vpc25fu53tdqebi8ca6gjiqfsa@4ax.com>

On Fri, 09 Feb 2001 18:08:55 GMT, tunneling@my-deja.com wrote:

> Maybe I should be more explicit. I am reading in a file that has text
> in this format:

 ... [copied to the __DATA__ section]

> There is a 7x10 matrix that exist, with null characters in many of the
> cells.

I can only see space chars.

>        In my case the matrix can change sizes between files. I need to
> read this file and print to a new file:
> 
> IS THIS BETTER FOR YOU TO UNDERSTAND

(Please don't shout, it seems rude. And no, it isn't clear :(

I'm not sure what your input format nor your output format looks like,
but this reads your supposed input format (10 rows of 7 char strings)
into a array of arrayrefs (2D array) (and does a bit of printing).

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

chomp( my @lines = <DATA> );

my @data = map [ split //, $_ ] => @lines;

# print the 'A' from line 8, col 7
print "[8][7]: $data[7][6]\n";

# print all lines with spaces in between the chars on each line
print join(' ', @$_) . "\n" for @data;

__DATA__
ITBFYTU
SHEOOON
 ITRU D
 ST   E
  E   R
  R   S
      T
      A
      N
      D

-- 
Good luck,
Abe
perl -e '$_=sub{split//,pop;print pop while@_};&$_("rekcah lreP rehtona
 tsuJ")'


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

Date: Tue, 13 Feb 2001 00:18:21 GMT
From: maheshasolkar@yahoo.com (Mahesh A)
Subject: Re: Two dimensional arrays
Message-Id: <3a887cba.25906391@news>

This is one way I could extract 

'IS THIS BETTER FOR YOU TO UNDERSTAND'

from 

ITBFYTU
SHEOOON
 ITRU D
 ST   E
  E   R
  R   S
      T
      A
      N
      D
-----------------------------------------

#!/usr/local/bin/perl -w
use strict;
my @lines=<DATA>;
map {
    my $i=$_;
    map {
        chomp;
        print "".${[split //]}[$i]."" if (${[split //]}[$i] ne " ");
} @lines;
print " ";
} (0..$#lines-3); ## Dont ask why this '3' ! But tell me if you find
out, I hadn't enough time (knowledge??)
print "\n";

__DATA__
ITBFYTU
SHEOOON
 ITRU D
 ST   E
  E   R
  R   S
      T
      A
      N
      D

% script.pl
IS THIS BETTER FOR YOU TO UNDERSTAND 
%


On Fri, 09 Feb 2001 14:50:36 GMT, tunneling@my-deja.com wrote:

>Do 2D arrays exist?
>Here is what I want to do.
>
>Starting with:
>abcdefg
>hijklmn
>opqrstu
>
>I would like to be able to store each character as if it were in a
nXn
>matrix, for this case [1,2] = b; [0,0] = a; etc.
>
>Any suggestions?
>
>
>Sent via Deja.com
>http://www.deja.com/



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

Date: Tue, 13 Feb 2001 00:46:52 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Two dimensional arrays
Message-Id: <slrn98h0vo.717.tjla@thislove.dyndns.org>

I was shocked! How could Mahesh A <maheshasolkar@yahoo.com>
say such a terrible thing:

>} (0..$#lines-3); ## Dont ask why this '3' ! But tell me if you find
>out, I hadn't enough time (knowledge??)

That's because it is a bug. It only works this way because of a
coincidence. Try increasing the number of words and see what happens.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
BOFH excuse #48:

bad ether in the cables


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 278
**************************************


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