[7966] in Perl-Users-Digest
Perl-Users Digest, Issue: 1591 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 6 19:07:22 1998
Date: Tue, 6 Jan 98 16:00:26 -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 Tue, 6 Jan 1998 Volume: 8 Number: 1591
Today's topics:
Re: "shift @array" question <doug1@net-link.net>
Re: Arrgghhhhh! There must be a simple solution to this <wtansill@erols.com>
Calling Into Perl DLL from Win32 App <andys@nvisual.com>
Re: Can I create a Linked List in Perl (Tad McClellan)
Re: Can I create a Linked List in Perl (Andrew M. Langmead)
Re: form+mail : script <Jan@ChipNET.cz>
Re: How to mimic C's #include "global.pl" <Jan@ChipNET.cz>
Re: I need money [Re: I need a script] <ldaffner@rsn.hp.com>
Ideas for PERL projects <andrew.spiers@virgin.net>
Re: Ideas for PERL projects (brian d foy)
Re: impure embedded perl <*@qz.to>
Re: Lexical scope and embedded subroutines. <tchrist@mox.perl.com>
Looking for way to download files to browsers using PER <juan@vibrant.com>
Re: Looking for way to download files to browsers using (brian d foy)
Re: Looping through hashes (Andrew M. Langmead)
Re: Mysterious FileHandle + fork() behavior; possible P <achen@nssdc.gsfc.nasa.gov>
Re: newbie question (Tad McClellan)
newbie: fork and sleep <Peter.Wirdemo@wirdemo.pp.se>
Perl and Eggdrop (Peazant)
Q: search matching "(" and ")" <ykhu@mtk.com.tw>
Re: Question about installation of module <enzrowi@nzsf00.epa.ericsson.se>
Re: Review of CGI/Perl book <craig@cgi-perl.com>
Re: searching many text files sequentially for strings (Frank)
Re: sending email (Net::SMTP).. problem <gbarr@ti.com>
Re: sending email (Net::SMTP).. problem <gbarr@ti.com>
Sinking STDOUT and STDERR <hattarki@rsn.hp.com>
Storing A Text File Into A Variable -- How?? (Tony K. Olsen)
Re: Testing for valid RegExps? <tycage@infi.net>
Re: Testing for valid RegExps? <tchrist@mox.perl.com>
UNIX commands via FTP on a MACINTOSH -- HAY-ELP! (Sean O'Dwyer)
Re: UNIX commands via FTP on a MACINTOSH -- HAY-ELP! (brian d foy)
Win32::Eventlog Read Method <shirley_mccraw@administaff.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 06 Jan 1998 16:54:54 -0500
From: Douglas Clifton <doug1@net-link.net>
Subject: Re: "shift @array" question
Message-Id: <34B2A82E.14577EC0@net-link.net>
Jerry Lineberry wrote:
> Hello,
> Ok, I have a script that works fine. However, I feel that it could
> have been done better. For instance, at one point I have to use the shift
> command three times in a row. Can this be done with one command?
>
> #!/usr/bin/perl -w
>
> $finger = "finger -m ";
> $list = "list";
> $domain = "\@nym.alias.net";
> @users = `$finger$list$domain`;
> shift @users; # How can I remove the first three lines
> shift @users; # without doing this?
> shift @users;
Try: splice @users, 0, 3;
> open(OUTPUT, ">nym.users") or die "Can't open newfile nym.users: $!\n";
> foreach $user (@users) {
> $user = $` if $user =~ m/\n/;
> @usrdomain = "$user$domain\n";
> print OUTPUT @usrdomain;
> }
> close(OUTPUT);
>
> ---
> Jerry Lineberry
> San Antonio, Texas
> (210) 746-1787
--
Douglas Clifton
Programmer
===================
Web One Inc.
Website Development
Phone: 888-699-WEB1
Phone: 616-552-9999
Fax: 616-552-9920
sales@weboneinc.com
www.weboneinc.com
===================
------------------------------
Date: Tue, 06 Jan 1998 18:44:48 -0500
From: "William B. Tansill, III" <wtansill@erols.com>
Subject: Re: Arrgghhhhh! There must be a simple solution to this script error
Message-Id: <34B2C1F0.7FE4@erols.com>
James Robshaw wrote:
>
> Can anyone please point me in the right direction.
>
> I have a perl script that works fine until I try to edit this particular
> line from
>
> print NEWFILE " <body >\n";
>
> into
>
> print NEWFILE " <body bgcolor="#B4BCCD" text="#000000" link="#000066"
> vlink="#990000">\n";
>
> Is it the repetition of the "#" that causes the error?
> Can I place a default character in front of the # to prevent the error?
>
> The script doesn't actually generate an error code, I just get the default
> Server Error 500.
>
> I have tried a couple of things, but none have worked. I'm going potty,
> especially as at the moment, I can only test the script on-line.
>
> All suggestions gratefully received.
>
> James.
>
> james@NOSPAMrobshaw.zynet.co.uk
You have embedded quotes within a quoted string. You have several
options:
1) Use single quotes to delimit the string.
2) Within the quoted string, manually insert an escape character (\)
before each non-terminating quote.
3) Use Quotemeta (perldoc -f quotemeta).
4) Use the "Here Document" syntax supported by PERL.
---
How do I set my laser printer to "stun"?
------------------------------
Date: Tue, 6 Jan 1998 22:35:42 -0000
From: "Andy Spencer" <andys@nvisual.com>
Subject: Calling Into Perl DLL from Win32 App
Message-Id: <34b2b1ae.0@newsread1.dircon.co.uk>
All,
Can I call the Perl Dll from my own win32 Process.?
I would prefer to call the DLL, rather that spawn the EXE.
I see perl300.dll exports CreateCPerl and PerlGetVersion, are these
standard (are they to be used, or reserved)
I assume PerlScript / ISAPIPerl use this DLL approach?
I would appreciate an email answer if possible.
TIA
AndyS
------------------------------
Date: Tue, 6 Jan 1998 11:51:26 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Can I create a Linked List in Perl
Message-Id: <uuqt86.nj2.ln@localhost>
draggs@hawkeye.idx.com wrote:
: I'm reasonably new to Perl,
You should become acquainted with the documentation that is shipped
as part of the perl distribution.
Lots and lots of it. You may not be used to such helpful free info
coming from C.
: but am an old C programmer. I was
: wondering if it was possible to create a c-style linked list and perl.
Since it has been enshrined as a Perl Frequently Asked Question,
you are not the only one wondering ;-)
: If it is, how would I go about doing so?
Like it says in the Perl FAQ, part 4, under:
"How do I handle linked lists?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 6 Jan 1998 22:42:16 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Can I create a Linked List in Perl
Message-Id: <EMDwEG.1Mr@world.std.com>
draggs@hawkeye.idx.com writes:
>I'm reasonably new to Perl, but am an old C programmer. I was
>wondering if it was possible to create a c-style linked list and perl.
>If it is, how would I go about doing so?
Very often you don't have to, since you can do very funky things with
arrays that you can't do in C. (Add and remove elements from
beginning, end, or middle with push/pop/shift/unshift and splice.)
If you really need to though, take a look at perl's "reference"
concept, which are functionally similar to to pointers in C. Use a
hash in perl as you would a struct in C (since it has named members,
they tend to act very similarly) and the field in which you would
store a pointer to another element in C, store a reference to the
other element instead. You'll probably also need to use the anonymous
hash construct "$elem = {}" to create new hashes for each element of
the linked list.
I often try to give example code in my responses, but I'm going to
pass on showing how to do a linked list. Building (and maintaining
linked lists is a tedious chore in any language. But here is an
example of using simple arrays to achieve the results of linked lists.
#!/usr/bin/perl -w
# input a lines of text, break them into words, and store them
# keeping sorted order.
my @words = ();
while(<>) {
for $word (split ' ') {
my $elem = 0;
my $done = 0;
until ($done) {
# iterate through the list and insert the new word before
# the first word greater than it. Since elements past the
# end of the list are always "undef", the current word
# will always be greater than it.
if(not defined $words[$elem] or $words[$elem] gt $word) {
splice @words, $elem, 0, $word;
$done = 1;
}
$elem++;
}
}
}
for $word (@words) {
print "$word\n";
}
Even this doesn't seem to be very perlish, however. In perl, one would
probably save the words in a hash and sort once done.
#!/usr/bin/perl -w
while(<>) {
for $word (split ' ') {
$count{$word}++;
}
}
for $word (sort keys %count) {
print map { "$_\n" } ($word) x $count{$word};
}
--
Andrew Langmead
------------------------------
Date: Tue, 06 Jan 1998 22:47:48 -0800
From: Jan Krynicky <Jan@ChipNET.cz>
Subject: Re: form+mail : script
Message-Id: <34B32514.4DD2@ChipNET.cz>
affix@usa.net wrote:
>
> hi,
> I need to find a simple PERL script that is used to send form mails,
> without any external pogram, (like blat!)
> This is for a NT server
> TQ
>
> Lawrence
Mail::Sender or SendMailEx from
http://www.chipnet.cz/depot/perl.htm
Jenda
------------------------------
Date: Tue, 06 Jan 1998 23:10:29 -0800
From: Jan Krynicky <Jan@ChipNET.cz>
Subject: Re: How to mimic C's #include "global.pl"
Message-Id: <34B32A65.5AC8@ChipNET.cz>
Moises G. Solis wrote:
>
> I have a Perl script called global.pl that
> contains global definitions. I want to bring
> this script into another script. I'm trying to
> mimic: #include "global.pl" from C. The question
> is, which is the best way for doing this?
>
> Thanks in advance,
> Moises.
require 'global.pl';
Make sure the last statement in global.pl is
1;
Jenda
------------------------------
Date: 06 Jan 1998 15:57:39 -0600
From: Larry Daffner <ldaffner@rsn.hp.com>
Subject: Re: I need money [Re: I need a script]
Message-Id: <f5oiurxmfjg.fsf@rsn.hp.com>
>>>>> "d" == dformosa <the> writes:
d> Interesting fact, you can get any multipal of 10 greater then 70
d> by the combernations of $20 and $50.
Actually, you can get any multiple of 10 >= 40 using only 20 and 50.
Proof:
Given: n,m,o >= 0
Consider n*20+m*50 = o*10
Inductive step:
a) for n >= 2, 20(n-2) + 50(m+1) = 10(o+1)
b) for m >= 1, 20(n+3) + 50(m-1) = 10(o+1)
c) Applying (a) results in m+1 >= 1, allowing (b)
Applying (b) results in n+3 >= 2, allowing (a)
base case:
n=2 results in 40. (o = 4). Therefore, for any o >= 4, o+1 is
possible. //
-Larry (followups to alt.geeking.math or whatever :)
--
| Larry Daffner - Software Engineer | email: ldaffner@rsn.hp.com |
| Hewlett Packard STO | |
Hare's Law:
Inside every large program is a small program struggling to get out.
------------------------------
Date: Tue, 06 Jan 1998 21:59:24 +0000
From: Andrew Spiers <andrew.spiers@virgin.net>
Subject: Ideas for PERL projects
Message-Id: <34B2A93B.A8B3443B@virgin.net>
Hi,
I am fairly new to PERL but have a reasonable programming background
!?!?! What I am after is ideas for projects that would me help learn how
to use PERL and possibly CGI.PM and LWP.PM.
Many thanks,
Andrew Spiers
------------------------------
Date: Tue, 06 Jan 1998 18:13:33 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Ideas for PERL projects
Message-Id: <comdog-ya02408000R0601981813330001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34B2A93B.A8B3443B@virgin.net>, andrew.spiers@virgin.net posted:
>I am fairly new to PERL but have a reasonable programming background
>!?!?! What I am after is ideas for projects that would me help learn how
>to use PERL and possibly CGI.PM and LWP.PM.
you could go through the Pelican book and find every instance where
Clinton says something like "this is beyond the scope of this book"
and then do it. that should give you lots of practice with
those modules. :)
[1]
Web Client Programming with Perl
Clinton Wong
ISBN 1-56592-214-X
<URL:http://www.oreilly.com>
--
brian d foy <comdog@computerdog.com>
Fifth Avenue Disaster! <URL:http://computerdog.com/brian/fire/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 6 Jan 1998 23:50:21 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: impure embedded perl
Message-Id: <qz$9801061836@qz.little-neck.ny.us>
Dean Hoover <dhoover@textwise.com> wrote:
> I ran my program through 'purify' to see if I had any memory related
> problems and gazillions of UMR (uninitialized memory read) warnings
> came out from libperl.a. This is probably an easy thing to fix in
> some future release of perl. Am I right?
My Purify User's Guide states that these often occur when copying
sturctures but that purify surpresses the warning in that case.
I would not place a lot of faith in Purify knowing when a UMR is
really only occuring because of copying. I'd imagine perl does a
fair amount of copying behind the scenes, and may not be using a
standard library call to do it. (In my own code I find UMRs are often
false alarms and supress them.)
Feel free to investigate and submit patches though.
Elijah
------
thinks this really belongs on the p5p list
------------------------------
Date: 6 Jan 1998 22:09:30 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Lexical scope and embedded subroutines.
Message-Id: <68ua2q$852$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
[his address is steveg@gcg.com for the spamorama]
In comp.lang.perl.misc, Steve Goldstein <steveg@gcg.com> writes:
:#!/usr/local/bin/perl
:foreach my $temp ( 'warm', 'cold') {
: What_is_the_temp($temp);
:}
:
:sub What_is_the_temp {
: my $param = shift;
: print "Outside it is $param.\n";
: embeddedsub();
: return;
: sub embeddedsub {
: print " Inside it is always $param.\n";
: return;
: }
:}
This solves your problem. I even turned off the redefinition
warnings.
#!/bin/perl -w
foreach my $temp ( 'warm', 'cold') {
What_is_the_temp($temp);
}
sub What_is_the_temp {
my $param = shift;
print "Outside it is $param.\n";
{
local $^W;
*embeddedsub = sub {
print " Inside it is always $param.\n";
return;
};
}
embeddedsub();
return;
}
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
It is Unix. It is possible to overcome any number of these bogus features. --pjw
------------------------------
Date: 6 Jan 1998 22:07:54 GMT
From: "Juan Vega" <juan@vibrant.com>
Subject: Looking for way to download files to browsers using PERL
Message-Id: <01bd1aee$9064b6a0$4b3d61c7@hercules.vibrant>
Folks,
I am trying to execute a download in my PERL script and cannot find the
method for doing so. This seems like a relatively simple task to me...is
it?
The desired result is:
1) User fills in html form in favorite browser and posts it to CGI script
(no problem)
2) CGI script parses information and writes to database (no problem)
3) CGI script sends *.exe to browser such that browser asks user where file
should be saved (big problem - I am lost)
4) CGI script send email to user with password for unlocking *.exe file (no
problem)
I have looked everywhere (Llama, net, Matt's place, etc.) and have found no
relief. Granted I am new at this PERL stuff but sending a file to a browser
ought to be easy enough. Please help!!!
Many thanks,
Juan
--
Juan Vega
juan@vibrant.com
------------------------------
Date: Tue, 06 Jan 1998 18:10:05 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Looking for way to download files to browsers using PERL
Message-Id: <comdog-ya02408000R0601981810050001@news.panix.com>
Keywords: from just another new york perl hacker
In article <01bd1aee$9064b6a0$4b3d61c7@hercules.vibrant>, "Juan Vega" <juan@vibrant.com> posted:
>3) CGI script sends *.exe to browser such that browser asks user where file
>should be saved (big problem - I am lost)
the persons in comp.infosystems.www.authoring.cgi should be
able to help. you could also check the CGI Meta FAQ or past
answers to this questions which are archived on DejaNews [1].
good luck :)
[1] <URL:http://www.dejanews.com>
--
brian d foy <comdog@computerdog.com>
Fifth Avenue Disaster! <URL:http://computerdog.com/brian/fire/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 6 Jan 1998 21:58:20 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Looping through hashes
Message-Id: <EMDuD8.Gxw@world.std.com>
Boris Statnikov <boromir@mindspring.com> writes:
>Is there a way to know the number of elements in a hash IN ONE OPERATION
$size = keys %hash;
>It turns out one is not supposed to do this:
>for (($key, $val) = each %myhash) {
> if ($val eq "donkey") {
> $myhash{"parrot"} = "silly bird";
> }
>}
For this case, (adding an element to the has if another key alredy
exists) why loop at all?
$myhash{parrot} = 'silly bird' if exists $myhash{donkey};
>In other words, one is not permitted to ADD elements to a hash while
>EACHing through it. Now, how do I accomplish the same thing (and how do
>I break out of each loop in order to accomplish it)?
In the more general case (adding elements while looping) how about
if you store the items in a second hash and copy everything over while
in the loop?
my %stuff_to_add = ();
while(($key,$val) = each %myhash) {
if($somecondition) {
$stuff_to_add{parrot} = 'silly bird';
}
}
%myhash = (%myhash, %stuff_to_add);
and of course, if you are going to add one element and then exit out
of the loop, you might as well just add it and break out, the messing
up of the iterator only happens on the next iteration.
while(($key,$val) = each %myhash) {
if($somecondition) {
$myhash{parrot} = 'silly bird';
last;
}
}
--
Andrew Langmead
------------------------------
Date: Tue, 6 Jan 1998 18:02:21 -0500
From: Allen Chen <achen@nssdc.gsfc.nasa.gov>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Mysterious FileHandle + fork() behavior; possible Perl bug?
Message-Id: <Pine.OSF.3.95.980106175544.1648D-100000@nssdc.gsfc.nasa.gov>
> As I said above, I'm including my test code again in the hopes that
> someone else will be able to shed some light upon this problem. My best
> guess is that the input buffer is somehow being confused when the child
> seeks back, even though that shouldn't happen from what I know. Shows how
> little I know, doesn't it? :-)
Well, I still have not solved the problem, but does not seem to be Perl's
fault. I wrote some quick C code which demonstrates the exact same
behavior! The problem must have something to do with the fork() system
call. The problem occurs under both Solaris 2.5.1 and Digital UNIX 4.0.
Perhaps it's time to post to a UNIX C programming newsgroup...
Here's the code (sorry for the lack of error checking and comments):
-Allen
Allen Chen / Systems Programmer / Raytheon STX Corporation ////
SSDOO Software, Systems / International Solar-Terrestrial Physics /////
e-mail: achen@nssdc.gsfc.nasa.gov / voice: (301) 286-7376 //////
--- cut here ----------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
main(int argc, char **argv) {
FILE *LIST;
char line[160];
int pid;
int status;
printf("Opening %s\n",argv[1]);
LIST=fopen(argv[1],"r");
fscanf(LIST,"%s\n",line);
while (!(feof(LIST))) {
if ((pid=fork()) < 0)
exit(-1);
else if (pid==0) {
printf("%s\n",line);
exit(0);
}
wait(&status);
fscanf(LIST,"%s\n",line);
}
}
------------------------------
Date: Tue, 6 Jan 1998 09:29:41 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: newbie question
Message-Id: <5lit86.h91.ln@localhost>
Bela Garzo (gand@vtsoft.hu) wrote:
: Could anybody help how to fix this code?
: I really need to store filehandle in a hash.
This is a Frequently Asked Question (part 5):
"How can I make a filehandle local to a subroutine?
How do I pass filehandles between subroutines?
How do I make an array of filehandles?"
: #!/usr/bin/perl
You should always use the -w switch.
Let perl help you debug your programs.
#!/usr/bin/perl -w
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 07 Jan 1998 00:16:28 +0100
From: Peter Wirdemo <Peter.Wirdemo@wirdemo.pp.se>
Subject: newbie: fork and sleep
Message-Id: <34B2BB4C.7DA3@wirdemo.pp.se>
Hi,
Could anyone please explain why I must have 2 sleep's ( in the
while loop ) to get the process to sleep. If I dont have 2 sleep's,
the process runs away forking as fast as it can.
Thanks
/Peter
Peter Wirdemo at Wirdemo pp se
#!/usr/bin/perl -w
use strict;
use diagnostics;
sub REAPER {
$SIG{CHLD} = \&REAPER;
my($waitpid) = wait;
}
sub do_exec {
my($forkpid);
$SIG{CHLD} = \&REAPER;
EXECFORK: {
if ($forkpid = fork) {
return($forkpid);
}
elsif (defined $forkpid) {
close(STDIN);
close(STDOUT);
close(STDERR);
setpgrp(0,$$);
exec("/bin/true");
}
elsif ($! =~ /No more processes/) {
# EAGAIN, supposedly recoverable fork error
sleep 5;
redo EXECFORK;
}
}
}
while(1) {
print "Execing...\n";
do_exec;
# I have to call sleep twice to get the process to sleep???
sleep();
sleep(5);
}
------------------------------
Date: Tue, 06 Jan 1998 23:45:46 GMT
From: peazant@internetaddress.com (Peazant)
Subject: Perl and Eggdrop
Message-Id: <34b2c1e7.3013247@roadrunner.micro-net.com>
Can Perl be used to made Eggdrop scripts with any amount of ease?
If you know how do do this, or you know a resource I could use to find
more info, I'd appreciate it.
------------------------------
Date: Sun, 04 Jan 1998 12:11:02 +0800
From: Hu_Yi_Kwang <ykhu@mtk.com.tw>
Subject: Q: search matching "(" and ")"
Message-Id: <34AF0BD5.EB05C5DE@mtk.com.tw>
My input file is something like:
( A1 ....
(B2 ...
(C3 ....
other text, may contain "(" and ")" pairs.
)
)
)
Q: How can I easily find the matching parir for "(" and ")" for A1?
Thanks,
YK Hu
------------------------------
Date: Wed, 07 Jan 1998 10:54:30 +1300
From: Ross Williamson <enzrowi@nzsf00.epa.ericsson.se>
Subject: Re: Question about installation of module
Message-Id: <34B2A816.3973@nzsf00.epa.ericsson.se>
Usually a make install should do what you want. :)
Nevin Kapur wrote:
>
> I downloaded the Statistics::Descriptive module from CPAN, ran
> Makelfile.PL and then make all. I get the following directory structure:
-- SNIP --
------------------------------
Date: Tue, 06 Jan 1998 16:02:12 -0600
From: Craig Patchett <craig@cgi-perl.com>
Subject: Re: Review of CGI/Perl book
Message-Id: <884123997.1755250696@dejanews.com>
In article <34B1E282.4764688D@patchett.com>,
craig@patchett.com wrote:
>
> And while I'm at it, Perl 4 is far from dead
I should reiterate that by Perl 4 I am referring to the intersection of
the features of Perl 4 and Perl 5, not necessarily Perl 4 as a standalone
package (although as someone else points out, there are still plenty of
Perl 4 installations around).
Craig
--------------------------------------------------------------------
Craig Patchett email : craig@cgi-perl.com
The CGI/Perl Cookbook www : http://cgi-perl.com
--------------------------------------------------------------------
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 06 Jan 1998 21:42:26 GMT
From: FHeasley@chemistry.com (Frank)
Subject: Re: searching many text files sequentially for strings and replacing
Message-Id: <34b2a4e6.23799176@news.halcyon.com>
On Tue, 06 Jan 1998 12:23:34 -0700, Erik <erik@peak.mrc.montana.edu>
wrote:
>I am trying to search through a directory full of text files, replacing
>text with other text, and writing a new version of the file in a
>different directory. Does someone have a template for the array
>operations and 'while' structure needed to do this?
>
Just use grep with readdir, open the files sequentially, close,
substitute and save.
Frank
------------------------------
Date: Tue, 06 Jan 1998 15:58:53 -0600
From: Graham Barr <gbarr@ti.com>
Subject: Re: sending email (Net::SMTP).. problem
Message-Id: <34B2A91D.B5DD6D8A@ti.com>
Eli the Bearded wrote:
> Okay, yes it is being done, that is not much of an issue, in my opinion.
> Is it being done frequently? I suspect not. Is it unreasonable for non-
> spammers to send mail like this? No. Is it unreasonable for Graham to
> dictate the ways we can send mail for the convience of his mail filtering?
I do not remember dictating anything. What I do remember is just
pointing out that this is a common, and yes it is frequent, method
used by spammers. And so there are several people, including myself,
that use this as a signature of SPAM for filtering purposes. Yes it
has on occasions filtered out "real", but that is my problem.
Graham.
--
Originality is the ability to conceal your source.
------------------------------
Date: Tue, 06 Jan 1998 16:41:50 -0600
From: Graham Barr <gbarr@ti.com>
Subject: Re: sending email (Net::SMTP).. problem
Message-Id: <34B2B32E.69EF9427@ti.com>
Eli the Bearded wrote:
> Graham, in this thread, has recommended that people *not* use his
> own SMTP module to send him mail because it does not add headers
> he wants to see when filtering. catty's comment is misplaced, but
> it is easy to find Graham's advice disingenuous.
You really do have a problem reading don't you. Or maybe you
just do not understand what you read. I did not tell anyone
"*not* use his own SMTP module ... because it does not add headers"
What I did say is that sending mail directly to the MX host for
that address is a common techneque used by spammers, and so is
also used in spam filters. At no time did I say not to use
Net::SMTP, why would I ??
Graham.
--
Originality is the ability to conceal your source.
------------------------------
Date: Tue, 06 Jan 1998 17:02:54 -0600
From: Mark Hattarki <hattarki@rsn.hp.com>
Subject: Sinking STDOUT and STDERR
Message-Id: <34B2B81D.59CC7C29@rsn.hp.com>
Hello all,
I have a program that dies if you are not a root user :
if ($username ne "root") {
die "Error: you must be root to run this, you lowly non-root person\a\n";
}
Earlier in the code I have this :
if ($DEBUG!=0) {
print "* Debuging is on; level $DEBUG\n";
}
and:
if ($DEBUG>0) {
print "* Begining $HOME/setup.pl\n";
}
My problem is that when the user is not root, the program terminates but
does not print the messages to the screen in proper order:
Error: you must be root to run this, you lowly non-root person
* Debuging is on; level 1
* Begining /opt/scaf_setup/config/bind/setup.pl
I understand that the buffering is causing this. But I don't know how to
do away with the buffering completely. I've tried bringing both stdout and
stderr into focus, then setting $|= 1 (I've tried 0 too), but that doesn't
work. How do I get the error message to be the last thing printed? In c++,
there is a flush command that you can send to a file class, is there
something similar for perl?
namaste,
Mark
--
"The belly is the reason man does not
so easily take himself for a god"
-- Nietzsche
------------------------------
Date: Tue, 6 Jan 1998 22:17:39 -0000
From: tkolsen@btinternet.com (Tony K. Olsen)
Subject: Storing A Text File Into A Variable -- How??
Message-Id: <MPG.f1cbdde9d0664bc989682@news.btinternet.com>
Hi Everyone,
I have been struggling through a brain seizure here tonight and
for the life of me I can't figure out how to store the output from a text
file into a variable.
The reason I want to do this is to retrieve the information from
the text file into a variable that I can then input into a CGI form so
that it will be the already filled in text area field in the form.
# retrieve text now if it exists.
$comment_file = "e:\\pfe\\programs\\database\\" . $db_serial . "-"
. $db_year;
open(IP, "<$comment_file") || die "cannot open the ",
$comment_file, " file";
while (<IP>) {
print;
}
this works fine and displays it to the screen. What I would like
is something along these lines:
while (<IP>) {
chop;
$var = $_;
}
Then I could generate a perl file using the $var like such to
display the comments already written to the file:
<TEXTAREA NAME="textdata" ROWS=15 COLS=69>
$var
</TEXTAREA>
Confused and punch drunk with a newborn baby in the house.
Replies and advice appreciated. Cheers.
--
___
(_B_)__
~(@ @)~
+-oOOo-(_)-oOOo-------------------------------------------------+
| "I played before the greatest fans in baseball, the Boston |
| fans, and I know what you're going to say about that: Old |
| Teddy Ballgame loved those fans, all right." --- Ted Williams |
+----------------+----------------------------------------------+
| Tony K. Olsen | URL: http://www.btinternet.com/~tkolsen |
| Cheltenham, UK | Email: mailto:tkolsen@btinternet.com |
+----------------+----------------------------------------------+
------------------------------
Date: Tue, 06 Jan 1998 17:08:22 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: Testing for valid RegExps?
Message-Id: <34B2AB56.512BA9F0@infi.net>
Mark Hazen wrote:
>
> Hi folks... please respond both via email and this group, if possible.
> This should have a decently quick and dirty answer....
>
> I'm looking for a way, in Perl, to test the validity of a regexp given by
> the user. I didn't find any such module on CPAN, but I'd really love to
> know if there's a way within Perl to do this without having to load
> another module (or with loading one of the standard modules).
>
Check out eval. You can use it to test a section of code and see if it
causes
any errors. So you could do something like
$regex = '(\w+)$';
eval {
$whatever =~ /$regex/;
};
if ($@) {
print "Error in expression $@\n";
} else {
# Do whatever you want with the regex
}
Or something like that. Check the perlfunc man page for more on eval.
+---+
Ty Cage Warren tycage@wsol.net
Systems Engineer InfiNet
Homepage: http://www.wsol.net/~tycage
PGP Public Key: http://www.wsol.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78 B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------
------------------------------
Date: 6 Jan 1998 22:37:29 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Testing for valid RegExps?
Message-Id: <68ubn9$auo$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Mark Hazen <mhazen@franklin.uga.edu> writes:
:I'm looking for a way, in Perl, to test the validity of a regexp given by
:the user.
chomp($pat = <INPUT>);
unless (eval { /$pat/, 1 }) {
die "bogus pattern $pat\n";
}
or even just
sub is_valid_regex {
my $pat = shift;
return eval { /$pat/, 1 };
}
How this interacts with a current //g may not be perfect. Perhaps
this would be safer.
sub is_valid_regex {
my $pat = shift;
my $str = '';
return eval { $str =~ /$pat/, 1 };
}
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
OOPS! You naughty creature! You didn't run Configure with sh!
I will attempt to remedy the situation by running sh for you...
--Larry Wall in Configure from the perl distribution
------------------------------
Date: Tue, 06 Jan 1998 17:01:04 -0500
From: sean@dcdX.net (Sean O'Dwyer)
Subject: UNIX commands via FTP on a MACINTOSH -- HAY-ELP!
Message-Id: <sean-0601981701050001@p5.ts1.white.ny.tiac.com>
I need to be able to set executability of scripts in my cgi-bin, using
commands like chmod, but I can't do that using Anarchie or Fetch (that I
know of).
Is there a way to do this from my Mac?
Sean
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
DIGITAL COOKIE DESIGN: graphic design for web and print
http://www.dcd.net/ (remove x to reply via email)
------------------------------
Date: Tue, 06 Jan 1998 18:07:11 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: UNIX commands via FTP on a MACINTOSH -- HAY-ELP!
Message-Id: <comdog-ya02408000R0601981807110001@news.panix.com>
Keywords: from just another new york perl hacker
In article <sean-0601981701050001@p5.ts1.white.ny.tiac.com>, sean@dcdX.net (Sean O'Dwyer) posted:
>I need to be able to set executability of scripts in my cgi-bin, using
>commands like chmod, but I can't do that using Anarchie or Fetch (that I
>know of).
not really a Perl question, but in Fetch under the remote menu
is "Set Upload Permissions..." or "Send FTP command...". further
questions related to your operating system or software should
go to a newsgroup devoted to that topic.
--
brian d foy <comdog@computerdog.com>
Fifth Avenue Disaster! <URL:http://computerdog.com/brian/fire/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 06 Jan 1998 16:06:53 -0600
From: Shirley McCraw <shirley_mccraw@administaff.com>
Subject: Win32::Eventlog Read Method
Message-Id: <34B2AAFD.5223@administaff.com>
I am trying to read the system eventlog on a NT 4.0
server using the Perl-Win32 extensions. However,
the Read method always fails. My test code
segment is listed below. Does anyone have
a code sample that works?
use Win32::Eventlog;
my $myLog, $number;
Win32::EventLog::Open($myLog,"System",'') || die $!;
$myReadFlags = EVENTLOG_FORWARDS_READ;
$myCount = 1;
$myLog->Read($myReadFlags,$myCount,\%list) || die ;
print "key = value\n";
foreach $key (keys %list)
{
print $key, '=', $list{$key}, "\n";
}
------------------------------
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 1591
**************************************