[11219] in Perl-Users-Digest
Perl-Users Digest, Issue: 4819 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 3 19:11:15 1999
Date: Wed, 3 Feb 99 16:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 3 Feb 1999 Volume: 8 Number: 4819
Today's topics:
Re: "glob"bing dot files <ludlow@us.ibm.com>
Re: alternative perl NG for newbies? (Tad McClellan)
Re: Are sub-second timers possible in Perl? <jdf@pobox.com>
Asyncronous and nonblocking IO on sockets. spazzz@goplay.com
Re: awk in perl (Tad McClellan)
Re: Best string/hex/string conversion? (Larry Rosler)
Re: capturing output during telnet session <jdf@pobox.com>
Catching undefined symbols in subs (Bill Moseley)
Re: Changing drives with ActiveState Perl on NT <RobLemley@nospam.com>
Changing from lower to upper case (Was: Newbie ?) <ludlow@us.ibm.com>
Re: Deleting duplicates in a text file <aqumsieh@matrox.com>
Re: Deleting duplicates in a text file (Martien Verbruggen)
Re: Excel and perl (Steve .)
formatted output <de_munnik@wxs.nl>
Re: formatted output (Larry Rosler)
Re: formatted output (Martien Verbruggen)
Help on making a Database using DB_File <straderb@mindspring.net>
Re: how to search for/replace name with HTML name/URL ? (Tad McClellan)
Is perl a freeware? <d9530229@mail.connect.usq.edu.au>
Re: Is perl a freeware? <ludlow@us.ibm.com>
Re: Is perl a freeware? (Martien Verbruggen)
Re: Newbie ? <allan@due.net>
Re: Newbie ? (Martien Verbruggen)
Re: newbie having trouble with concatination <aqumsieh@matrox.com>
Re: perl newbie: need help pasing web forms <ludlow@us.ibm.com>
Re: problem forking with perl: child sometimes dies (Martien Verbruggen)
Q: extracting tables from HTML document? anna@water.ca.gov
Re: Read emails from a perl program <allan@due.net>
Re: Regex for e-mail addresses? (John Stanley)
Re: Regex for e-mail addresses? <revjack@radix.net>
Searching for char in a string lamj@softhome.net
Re: Searching for char in a string (Tad McClellan)
select and detecting FTP in process (Timothy Church)
Re: Simple Perl Script <aqumsieh@matrox.com>
The best way to learn C? <aidan@crucibledesign.com>
Re: The best way to learn C? (Steve Leibel)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 03 Feb 1999 17:33:08 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: "glob"bing dot files
Message-Id: <36B8DCB4.BF8FC963@us.ibm.com>
Martien Verbruggen wrote:
>
> In article <36B8C83D.7E70E288@us.ibm.com>,
> James Ludlow <ludlow@us.ibm.com> writes:
>
> > my @files = (glob(".*"), glob("*"));
>
> No need for two calls to glob, or a temp list:
>
> my @files = glob '.* *';
Whoa! So perldoc wasn't kidding when it said, "expansions such as a
shell would do." It just shows that I've been spending _way_ too much
time with the MS-DOS prompt.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Wed, 3 Feb 1999 15:58:14 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: alternative perl NG for newbies?
Message-Id: <mpga97.1t1.ln@magna.metronet.com>
Andrew Fry (andrewf@beausys.demon.co.uk) wrote:
: In article <798js5$6b$1@client2.news.psi.net>, Abigail <abigail@fnx.com>
: writes
: >Andrew Fry (andrewf@beausys.demon.co.uk) wrote on MCMLXXXI September
: >MCMXCIII in <URL:news:OxisJAACj3t2EwbQ@beausys.demon.co.uk>:
: BTW. I tried 'man perl' on UnixWare 7.0.1 some time ago ... it doesnt
: produce anything.
Having an incompetent system administrator does not make you
exempt from observing netiquette.
When that happens, you should send your Perl questions to the
dolt who installed it without the docs.
Repeat every couple of hours until the sysadmin either:
a) answers your question
b) fixes the mistake (installs the docs)
c) quits
(if 'c', then repeat the procedure with the next sysadmin
until you get a properly configured perl)
: Unfortunately, I dont have the time to find out
: why this is.
It takes just as long to type up an email to your sysadmin
as it does to type up a Usenet post.
If you do not have the resources available to do the things
that netiquette demands before posting, then you should not post.
: >$$ (b) newbies have all the time in the world to read documentation
: >
: >Oh. Right. They are execused from reading the documentation, cause their
: >time is so valueble. Wasting time of hundreds or thousands of people
: >reading their question doesn't matter?
: 1. I was not suggesting that newbies should be excused reading
: documentation, nor that their time is so valuable as to be so
: excused. These are absurd suggestions, and it is wrong of you
: to read these interpretations into what I said.
Try stating it more clearly then.
I thought you were saying the same thing that Abigail thought.
: 2. "Wasting time of hundreds/thousands of people reading their
: question".
: Oh no ... here comes the hyperbole! How long does it take to read
: one question and decide that it is to trivial to respond to, for
: goodness sake ? (Probably a small fraction of the time you spend
: on-line, I guess).
But there isn't one question that is too trivial.
There are dozens. Often more than half of all postings.
And each of those dozens of "few seconds" is multiplied
by the number of readers of the group (thousands likely).
When I work that math, I come up with a not insignificant number...
It is absurd to suggest there there is only the occasional
"read the manual for me" article.
If that were true, there wouldn't be nearly the passion your
opponents exhibit.
: The suggestion is that all newbies should...
: a) be aware of, and read thoroughly, all on-line documentation
They most certainly must be aware of the online documentation.
If they are not, and they get flamed, the response should be
something like "Oh. I didn't know about that. Sorry."
When you break rules of etiquette, you shouldn't get all
huffy when someone tries to straighten you out.
When you take cuts in line, you gotta kinda expect that
someone is going to say something about it.
It is not suggested that they thoroughly read all of the
online documentation.
_I_ haven't even done that.
It _is_ suggested that they _check_ to see if they can find
any relevant stuff in the docs before posting though.
A simple word search can often lead to the answer without
reading the whole damn corpus.
: b) be aware of, and read a number of recommended books
I don't _ever_ remember seeing someone flamed
for asking a question that is answered only in a book.
Please give me enough information for me to find the posting
that you are referring to on DejaNews.
There seems to me to be a good deal of "reading in interpretations
of what was said" on both sides here...
: c) be aware of, and read, the code inside Perl modules
You are being absurd yet again.
Provide a cite that will allow us to find any example of a
posting that you are basing this claim on.
: .... before even daring to post a question on this newsgroup.
: I dont know about other people, but, while I realize the importance of
: reading documentation, I dont always have time to do all this.
If you do not have the resources available to do the things
that netiquette demands before posting, then you should not post.
If you post anyway, then you shouldn't get all huffy when
someone takes you to task for your bad manners.
If you do not have time to stand in line, then you cannot
ride the ride.
: >$$ I say: if you dont have anything more useful to say than this, then
: >$$ DONT BOTHER SAYING ANYTHING!
I don't think that letting folks continue in ignorance
is helpful either.
: >That doesn't help, does it? RTFM points someone to the manual, saying
: >"what you ask is in the manual". Being silent doesn't help the person
: >asking the question.
: No ... nor does RTFM in my opinion.
You have your opinion.
We have our opinions.
We must agree to disagree here. You are not going to change our minds.
Our opinion is that a pointer to the docs is helpful.
We are going to keep on doing it.
Deal with it.
----------------------------------------------
In article <1995Nov9.193745.13694@netlabs.com>, lwall@netlabs.com (Larry
Wall) wrote: ...
<Larry> [snip] I view a programming language as a place to be
<Larry> explored, like Disneyland. You don't need to have a lot of preparation
<Larry> to explore a theme park. You do have to go along with the crowd
<Larry> control measures, though. In a sense, each ride has its own
<Larry> prerequisites--if you cut in line, you risk getting tossed out of the
<Larry> park.
<Larry>
<Larry> What we have here in this newsgroup is a failure in crowd control.
<Larry> Reading the FAQ is like staying in line--it's something you should
<Larry> learn in kindergarten. Usenet needs a better kindergarten.
----------------------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 04 Feb 1999 00:31:27 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Jeffrey Davey <Jeffrey_Davey-P93404@email.mot.com>
Subject: Re: Are sub-second timers possible in Perl?
Message-Id: <m3ww1zf4j4.fsf@joshua.panix.com>
Jeffrey Davey <Jeffrey_Davey-P93404@email.mot.com> writes:
> I am trying to implement a sub-second timer in Perl, but up to now
> haven't even been able to determine if this is possible.
perldoc perlfaq8, "How can I sleep() or alarm() for under a second?"
> I've scanned the FAQ questions, but haven't found much helpful info
^^^^^^^
> yet.
I think you mean "skimmed".
Webster's Unabridged:
scan v.t. : 3. To go over and examine point by point; to examine with
care; to look closely at or into; to scrutinize.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Wed, 03 Feb 1999 23:10:55 GMT
From: spazzz@goplay.com
Subject: Asyncronous and nonblocking IO on sockets.
Message-Id: <79al1q$6tl$1@nnrp1.dejanews.com>
How do I fcntl() a socket to set it's flags for FASYNC or O_NONBLOCK?
TIA,
Jeff
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 3 Feb 1999 17:36:50 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: awk in perl
Message-Id: <iima97.q72.ln@magna.metronet.com>
Richard G. Hall (Richard_G_Hall@yahoo.com) wrote:
: I have a file containing approx. 1000 emails and I'm
: trying to extract a singular field from each email.
: INTERNAL_HOST_NO = 151
: What I want to achieve is storing into an array ALL the
: INTERNAL_HOST_NO's.
: In ksh I might do something like:
: grep ^INTERNAL_HOST_NO ${INFILE} | awk '{print $2}'
: to gain the value but I'd like to learn how to do it in
: perl.
perl -n -e 'print "$1\n" if /^INTERNAL_HOST_NO\s*=\s*(\d+)$/' filename
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 3 Feb 1999 14:30:29 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Best string/hex/string conversion?
Message-Id: <MPG.11226ddd97adb7b49899fc@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36B8B6C9.5459D2E@action.cnchost.com> on 03 Feb 1999 13:07:58
PST, Tom Williamson <tomw@action.cnchost.com> says...
> I have what I'm sure is a SIMPLE question, I just can't find a SIMPLE
> answer for it. I am hoping that someone here knows it.
Yes.
> I have a string of essentially random byte values (from 000 to 255). I
> would like to "escape" this into a string formatted like a (very) large
> hex number. For example the following series of bytes:
>
> \0xff \x45 \0x27 \0x00 (etc.)
I assume that the 0 after the \ is optional; we'll accept it either way,
but won't be able to reproduce it the same way as it went in, of course.
> would become:
>
> "0xFF452700...." (etc.)
>
> It would also be nice to be able to convert it back again to the
> previous byte stream. Having heard that Perl is really whiz-bang for
> manipulating strings and data, I'm sure there is a quick, short and easy
> way to do this, but being a Perl newbie, I don't know what it is - all
> I've come up with is horrible routines with lots of loops, etc.. Can
> anyone help?
Here it is. There are loops, of course, but they are hidden.
#!/usr/local/bin/perl -w
use strict;
$_ = '\0xff \x45 \0x27 \0x00';
my $y = '0x' . join "", /\\0?x([\da-fA-F]{2})/g;
print $y, "\n";
$y = '\x' . join ' \x', substr($y, 2) =~ /(..)/g;
print $y, "\n";
__END__
Output:
0xff452700
\xff \x45 \x27 \x00
Here are some Other Ways to do the second step:
$y = '\x' . join ' \x', unpack 'x2' . 'A2' x (length($y)/2 - 1), $y;
$y = '\x' . join ' \x', map substr($y, 2 * $_, 2),
1 .. length($y)/2 - 1;
When you feel comfortable with these and other functional ways of
solving this kind of problem, you will no longer be such a newbie. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 04 Feb 1999 00:24:42 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: "Lee Ramirez" <lee.ramirez@westgroup.com>
Subject: Re: capturing output during telnet session
Message-Id: <m3zp6vf4ud.fsf@joshua.panix.com>
"Lee Ramirez" <lee.ramirez@westgroup.com> writes:
> I need this output in a file, so I end up having to paste G-00 at
> the end of the file.
The documentation for the cmd() method states
It's assumed that the program to which you're sending is some
kind of command prompting interpreter such as a shell.
If that's not the case, then you probably shouldn't be trying to
coerce cmd() into some other behavior...
Have you tries the $obj->print() and $obj->getline() methods?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Wed, 3 Feb 1999 14:58:51 -0800
From: moseley@best.com (Bill Moseley)
Subject: Catching undefined symbols in subs
Message-Id: <MPG.11227482e8fe0f4e9896a0@nntp1.ba.best.com>
Two embarrassing questions:
1) Ok, unlikely that slowcpu() below will ever run.
But just in case, how do I get perl to tell me that
unknown_name() is undefined?
#! /url/local/bin/perl -w
use strict;
my $later = time() + 100;
&slowcpu if time() > $later;
sub slowcpu {
return unknown_name( 123 );
}
2) Jonathan Feinberg helped me find the cause of this error:
[Tue Feb 2 20:53:20 1999] admin5.cgi: Can't coerce array into hash
at (eval 23) line 23.
Turned out to be line 706 and within a here doc. How do I, from that
error message find find the problem line?
Can Perl destroy brain cells?
--
Bill Moseley mailto:moseley@best.com
------------------------------
Date: Wed, 3 Feb 1999 17:14:35 -0600
From: "Rob Lemley" <RobLemley@nospam.com>
Subject: Re: Changing drives with ActiveState Perl on NT
Message-Id: <YgNnSm8T#GA.154@pet.hiwaay.net>
How do you know that what you're doing is not working?
And what do you mean that the "working directory in the
context of the perl script is still ..."?
When you say "it doesn't work" you are not telling
us *why* you think that it is not working. One thing
you should do is check the return code of the chdir.
Once you issue the chdir call, your working directory
*is* the directory on the other drive. Any files that
you open after that chdir will be relative to the
dir that you chdir'ed into, it doesn't matter which
drive the dir is on. And any processes you
start (via system() for example), will start in the
dir that you chdir'ed into.
D:\> perl
print Win32::GetCwd() . "\n";
chdir 'c:/temp';
print Win32::GetCwd() . "\n";
chdir 'd:/temp';
print Win32::GetCwd() . "\n";
__END__
ALSO, in your examples, probably none of them will work,
because if you want to use backslashes(\) in your paths,
then you need to either use single quotes or double-up
the backslashes:
chdir "F:/temp"; # ok
chdir "F:\\temp"; # ok
chdir 'F:\temp'; # ok
chdir "F:\temp"; # BAD, F<colon><tab>temp
Also, on 32-bit windoze, system("cd somedir"); will NOT
change the current directory of the calling perl script.
Phil Tomson wrote in message <797hkq$cv5$1@user2.teleport.com>...
>In article <03usUKwS#GA.249@pet.hiwaay.net>,
>Rob Lemley <RobLemley@nospam.com> wrote:
>>Phil Tomson wrote in message <78qem9$lbc$1@user1.teleport.com>...
>>...
>>>chdir('F:\somedir') won't work if I'm running the script on drive c: - the
>>>working directory is still going to be the one I'm in on drive c:. I
>>...
>>
>>Perl 5 ActivePerl binary build 507, WinNT 4.0, ServicePack 3:
>>
>>system('cd');
>>chdir 'c:\temp';
>>system('cd');
>>print "$_\n" while(<*>);
>>
>>
>
>This doesn't do what we want it to....
>
>>You could be hitting NT permission problems,
>>which is very common. Or, maybe your
>>syntax is different than the text in your
>>message. A little sample script would help!
>>
>
>To reiterate the problem (and add some info): We're starting a perl script
>on drive C: (for example) and at some later time we want to move the
>current working directory to a networked drive, drive F:, for example, and
>perform some operations there.
>
>So, let's say I started this little script running at C:\temp and later on
>I want the current working directory to be at F:\somedir (It has to be
>this way since we're actually running another perl script on a Sun which
>is monitoring what is going on in /usr/home/somedir [mapped to F: on the
>PC] in case the PC bluescreens ( BSODs, dies ) - that's a very simplified
>explanation). The problem is I can't issue something like:
>
>system("cd F:\somedir");
>
> or
>
>chdir("F:\somedir");
>
>because all that does is change the current directory of drive F:, my
>current working directory in the context of the perl script is still
>C:\temp.
>
>Now, if I issue the command:
>
>chdir("C:\temp\somedir");
>
>That will work since C is the drive I started out on.
>
>Like I said before, this isn't a problem on Unix since drives and
>directories all look the same - how does one deal with this on the PC?
>(OK, I know, run Linux - how does one deal with this on a PC running
>Windows?)
>
>Phil
>--
>Phil Tomson
>FreeHDL Project
>http://www.freehdl.seul.org/
------------------------------
Date: Wed, 03 Feb 1999 17:40:22 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Changing from lower to upper case (Was: Newbie ?)
Message-Id: <36B8DE66.560423DB@us.ibm.com>
dmeilinger@cng.dl.nec.com wrote:
> I'm sure this is a quick one for anyone who has been using Perl for a while.
> I am trying to get a string match to change the case of an input string, i.e.
> change an occurance of 'KEY' to 'key' or vice versa. I don't want to match
> any case (/i) but want to substitute an upper case letter for its lower, etc.
perldoc -f uc
perldoc -f lc
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Wed, 3 Feb 1999 13:45:01 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Deleting duplicates in a text file
Message-Id: <x3yd83rmimq.fsf@tigre.matrox.com>
kevin@sahara.research-inc.com () writes:
> cat log* | addressextractor.pl | sort | uniq > uniquelist.txt
^^^^^^^^
sort has a -u option that extracts and sorts only unique elements. So
even your little non-Perl solution can be shorter (and probably
faster).
------------------------------
Date: Wed, 03 Feb 1999 23:38:53 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Deleting duplicates in a text file
Message-Id: <h65u2.49$_E3.4792@nsw.nnrp.telstra.net>
In article <x3yd83rmimq.fsf@tigre.matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> writes:
>
> kevin@sahara.research-inc.com () writes:
>
>> cat log* | addressextractor.pl | sort | uniq > uniquelist.txt
>
> ^^^^^^^^
>
> sort has a -u option that extracts and sorts only unique elements. So
> even your little non-Perl solution can be shorter (and probably
> faster).
<comment tone=pedantic>
That is of course not strictly true. For many sort tools that I know
of, the -u option causes output to only contain lines with unique sort
_keys_. In many cases, and certainly the one at hand, the whole line
is the sort key. This is not always the case.
if the file contains something like:
1534 some text
1534 some other text
# sort -n -u filename
1543 some other text
# sort -n filename | uniq
1543 some other text
1543 some text
</comment>
Martien
--
Martien Verbruggen |
Interactive Media Division | 75% of the people make up 3/4 of the
Commercial Dynamics Pty. Ltd. | population.
NSW, Australia |
------------------------------
Date: Wed, 03 Feb 1999 23:26:33 GMT
From: syarbrou@nospam.enteract.com (Steve .)
Subject: Re: Excel and perl
Message-Id: <36b8dae0.28046934@news.enteract.com>
That wouldn't work. This is going to be an automated system on a
Linux box. Doing this to fifty xls files a week would eliminate the
point.
On Sat, 30 Jan 1999 19:42:31 -0800, Abraham Grief <abey@hill.ucr.edu>
wrote:
>
>On Sat, 30 Jan 1999, Steve . wrote:
>
>> I have an excel spreadsheet that I want to extract the data from for
>> manipulation. Is there a way in perl to read an excel spreadsheet?
>> Thanks.
>>
>> Steve
>
>When I had to do this, I saved the spreadsheet as tab-delimited text from
>Excel and worked from there. Also, watch out for posting the same message
>multiple times.
>
>HTH
>
------------------------------
Date: Wed, 3 Feb 1999 23:54:20 +0100
From: "De Munnik Schoenen B.V." <de_munnik@wxs.nl>
Subject: formatted output
Message-Id: <79ak40$9fp$1@reader2.wxs.nl>
Hi,
I would like to know how to do formatted output on numbers. I want all my
numbers to look like this 0000.00
I think it's very ease just like it's in C but I just don't know how.
with regards
Martijn de Munnik
------------------------------
Date: Wed, 3 Feb 1999 15:42:07 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: formatted output
Message-Id: <MPG.11227eac5300ab169899fd@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <79ak40$9fp$1@reader2.wxs.nl> on Wed, 3 Feb 1999 23:54:20
+0100, De Munnik Schoenen B.V. <de_munnik@wxs.nl> says...
> I would like to know how to do formatted output on numbers. I want all my
> numbers to look like this 0000.00
> I think it's very ease just like it's in C but I just don't know how.
It's "just like it's in C" so you do know how. `perldoc -f sprintf`.
In this case,
printf '%07.2f', ...
But "all" your numbers won't look like 0000.00; for example, negative
numbers, or numbers >= 10000. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 03 Feb 1999 23:55:53 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: formatted output
Message-Id: <dm5u2.59$_E3.4792@nsw.nnrp.telstra.net>
In article <79ak40$9fp$1@reader2.wxs.nl>,
"De Munnik Schoenen B.V." <de_munnik@wxs.nl> writes:
> I would like to know how to do formatted output on numbers. I want all my
# perldoc -f printf
# perldoc -f sprintf
> numbers to look like this 0000.00
$fnum = sprintf("%07.2f", $num);
> I think it's very ease just like it's in C but I just don't know how.
Yep. Exactly as in C. We even use the same function names.
Martien
--
Martien Verbruggen |
Interactive Media Division | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd. | thing but mean your mother.
NSW, Australia |
------------------------------
Date: Wed, 3 Feb 1999 18:44:04 -0500
From: "Billy Strader" <straderb@mindspring.net>
Subject: Help on making a Database using DB_File
Message-Id: <79amls$6vf$1@camel25.mindspring.com>
Hey everyone....
Well I am kind of new to the perl prog. stuff but I have vreated some
interested programs. The program I am trying to create now deals with
making a Database. I am using a unix based system but I couldn't find any
Unix mailing list.... So here I go...
Here is what I need to do I need to create a a form/site where the first
time a tech/user goes there it looks for a cookie and then compares it to a
DB to see if they have been here or not. If they haven't been here yet it
will ask them to fill out a form asking for some basic info:
Name
E-mail address
Supervisor
Once they fill it out it places a cookie on their system with a unquie ID
number. It also creates a section for that user for more information. OK
once the cookie is in place when they comeback to the site it sees the
cookie and brings their info up now is what we do all the time (every night)
is fill out a end of shift report. With each report it records the date,
the user, number of hours on the phone, number of calls, number of hours
doing e-mail, number of e-mails, and number of other calls (I work in a call
center). It will also have a comment field. OK once they fill this info in
it will dump the data to a database and record it. It will also bring
another screen back giving the tech their effiecenty which is in the format
of :
3.5 calls = 1 hour
8 e-mails = 1 hour
So by 8 hours we need 28 calls. So it is pretty easy to calc. The other
calls we just add to the ordinary calls. So it would be more :
(other calls) + (reg calls) / Hours to get effeicienty.
OK well also what I need to do is make it so it also creates a graph. So we
can see how much of we vary day by day in number of calls or effeicenty.
Another section I gotta include to search this database is another site
where one can select which ever tech or all the techs and do a look up
between certain dates.
We currently have a working type of database but it is a flat database (just
text) and it doesn't have any of the graphics working with it yet. I would
give you all the URL but the server does not allow any connections to it
from outside our domain. But if anyone can give me any help with ideas or
just some good links on understanding how to work with the databases or
graphics it will be greatly appricated....
Thanks for listening....
Billy Strader
Mindspring Technical Support
Mindspring Enterprises Inc.
P.S. Sorry for all the miss spellings....
------------------------------
Date: Wed, 3 Feb 1999 17:03:05 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how to search for/replace name with HTML name/URL ?
Message-Id: <9jka97.1t1.ln@magna.metronet.com>
John Owens (jowens@blit.Stanford.EDU) wrote:
: My group has a large number of web pages that have people's names on
: them. What I would like to do is automate adding HTML references to
: each name I find.
: Making this more difficult is instances of "Bitdiddle, Ben" and
: "Bitdiddle, Ben X." and "Ben X. Bitdiddle" (for example).
Also making it more difficult are when there is more than
one Ben Bitdiddle.
: Also making
: it more difficult are existing links:
: "<a href="http://www.foo.com/~ben">Ben Bitdiddle</a>" (although I
: ought to keep the canonical file with no links and run the Perl script
: on it each time I want to incorporate the links).
: None of this seems like rocket science, but I'd prefer not to reinvent
: the wheel. If those with more Perl experience than I could point me at
: some previously written scripts that help me accomplish my task I'd
: appreciate it very much.
I did this same thing a few weeks ago for a Superbowl website.
Unfortunately, it was a work for hire, so I cannot share it with you.
So I'll just describe the approach I used. See below.
There are two NFL players named "Rod Smith" and "Kevin Williams".
I was able to disambiguate references to them by figuring out
the context of which team was being discussed.
Would have been a real pain if they were on the same team.
If they cannot be disambiguated, then you have to decide how
you are going to deal with it. Put in more than one link
is probably what I would do.
Here's a description of how I did it. (you can make the hash values
be references to arrays to handle the case where different people
have the same name):
Make a hash with names as keys, and URLs as values.
Generate all of the name permutations that you want to handle,
and make a hash entry for each of those too.
Mash all of the keys together into a big "or group" to be
used in a regex. (see also Perl FAQ, part 6:
"How do I efficiently match many regular expressions at once?")
$namesRE = join '|', reverse sort keys %xref;
s!($namesRE)!<a href="$xref{$1}">$1</a>!g;
Ran slow as a pig.
But it was "batch", so I didn't mind.
Good luck!
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 03 Feb 1999 19:08:03 +1000
From: PiangFa <d9530229@mail.connect.usq.edu.au>
Subject: Is perl a freeware?
Message-Id: <36B811F2.16AF0790@mail.connect.usq.edu.au>
can I download it?
------------------------------
Date: Wed, 03 Feb 1999 17:35:12 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Is perl a freeware?
Message-Id: <36B8DD30.AFE3213@us.ibm.com>
PiangFa wrote:
>
> can I download it?
www.perl.com
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Wed, 03 Feb 1999 23:57:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Is perl a freeware?
Message-Id: <2o5u2.60$_E3.4792@nsw.nnrp.telstra.net>
In article <36B811F2.16AF0790@mail.connect.usq.edu.au>,
PiangFa <d9530229@mail.connect.usq.edu.au> writes:
> can I download it?
Maybe you should try a few things.. Like pointing your web browser to
http://www.perl.com/
Martien
PS. You'll find out that perl is free. Any advice to silly questions
on this newsgroup however is charged at a going rate of about $1 - $5
per word, depending on context. That is why I am going on about this,
because every word I type earns me another $5. Expect the bill soon.
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: Wed, 3 Feb 1999 18:39:34 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: Newbie ?
Message-Id: <d75u2.491$L1.9546@nntp1.nac.net>
dmeilinger@cng.dl.nec.com wrote in message
<79aivk$55j$1@nnrp1.dejanews.com>...
:I'm sure this is a quick one for anyone who has been using Perl for a while.
:I am trying to get a string match to change the case of an input string, i.e.
:change an occurance of 'KEY' to 'key' or vice versa. I don't want to match
:any case (/i) but want to substitute an upper case letter for its lower, etc.
:So using:
:$temp = "KEY";
:It would be.....
:"$temp=~ s/ /i" what ?
:to give me a $temp that eq "key"
check out
perldoc -f uc
perldoc -f lc
perldoc -f ucfirst
perldoc -f lcfirst
So the simple way is
$temp = lc($temp);
Just to round out your request, not that it is very useful:
$temp = "KEY";
$temp =~ s/([A-Z]+)/lc($1)/e;
HTH
AmD
------------------------------
Date: Wed, 03 Feb 1999 23:53:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie ?
Message-Id: <2k5u2.58$_E3.4792@nsw.nnrp.telstra.net>
In article <79aivk$55j$1@nnrp1.dejanews.com>,
dmeilinger@cng.dl.nec.com writes:
> I am trying to get a string match to change the case of an input
> string, i.e. change an occurance of 'KEY' to 'key' or vice versa.
> I don't want to match any case (/i) but want to substitute an upper
> case letter for its lower, etc.
# perldoc -f uc
# perldoc -f lc
You could also read perlfaq4:
# perldoc perlfaq4
How do I capitalize all the words on one line?
The recipes there can be easily translated to lowercase.
> "$temp=~ s/ /i" what ?
$temp = "\L$temp";
Martien
--
Martien Verbruggen |
Interactive Media Division | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd. | things get worse.
NSW, Australia |
------------------------------
Date: Wed, 3 Feb 1999 13:43:16 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: newbie having trouble with concatination
Message-Id: <x3yemo7mipn.fsf@tigre.matrox.com>
slinberg@crocker.com (Steve Linberg) writes:
> > : > $line =~ /\s*(\S+.*)$/; # this gets rid of tab at the start and \n
^^^
no \s*
> > : Your .* matches everything to the end of the string.
> >
> > No, it doesn't match the newline at the end of the string,
> > which, I believe, was the whole point :-)
>
> It doesn't?
Of course not! unless you use the /s modifier, which he doesn't use.
> $line =~ s/\s*(.*?)\s*$/$1/;
^^^
^^^
this \s* matches the \n character.
>
> Looks like it matched the newline to me. "." matches everything, right?
No! The newline was matched by the \s* which you have in your regexp,
but which is not in the original poster's regexp. Try removing it and
running you little test case again. Better still, have another look at
perldoc perlre.
> Memo to self: reread the FAQ once a month. Things slip out.
Good memo. Circulate.
Ala
------------------------------
Date: Wed, 03 Feb 1999 17:46:12 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: perl newbie: need help pasing web forms
Message-Id: <36B8DFC4.D3118EBA@us.ibm.com>
Michael Nanfito wrote:
> I have a script to parse web forms. It works fine except for
> characters such as commas (,) and slashes (/). Takes text
> fine and outputs it ok. But I want to collect some URLS
> from people. This is what I get:
>
> You suggested the URL: http%3A%2F%2Fwww.ups.edu
>
> Here is the script I am using:
You will save yourself hours of drudgery with your current problem, and
many others by using the CGI.pm module. It is the de-facto standard by
which Perl-based CGI programs are (should be) written.
http://stein.cshl.org/WWW/software/CGI/cgi_docs.html
And of course:
www.perl.com
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Wed, 03 Feb 1999 23:46:30 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: problem forking with perl: child sometimes dies
Message-Id: <qd5u2.52$_E3.4792@nsw.nnrp.telstra.net>
In article <79aj29$57g$1@nnrp1.dejanews.com>,
k2k2@my-dejanews.com writes:
> In article <F6K3qv.Gx@news.boeing.com>,
> ced@bcstec.ca.boeing.com (Charles DeRykus) wrote:
>>
>> $SIG{HUP} = 'IGNORE' # add to child
>
> Hmm. Nope, that doesn't seem to make any difference... any other ideas?
Yes. Not quoting all the text of a message when it is not appropriate,
and certainly not quoting the signature.
You seem to be working with an old version of perl. 5.004_01 is old,
even though it doesn't _seem_ too different from 5.004_04. I doubt
very much that anyone here has that version of perl still installed to
see if they can reproduce the bug. It may be a problem with that
version of perl. It may be a problem that existed in your system's C
libraries when that perl was compiled. It may be a difference in the
configuration of the two perls.
# perl -V
should give you more information about how it was configured, and for
what OS it was built (version, architecture, etc). Maybe you could
check those to see if there were differences. If not, my guess is it
could be a bug in perl 5.004_01. Install a newer version. It's long
overdue.
Without logging in to those machines, I don't think there's much else
I can tell you.
Martien
--
Martien Verbruggen |
Interactive Media Division | 75% of the people make up 3/4 of the
Commercial Dynamics Pty. Ltd. | population.
NSW, Australia |
------------------------------
Date: Wed, 03 Feb 1999 23:22:58 GMT
From: anna@water.ca.gov
Subject: Q: extracting tables from HTML document?
Message-Id: <79aloa$7ci$1@nnrp1.dejanews.com>
This is probably easy but my brain is feeling a bit toasty. I'm trying to
extract anything between <table> ... </table> from an HTML document including
the table tags and leave any other HTML tags that I might find in the
document.
Essentially, I'm looking to lift entire tables from an HTML document. Any
comments on the code below?
For starters, I'd start here:
$summaryIn = "SUMMARY.html";
open(SUMMARY, "<$summaryIn") || die "\nCan't open file: $!\n";
while ($html = <SUMMARY>) {
($junk, $table, $junk2) = split(/table/,$html);
}
print "<table${table}>\n";
close(SUMMARY) || die "\nCan't close file: $!\n";
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 3 Feb 1999 18:49:21 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: Read emails from a perl program
Message-Id: <lg5u2.494$L1.9490@nntp1.nac.net>
dragnovich@my-dejanews.com wrote in message
<79ai4m$4ie$1@nnrp1.dejanews.com>...
:Hello folks!
:I want to make a program that will be residing under my FreeBSD server. This
:program will do this simple task:
:Stay on the server crontab, if a NEW email comes to my account it detects it!
:get the Sender data and subject of the email (not marking it as readed) and
:send this data to me, to tell me that I have a mail! =-) Lets say to my ICQ,
:or to my chat channel or to my AOL Instant Mesenger or if IM REALY, REALY
:NOT ONLINE to my pager! (Yea.. Yea.. there are MANY applications that do
:thing like this.. but I want to do it by the hard way programming it my self,
:OK!) =-)
:Well I know How to do the send data part! but How can I detect that a new
mail has arrived? how to read the From : camp and the Subject : camp ?? That's
all :that I need!
Modules are your friend, see Mail:POP3Client.
Here is snippet from a program I use, it should get you started.
#!/usr/local/bin/perl -w
use strict;
use Mail::POP3Client;
my $pop = new Mail::POP3Client("account", "password", "pop3.domain.tdl");
for (my $i = 1; $i <= $pop->Count; $i++) {
print "$i) ";
foreach ($pop->Head($i)) {
/^(From|Subject): / and print $_, "\n";
}
print "\n";
}
HTH
AmD
------------------------------
Date: 3 Feb 1999 23:22:29 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Regex for e-mail addresses?
Message-Id: <79alnl$pg7$1@news.NERO.NET>
In article <797jou$64e$1@news1.Radix.Net>,
Ed Hitler <revjack@radix.net> wrote:
>Let me rephrase the question.
>...
>What I'm after is, "the stuff on either side of the @ sign, but not
>brackets or parentheses".
Let's rephrase the question based on what you want to accomplish. You
want to count the number of articles posted by user, as I recall, or
number of users, or something like that. Something to do with the
number of unique addresses. You don't need to split out the email
address to do this, you already have a string with the information in
it.
Most people do not change their From: header when they post, so they
will be the same each time. If making sure that minor changes do not get
counted as a new person, then you need to explain how you will keep from
counting different email addresses for the same person as more than one
person.
------------------------------
Date: 3 Feb 1999 23:47:53 GMT
From: Ed Hitler <revjack@radix.net>
Subject: Re: Regex for e-mail addresses?
Message-Id: <79an79$3js$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
John Stanley explains it all:
:Let's rephrase the question based on what you want to accomplish. You
:want to count the number of articles posted by user, as I recall, or
:number of users, or something like that. Something to do with the
:number of unique addresses. You don't need to split out the email
:address to do this, you already have a string with the information in
:it.
Well, what I really *really* wanted to accomplish was determining a
regex that will pull an e-mail address from any arbitrary line of text.
Thanks to Larry Rosler for providing just what I needed, and for taking
the time to explain it in detail.
FYI, I generally change my From: header every time I log on, no reason
except perversity. (I'm leaving it unchanged in this thread so as not to
confuse anyone).
:Most people do not change their From: header when they post, so they
:will be the same each time. If making sure that minor changes do not get
:counted as a new person, then you need to explain how you will keep from
:counting different email addresses for the same person as more than one
:person.
It would probably be amusing to observe attempts to compel this
explanation.
Thanks for the followup.
--
/~\ ninetieth relict whet upwind candle Syria morsel post Hayden La
C oo Neanderthal ammoniac Gwyn ASTM normalcy broach Benedict isingla
_( ^) 1 , 0 0 0 , 0 0 0 m o n k e y s c a n ' t b e w r o n g
/___~\ http://3509641275/~revjack 02/03/99 18:42:38 revjack@radix.net
------------------------------
Date: Wed, 03 Feb 1999 23:17:50 GMT
From: lamj@softhome.net
Subject: Searching for char in a string
Message-Id: <79alem$72a$1@nnrp1.dejanews.com>
I have been looking for the most efficient way to find if there are any a-z
and A-Z characters in a string variable $abc but without success. Can anyone
please tell me the best way to do such a search?
Jason Lam
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 3 Feb 1999 17:05:09 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Searching for char in a string
Message-Id: <5nka97.1t1.ln@magna.metronet.com>
lamj@softhome.net wrote:
: I am looking for a way to find if there are any a-z and A-Z character in a
: variable $abc. I have been trying to find to most efficient way to do it but
: without success, can anyone guide me to the best way to do it?
print "found a letter in '$abc'\n" if $abc =~ tr/a-zA-Z//;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 03 Feb 1999 22:11:22 GMT
From: tNOchurch@gmuSPAM.eduALLOWED (Timothy Church)
Subject: select and detecting FTP in process
Message-Id: <36b8c90e.26492145@news.newsguy.com>
I am trying to monitor a directory to see if files have been input via
ftp. If files are present, I need to know if an ftp is inprocess.
I have been trying to use the select statement to do this. Does
anyone have example code they could point me at?
------------------------------
Date: Wed, 3 Feb 1999 13:37:30 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Simple Perl Script
Message-Id: <x3yg18nmiz9.fsf@tigre.matrox.com>
Stuart Lester <gt3511a@prism.gatech.edu> writes:
> Does anyone happen to know how to get perl to do the following (when
> passed a filename and string):
> Search the entire file <filename> for the string. When found the ENTIRE
> line is deleted. Repeat for all instances of <string>.
It depends on your notion of what a "line" is. But for the default
case, where a line is a string terminated with a carriage return,
something like that would work:
% perl -ne 'print unless /PATTERN/' file > newfile
Otherwise, you might want to adjust the value of $/ according to your
needs.
Ala
------------------------------
Date: Wed, 03 Feb 1999 23:02:01 +0000
From: Aidan Rogers <aidan@crucibledesign.com>
Subject: The best way to learn C?
Message-Id: <36B8D569.14C64624@crucibledesign.com>
Before anyone sends me deragtory flame messages, I am fully aware that
this is
the Perl newsgroup.
I am a Perl programmer, and it is the only language I really know (and
love). However, I want to learn how to program in C (and eventually
C++), for
the usual job related reasons. Can anyone who has taught themselves
recommend
a way to go about it? Is there a good book on the subject (like the
Camel book
is to Perl)? The reason I'm asking on the ng is because I want the
answer from a
fellow Perl programmer, someone who knows the Perl frame of mind, and so
can recommend a better way than someone who only programs in C.
Thanks (for your patience, and in advance for your help),
Aidan Rogers
------------------------------
Date: Wed, 03 Feb 1999 15:47:19 -0800
From: stevel@coastside.net (Steve Leibel)
Subject: Re: The best way to learn C?
Message-Id: <stevel-0302991547190001@192.168.100.2>
In article <36B8D569.14C64624@crucibledesign.com>, Aidan Rogers
<aidan@crucibledesign.com> wrote:
> Before anyone sends me deragtory flame messages, I am fully aware that
> this is
> the Perl newsgroup.
>
> I am a Perl programmer, and it is the only language I really know (and
> love). However, I want to learn how to program in C (and eventually
> C++),
If you are already a programmer, then by far the best book on C is "The C
Programming Language" by Kernighan and Ritchie. Make sure you get the 2nd
edition (ANSI version).
This book is a little difficult for a complete beginner; but for a
programmer, this is the way to go. Start at page 1, take your time, and
spend a few months with this book. You'll never regret it. In fact it
will make you a better Perl programmer. After all, Perl is written in C,
right?
Steve L
stevel@coastside.net
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4819
**************************************