[21872] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4076 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 7 00:06:38 2002

Date: Wed, 6 Nov 2002 21:05:16 -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           Wed, 6 Nov 2002     Volume: 10 Number: 4076

Today's topics:
    Re: A Unix guy moving to Windows 2000 <pkent77tea@yahoo.com.tea>
    Re: A Unix guy moving to Windows 2000 <jurgenex@hotmail.com>
    Re: A Unix guy moving to Windows 2000 <lance@augustmail.com>
    Re: A vision for Parrot (Cameron Laird)
    Re: A vision for Parrot <dnew@san.rr.com>
    Re: A vision for Parrot <graham.lee@wadham.ox.ac.uk>
    Re: CGI Upload Problems <stedman@siam.org>
    Re: file order in opendir DH <goldbb2@earthlink.net>
        forwardlooking regex ? <lance@augustmail.com>
    Re: forwardlooking regex ? <bwalton@rochester.rr.com>
    Re: forwardlooking regex ? (Charles DeRykus)
    Re: forwardlooking regex ? <krahnj@acm.org>
        hash problem <lance@augustmail.com>
    Re: hash problem <mgjv@tradingpost.com.au>
    Re: How much faster is dbm over MySQL <goldbb2@earthlink.net>
    Re: How much faster is dbm over MySQL (Malcolm Dew-Jones)
    Re: How to guarantee process ID stays with web connecti <nospam@nospam.com>
    Re: How to guarantee process ID stays with web connecti <spam@thecouch.homeip.net>
    Re: How to guarantee process ID stays with web connecti <jurgenex@hotmail.com>
    Re: How to guarantee process ID stays with web connecti <mgjv@tradingpost.com.au>
    Re: Is it wrong to store method definitions in a databa (Bryan Castillo)
    Re: param($var). <goldbb2@earthlink.net>
    Re: Perl module to read mails from Microsoft Outlook <turajb@hoflink.com>
    Re: regex or substr or both? <lance@augustmail.com>
    Re: Returning matches in an array <renerobinson at comcast dot net>
    Re: Returning matches in an array (Jay Tilton)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 07 Nov 2002 02:08:47 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: A Unix guy moving to Windows 2000
Message-Id: <pkent77tea-9FA183.02084707112002@news-text.blueyonder.co.uk>

In article <aqbrc6$krm$1@cronkite.temple.edu>, stan@temple.edu wrote:
<snip>
> system("date > date.output");
> system("ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
> system("pwd");
> system("df -k");

this is the stuff that causes problems when going from one platform to 
another (unix to windows) or even from one flavour of Unix to a slightly 
different flavour of Unix.

_Any_ time you invoke system() (or its chums) you're at the mercy of the 
local system. I've seen unix systems where the was _no_ ls(1) command[1] 
for example.

So, if you want to write portable code, don't invoke system. Or maybe 
you could have a conditional block for each target operatin gsystem if 
that's what you need.

In any case, this is what you can do in pure portable perl:

use localtime(), printf() and open() to create a file that contains your 
formatted date string

use opendir(), readdir(), closedir(), grep{}, open() to do that listing 
thing - you can use stat() to get more file info.

use Cwd; print cwd(); to get the current working directory

Df is going to be very platform specific - maybe here you are best off 
invoking an OS specific tool. On unix use df, on Win maybe use some 
Win32::* module, or some command-line tool.

P

[1] You may achieve a similar, if not exactly identical effect, by 
unmounting /usr on a machine where everythign is dynamically linked, 
even the core POSIX tools. Do not do that.

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Thu, 07 Nov 2002 03:55:13 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: A Unix guy moving to Windows 2000
Message-Id: <Buly9.9251$Wf5.5736@nwrddc04.gnilink.net>

stan@temple.edu wrote:
[...]
> #!/usr/bin/perl -w
> print "Hello world!\n";
> system("date > date.output");
You may want to check "perldoc -f time" or any of the numerous Date modules
on CPAN

> system("ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
You may want to check "perldoc -f readdir" or "perldoc -f glob".

> system("pwd");
You may want to check "perldoc Cwd"

> system("df -k");
And I think I saw a module for that on CPAN, too.

jue




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

Date: Wed, 06 Nov 2002 22:15:21 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: Re: A Unix guy moving to Windows 2000
Message-Id: <pan.2002.11.07.04.15.21.50775.7537@augustmail.com>

Not a perl monk but here is something I found that I wrote
in Win2000 a while back.  Use ctime instead of system(date).



# Get current date and split it up into seperate parts to be used later 
$now = ctime();
($day,$month,$numday,$tim,$yr) = unpack("A4 A4 A3 A9 A4",$now);
if($month=~/Jan/){$numonth="01";}
if($month=~/Feb/){$numonth="02";}
if($month=~/Mar/){$numonth="03";}
if($month=~/Apr/){$numonth="04";}
if($month=~/May/){$numonth="05";}
if($month=~/Jun/){$numonth="06";}
if($month=~/Jul/){$numonth="07";}
if($month=~/Aug/){$numonth="08";}
if($month=~/Sep/){$numonth="09";}
if($month=~/Oct/){$numonth="10";}
if($month=~/Nov/){$numonth="11";}
if($month=~/Dec/){$numonth="12";}
if($numday=~/ 1/){$numday="01";}
if($numday=~/ 2/){$numday="02";}
if($numday=~/ 3/){$numday="03";}
if($numday=~/ 4/){$numday="04";}
if($numday=~/ 5/){$numday="05";}
if($numday=~/ 6/){$numday="06";}
if($numday=~/ 7/){$numday="07";}
if($numday=~/ 8/){$numday="08";}
if($numday=~/ 9/){$numday="09";}

# create date variables to be used later
$realdate="$yr$numonth$numday";
#print "$realdate \n";
#print "$numonth \n";
#print "$numday \n";
#print "$now \n";

Lance


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

Date: Wed, 06 Nov 2002 23:52:00 -0000
From: claird@lairds.com (Cameron Laird)
Subject: Re: A vision for Parrot
Message-Id: <usjap08oved667@corp.supernews.com>

In article <3DC943CF.84A68F32@san.rr.com>, Darren New  <dnew@san.rr.com> wrote:
			.
			.
			.
>As long as you don't want to do development in multiple languages or
>dynamically load code safely over the net into some other OS process,
>Tcl and Python are pretty good choices. Otherwise, you might want to
>consider C# or Java. 
			.
			.
			.
Actually, many of the early experiments in "agenting"--safe
evaluation of network-loaded code--were done with Tcl.  This
was before Java acquired the name it now has.  It's possible
to make an argument that the Tcl security model, which is
quite distinct from Java's, is safer.

But you were around for this, weren't you, Darren?
-- 

Cameron Laird <Cameron@Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://phaseit.net/claird/home.html


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

Date: Thu, 07 Nov 2002 02:33:28 GMT
From: Darren New <dnew@san.rr.com>
Subject: Re: A vision for Parrot
Message-Id: <3DC9D0F8.45142D73@san.rr.com>

Cameron Laird wrote:
> But you were around for this, weren't you, Darren?

Indeed. I was one of the first users, I suspect, compiling my own
safe-tcl interpreter. I have no idea what I was thinking when I included
Tcl in that list. Some double-negation turning into a single-negation
twixt brain and fingers, I think.


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

Date: Thu, 07 Nov 2002 03:00:45 +0000
From: Frodo Morris <graham.lee@wadham.ox.ac.uk>
Subject: Re: A vision for Parrot
Message-Id: <aqcku8$mlt$3@news.ox.ac.uk>

Laotseu wrote:
> Frodo Morris <graham.lee@wadham.ox.ac.uk> wrote in message news:<aq8g9u$6c7$1@news.ox.ac.uk>...
> 
>>Cameron Laird wrote:
> 
> 
> (snip some)
> 
> 
>>that's what I call the conducting 
>>machine: "Apple" because it sends Jobs away, does nothing for a while 
>>then gets Jobs back :-) 
> 
> 
> lol :-))))
> 
> (snip some more)
> 
> Laotseu
Glad you approve :-)

-- 
FM



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

Date: Wed, 6 Nov 2002 18:18:51 -0500
From: "Josh Stedman" <stedman@siam.org>
Subject: Re: CGI Upload Problems
Message-Id: <klhy9.20490$T_.505751@iad-read.news.verio.net>


"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.40.0211062217260.15931-100000@lxplus075.cern.ch...
> > Don't need an action tag...
>
> For the meaning of the word "tag", see
> http://www.flightlab.com/~joe/sgml/faq-not.txt part 5.  [1]
>
> What we have here is the action _attribute_, of the form tag.

True, very true -- I was just writing a quick response and that's what the preivous poster used.  I
din't feel like correcting him.

> > the default is to call itself.
>
> That used to be the case in earlier HTML specifications, and probably
> it's what browsers will do anyway, but for some strange reason the
> omission of the action attribute is no longer permitted according to
> the spec, and will raise a syntax validation error.

> But technically, one _is_ required to supply an action attribute,
> even if it's the same script.  See e.g
> http://www.w3.org/TR/html401/interact/forms.html#h-17.3
>
>   action      %URI;          #REQUIRED -- server-side form handler --

Ehh... yeah, but it's working fine and adding it in seems redundant to me.  Besides, it takes away
all the mystique of the script ;)
I'll probably put it in with my first update.




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

Date: Wed, 06 Nov 2002 19:01:35 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: file order in opendir DH
Message-Id: <3DC9AD5F.F0270442@earthlink.net>

Darren Dunham wrote:
[snip]
> > opendir DH, $dir or die "Cannot open $dir: $!";
> > foreach $file (readdir DH) {
> 
> Change that to
> 
> my @sorted_files = sort (readdir DH);
> foreach $file (@sorted_files) {

There is no need to store data in a temporary array to sort it.

   foreach my $file (sort readdir DH) {

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Wed, 06 Nov 2002 19:51:47 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: forwardlooking regex ?
Message-Id: <pan.2002.11.07.01.51.47.648369.6618@augustmail.com>

I am writing a regex such that I can pick out the third set of numbers:

27.1 30.5 29.3

with /(\d\d\.\d)\D+(\d\d\.\d)\D+(\d\d\.\d)\D+/;
print $3;

How can I make this more efficient by using 
quantifiers and (character sets [] or grouping them() )?
I want to do this because sometimes I will be grabbing
the 3rd number and sometimes the 9th number and I don't
want to string together 9 #(\d\d\.\d)\D+#'s

Lance
 


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

Date: Thu, 07 Nov 2002 02:34:48 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: forwardlooking regex ?
Message-Id: <3DC9D123.108@rochester.rr.com>

Lance Hoffmeyer wrote:

> I am writing a regex such that I can pick out the third set of numbers:
> 
> 27.1 30.5 29.3
> 
> with /(\d\d\.\d)\D+(\d\d\.\d)\D+(\d\d\.\d)\D+/;
> print $3;
> 
> How can I make this more efficient by using 
> quantifiers and (character sets [] or grouping them() )?
> I want to do this because sometimes I will be grabbing
> the 3rd number and sometimes the 9th number and I don't
> want to string together 9 #(\d\d\.\d)\D+#'s
> 
> Lance
>  
> 

Try:

$_=<DATA>;
$n=9;
print $1 if /(?:(\d\d\.\d)\D+){$n,$n}/;
__END__
27.1 30.5 29.3 27.2 30.6 29.4 27.3 30.7 29.5 27.4 30.8 29.6

for example.
-- 
Bob Walton



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

Date: Thu, 7 Nov 2002 03:33:02 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: forwardlooking regex ?
Message-Id: <H56sJ3.Los@news.boeing.com>

In article <pan.2002.11.07.01.51.47.648369.6618@augustmail.com>,
Lance Hoffmeyer  <lance@augustmail.com> wrote:
>I am writing a regex such that I can pick out the third set of numbers:
>
>27.1 30.5 29.3
>
>with /(\d\d\.\d)\D+(\d\d\.\d)\D+(\d\d\.\d)\D+/;
>print $3;
>
>How can I make this more efficient by using 
>quantifiers and (character sets [] or grouping them() )?
>I want to do this because sometimes I will be grabbing
>the 3rd number and sometimes the 9th number and I don't
>want to string together 9 #(\d\d\.\d)\D+#'s
>

if  ( / (?:              # group the following 
          \d\d\.\d\D     # pattern 
        ){8}             # 8 times
        (\d\d\.\d\D)     # capture 9th instance of pattern 
      /x  )              # x = ignore whitespace in regex definition 
                         #     for readability
 {
    print $1;
 }

--
Charles DeRykus


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

Date: Thu, 07 Nov 2002 04:26:26 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: forwardlooking regex ?
Message-Id: <3DC9EB4C.4FCA36B6@acm.org>

Lance Hoffmeyer wrote:
> 
> I am writing a regex such that I can pick out the third set of numbers:
> 
> 27.1 30.5 29.3
> 
> with /(\d\d\.\d)\D+(\d\d\.\d)\D+(\d\d\.\d)\D+/;
> print $3;
> 
> How can I make this more efficient by using
> quantifiers and (character sets [] or grouping them() )?
> I want to do this because sometimes I will be grabbing
> the 3rd number and sometimes the 9th number and I don't
> want to string together 9 #(\d\d\.\d)\D+#'s

$_ = q/ 27.1 30.5 29.3 /;

my $third = (split)[2];

# or

my $third = (/[\d.]+/g)[2];



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 06 Nov 2002 22:02:04 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: hash problem
Message-Id: <pan.2002.11.07.04.02.04.498833.7537@augustmail.com>

Can someone tell me why these are not matching up



my $column= "A";
print "\n $column \n\n";

%col2num=("A",1,"B",2,"C",3);
foreach $key (keys(%col2num))
{
print "at $key we have $col2num{$key}\n";
if ($column == $key){$colnum = $col2num{$key}}
}
print "\n $colnum \n";



Lance



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

Date: Thu, 07 Nov 2002 04:10:44 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: hash problem
Message-Id: <slrnasjq2g.2kt.mgjv@verbruggen.comdyn.com.au>

On Wed, 06 Nov 2002 22:02:04 -0600,
	Lance Hoffmeyer <lance@augustmail.com> wrote:
> Can someone tell me why these are not matching up
> 
> 
> 
> my $column= "A";
> print "\n $column \n\n";
> 
> %col2num=("A",1,"B",2,"C",3);

A more idiomatic way of initialising hashes is

my %col2num = ( A => 1, B => 2, C => 3);

Why did you lexically scope $column, but didn't bother to do so for
any of the other variables?

> foreach $key (keys(%col2num))
> {
> print "at $key we have $col2num{$key}\n";
> if ($column == $key){$colnum = $col2num{$key}}

This, I think [1], is your problem.

Both $key and $column are strings. You should use eq, not ==. Both
strings in numerical context (for the given data sets) evaluate to 0,
and therefore, the == will always compare true.

Please, make sure that you run your programs with warnings and
strictures enabled. The first of these two would have alerted you to
that problem right away, and you wouldn't have had to post here for
something as trivial as that.

> }
> print "\n $colnum \n";

This whole thing could have simply been replaced with:

my $colnum = $col2num{$column};

That's, of course, the whole point of having a hash in the first
place.

Next time you post, make sure that you use both warnings and strict.
Here in clp.misc people really resent having to do the work of a
machine.

Martien

[1] You fail to actually describe what you expect as output. I'm just
guessing that you expected a 1 on the last line of output.
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | In a world without fences, who needs Gates?
                        | 


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

Date: Wed, 06 Nov 2002 19:09:27 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How much faster is dbm over MySQL
Message-Id: <3DC9AF37.AB2687D4@earthlink.net>

Hobo wrote:
> 
> (Apologies if this is OT)
> 
> I often read that the various key-value databases you use with dbmopen
> are faster than MySQL, but have never seen anything quantifiable.
> Exactly how much faster?

Well, it depends on what interface you're using.  If you're using the C
dbmopen function to hook up with a Berkeley db file, it's likely to be
rather faster than the perl dbmopen function, due to how slow the tie
interface is.

Also, are you using the hash or btree format?

Similarly, how are you hooked up to MySQL?  Through perl's DBI?  Through
Win32::ODBC?  Through IPC::Open2 and the sql shell supplied by MySQL?

Also, are you doing a search on the primary key of the table, or some
other column?

> A rough estimate in some form other than "very" would be appreciated.
> Also, what is the largest value I can enter using dbmopen on
> whatever vesion of dbm Red Hat uses?

   perldoc AnyDBM_file
   perldoc BerkeleyDB # This is from CPAN, not installed by default.

> Also, what version of dbm does Red Hat use?

Good question -- ask on a newsgroup for Red Hat.  Or a newsgroup for the
Berkeley database library.

> I want to do simple key-value retrieval with large values ranging
> from 10-20K, would I be better off with MySQL?

Maybe.  It depends on how many pieces of data.  Implement each, and
benchmark them.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: 6 Nov 2002 16:38:57 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: How much faster is dbm over MySQL
Message-Id: <3dc9b621@news.victoria.tc.ca>

Hobo (myusenetclient@requiresthis.com) wrote:


: (Apologies if this is OT)

: I often read that the various key-value databases you use with dbmopen are
: faster than MySQL, but have never seen anything quantifiable. Exactly how
: much faster? A rough estimate in some form other than "very" would be
: appreciated. Also, what is the largest value I can enter using dbmopen on
: whatever vesion of dbm Red Hat uses? Also, what version of dbm does Red
: Hat use? I want to do simple key-value retrieval with large values ranging
: from 10-20K, would I be better off with MySQL?

You should always determine what functionality you need, and choose the
best tool for the job.  Either will be fast enough for normal work.  The
questions is, which one best fits your needs.


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

Date: Wed, 6 Nov 2002 15:08:53 -0800
From: "Tan D Nguyen" <nospam@nospam.com>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <aqc7cq$8pe7h$1@ID-161864.news.dfncis.de>


"Joe Moschak" <joe@amrita.net> wrote in message
news:aqbn60$88i$1@ins22.netins.net...
> Every time I invoke a perl script from a web page, I get a different
process
> ID (PID) and consequently different values for any variables.
This is what you should expect from CGI scripts. Whenever you invoke your
script, the webserver (Apache) would spawn a completely new process to
handle this.

> How can I make it so that each time I invoke my script from a given web
session I get
> the same PID instead of a different one?
Try to migrate your scripts to mod_perl stuff. It's not hard, yet gives you
tremendous performance boost.

> In the same web session I clicked a link that invoked my program 3 times
> within a couple minutes.  But as you can see, each time I got a different
> process id.
When you click on the link, you don't stay in the same web session. Instead,
you force the web server to spawn off new process as explained above.




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

Date: Wed, 06 Nov 2002 20:20:25 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <3DC9BFD9.1090602@thecouch.homeip.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1



Tan D Nguyen wrote:
|>How can I make it so that each time I invoke my script from a given web
|
| session I get
|
|>the same PID instead of a different one?
|
| Try to migrate your scripts to mod_perl stuff. It's not hard, yet
gives you
| tremendous performance boost.

That does not guarantee the same PID for each call to the perl scripts.

1. Apache usually spawns several children to handle connections.  Child
1 can handle a request and child 2 handle the next request.

2. Depending on your apache configuration, each child will only live for
so long/handle so many requests before getting recycled.


-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE9yb/ZeS99pGMif6wRAkF6AKCQGNkerjI9Fa/64tQzZyqvaW0lbQCeKMmu
UdLzTMqjR5sjq8onteaKczw=
=a+og
-----END PGP SIGNATURE-----



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

Date: Thu, 07 Nov 2002 04:02:32 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <sBly9.9289$Wf5.5017@nwrddc04.gnilink.net>

Joe Moschak wrote:
> Every time I invoke a perl script from a web page, I get a different
> process ID (PID) and consequently different values for any variables.
> How can I make it so that each time I invoke my script from a given
> web session I get the same PID instead of a different one?

GRIIINNNN, this is a good one.
You are getting a new PID because the web server starts a new process every
time.
This is the way web servers work. How could they possibly do it any
different? The process from the previous invocation may still be active.
Should they create a new process for the second invocation with the same
process ID as the first one? Just impossible.

jue

BTW: none of this is related to Perl in any way.




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

Date: Thu, 07 Nov 2002 04:16:19 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <slrnasjqd0.2kt.mgjv@verbruggen.comdyn.com.au>

On Wed, 6 Nov 2002 12:31:12 -0600,
	Joe Moschak <joe@amrita.net> wrote:
> Every time I invoke a perl script from a web page, I get a different process
> ID (PID) and consequently different values for any variables.  How can I
> make it so that each time I invoke my script from a given web session I get
> the same PID instead of a different one?  Below is code I use to verify that
> I get different PIDs each time.

This question has nothing whatsoever to do with Perl.

Why do you think you need the same pid every time?

If you need some persistency in data or some sort of "session"
management id, there are many ways to achieve that with webbie stuff
without needing a pid.  There are other groups that talk about this
sort of stuff, in the comp.infosystems.www.* hierarchy.  I am sure
there are Perl modules available on CPAN to do this as well. 

Since you don't actually tell us what it is you are trying to achieve,
there is very little concrete help anyone can offer.

If you still think you do need a stable pid, write a server process,
and have your CGI processes connect to that server process. Of course,
whenever the server process restarts, the pid will most likely change.

It is hardly ever useful to worry about the pid your process has.

Martien
-- 
                        | 
Martien Verbruggen      | If at first you don't succeed, destroy all
Trading Post Australia  | evidence that you tried.
                        | 


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

Date: 6 Nov 2002 20:07:14 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Is it wrong to store method definitions in a database?
Message-Id: <1bff1830.0211062007.2cdb5de8@posting.google.com>

> First possible re-think:  If you can add cron jobs any time you want,
> how about you specifically schedule the cron job to run at the time of
> the first scheduled collection (as a kind of once-only cron job).
> 

I would think the at command(s) would make better sense then cron in 
this situation.  

> That is, have your Perl cron job only run when there *is* a job
> scheduled, rather than frequently running, checking for jobs, and then
> exiting due to not finding any to run.

Using cron you would have to remove the entry once the job was done.  And 
I would think you would be trying to do that programmatically.  I've
never considered editing crontabs programmatically, I would think you would run
into sync. issues.  Isn't the crontab a single file entry?

At should be simpler to manipulate from perl also, than cron.

Opinions?


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

Date: Wed, 06 Nov 2002 18:59:02 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: param($var).
Message-Id: <3DC9ACC6.78D868C1@earthlink.net>

Todd Anderson wrote:
> 
> Hello,
> The code below replaces \n with <br> for param($var).
> foreach $var (@display_items)
>     {
>         my $value = param($var);
>         $value =~ s/\r\n/<br>/g;
>         param($var, $value);
>     }

How do you distinguish between a user typing in an actual <br>, and a
newline?

> I need to do the same thing with variables that have been converted
> ie:
> $text = param('text');
> Something like...
> foreach $var (@display_items)
>     {
>         $var =~ s/\r\n/<br>/g;
>     }
> But this of course, only replaces \n in the handle name and not the
> value.
> 
> Any help is appreciated
> Thanks in advance for your help.

Show us what you want to do with this munged data, and we can help
you... it feels like you've got an XY problem of some sort, but you're
only telling us the Y.  (An XY problem is, I need to do X, I want to use
Y to do it, how do I use Y?)

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 07 Nov 2002 03:53:10 GMT
From: "James" <turajb@hoflink.com>
Subject: Re: Perl module to read mails from Microsoft Outlook
Message-Id: <Gsly9.7031$h4.4460@news4.srv.hcvlny.cv.net>

This is just a much more simple solution, but assuming the email address is
a POP account & the data is in the email itself (not an attachment) why not
use one of the many POP email modules out there to read the email while it
is on the server before it is downloaded.  The "Perl For Dummies" (2nd
Edition) book tells you how to read emails for a POP account (Chapter 15)
using the Mail::POP3Client module.  It may not be a perfect solution, but it
may help...

"Abid Mohammed" <mohammed@cse.unl.edu> wrote in message
news:aqbcm9$ekq$1@unlnews.unl.edu...
> Hi,
>
> I am trying to do the following and need some help. I have reports mailed
to my mailbox(Microsoft Outlook)
> which are put in a particular folder (say reports). I need to read the
mails from the folder 'reports' parse
> the data and project it in a two dimensional graph. Could any one let me
know how to achieve this.
>
> Thanks




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

Date: Wed, 06 Nov 2002 19:54:49 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: Re: regex or substr or both?
Message-Id: <pan.2002.11.07.01.54.47.899754.6618@augustmail.com>

Thanks David!  I see I was making this much
more complex than it was (as is usual.  
I forgot about the $/=undef to ignore \n.

Lance


>> This gets you what you want pretty quick and easy:
>>
>> ######################################### open(FILE,
>> "</file/path/gender.txt"); my $file;
>> {local $/=undef;$file=<>}
> 
> Sorry, I for got to put the file handle in here.  It should be like this
> {local $/=undef;$file=<FILE>}
> rather than
> {local $/=undef;$file=<>}
> 
> By the way setting $/=undef causes the whole file to be slurped into a
> scalar instead of an array.
> 
>> close(FILE);
>>
>> # if you intend to just find the number HERE: #
>> ------------------------------------------- $file =~ /Table
>> 1.*?Male.*?\d+\D+(\d+)/s; # find "Table 1" then the very next occurence
>> of "Male", then the # very next digit (1 or more that is), then a
>> non-digit (1 or more) # then assigns the one or more digits after that
>> to $1 , Note the # s on the end, thats how span multiple lines my
>> $second_number = $1;
>>
>> # if you intend to replace that number HERE: #
>> ------------------------------------------- my $replacement = "this
>> replaces the second number"; $file =~ s/(Table
>> 1.*?Male.*?\d+\D+)\d+/$1$replacement/s;
>> #########################################
>>
>> Regards,
>> David
>>
>>
>>
>>
>>



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

Date: Wed, 6 Nov 2002 19:56:09 -0500
From: "Rene Robinson" <renerobinson at comcast dot net>
Subject: Re: Returning matches in an array
Message-Id: <MQCdnThD5OHsIFSgXTWcoA@comcast.com>

perl's grep function works well...

"emcee" <emcee@inorbit.com> wrote in message
news:4fac3c33.0211061132.79d7ea53@posting.google.com...
> Is there someway of returning every match for a regex in an array
> rather than individual matches in varibles such as $1, $2 and so on?
> The only way I can do it is to run a loop that finds a match than
> split the original string at that match, combine all the varibles
> after the first in the array into a single varible and splitting that.
> But this seem like alot of extra trouble, is this the only way of
> doing it?




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

Date: Thu, 07 Nov 2002 03:28:09 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Returning matches in an array
Message-Id: <3dc9dd25.291594586@news.erols.com>

emcee@inorbit.com (emcee) wrote:

: Is there someway of returning every match for a regex in an array
: rather than individual matches in varibles such as $1, $2 and so on?

Assign the return from m// to an array.

    my @matches = $var =~ /(.)/g;



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

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


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