[23245] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5466 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 8 21:08:37 2003

Date: Mon, 8 Sep 2003 18:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 8 Sep 2003     Volume: 10 Number: 5466

Today's topics:
        Creating special DATE format <ducott@hotmail.com>
    Re: Creating special DATE format <tony_curtis32@yahoo.com>
    Re: Creating special DATE format <noreply@gunnar.cc>
    Re: Creating special DATE format <ducott@hotmail.com>
    Re: Creating special DATE format <ducott@hotmail.com>
    Re: Creating special DATE format <tony_curtis32@yahoo.com>
    Re: Creating special DATE format <noreply@gunnar.cc>
    Re: Creating special DATE format <ducott@hotmail.com>
        Flocking Advise <ducott@hotmail.com>
    Re: Help configuring Perl with Apache 2 <postmaster@castleamber.com>
    Re: Problem with simple contact script. (Tad McClellan)
    Re: Problem with simple contact script. <noreply@gunnar.cc>
    Re: Problem with simple contact script. <postmaster@castleamber.com>
    Re: Problem with simple contact script. <noreply@gunnar.cc>
    Re: Problem with simple contact script. <flavell@mail.cern.ch>
        single text file into multiple arrays (Faz)
    Re: single text file into multiple arrays <uri@stemsystems.com>
    Re: single text file into multiple arrays <noreply@gunnar.cc>
    Re: single text file into multiple arrays <jkeen@concentric.net>
    Re: single text file into multiple arrays <uri@stemsystems.com>
    Re: single text file into multiple arrays <noreply@gunnar.cc>
    Re: single text file into multiple arrays <uri@stemsystems.com>
    Re: Telnet proxy <da_bisti@yahoo.com>
        Using URI::Find to detect Web URL's <ducott@hotmail.com>
    Re: Using URI::Find to detect Web URL's <postmaster@castleamber.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 08 Sep 2003 23:14:51 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Creating special DATE format
Message-Id: <L387b.116217$la.2582463@news1.calgary.shaw.ca>

Hello peoples,

I could use some help writing a script that will create and print the date
in a special format. Here is what I am looking to accomplish:

When my main script is executed:

assign the date to a variable in this format = month/day/year all in two
digit format like so: 09/08/03

something like:

A) if $monthday is less than 10 ... add a "0" before it ... thus creating
01, 02 ,03 etc for the first 9 days of a month, otherwise all other
monthdays can remains in 2 digit format
B) if $month = "January" then $month = "01" and so on for other months
C) if $year = 2003 then remove first two digits, thus creating 03 and so on
for other years
D) Then assemble the date like this: $today = $monthday/$month/$year
E) print $today

I've been search all the doc's I can today but havent been able to find
examples on how to do this. If you can help me, I would be forever greatful.
TIA

Randy




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

Date: Mon, 08 Sep 2003 18:16:59 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Creating special DATE format
Message-Id: <87ad9erhuc.fsf@limey.hpcc.uh.edu>

>> On Mon, 08 Sep 2003 23:14:51 GMT,
>> "\"Dandy\" Randy" <ducott@hotmail.com> said:

> Hello peoples, I could use some help writing a script
> that will create and print the date in a special
> format. Here is what I am looking to accomplish:

> When my main script is executed:

> assign the date to a variable in this format =
> month/day/year all in two digit format like so: 09/08/03

perldoc POSIX  ---> strftime

    strftime('%m/%d/%y', ...)

amongst other solutions.  If you have the choice, I would
suggest %Y though so that you get the full year format,
and the order %Y-%m-%d (much easier to sort).

hth
t


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

Date: Tue, 09 Sep 2003 01:25:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Creating special DATE format
Message-Id: <bjj385$jim71$1@ID-184292.news.uni-berlin.de>

"Dandy" Randy wrote:
> When my main script is executed:
> 
> assign the date to a variable in this format = month/day/year all
> in two digit format like so: 09/08/03

     use Date::Format;
     my $date = time2str('%D', time);

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



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

Date: Mon, 08 Sep 2003 23:52:36 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Re: Creating special DATE format
Message-Id: <8D87b.926667$3C2.21131102@news3.calgary.shaw.ca>

"Gunnar Hjalmarsson" wrote

>      use Date::Format;
>      my $date = time2str('%D', time);

Gunnar, is the syntax for your code above correct? It does not function as
written.

Randy




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

Date: Tue, 09 Sep 2003 00:07:55 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Re: Creating special DATE format
Message-Id: <vR87b.116361$la.2587353@news1.calgary.shaw.ca>

"Tony Curtis" wrote
> perldoc POSIX  ---> strftime
>
>     strftime('%m/%d/%y', ...)
>
> amongst other solutions.  If you have the choice, I would
> suggest %Y though so that you get the full year format,
> and the order %Y-%m-%d (much easier to sort).

Tony, I have done a little reading on this POSIX thingy. The code as you
wrote it above did not seem to function. ... on perdoc, it shows this
example:

$str = POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2 );
print "$str\n";

But what this code does is write the date for Dec 12, 1995 ... i'm looks for
the present date when the code is run in two digit format ... can you help?
TIA
R




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

Date: Mon, 08 Sep 2003 19:14:09 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Creating special DATE format
Message-Id: <8765k2rf72.fsf@limey.hpcc.uh.edu>

>> On Tue, 09 Sep 2003 00:07:55 GMT,
>> "\"Dandy\" Randy" <ducott@hotmail.com> said:

> "Tony Curtis" wrote
>> perldoc POSIX ---> strftime
>> 
>> strftime('%m/%d/%y', ...)
>> 
>> amongst other solutions.  If you have the choice, I
>> would suggest %Y though so that you get the full year
>> format, and the order %Y-%m-%d (much easier to sort).

> Tony, I have done a little reading on this POSIX
> thingy. The code as you wrote it above did not seem to
> function. ... on perdoc, it shows this example:

It was simply an outline, indicated by the ellipsis...

> $str = POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 12,
> 11, 95, 2 ); print "$str\n";

> But what this code does is write the date for Dec 12,
> 1995 ... i'm looks for the present date when the code is
> run in two digit format ... can you help?

Arguments 2... are a list in the order returned by
localtime.  So you just want that with localtime's default
argument ("now").

    use POSIX qw(strftime);
    my $date = strftime('%Y-%d-%m', localtime);

hth
t


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

Date: Tue, 09 Sep 2003 02:16:55 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Creating special DATE format
Message-Id: <bjj69b$jqfe3$1@ID-184292.news.uni-berlin.de>

"Dandy" Randy wrote:
> "Gunnar Hjalmarsson" wrote
> 
>>     use Date::Format;
>>     my $date = time2str('%D', time);
> 
> Gunnar, is the syntax for your code above correct?

Yes, at least it works fine for me. Of course, it presupposes that the 
module Date::Format is installed. It's available on my IndigoPerl 
installation, which made me believe that it is part of the standard 
distribution, but now I realize that it isn't...

Using a module for things like these is convenient. Tony gave you 
another suggestion. But of course, it can be done with plain Perl:

     my @t = (localtime)[3..5];
     my $date = sprintf "%02d/%02d/%02d", ++$t[1], $t[0], $t[2] % 100;

> It does not function as written.

What happens?

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



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

Date: Tue, 09 Sep 2003 00:20:56 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Re: Creating special DATE format
Message-Id: <I197b.926761$3C2.21133367@news3.calgary.shaw.ca>

"Tony Curtis" wrote

>     use POSIX qw(strftime);
>     my $date = strftime('%Y-%d-%m', localtime);

Thanx, worked great.

R




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

Date: Tue, 09 Sep 2003 01:03:25 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Flocking Advise
Message-Id: <xF97b.926841$3C2.21137906@news3.calgary.shaw.ca>

Hey ... could use some advise on the best file locking method ... at present
I use the following:

#!/usr/bin/perl

use strict;
use 5.004;
use Fcntl qw(:DEFAULT :flock);

open (FH, "<data.txt") or die "Can't open file: $!";
flock (FH, LOCK_EX) or die "Can't lock file: $!";
$data=<FH>;
chomp ($data);
($total,$opened,$followed)=split(/\|/,$data);
close(FH);

$opened = $opened + 1;

sysopen(FH, "data.txt", O_WRONLY | O_CREAT) or die "can't open filename:
$!";
flock (FH, LOCK_EX) or die "can't lock filename: $!";
truncate (FH, 0) or die "can't truncate filename: $!";
print FH "$total|$opened|$followed\n";
close FH;

print "Content-type: text/html \n\n";
print "Done\n";
exit;

It seems to work ok, but am not sure if it is a good approach or not. One of
my main questions is ... what about sememorph locks ... been reading in
different places that you start you file open code by opening a dummy
sememorph file ... kinda like this:

open S, "> somefile.sem" or die ...;
flock S, LOCK_EX or die ...;
open F, "> somefile" or die ...;
# Now write F
close F;
close S;

What I see going on here is the code opens a file that does not contain
critical data, thus protecting the real data, and the user cannot open the
real file until the sem lock becomes free ... Two questions ... is this a
good approach, and secondly ... whats inside the sem file? is it an empty
dummy file? does it have to have a .sem extension? Thank you for you
opinions.

Randy




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

Date: Tue, 09 Sep 2003 00:06:15 +0200
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Help configuring Perl with Apache 2
Message-Id: <1063058880.857328@halkan.kabelfoon.nl>

Tad McClellan wrote:

> John Bokma <postmaster@castleamber.com> wrote:
> 
>>Tad McClellan wrote:
>>
>>>Cyde Weys <cyde@umd.edu> wrote:
>>
>>>>I just asked what was the 
>>>>point of saying *plonk* 
>>>
>>>So that the lurkers will know what price they may pay should
>>>they ever feel the urge to post their server setup questions here.
>>
>>A *plonk* is as off topic as the original post and hence adds to the noise.
> 
> For one thread's worth, while perhaps preventing many more such threads.

Ha, I haven't seen this happen in 12 years Usenet experience and I don't 
expect it to happen ever. Every reply causes a new reply especially in 
off topic posts. I think that off topic posts have an avarage longer 
thread compared to on topic posts...

>>Just ignore off topic posts and don't reply in any way.
> 
> No thank you.
> 
> If you litter in the park, I will ask you to not do that anymore.

Indeed. And you don't throw more litter against my head :-D.

-- 
Kind regards,       feel free to mail: mail(at)johnbokma.com (or reply)
                     virtual home: http://johnbokma.com/  ICQ: 218175426
John                web site hints: http://johnbokma.com/websitedesign/



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

Date: Mon, 8 Sep 2003 17:12:51 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem with simple contact script.
Message-Id: <slrnblpvn3.jjh.tadmc@magna.augustmail.com>

Tom <tom@ztml.com> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnblp0p4.ic0.tadmc@magna.augustmail.com>...
>> Tom <tom@ztml.com> wrote:
>> > .
>> > .
>> > 
>> > Try this...
>> > 
>> > open(SM,">/usr/sbin/sendmail") or die $!;
>> 
>> 
>> Do not try that.
>> 
>> It does not invoke any programs, it attempts to open/create a file.
>> 
>> It has nothing to do with your problem.
>> 
>> This answer is from the Twilight Zone...
> 
> Sorry, I jump the gun. Perhaps you might want to try this...


> use Mail::sendMail;
            ^
            ^

> if($towhom  eq "loanofficer")
> {
> 	$towhom = "loanofficer\@mortgage-pros.com";
> }
> elsif ($towhom eq "marketing")
> {
> 	$towhom="marketing\@mortgage-pros.com";
> }
> elsif ($towhom eq "broker") 
> {
>  	$towhom="broker\@mortgage-pros.com";
> }


> I hope this will meet your approval 


Nope.

1) It will not compile (a prerequisite of approval).

2) It will function as a mail relay to any address in the whole wide world!


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


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

Date: Tue, 09 Sep 2003 00:44:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Problem with simple contact script.
Message-Id: <bjj0qq$j5lge$1@ID-184292.news.uni-berlin.de>

Tad McClellan wrote:
> Tom <tom@ztml.com> wrote:
>> I hope this will meet your approval
> 
> Nope.

<snip>

> 2) It will function as a mail relay to any address in the whole
> wide world!

With hardcoded addresses? How?

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



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

Date: Tue, 09 Sep 2003 01:30:23 +0200
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Problem with simple contact script.
Message-Id: <1063063928.44362@halkan.kabelfoon.nl>

Gunnar Hjalmarsson wrote:

> Tad McClellan wrote:
> 
>> Tom <tom@ztml.com> wrote:
>>
>>> I hope this will meet your approval
>>
>>
>> Nope.
> 
> 
> <snip>
> 
>> 2) It will function as a mail relay to any address in the whole
>> wide world!
> 
> 
> With hardcoded addresses? How?

there is no final "else"


-- 
Kind regards,       feel free to mail: mail(at)johnbokma.com (or reply)
                     virtual home: http://johnbokma.com/  ICQ: 218175426
John                web site hints: http://johnbokma.com/websitedesign/



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

Date: Tue, 09 Sep 2003 01:50:09 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Problem with simple contact script.
Message-Id: <bjj4mu$jknc5$1@ID-184292.news.uni-berlin.de>

John Bokma wrote:
> Gunnar Hjalmarsson wrote:
>> Tad McClellan wrote:
>>> 2) It will function as a mail relay to any address in the whole
>>> wide world!
>> 
>> With hardcoded addresses? How?
> 
> there is no final "else"

Aha. Thanks!

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



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

Date: Tue, 9 Sep 2003 01:14:32 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Problem with simple contact script.
Message-Id: <Pine.LNX.4.53.0309090059110.20572@lxplus095.cern.ch>

On Tue, Sep 9, Gunnar Hjalmarsson inscribed on the eternal scroll:

> Tad McClellan wrote:
> > Tom <tom@ztml.com> wrote:
> >> I hope this will meet your approval
> >
> > Nope.

Disastrous.  Fortunately it was prefaced with the sure-fire bogosity
alert, "try this".  But I'm surprised you were taken-in by it.

> > 2) It will function as a mail relay to any address in the whole
> > wide world!
>
> With hardcoded addresses? How?

Look at it again.  Properly.  They're out to get you, so there's no
harm in applying a degree of paranoia.

At least, it has served as a clear demonstration of the inadvisability
of rolling one's own.   All the mistakes have been made before, and
corrected, by better programmers than me.

The lack of warnings and taint checks might have helped as a
supplementary clue; some might have rated the use of a hand-rolled
content-type (without the very necessary charset! - see CA-2000-02)
despite invoking CGI.pm which knows how to do things properly;  but -
most of all - the lack of any explanation WHY a particular thing was
being done in a particular way, and what particular dangers are
necessary to avoid.  Just "try this", a lump of unadorned code, "like
it or lump it" as we say in our neck of the woods. Thus we would learn
nothing, and rate to do no more than propagate cargo-cult code, if we
follow such an example.

all the best

-- 
  I am coming to the conclusion that, as the sum of human knowledge
  increases, more and more people feel overwhelmed by the sheer mass of
  it, and cope with the problem by metaphorically pulling the bedcovers
  over their heads and refusing to know anything at all. - Sue on uk.railway


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

Date: 8 Sep 2003 15:32:17 -0700
From: lfazal@hotmail.com (Faz)
Subject: single text file into multiple arrays
Message-Id: <13ddbd75.0309081432.43bc9485@posting.google.com>

hello all

I have a text file as below

a
b
c
d
e
a1
b1
c1
d1
e1
a2
b2
c2
d2
e2

I want to read the text file and put them into multiple arrays
grouping them. at the end I want to have

arrayA should contain a a1 a2
arrayB should contain b b1 b2
arrayC should contain c c1 c2

Thanks
Faz


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

Date: Mon, 08 Sep 2003 22:43:53 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: single text file into multiple arrays
Message-Id: <x78yoyj3yy.fsf@mail.sysarch.com>

>>>>> "F" == Faz  <lfazal@hotmail.com> writes:

  F> a
  F> b
  F> c
  F> d
  F> e
  F> a1
  F> b1
  F> c1
  F> d1
  F> e1
  F> a2
  F> b2
  F> c2
  F> d2
  F> e2

untested

local $/ ;

push @{$buckets{uc $2}, $1 while <> =~ /(([a-z]+)\d*)/g ;

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Tue, 09 Sep 2003 01:13:30 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: single text file into multiple arrays
Message-Id: <bjj2hv$k29vn$1@ID-184292.news.uni-berlin.de>

Uri Guttman wrote:
>>>>>>"F" == Faz  <lfazal@hotmail.com> writes:
> 
> 
>   F> a
>   F> b
>   F> c
>   F> d
>   F> e
>   F> a1
>   F> b1
>   F> c1
>   F> d1
>   F> e1
>   F> a2
>   F> b2
>   F> c2
>   F> d2
>   F> e2
> 
> untested
> 
> local $/ ;
--^^^^^^^^^^
Shouldn't be there.

> push @{$buckets{uc $2}, $1 while <> =~ /(([a-z]+)\d*)/g ;
------------------------^
Missing right curly bracket.

After those corrections, the above line creates the hash %buckets 
containing anonymous arrays. It can be printed like this:

     for (sort keys %buckets) {
         print "\@{\$buckets{$_}}: @{$buckets{$_}}\n";
     }

which results in the following output:

     @{$buckets{A}}: a a1 a2
     @{$buckets{B}}: b b1 b2
     @{$buckets{C}}: c c1 c2
     @{$buckets{D}}: d d1 d2
     @{$buckets{E}}: e e1 e2

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



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

Date: 08 Sep 2003 23:17:55 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: single text file into multiple arrays
Message-Id: <bjj2n3$r74@dispatch.concentric.net>


"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x78yoyj3yy.fsf@mail.sysarch.com...
> >>>>> "F" == Faz  <lfazal@hotmail.com> writes:
>
>
> untested
>
> local $/ ;
>
> push @{$buckets{uc $2}, $1 while <> =~ /(([a-z]+)\d*)/g ;
>
Uri:

I only get the OP's intended result if I comment out 'local $/;'  That
slurps everything in and the while loop shuts off after the first match.

jimk




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

Date: Mon, 08 Sep 2003 23:29:17 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: single text file into multiple arrays
Message-Id: <x7y8wyhnaq.fsf@mail.sysarch.com>

>>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:

  >> untested
  >> local $/ ;
  GH> --^^^^^^^^^^
  GH> Shouldn't be there.

and why not? i wanted a full file slurp, not a line by line one. it
would be faster this way than yours.

  >> push @{$buckets{uc $2}, $1 while <> =~ /(([a-z]+)\d*)/g ;
  GH> ------------------------^
  GH> Missing right curly bracket.

untested as promised!

  GH> After those corrections, the above line creates the hash %buckets
  GH> containing anonymous arrays. It can be printed like this:

  GH>      for (sort keys %buckets) {
  GH>          print "\@{\$buckets{$_}}: @{$buckets{$_}}\n";
  GH>      }

use Data::Dumper ;
print Dumper \%buckets ;

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Tue, 09 Sep 2003 01:43:00 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: single text file into multiple arrays
Message-Id: <bjj49f$jdj3t$1@ID-184292.news.uni-berlin.de>

Uri Guttman wrote:
>>>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> 
>   >> local $/ ;
>   GH> --^^^^^^^^^^
>   GH> Shouldn't be there.
> 
> and why not? i wanted a full file slurp, not a line by line one. it
> would be faster this way than yours.

Well, since all it results in is:

     %buckets = ( A => ['a'] );

it's probably faster. ;-)  Maybe it's possible to modify it in some
other way to fulfil your intention, but in that case I think you'd
better show us.

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



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

Date: Tue, 09 Sep 2003 00:02:07 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: single text file into multiple arrays
Message-Id: <x7smn6hls0.fsf@mail.sysarch.com>

>>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:

  >> >> local $/ ;
  GH> --^^^^^^^^^^
  GH> Shouldn't be there.
  >> and why not? i wanted a full file slurp, not a line by line one. it
  >> would be faster this way than yours.

  GH> Well, since all it results in is:

  GH>      %buckets = ( A => ['a'] );

  GH> it's probably faster. ;-)  Maybe it's possible to modify it in some
  GH> other way to fulfil your intention, but in that case I think you'd
  GH> better show us.

this works with or without the scalar:
local $/ ;
map { push @{$buckets{uc $2}}, $1 while /(([a-z]+)\d*)/g } scalar <> ;

note the horrid use of map in a oid context. i needed something to set
$_ without a full foreach block or whatever. this is an odd case for
wanting multiple statement modifiers but i know p6 won't get them. it
would look too contrived to write that like:
push @{$buckets{uc $2}}, $1 while /(([a-z]+)\d*)/g } for scalar <> ;

here is a shorter one. golf anyone> the names could be shortedn and the
regex is not well defined by the OP (i wrote a simple general alphas
followed by optional digits).

$_ = <> ; push @{$buckets{uc $2}}, $1 while /(([a-z]+)\d*)/g ;

the problem with my untested code was that it was executing <> each time
through the while and i just wanted the regex to execute.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Tue, 09 Sep 2003 00:21:55 GMT
From: Tom Feist <da_bisti@yahoo.com>
Subject: Re: Telnet proxy
Message-Id: <uhe3mn74v.fsf@yahoo.com>

Shuttermutt <shuttermutt@nospam.com> writes:

> Actually, I'm restricted to telnet since I don't have control over the
> server side of things. I don't need a firewall type proxy as much as a
> spy layer between the client of the user's choice and the server. You
> see, I want to analyze the data being sent back and forth, catch
> what's interesting, and use that as a part of a scripting framework
> for a telnet-based game.
>
> For example, if the server sent "Player Mutt moved from [A] to [B]" to
> the client, I'd like to catch that and then let scripts act on that
> information as they see fit. That way, if someone wanted to write a
> prog that fired when a player moved and acted accordingly, my
> framework would provide the necessary event and data to let them do
> that.

You could try using POE, specifically something like:
http://poe.perl.org/?POE_Cookbook/TCP_Forwarding and with the added
bonus of the event driven POE kernel available for doing the actual
logic.  It really is a very handy framework for lots of common things.
(Uncommon ones too, I wouldn't doubt)

-- 
Shabble.
(Whose alarm clock is now running a small perl script)


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

Date: Mon, 08 Sep 2003 23:30:54 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Using URI::Find to detect Web URL's
Message-Id: <Oi87b.918947$ro6.18427188@news2.calgary.shaw.ca>

A while back I added a post about URL detection. To date I have not been
able to figure it out. There seems to be very little docu. on this. This is
what I'm trying to do. I have an html web page with a single textarea form
named "content" The form action points to my detect.pl script.

#!/usr/bin/perl
use URI::Find;

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$form{$name} = $value;
}

$htmlcontent = $form{'content};
$htmlcontent=~ s/\n/<br>/g; #replaces breaklines with html <br>'s

<Missing URL detection code goes here>

open (FILE, ">data/content.txt") or &error("Unable to open");
flock FILE, 2;
print FILE $htmlcontent;   #final scanned/replaced variable
close(FILE);

So basically what I'm looking to do is assign the form data to a variable,
then scan it for web AND email addressed, and repleace them with the needed
HTML tags ... <a href ... <mailto ... etc. ect. Then the changed data gets
saved to a text file, where I use SSI to include the data into my page.
Points to note would be the form data will almost always contain multipul
lines and perhaps multipul occurances of web addressed. Can someone please
help me fill in the missing code? TIA!!!!!

Randy




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

Date: Tue, 09 Sep 2003 01:39:09 +0200
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Using URI::Find to detect Web URL's
Message-Id: <1063064454.831685@halkan.kabelfoon.nl>

"Dandy" Randy wrote:

> A while back I added a post about URL detection. To date I have not been
> able to figure it out. There seems to be very little docu. on this. This is
> what I'm trying to do. I have an html web page with a single textarea form
> named "content" The form action points to my detect.pl script.
> 
> #!/usr/bin/perl
> use URI::Find;
> 
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $form{$name} = $value;
> }
> 
> $htmlcontent = $form{'content};

Amazing, this could be done with 2 lines using CGI.pm. Don't write your 
own decoding stuff.

> $htmlcontent=~ s/\n/<br>/g; #replaces breaklines with html <br>'s
> 
> <Missing URL detection code goes here>
> 
> open (FILE, ">data/content.txt") or &error("Unable to open");

No need for that & IIRC

> flock FILE, 2;

use Fnctl; to make is more readable (named constants instead of 2)
Also, I guess you should rewind since someone could have added between 
the open and flock IIRC.

Finally, flock can fail...

> print FILE $htmlcontent;   #final scanned/replaced variable
> close(FILE);

You should test if close succeeds. Even print for that matter.

> So basically what I'm looking to do is assign the form data to a variable,

I recommend CGI.pm for this

> then scan it for web AND email addressed, and repleace them with the needed
> HTML tags ... <a href ... <mailto ... etc. ect. Then the changed data gets
> saved to a text file, where I use SSI to include the data into my page.

Sounds dangerous to me.

-- 
Kind regards,       feel free to mail: mail(at)johnbokma.com (or reply)
                     virtual home: http://johnbokma.com/  ICQ: 218175426
John                web site hints: http://johnbokma.com/websitedesign/



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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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.  

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


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