[9598] in Perl-Users-Digest
Perl-Users Digest, Issue: 3192 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 18 01:07:23 1998
Date: Fri, 17 Jul 98 22:00:22 -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 Fri, 17 Jul 1998 Volume: 8 Number: 3192
Today's topics:
Re: -w on production code (was Re: better way of gettin (William R. Ward)
/^[a-z0-9]/ <chapin@ecst.csuchico.edu>
Re: /^[a-z0-9]/ (Larry Rosler)
Re: /^[a-z0-9]/ (Abigail)
Re: clp.moderated <rra@stanford.edu>
Failed to compile perl because make does not how to mak <chuanlarp@bigfoot.com>
Re: Free email script setups? Any clues ... graeberbgood@my-dejanews.com
GUI avaible for the Perl debugger (UNIX only) (Curt McKelvey)
Re: hash undef problem <tchrist@mox.perl.com>
Re: Help me on the if-then-else branch (Abigail)
Re: I'm baffled.. (and an amateur:) <rra@stanford.edu>
Re: Matching values in a hash (Craig Berry)
Re: Matching values in a hash (Abigail)
Re: Mutiple pattern searches (Tad McClellan)
Re: Perl Beautifier Home Page <rra@stanford.edu>
Re: Perl Beautifier Home Page (Abigail)
Perl embedders livshits@acm.org
Re: perl question on split (Larry Rosler)
Q: Coding Quiz result format? <uri@sysarch.com>
Reading in an email message into a Perl program <george@tapestry.net>
Re: Reading in an email message into a Perl program <aperrin@mcmahon.qal.berkeley.edu>
Re: Telnet Calls (-)
Re: usage of open2.pl <rra@stanford.edu>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Jul 1998 19:16:14 -0700
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <waavhp189e9.fsf@ese.UCSC.EDU>
Is it at all possible to have a warnings.pm pragma so that:
use warnings;
and
no warnings;
can be used in lieu of providing or not providing the -w flag? It
would be scoped the way
use strict;
is, so that included modules won't cause warnings unless *they* have
use warnings;
in the file.
It seems to me that this would take care of almost all of the
complaints.
--Bill.
--
William R Ward Bay View Consulting http://www.bayview.com/~hermit/
hermit@bayview.com 1803 Mission St. #339 voicemail +1 408/479-4072
hermit@cats.ucsc.edu Santa Cruz CA 95060 USA pager +1 408/458-8862
PGP Key 0x2BD331E5; Public key at http://www.bayview.com/~hermit/pubkey.txt
-----------------------------------------------------------------------------
"Language is a virus from outer space." --William S. Burroughs
------------------------------
Date: Fri, 17 Jul 1998 17:41:23 -0700
From: Juan Guevara <chapin@ecst.csuchico.edu>
Subject: /^[a-z0-9]/
Message-Id: <Pine.HPP.3.95.980717173313.4983A-100000@cancer.ecst.csuchico.edu>
hello (yeah... I'm a newbie)
/^[a-z0-9]/
In unix shell, that's suppose to check if there are non-alphanumeric
characters in the input. I already searched through 2 different
perl books (the camel book + using perl 5) and I still don't know how
to tell perl to check for all characters NOT included inside the brackets.
All I'm trying to do is check to see if the user entered non-alphanumeric
characters.
Please send your ideas to chapin@ecst.csuchico.edu
-juan
--
Juan Guevara
chapin@ecst.csuchico.edu *Make every move as if it were your last*
http://www.ecst.csuchico.edu/~chapin
------------------------------
Date: Fri, 17 Jul 1998 18:12:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: /^[a-z0-9]/
Message-Id: <MPG.10199660b56a9fd5989728@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <Pine.HPP.3.95.980717173313.4983A-
100000@cancer.ecst.csuchico.edu> on Fri, 17 Jul 1998 17:41:23 -0700, Juan
Guevara <chapin@ecst.csuchico.edu> says...
...
> /^[a-z0-9]/
>
> In unix shell, that's suppose to check if there are non-alphanumeric
> characters in the input.
Why do you think that? What do you mean by 'unix shell'? I know of no
shell that understands syntax like that. Do you mean a specific Unix
command? If so, you are close, but still wrong.
> I already searched through 2 different
> perl books (the camel book + using perl 5) and I still don't know how
> to tell perl to check for all characters NOT included inside the brackets.
>
> All I'm trying to do is check to see if the user entered non-alphanumeric
> characters.
Search the Camel a bit harder. Start by looking for 'character class'
in the index.
If you consider _ (underscore) to be an alphanumeric, you don't need a
character class -- look at \w and \W. If you don't consider _ to be an
alphanumeric, the character class is [^a-zA-Z0-9] or [^a-zA-Z\d] so you
were on the right track.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 18 Jul 1998 04:49:18 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: /^[a-z0-9]/
Message-Id: <6op9ge$ct2$2@client3.news.psi.net>
Juan Guevara (chapin@ecst.csuchico.edu) wrote on MDCCLXXXII September
MCMXCIII in <URL: news:Pine.HPP.3.95.980717173313.4983A-100000@cancer.ecst.csuchico.edu>:
++
++ hello (yeah... I'm a newbie)
++
++ /^[a-z0-9]/
++
++ In unix shell, that's suppose to check if there are non-alphanumeric
++ characters in the input. I already searched through 2 different
++ perl books (the camel book + using perl 5) and I still don't know how
++ to tell perl to check for all characters NOT included inside the brackets.
Well, you're almost there.
/[^a-z0-9]/
But that disallowes A-Z and accented letters as well. Perhaps you want /\W/.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: 17 Jul 1998 21:06:06 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: clp.moderated
Message-Id: <m3g1fzkdld.fsf@windlord.Stanford.EDU>
Abigail <abigail@fnx.com> writes:
> Russ Allbery (rra@stanford.edu) wrote on MDCCLXXXI September MCMXCIII:
>> Find a different provider? Newsguy is extremely inexpensive for a
>> fairly solid newsfeed.
> I don't think management will go for that..... PSI salestalks make PHB's
> drool.
Convince them to allow NNTP through your firewall and pay whatever it is,
something like $20 a year, for a Newsguy account just for yourself?
That's probably what I'd do in the same situation.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Fri, 17 Jul 1998 23:43:50 -0400
From: "chuanlarp satchavarodom" <chuanlarp@bigfoot.com>
Subject: Failed to compile perl because make does not how to make README file
Message-Id: <6op5et$8tp$1@winter.news.erols.com>
dear all.
I recently downloaded perl5 and tried to compile it on DynixPTX Pentium
machine. the configure ran fine, but when I tried to make it. The make
stopped suddenly after start saying that make does not how to make README.
Please help me.
Thank you
Joseph
------------------------------
Date: Sat, 18 Jul 1998 01:16:21 GMT
From: graeberbgood@my-dejanews.com
Subject: Re: Free email script setups? Any clues ...
Message-Id: <6oot15$nns$1@nnrp1.dejanews.com>
NetRoamer looks like a nice program, but is not free (the cgi rescource lists
it at $399.00) - not even free for evaluation! You have to pay to see if it
will even work on your server. They boast support, but some have heard
complaints of e-mail questions going unanswered.
In article <01bdb0c0$02662560$ca7895cf@sparky2>,
tomh@ncfweb.net wrote:
> Hi,
>
> Anyone have experience with any free email packages? Found two at Matt's CGI
script library
> http://www.cgi-resources.com/Programs_and_Scripts/Perl/Web_Based_E_Mail/
>
> Both NetRoamer and or MailMan do not have any support and or way to purchase
the scripts. No way
> to contact them.
>
> Anyone know of other scripts that do YAHOO type free email functions for web
sites and have "some"
> support?
>
> Thanks for your time.
>
> Tom Hicks
> tomh@ncfweb.net
> InternetTemps People with skills and those that need them.
> http://www.internettemps.com
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 17 Jul 1998 17:12:00 GMT
From: mckelvey@usacmckelve.eng.mc.xerox.com (Curt McKelvey)
Subject: GUI avaible for the Perl debugger (UNIX only)
Message-Id: <1998Jul17.171200.12792@news.wrc.xerox.com>
-es a GUI available for the Perl debugger. It should work on all UNIX
systems. It does require the TkPerl extension, it has been tested with
800.003 and 800.005, under both Linux and Solaris.
The GUI consists of two windows: the debugger TTY that you are used to, and
a source window that follows the TTY around. From the source window you can
do almost any command with keyboard shortcuts. For example, to set a break
you just position the cursor on the line you want to break and type (Meta-b).
Buttons are also available for some commonly used commands.
Other neat features include:
- a list of subroutines and packages for the current file,
you can click on that list to position the source window.
- a listing of all files that are used in your program to speed viewing
of relevant files.
More information, screenshots, and the software for download are available at:
http://members.tripod.com/~CurtMcKelvey/perldbgui/
If you would like to join the development effort, please email me. I would
like to have people adding features to this.
Please check it out...
Thanks,
Curt McKelvey
------------------------------
Date: 18 Jul 1998 01:38:04 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: hash undef problem
Message-Id: <6oou9s$ln1$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Eric Sheng <shenge@ece.ucdavis.edu> writes:
:what I need to do at one point is "undef" all the data structure under a
:certain $element_name. I am doing:
: undef $all_groups{$group_name}{$element_name}
:but I believe it is not deleting the $element_name itself. So after
:the above line if I do:
% man perlfaq4:
...
What's the difference between "delete" and "undef" with hashes?
--tom
--
If you take Fred Cohen's definition of virus, then Unix itself is
one of the most successful viruses ever written, since it tends to
result in the creation of modified versions of itself on other
computer systems! -- Gene Spafford
------------------------------
Date: 18 Jul 1998 04:51:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help me on the if-then-else branch
Message-Id: <6op9jq$ct2$3@client3.news.psi.net>
Abigail (abigail@fnx.com) wrote on MDCCLXXXI September MCMXCIII in
<URL: news:6oomha$9s4$5@client3.news.psi.net>:
++ Mark Stang (markstang@ncgroup.com) wrote on MDCCLXXXI September MCMXCIII
++ in <URL: news:6oo1or$ku8$1@usenet1.interramp.com>:
++ ++ I'm a newbie too, but I think your code should be changed to read
++ ++
++ ++ $name = chomp(<STDIN>);
++
++
++ No, I don't think so. Unless he has his name stored in $/, which
++ is unlikely.
Uhm, of course $name = chomp(<STDIN>); is illegal. <STDIN> is not
modifyable, so it can't be chomped.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: 17 Jul 1998 21:17:46 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: I'm baffled.. (and an amateur:)
Message-Id: <m3af67kd1x.fsf@windlord.Stanford.EDU>
Ronald J Kimball <rjk@coos.dartmouth.edu> writes:
> Yong Huang <yong@shell.com> wrote:
>> A CGI script has to go through a lot of debugging as any program
>> does. It's much easier to insert a print "\$var is now: $var.\n"; into
>> the individually print'ed lines than into a here doc. Other than
>> debugging, you really want to insert a lot of if ($foo==$bar) {print
>> "XXX";} else { print "YYY";} type of blocks in your code. My approach
>> is much easier to maintain.
> Have you considered using the debugger?
I have. I like print statements *much* better. But I don't entirely
understand the problem of the original poster, as I don't see why using
heredocs or quoted strings prevents one from inserting more print
statements....
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 18 Jul 1998 00:01:31 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Matching values in a hash
Message-Id: <6oookr$ka1$7@marina.cinenet.net>
Juli@my-dejanews.com wrote:
: while (defined ($line = <FILE>) ) {
: foreach $key (keys %in) {
: if ($key =~ /\bfoo\b/) {
: if ($in{$key} =~ /$line/ ) {
: push (@thefile, $line);
: }
: }
: }
: }
: What I am doing here is reading in a file, line by line.
: Foreach key that matches foo
: If the value matches a line in the file
: write line to the array......
:
: The first match works fine,
: but I am not able to match the value with anything in the file.
Well, to start with, the fixed key-qualifying part should be moved out of
the loop. That in turn simplifies your code markedly. Here's what I get
(untested):
@qualified_keys = grep { /\bfoo\b/ } keys %in;
while (defined ($line = <FILE>) {
foreach $key (@qualified_keys) {
push @theFile, $line if $in{$key} =~ $line;
}
}
Two things to note:
* I strongly suspect that last clause should be $line =~ /$in{$key}/ --
that is, I doubt the file consists of patterns, but rather guess that
the hash values are patterns.
* You'll get multiple pushes of a line if it matches more than one hash
value.
HTH...
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 18 Jul 1998 04:59:26 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Matching values in a hash
Message-Id: <6opa3e$ct2$4@client3.news.psi.net>
Juli@my-dejanews.com (Juli@my-dejanews.com) wrote on MDCCLXXXI September
MCMXCIII in <URL: news:6oon22$ek0$1@nnrp1.dejanews.com>:
++ while (defined ($line = <FILE>) ) {
++ foreach $key (keys %in) {
++ if ($key =~ /\bfoo\b/) {
++ if ($in{$key} =~ /$line/ ) {
++ push (@thefile, $line);
++ }
++ }
++ }
++ }
++ What I am doing here is reading in a file, line by line.
++ Foreach key that matches foo
++ If the value matches a line in the file
++ write line to the array......
I would write that as:
my @lines = map {$in{$_}} grep {/\bfoo\b/} keys %in;
while (defined ($line = <FILE>)) {
push @thefile, ($line) x grep {/$line/} @lines;
}
But, I don't think that's what you want. And I don't understand the
explaination of what you want.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Fri, 17 Jul 1998 20:23:28 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Mutiple pattern searches
Message-Id: <hetoo6.gjd.ln@localhost>
John Nguyen (RC0705@email.sps.mot.com) wrote:
: Is there a way of searching a text file using multiple search patterns.
Your Question has been Asked Frequently before...
: How do
: you specify an array in a search pattern and have a ! (not) symbol in
: front of each element since I only want lines that do not include these
: string patterns.
I don't know how to put a not symbol in front of each element
(well, I do, but we don't need to).
because the !~ operator negates the sense of the match!
print "no match\n" if $str !~ /one|two|three/;
^^
^^
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Jul 1998 21:04:58 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl Beautifier Home Page
Message-Id: <m3iukvkdn9.fsf@windlord.Stanford.EDU>
Eli the Bearded <*@qz.to> writes:
> In comp.lang.perl.misc, Russ Allbery <rra@stanford.edu> wrote:
>> Anything that's nested more than four levels needs rewriting. I've
>> encountered *very, very* few exceptions to that principle that can be
>> justified. If you use a four-space indent, you should be able to
>> handle four level nesting without continuation with very little
>> difficulty.
> Don't use commented REs very often do you?
I use them a *lot*, actually, but when I do that I use one to two space
indents and am not hesitant about continuing a regular expression across
multiple lines or leaving blank lines with just a comment to finish the
comment.
> This will just fit in eighty columns with tabs at eight and shiftwdith
> at four, but I would prefer it if I could have the comment text indented
> to match the code. (There is, actually, a violation of the indent style
> here to coerce it to fit into the narrow line.)
I usually use one space indents in the comments to match the code, and
with regexes like yours, using one space indents in the regex and in the
comment usually works.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 18 Jul 1998 04:45:07 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6op98j$ct2$1@client3.news.psi.net>
Ronald J Kimball (rjk@coos.dartmouth.edu) wrote on MDCCLXXXI September
MCMXCIII in <URL: news:1dcbrl6.1nvk5lmi8evshN@bay1-252.quincy.ziplink.net>:
++ Abigail <abigail@fnx.com> wrote:
++
++ > ++ Maybe more than 80 chars are also needed when you have variables
++ > ++ called enormousStudlyCappedName1?
++ > 1234567890123456789012345
++ > 1 2
++ >
++ > Nope. 25 << 80.
++
++ I suppose if the script consisted solely of variable names on on lines
++ by themselves, then Abigail would be right.
++
++ Most code involves using variables within more complicated expressions,
++ however. :-)
I often have expressions that can easily take over 5 lines, without
getting hard to read.
Abigail
--
@rows = $sybase -> fetch_table (
table => "release_log",
where => {rel_area => $target,
notused => 0,
update_type => $UPDATES},
order => "relcuttime",
noquotes => [qw /notused/],
fields => [qw (relcuttime sourcemach)],
"last" => 1);
------------------------------
Date: Sat, 18 Jul 1998 00:33:05 GMT
From: livshits@acm.org
Subject: Perl embedders
Message-Id: <6ooqg1$jlr$1@nnrp1.dejanews.com>
Is there a mailing list specifically for Perl embedders?
Please email. Thanks,
- Vladimir
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 17 Jul 1998 17:23:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: perl question on split
Message-Id: <MPG.10198addfeb41eee989727@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <35AFDB59.139F7912@best.com> on Fri, 17 Jul 1998 16:16:42 -
0700, Todd Hansen <gaheris@best.com> says...
...
> As near as I can tell, the problem seems to be with the split(/./,
> $responses[12]) part of the statement, specifically, the delimiter.
> Does anyone know if using the period as a delimiter is not allowd in
> this operation, or identify what else may be wrong with this code?
Using the period as a delimiter is allowed. However, the period is a
metacharacter in a regex, meaning by default "match everything except
new-line". So you must say /\./ to split on a literal period.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 17 Jul 1998 20:12:58 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Q: Coding Quiz result format?
Message-Id: <x7oguom2yd.fsf_-_@sysarch.com>
i have gotten a couple of emails and several posted followups to the
quiz. should i gather the replies and create a summary of them and my
answers/critiques? i may wait a couple of more days to let more people
see the quiz as we know how slow some news feeds are.
some answers are basically on the money but worded slightly differently,
some are sarcastic/silly and some are just wrong.
and no one has gotten the bonus yet.
one posting didn't address the quiz but me personally and i have replied
directly. i do think this is open for debate and i have debated this
many times in giving this quiz. my answers are not right by fiat but by
many years of coding and learning about other people's coding
methodologies and styles. no one has yet shown me a better set of
answers and backed it with logic and only a few so totally disagree with
them that we have to agree to disagree (but they are wrong :-).
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 18 Jul 1998 00:23:08 GMT
From: "George H" <george@tapestry.net>
Subject: Reading in an email message into a Perl program
Message-Id: <01bdb1e1$70b96c80$1295cdcf@dbowen>
I am trying to write a program to parse email messages as they arrive and
extract certain headers. Right now, I am trying to write the simplest of
programs to just test that I can even do anything with an e-mail message.
I am running Perl 5.004, Linux release 1.3, Sendmail 8.8.5.
Here is what I have done.
I set up an alias in my /etc/aliases file that looks like ...
testing: "|/home/george/emailparse.pl"
I tried reading from standard input and I tried the @ARGV array. My code
for both is below. From the command line they work fine ... but when I
send the e-mail to the alias 'testing' ... nothing.
Has anyone done something like this and have an example? I am stuck.
Thanks,
George
george@tapestry.net
########STDIN######
#!/usr/bin/perl5 -w
alarm(600);
use strict;
my $homedir = "/home/george";
while(<>){
if ($_ =~ 'From:')
{
open(TEST, ">>$homedir/parsedfrom");
print TEST $_;
close TEST;
}
}
########@ARGV######
#!/usr/bin/perl5 -w
alarm(600);
use strict;
my $homedir = "/home/george";
my $line;
foreach $line (@ARGV){
if ($line =~ 'From:')
{
open(TEST, ">>$homedir/parsedfrom");
print TEST $line;
close TEST;
}
}
------------------------------
Date: Fri, 17 Jul 1998 21:00:33 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
To: George H <george@tapestry.net>
Subject: Re: Reading in an email message into a Perl program
Message-Id: <35B01DE1.62FA4052@mcmahon.qal.berkeley.edu>
George H wrote:
> ...
> I tried reading from standard input and I tried the @ARGV array. My code
> for both is below. From the command line they work fine ... but when I
> send the e-mail to the alias 'testing' ... nothing.
>
@ARGV won't get you anywhere -- when you're piping your input (as in via a
forward file), it's coming in STDIN. Run the first one from the command
line, then type From: whoever, then Ctrl-D. See if it works. I suspect
you'll want this though:
NOT if ($_ =~ 'From:')
BUT INSTEAD if ($_ =~ /^From:/)
Hope this helps.
Andy Perrin
> Has anyone done something like this and have an example? I am stuck.
>
> Thanks,
>
> George
> george@tapestry.net
>
> ########STDIN######
> #!/usr/bin/perl5 -w
>
> alarm(600);
> use strict;
> my $homedir = "/home/george";
>
> while(<>){
> if ($_ =~ 'From:')
> {
> open(TEST, ">>$homedir/parsedfrom");
> print TEST $_;
> close TEST;
> }
> }
>
> ########@ARGV######
> #!/usr/bin/perl5 -w
>
> alarm(600);
> use strict;
> my $homedir = "/home/george";
> my $line;
>
> foreach $line (@ARGV){
> if ($line =~ 'From:')
> {
> open(TEST, ">>$homedir/parsedfrom");
> print TEST $line;
> close TEST;
> }
> }
--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting - (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King
http://socrates.berkeley.edu/~aperrin to e-mail me)
e-mail wheres-andy@socrates.berkeley.edu to find me!
-------------------------------------------------------------
------------------------------
Date: Sat, 18 Jul 1998 00:45:13 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Telnet Calls
Message-Id: <35afef49.320023643@nntp.idsonline.com>
mnc@diana.law.yale.edu (Miguel Cruz) Said this:
>Kelly Hirano <hirano@Xenon.Stanford.EDU> wrote:
>>In article <6olnqk$hu4$1@nnrp1.dejanews.com>,
>> <david2020@my-dejanews.com> wrote:
>>>Can anybody provide me with a script that can generate hundreds of
>>>simultaneous telnet sessions?
>>>
>>>I tried using fork(), but it seems that it's taking a lot of resources.
>>
>>of course it's using lots of resources. you said "hundreds of simultaneous
>>telnet sessions". each session is a process -- not just a process, a big perl
>>process.
>
>But I think his point is that it only needs to be a socket. If he's trying
>to load-test a server, then he doesn't need all the overhead on the client
>side.
>
Not having done too much in the way of sockets programming, I may be
completely off...... but wouldn't simply doing a foreach or while loop
around the socket construction routine work? I mean, something like
this (the code isn't syntactically correct, but the flow concept is
good).......
for (1..100)
{
$counter++
build and open socket "$counter";
}
Like I said, the syntax is nothing, it's the idea.... increment or
somehow change the socket number for each iteration of the loop, open
a new socket. then you could proceed to the "communicate with each
socket" portion of the script and do yet another loop, this time from
an array of the open sockets.
You can have more than one socket open per process, right?
------------------------------
Date: 17 Jul 1998 21:14:40 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: usage of open2.pl
Message-Id: <m3d8b3kd73.fsf@windlord.Stanford.EDU>
Sara Malkawi <smalkawi@engin.umich.edu> writes:
> I have been reading the online documentation for open2.pl, and am
> getting more confused. The module itself says (in comments) to use it
> like $pid = &open2('input', 'output', 'ssh srvr2.engin.umich.edu'); and
> then use $input and $output for I/O. The online docs on the Perl website
> say to use it like
> use IPC::Open2;
> $pid = open2(\*RDR, \*WTR, 'some cmd and args');
A lot of your confusion will probably be banished by the note that
open2.pl is the old, obsolete version which has been replaced by the newer
IPC::Open2 that you want to use instead.
> Also, how do I actually read and write? Do I use something like
> print $output "$str\n";
> or
> print WTR "$str\n";
> ??
You can use the standard file handle operations, so you want the latter.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3192
**************************************