[7490] in Perl-Users-Digest
Perl-Users Digest, Issue: 1116 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 2 16:18:35 1997
Date: Thu, 2 Oct 97 13:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 2 Oct 1997 Volume: 8 Number: 1116
Today's topics:
Re: A Tricky Question!! <chris_braiotta@harvard.edu>
Re: A Tricky Question!! <rootbeer@teleport.com>
Re: associative arrays prob (Jon Orwant)
Re: Bigtime Newbie needs a teeny bit of help . . . (Andrew M. Langmead)
Can somebody help? <huang@scra.org>
Re: Can somebody help? (brian d foy)
Re: Can somebody help? huang@scra.org
Re: Can somebody help? (Jeremy D. Zawodny)
DBD::Oracle and Perl5.004_03 - dumps core <chris@ixlabs.com>
Re: Deleting duplicates in an array (Terry Michael Fletcher - PCD ~)
Re: fflush... <jay@rgrs.com>
Re: HTML->RTF ? <usenet-tag@qz.little-neck.ny.us>
ioctl (Markus Borbely)
Making a PL file and/or distributing a program <clark@s3i.com>
Re: MSQL interface (brian d foy)
msqlperl (David Siebert)
Re: Net::FTP doesn't seem to work... (M.J.T. Guy)
Re: Newbie ques: How to concatenate two strings? <ksimonds@graphicaldynamics.com>
NT Registry SerialNumber wrong <wdawes@solacomm.com>
Re: NT Registry SerialNumber wrong <Jan.Krynicky@st.mff.cuni.cz>
Re: NT Registry SerialNumber wrong <wdawes@solacomm.com>
Number of Emails? <salewel@ncfcomm.com>
Re: Number of Emails? <yash@teczar.com>
Re: Number of Emails? (Matthew Cravit)
Re: Number of Emails? (brian d foy)
Perl Newbie *PLease help* (Raven)
Re: Perl to Java Compiler? moc.cnioro@sfd.strip.this.and.reverse
Signal handling through CGI <fussy@mpinet.net>
Re: Strip spaces in filenames <mouse@sirca.usyd.edu.au>
Re: Strip spaces in filenames (Floyd Pierce)
Trying to install modules FCGI <kinlam@mec.cuny.edu>
Re: Trying to install modules FCGI (brian d foy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 02 Oct 1997 14:48:50 -0500
From: Chris Braiotta <chris_braiotta@harvard.edu>
Subject: Re: A Tricky Question!!
Message-Id: <3433FA9F.3E2AD2AD@harvard.edu>
Claudia Ma wrote:
> I can't figure out how to make the program "click the submit", and wonder if
> this could be done in Perl.
>
You don't have to "click the submit" if you just decode the get statement of the
search engine you're using. That is, when you submit your query to say,
altavista, it generates a very ugly url, with your query embedded in it. Just
decode that, plug it in, and send it off. It's a relatively simple matter to
parse the results.
Even in Java.
Chris Braiotta
chris_braiotta@harvard.edu
------------------------------
Date: Thu, 2 Oct 1997 12:21:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Claudia Ma <maclaudi@cps.msu.edu>
Subject: Re: A Tricky Question!!
Message-Id: <Pine.GSO.3.96.971002122021.698C-100000@usertest.teleport.com>
On 2 Oct 1997, Claudia Ma wrote:
> Subject: A Tricky Question!!
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> I can't figure out how to make the program "click the submit", and
> wonder if this could be done in Perl.
Perl can request remote web pages, if that's what you want. Try the LWP
module. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 02 Oct 1997 16:01:04 GMT
From: orwant@fahrenheit-451.media.mit.edu (Jon Orwant)
To: webadmin <webadmin@prestel.net>
Subject: Re: associative arrays prob
Message-Id: <ORWANT.97Oct2120104@fahrenheit-451.media.mit.edu>
webadmin <webadmin@prestel.net> writes:
I have an associative array which takes in details from a form
$in{'name1'}
$in{'name2'}
$in{'name3'}
$in{'name4'}
etc etc
I want to write these details contained with out to a file.
But I want to do it using a for loop rather than writing exh one out
individually
But I cant figure it out
for ($x=1; $x<=6; $x++)
{
print FILE $in{'name$x'};
}
does not work or any other formation, is there a way around it, or do I
just have to use the longwinded route.
Your single quotes don't replace the $x with its value. Try double quotes.
-Jon
------------------------------------
Jon Orwant http://tpj.com
Editor & Publisher, The Perl Journal
------------------------------
Date: Thu, 2 Oct 1997 19:23:22 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Bigtime Newbie needs a teeny bit of help . . .
Message-Id: <EHFv6y.2vs@world.std.com>
rama@rely.com (Rama Polefka) writes:
>i have a simple problem -
>i need to run a series of commands at specified intervals to trigger a
>mail flush. the series of commands is as follows:
>telnet secondary-mx.xxx.net 25
>etrn#mydomain.com
>quit
The first thing to be aware of, is that you don't need to run a
"telnet" program, you just need to open a TCP connection to the remote
host. Since perl has all sorts of networking fascilities built in, you
might want to use perl directly.
use IO::Socket;
my $sock = new IO::Socket::INET PeerAddr => 'secondary-mx.xxx.net:smtp(25)',
Proto => 'tcp';
die "socket error: $!\n" unless $sock;
print $sock "etrn#mydomain.com\nquit\n";
See the TCP client section of the perlipc man page for details.
For the "execute at a regular interval" part, you might want to use
the fascilities built into NT for timed execution. If that does not
suit you for some reason, then take a look at the "time" and "sleep"
calls. time() will return the current time, (useful for determining
how much time there is between now and some future or past time.) and
sleep() will block execution for a cetain number of seconds. You might
want to throw in stuff like localtime() (takes a time in the format of
the time() function and returns month/day/year/hours/mins/secs/etc.)
and the Time::Local modules (which does the reverse.)
--
Andrew Langmead
------------------------------
Date: Thu, 2 Oct 1997 12:14:04 -0400
From: Yong Huang <huang@scra.org>
Subject: Can somebody help?
Message-Id: <3433C84E.AD7@scra.org>
Why is nothing printed from this script? Thanks for help.
#!/usr/local/bin/perl
$_ = "c:\q.htm";
m/\\/;
print $`."\n"; #expected c:
print $&."\n"; #expected \
print $'."\n"; #expected q.htm
------------------------------
Date: Thu, 02 Oct 1997 12:35:00 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Can somebody help?
Message-Id: <comdog-ya02408000R0210971235000001@news.panix.com>
In article <3433C84E.AD7@scra.org>, huang@scra.org wrote:
>Why is nothing printed from this script? Thanks for help.
>
>#!/usr/local/bin/perl
>$_ = "c:\q.htm";
>m/\\/;
>print $`."\n"; #expected c:
>print $&."\n"; #expected \
>print $'."\n"; #expected q.htm
because there was no match?
i'll anticipate your next question - "why was there no match?"
try
print $_, "\n";
and see what that string really contains. remember, avoiding
double quotes except when you want interpolation saves a lot
of hassle. :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 2 Oct 1997 17:23:54 GMT
From: huang@scra.org
Subject: Re: Can somebody help?
Message-Id: <610lba$2l7$1@news.tamu.edu>
I got help from somebody else. He asked me to escape \ in "c:\q.htm".
Now the question is, if "c:\q.htm" is user input and I do want c:, \, and
q.htm. Use split? I tried and it didn't work. Add a \ to make the original
string "c:\\q.htm"? Thank you for your help.
Yong
------------------------------
Date: Thu, 02 Oct 1997 17:40:33 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Can somebody help?
Message-Id: <3435dc80.79500896@igate.hst.moc.com>
[cc'd automagically to original author]
On 2 Oct 1997 17:23:54 GMT, huang@scra.org wrote:
>I got help from somebody else. He asked me to escape \ in "c:\q.htm".
>Now the question is, if "c:\q.htm" is user input and I do want c:, \, and
>q.htm. Use split?
No.
>I tried and it didn't work. Add a \ to make the original
>string "c:\\q.htm"? Thank you for your help.
Yes.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Thu, 02 Oct 1997 12:15:58 -0700
From: Chris Schoenfeld <chris@ixlabs.com>
To: dbi-users@fugue.com
Subject: DBD::Oracle and Perl5.004_03 - dumps core
Message-Id: <3433F2EE.2171@ixlabs.com>
I recently attempted to install DBD::Oracle 0.47 on a Sparc 20 Solaris
2.5 machine with perl 5.004_03 and DBI 0.90.
I get the following errors:
On perl Makefile.PL:
'COMPRESS' is not a known MakeMaker parameter name.
'SUFFIX' is not a known MakeMaker parameter name.
On make test:
t/base..............dubious
Test returned status 0 (wstat 139)
test program seems to have generated a core
after all the subtests completed successfully
t/plsql.............Unable to connect to Oracle (ORA-1034: ORACLE not
available)
dubious
Test returned status 0 (wstat 139)
test program seems to have generated a core
In addition, all our Oracle production scripts (which use earlier
versions of DBD, DBI, perl) work fine on the old perl but dump core with
the new perl. ALl other perl scripts seem OK.
Has anyone else experienced this?
Chris
------------------------------
Date: 2 Oct 1997 16:11:07 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: Deleting duplicates in an array
Message-Id: <610h2r$78v$1@news.fm.intel.com>
Mark Chaffee (chaffee@cpdmfg.cig.mot.com) so eloquently and verbosely pontificated:
> Is there a built in function to delete duplicates in an array? If not,
> what would be the easiest way to perform this operation?
this happens to be a(n) FAQ.
since there are several ways already listed there, ill just point you to it.
it is in perlfaq4, under DATA:Arrays, "How can I extract just the unique
elements of an array?"
http://www.perl.com/perl/faq
by the way, if you have time, you should read the whole thing, there are *lots*
of good tips in there!
Hope that helps!
--
#!/usr/local/bin/perl -- tfletche@pcocd2.intel.com
map{$;.=chr$_}(112,114,105,110,116,32,117,110,112,97,99,107,32,34,117,
34);$_=$;.=q>,':2G5S="!A;F]T:&5R(%!E<FP@:&%C:V5R+`H`'>;y[\034]{}d;eval
------------------------------
Date: 02 Oct 1997 13:57:44 -0400
From: Jay Rogers <jay@rgrs.com>
To: Chris Gerber <gerberc@cs.uregina.ca>
Subject: Re: fflush...
Message-Id: <827mbw82uf.fsf@shell2.shore.net>
Chris Gerber <gerberc@cs.uregina.ca> writes:
> Hi, I was wondering if anyone knows a way to flush a file buffer from
> within perl. There doesn't appear to be any built-in function that does
> this, and neither fcntl or ioctl will let me do a flush either.
For perl5.003 or less see POSIX.pm
For perl5.004 or greater see IO::Handle
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: 2 Oct 1997 17:07:33 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: HTML->RTF ?
Message-Id: <eli$9710021304@qz.little-neck.ny.us>
Chris Nandor <pudge@pobox.com> wrote:
> Anyone got something to convert HTML to RTF or Word or something? Can't
> seem to find anything ...
There is an HTML module at CPAN that can convert HTML to plain text,
IIRC. Can't seem to find anything (perl or not perl) to do anything
with RTF.
Elijah
------
would like an rtf -> plain text converter
------------------------------
Date: 2 Oct 1997 19:42:01 GMT
From: e95mbo@efd.lth.se (Markus Borbely)
Subject: ioctl
Message-Id: <610te9$72v$1@news.lth.se>
Hi!
I'd be happy if anyone can point me out to the module I
need. I'm working in X and need to read one single
character at a time. And in non canonical mode... So the
user don't need to press return after every single keystroke.
A second wish is to write out characters in a textwindow
something like write(x,y,$string)
I don't have the deep knowledge about unix ioctl I wish
and this may be the place to start... (If I find the
package I need)
Oh yeah... if you you say CPAN or RTFM, then don't say it... :)
thanx in advance...
_____________________________________________________
/ \ \
|__| Markus Borbely +46(0)46-39 73 55 |
| e95mbo@efd.lth.se Magistratsvdgen 57M12 |
| www.efd.lth.se/~e95mbo/ 22644 Lund ____ |
| _______________________________________/ __ \____|_
\/______________________________________| (__) |____/
\____/
| |
| |
|/\|
------------------------------
Date: 02 Oct 1997 14:23:01 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Making a PL file and/or distributing a program
Message-Id: <dbu18xbwa.fsf@s3i.com>
Greetings
I will be distributing a perl program to several of my co-workers.
Because of the way that my system is set up, I have as the first line of my
perl script;
#!/home/dorman/bin/perl
(Don't worry, in the development process, I use the -w).
In any case, I know that this is incorrect for my co-workers, who work on
other machines, and their perl can be just about anywhere.
How do I make a version of the program, similar to the one in libwww, with a
.PL extension, that produces the local working version (with the appropriate
first line)?
After looking at MakeMaker and h2xs, I am just confused rather than
enlightened.
--
Clark
------------------------------
Date: Thu, 02 Oct 1997 12:25:09 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: MSQL interface
Message-Id: <comdog-ya02408000R0210971225090001@news.panix.com>
In article <Pine.SOL.3.91.971002124924.6390A-100000@frodo.student.gu.edu.au>, "PRASHANTH N.R. RAGHAVENDRA RAO" <s1095261@frodo.student.gu.edu.au> wrote:
>I am a novice perl programmer trying to interface msql to www.
>I am able to insert, search and display records. But I am not able to
>delete or update the database. When I modify the name in the textfield,
>nothing happens when I reload. I am putting the code I am using below
have you checked the database to see if the update was preformed? try
using the msql monitor to issue commands to the database directly. if
you are able to determine that the database was not updated, then start
looking at what might have happened in the code.
good luck :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 2 Oct 1997 17:47:37 GMT
From: dsiebert@gate.net (David Siebert)
Subject: msqlperl
Message-Id: <610mnp$4t0$1@news.gate.net>
I am looking for documentation for msqlperl. Anybody got any???? of a
location I can get it?
------------------------------
Date: 2 Oct 1997 16:37:29 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Net::FTP doesn't seem to work...
Message-Id: <610ik9$l7o$1@lyra.csx.cam.ac.uk>
Jay Flaherty <fty_no_spam@utk.edu> wrote:
>2. put some error trapping routines in. ie:
>
>$ftp{$host}->login("LoginName","LoginPassword")
>or die "Unable to log into $ftp{$host}: !$\n";
^^
I presume you mean $!. Otherwise good advice.
>$ftp{$host}->get($fullfile, "./$file")
>
>or die "Unable to get file $fullfile: !$\n"
^^
And here.
Mike Guy
------------------------------
Date: Thu, 2 Oct 97 17:35:01 GMT
From: "Koll Simonds" <ksimonds@graphicaldynamics.com>
Subject: Re: Newbie ques: How to concatenate two strings?
Message-Id: <610m06$250$2@brokaw.wa.com>
> >Perhaps you shouldn't modify a program in any language if you
> >don't know the language.
>
> That wasn't the advice I asked, Abigail, but thanks anyway.
>
> >"Hey Doc, this has GOT to be the ultimate newbie question, but I don't
> > know medication, and I need to fix the lung I'm dealing with while
> > operating on my kid."
>
> I'm sorry, Abs, I didn't know you owned this newsgroup.
Ah, you grovel and genuflect to those who know more (the perl way) and you
still get your chops busted for asking a newbie question. Perhaps those of
us who don't live the language should search for a newsgroup such as:
comp.lang.perl.unwashed
comp.lang.perl.not-elite
comp.lang.perl.pagans
Makes Microsoft seem downright warm & fuzzy.
Koll in Seattle
------------------------------
Date: Thu, 02 Oct 1997 11:16:53 +0000
From: Will Dawes <wdawes@solacomm.com>
Subject: NT Registry SerialNumber wrong
Message-Id: <34337495.7A7@solacomm.com>
I'm using build 310 of Perl-Win32 to set NT4 Registry values. So far,
everything is able to be set except for the SerialNumber subkey. When I
do the following:
SetValueEx("SerialNumber",$nullval,REG_BINARY,"0");
I get the following Registry entry:
SerialNumber:REG_BINARY: 30
After some experimentation, I discover that the ASCII character map is
being used: "0" is /x30, "1" is /x31, ... , "z" is /x7b. Knowing this,
however, will not help me set the SerialNumber for a DDE Trused Share to
"08 00 00 09 00 00 00 01". How to I do this?
Is this a Perl-Win32 Registry.pm bug? Microsoft Registry feature?
--
Will Dawes/ Systems Engineer
SOLA Communications, Inc., Lafayette, Louisiana
(318) 268-4393/ email: wdawes@solacomm.com
------------------------------
Date: Thu, 02 Oct 1997 19:35:42 -0700
From: Jan Krynicky <Jan.Krynicky@st.mff.cuni.cz>
To: wdawes@solacomm.com
Subject: Re: NT Registry SerialNumber wrong
Message-Id: <343459FD.6DCC@st.mff.cuni.cz>
Will Dawes wrote:
>
> I'm using build 310 of Perl-Win32 to set NT4 Registry values. So far,
> everything is able to be set except for the SerialNumber subkey. When I
> do the following:
> SetValueEx("SerialNumber",$nullval,REG_BINARY,"0");
> I get the following Registry entry:
> SerialNumber:REG_BINARY: 30
>
> After some experimentation, I discover that the ASCII character map is
> being used: "0" is /x30, "1" is /x31, ... , "z" is /x7b. Knowing this,
> however, will not help me set the SerialNumber for a DDE Trused Share to
> "08 00 00 09 00 00 00 01". How to I do this?
> Is this a Perl-Win32 Registry.pm bug? Microsoft Registry feature?
>
> --
> Will Dawes/ Systems Engineer
> SOLA Communications, Inc., Lafayette, Louisiana
> (318) 268-4393/ email: wdawes@solacomm.com
None of them. You have to use pack() or a string
of characters with the codes with REG_BINARY.
Try:
SetValueEx("SerialNumber",$nullval,REG_BINARY,pack('C1',0));
or
SetValueEx("SerialNumber",$nullval,REG_BINARY,"\x00");
the other example would be :
SetValueEx("SerialNumber",$nullval,REG_BINARY,pack('C8',08,00,00,09,00,00,00,01));
#(the values are in decimal)
or
SetValueEx("SerialNumber",$nullval,
REG_BINARY,pack('C8',0x08,0x00,0x00,0x09,0x00,0x00,0x00,0x01));
#(the values are in hexadecimal)
or
SetValueEx("SerialNumber",$nullval,
REG_BINARY,"\x08\x00\x00\x09\x00\x00\x00\x01"
);
HTH, Jenda
------------------------------
Date: Thu, 02 Oct 1997 14:03:12 +0000
From: Will Dawes <wdawes@solacomm.com>
Subject: Re: NT Registry SerialNumber wrong
Message-Id: <34339B90.7F04@solacomm.com>
Will Dawes wrote:
>
> I'm using build 310 of Perl-Win32 to set NT4 Registry values. So far,
> everything is able to be set except for the SerialNumber subkey. When I
> do the following:
> SetValueEx("SerialNumber",$nullval,REG_BINARY,"0");
> I get the following Registry entry:
> SerialNumber:REG_BINARY: 30
>
> After some experimentation, I discover that the ASCII character map is
> being used: "0" is /x30, "1" is /x31, ... , "z" is /x7b. Knowing this,
> however, will not help me set the SerialNumber for a DDE Trused Share to
> "08 00 00 09 00 00 00 01". How to I do this?
> Is this a Perl-Win32 Registry.pm bug? Microsoft Registry feature?
>
> --
> Will Dawes/ Systems Engineer
> SOLA Communications, Inc., Lafayette, Louisiana
> (318) 268-4393/ email: wdawes@solacomm.com
>>
>> On 10/2/97 Jan Krynicky <Jan.Krynicky@st.ms.mff.cuni.cz> replied :
>>
None of them. You have to use pack() or a string
of characters with the codes with REG_BINARY.
Try:
SetValueEx("SerialNumber",$nullval,REG_BINARY,pack('C1',0));
or
SetValueEx("SerialNumber",$nullval,REG_BINARY,"\x00");
the other example would be :
SetValueEx("SerialNumber",$nullval,REG_BINARY,pack('C8',08,00,00,09,00,00,00,01));
#(the values are in decimal)
or
SetValueEx("SerialNumber",$nullval,
REG_BINARY,pack('C8',0x08,0x00,0x00,0x09,0x00,0x00,0x00,0x01));
#(the values are in hexadecimal)
or
SetValueEx("SerialNumber",$nullval,
REG_BINARY,"\x08\x00\x00\x09\x00\x00\x00\x01"
);
HTH, Jenda
>>>
>>> On 10/2/97, Will Dawes replied
>>> Thanks Jan/Jenda, it worked!
>>>
------------------------------
Date: 2 Oct 1997 18:47:38 GMT
From: "Spencer Alewel" <salewel@ncfcomm.com>
Subject: Number of Emails?
Message-Id: <01bccf64$be680aa0$16b84dcc@flax.ncfcomm.com>
I'm just starting to learn Perl and I was wondering if someone could pass
some hints on as to how to count the number of emails that a particular
individual or account has.
------------------------------
Date: Thu, 02 Oct 1997 15:14:04 -0400
From: Yash Khemani <yash@teczar.com>
To: Spencer Alewel <salewel@ncfcomm.com>
Subject: Re: Number of Emails?
Message-Id: <3433F27C.431B3FEC@teczar.com>
Spencer Alewel wrote:
>
> I'm just starting to learn Perl and I was wondering if someone could pass
> some hints on as to how to count the number of emails that a particular
> individual or account has.
i assume you mean for a unix mailbox...
i also assume this is a learning exercise, since many such
implementations
exist in perl.
you need to be aware of two things:
- using regular expressions in perl
- RFC822 describing mail header formatting
start with that, and hollar if you have questions...
yash
------------------------------
Date: 2 Oct 1997 12:21:47 -0700
From: mcravit@best.com (Matthew Cravit)
Subject: Re: Number of Emails?
Message-Id: <610s8b$p0a$1@shell3.ba.best.com>
In article <01bccf64$be680aa0$16b84dcc@flax.ncfcomm.com>,
Spencer Alewel <salewel@ncfcomm.com> wrote:
>I'm just starting to learn Perl and I was wondering if someone could pass
>some hints on as to how to count the number of emails that a particular
>individual or account has.
This is not a Perl-specific question, really, but it can be easily done in
Perl. The approach I have used for this, which seems to work for UNIX mail
spool files, is something like this:
#!/usr/bin/perl
use IO::File;
$count = 0;
$fh = new IO::File "/var/mail/user";
if (defined $fh) {
while (<$fh>) {
$count++ if ($_ =~ m/^From /);
}
undef $fh;
} else {
die("Could not open mail spool file: $!\n");
}
print "The mail file had $count messages in it.\n";
exit 0;
__END__
Hope this helps.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@taos.com (work) | time you make it.
------------------------------
Date: Thu, 02 Oct 1997 15:46:44 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Number of Emails?
Message-Id: <comdog-ya02408000R0210971546440001@news.panix.com>
In article <610s8b$p0a$1@shell3.ba.best.com>, mcravit@best.com (Matthew Cravit) wrote:
>In article <01bccf64$be680aa0$16b84dcc@flax.ncfcomm.com>,
>Spencer Alewel <salewel@ncfcomm.com> wrote:
>>I'm just starting to learn Perl and I was wondering if someone could pass
>>some hints on as to how to count the number of emails that a particular
>>individual or account has.
> while (<$fh>) {
> $count++ if ($_ =~ m/^From /);
> }
so what happens with "From"'s embedded in the email text and happen to
be right after an $INPUT_RECORD_SEPARATOR? $count will only be the
greatest lower bound - not necessarily the number of email messages.
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 2 Oct 1997 18:59:00 GMT
From: u9556974@qub.ac.uk (Raven)
Subject: Perl Newbie *PLease help*
Message-Id: <610qtk$bij$1@fu-berlin.de>
Hi.
I started programming in Perl about 3 days ago.
Atm, I am trying to write a script that will fetch all the links
from a page that stay on that server...specifically yahoo..., and
then go into each of those links and do the same for the pages they lead to.
#!usr/local/bin/perl -w
use strict;
use LWP::UserAgent;
my ($request, $ua, $response);
open(YAHOO, 'yahoo.scifi') || die "Couldn't open file: $!\n";
open(NEWYAHOO, 'newyahoo.scifi') || die "Couldn't open output file: $!\n";
while (<NEWYAHOO>) {
while (m#\/.*\/#) {
print "found $& ";
$ua = new LWP::UserAgent;
$request = new HTTP::Request 'GET', "http://www.yahoo.co.uk$&";
$response = $ua->request($request, 'yahoo.scifi');
while (<YAHOO>) {
next unless (/<HR>/i);
while (<YAHOO>) {
next if $_ =~ /(gopher:|ftp:|http:|muds)/i;
next unless $_ =~ /href/i;
open(NEWYAHOO, '>>newyahoo.scifi');
print NEWYAHOO;
print "added $_";
}
}
}
}
exit;
that's my code
now, in newyahoo.scifi is the http: reference to the first page.
what should happen is that it reads the reference, and goes to the page.
this bit works fine.
then it should append all the links that don't go off site onto newyahoo
.scifi, the first new link should be checked, and all its links be added,
and so on.
but it doesn't work!!!
can someone who understands all this stuff better than me please explain
what I am doing wrong, and how I can correct it, cos its driving me
mental!
Thanks in advance
Aidan
------------------------------
Date: 2 Oct 1997 12:53:51 -0400
From: moc.cnioro@sfd.strip.this.and.reverse
Subject: Re: Perl to Java Compiler?
Message-Id: <610jiv$sm@obiwan.oroinc.com>
In article <342de16b.9295342@news.tornado.be>,
Bart Lateur <bart.mediamind@tornado.be> wrote:
>eric.arnold@sun.com (Eric Arnold) wrote:
>
>>I wonder if it would be kosher to suggest to the Java folks to add a
>>Perl5 style regexp package into the Java core? I have no idea whether
>>they would even be interested, but it brings up a general question:
>>what's the process for using Perl code fragments in commercial
>>products? Is there one, or is it prohibited completely by the
>>copyright?
I missed the original article, but anyhow, we produce an independent
implementation of Perl5 regular expressions for Java. You can find
it (OROMatcher) at www.oroinc.com. We also produce a companion package
called PerlTools which wraps the OROMatcher engine, allowing the use
of Perl expressions like s/(foo)(bar)/$2$1/
The software is free for most uses, including the development of commercial
software, because we don't see any reason why you should have to pay
for something in Java that's already free in Perl and other languages
(e.g., TCL, Python, etc.). Netscape uses OROMatcher for the regular
expression support in their Java LDAP SDK and we have many reports of
programmers at Sun Microsystems using the software. We're willing to
work with Sun to make the software a standard part of Java, but we're
probably too small a company to make that happen (see what happened
with ObjectSpace's JGL). In any case, Perl5 regex support for Java
is here, it's free, and it works.
daniel
orororororororororororororororororororororororororororororororororororororo
Daniel F. Savarese moc.cnioro@sfd :liame
ORO, Inc. "Component software for the Internet."tm http://www.oroinc.com/
orororororororororororororororororororororororororororororororororororororo
------------------------------
Date: Thu, 02 Oct 1997 08:07:40 -0400
From: Mike Fussy <fussy@mpinet.net>
Subject: Signal handling through CGI
Message-Id: <34338E8C.461CCC03@mpinet.net>
I'm in the process of writing some cgi programs in perl that are
handling file uploading and doing quite a bit of ipc. Often, the size of
the file(s) uploaded get quite large and I need to do some file and
spawned process cleanup if the user decides to terminate the script
(such as by hitting 'stop' from the browser) prematurely.
Does anyone know which, if any, signal is sent to the process if a user
presses stop from the browser? If not, how can I get this info?
Any help is appreciated.
-- Mike
------------------------------
Date: Wed, 01 Oct 1997 11:10:32 +1000
From: Tim Smithers <mouse@sirca.usyd.edu.au>
Subject: Re: Strip spaces in filenames
Message-Id: <3431A308.26F5@sirca.usyd.edu.au>
Floyd Pierce wrote:
> for i in `find . -name '*.txt' -print`
> > do
> > x=`echo $i|sed 's/\.txt$/\.bak/'`
> > mv $i $x
> > done
>
> Bit more typing but it works.
No It doesn't. The original question involves filenames with spaces.
> --
> Floyd Pierce floydp at xnet.com
> floydp at ix.netcom.com
TRY:
(IFS="";
for i in `find . -type f -name '*.txt' -print`
do
mv $i `echo $i | sed -e 's/\.txt$/.bak/'`
done
)
The IFS="" will stop the for loop splitting words up by spaces,
retaining
the whole line. You need to put it in ()'s, so that your IFS variable is
not set for your normal shell.
P.S: IFS is the Internal Field Seperator. You can set it to anything you
like,
and the shell will split words on those characters.
It is often used to loop through parts of the PATH.
ie: OLDIFS="$IFS"
IFS=":"
for i in $PATH
do
echo "PATH COMPONENT: $i"
done
IFS="$OLDIFS"
-mouse
------------------------------
Date: Thu, 02 Oct 1997 19:14:39 GMT
From: floydp@_REMOVE_xnet.com (Floyd Pierce)
Subject: Re: Strip spaces in filenames
Message-Id: <3433f247.15270177@nntp.ix.netcom.com>
Tim Smithers <mouse@sirca.usyd.edu.au> wrote:
>
> No It doesn't. The original question involves filenames with spaces.
>
Works perfectly for the question I followed up to 17 days ago. If he
dosen't have the answer by now I'm sure he's hung himself.
--
Floyd Pierce floydp at xnet.com
floydp at ix.netcom.com
------------------------------
Date: Thu, 2 Oct 1997 14:28:21 -0500
From: "kinlam" <kinlam@mec.cuny.edu>
Subject: Trying to install modules FCGI
Message-Id: <610t6c$no6@news.cuny.edu>
Hi :
I download a modules(FCGI-0.30) from CPAN. When I try to install it, It
give an error of "perl isn't compiled with perlio/sfio support. I found out
from the REAME file that come with FCGI module that I have to configure perl
with the following option
'./Configure -Duseperlio -Dusesfio'. So, I did, but I get the same error
when try to install it (perl Makefile.PL).
Any comment E-mail or posted will be greatly appreciated.
kin
E-mail : kinlam@mec.cuny.edu
------------------------------
Date: Thu, 02 Oct 1997 15:37:22 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Trying to install modules FCGI
Message-Id: <comdog-ya02408000R0210971537220001@news.panix.com>
In article <610t6c$no6@news.cuny.edu>, "kinlam" <kinlam@mec.cuny.edu> wrote:
> I download a modules(FCGI-0.30) from CPAN. When I try to install it, It
>give an error of "perl isn't compiled with perlio/sfio support. I found out
>from the REAME file that come with FCGI module that I have to configure perl
>with the following option
> './Configure -Duseperlio -Dusesfio'. So, I did, but I get the same error
>when try to install it (perl Makefile.PL).
did you recompile perl after you ran Configure? did it pass all of the
tests? does `perl -V` show that you used the sfio library?
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1116
**************************************