[6840] in Perl-Users-Digest
Perl-Users Digest, Issue: 465 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 13 07:07:16 1997
Date: Tue, 13 May 97 04:00:24 -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 Tue, 13 May 1997 Volume: 8 Number: 465
Today's topics:
Re: Decimals in PERL5 <ajohnson@gpu.srv.ualberta.ca>
dialling a modem from perl <usenet-tag@qz.little-neck.ny.us>
How do You use perl to Permanently Change a Directory? (Kevin M Simonson)
Re: How do You use perl to Permanently Change a Directo (Jon Bell)
Re: Incorrect warning? (Chipmunk)
Re: Memory Clearing <Torsten.Naumann@informati.tu-chemnitz.de>
Re: Memory Clearing (Abigail)
New draft of scripting white paper (John Ousterhout)
Re: New draft of scripting white paper <barmar@bbnplanet.com>
Re: New draft of scripting white paper <graham.matthews@maths.anu.edu.au>
Re: openning a file like readonly... (Geoffrey Hebert)
Re: Perl on Windows NT4.0 <gordon.leslie.mcdorman@sap-ag.de>
Re: Perl5.003 (released) under HPUX 9.07 (Jim Ray)
Pre-made script to search FTP sites and display HTML in (Sam Schlansky)
Problem using variables as filenames. <jbrandon@cats.ucsc.edu>
Re: Problem using variables as filenames. <rootbeer@teleport.com>
Re: Randal Schwartz (Tung-chiang Yang)
Re: REQ: Perl obfuscator (Abigail)
Re: scalar holds compiled code (Zach Baker)
Re: sendmail script <kurt@enterprise.net>
Re: sendmail script (brian d foy)
Re: sendmail script (Neil Briscoe)
Re: sendmail script (Geoffrey Hebert)
Re: Show variables during debug?? Debuggers in general. <billc@tibinc.com>
Similiar Function for getspnam( ) ? <edchang@ix.netcom.com>
Re: Something I'm missing <fawcett@nynexst.com>
Re: split problem (Charles DeRykus)
Re: system () won't execute the called program. (Lloyd Zusman)
Timer on my perl script <chchee@iti.gov.sg>
What is the context of $a->m1 in $a->m1->m2 ? <scribble@wwa.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 10 May 1997 13:13:24 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Decimals in PERL5
Message-Id: <3374BAC4.C2AC0E1@gpu.srv.ualberta.ca>
Greg Satterfield wrote:
>
> Can someone tell me how to format numbers in perl to 2 decimal points?
> Example, after a math calculation, how can I change the number
> 859.68542567832 to 859.68?
>
> Thanks,
> Greg
the following suffices to change
your number to 859.68:
$_="859.68542567832";
s$^\d+(\.\d+)?\$$859.68$;
print;
...it has the added benefit of being reasonably general in
that it will in fact change quite a variety of numbers to
859.68
I've heard that the FAQ and docs might have further info on
formatting numbers with some printf() or sprintf()
functions---but why post here if you wanted to read the
documentation right?
regards
andrew
------------------------------
Date: 11 May 1997 00:35:38 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: dialling a modem from perl
Message-Id: <5l348q$k2n$1@news.netusa.net>
I wanted a quikc hack to send dial commands to a modem because my
touch tone-phone is dead. I don't especially feel like buying a
new one and people who tell me to do so will be flamed.
Anyway, I wrote a quick hack to do it and it worked. Then I decided
to beef it up, and it stopped working. I can't figure out why it
stopped working. I am using perl 5.003 with '-w'. It should work
from the command line or interactively. The slightly stripped code
for command line use is:
open(MODEM,">/dev/modem") || die "$0: Can't get at the modem.\n";
syswrite MODEM,"ATX0\n",5 || die "$0: Can't talk to the modem.\n";
$dial="[0-9*#]";
$invdial="[^0-9*#]";
if (@ARGV) {
print "Dialing: "
foreach $block (@ARGV) {
if ($block =~ m:$dial:) {
$block =~ y:$invdial::d;
$length = 8 + ($block =~ y:$dial:$dial:) ;
print "$block "; # "$length:ATD $block ;\n";
syswrite MODEM,"ATD $block ;\r\n",$length || warn "$!";
sleep 1;
} # dialing block
}
print "\n";
}
syswrite MODEM,"ATH\r\n",4;
close MODEM;
I never get any warnings or errors, but it does not work either.
Anyone have any suggestions? I know the device file is the right
one and I know I have privledges to use it.
While I am asking, why doesn't this work usefully:
if (($pid=fork)!=0) {
open (MODEM,"</dev/modem") || die "$0: Can't read from modem.\n";
while(<MODEM>){
s/^[^!-~]+|[^!-~\r\n]+$//g;
print STDERR " $_";
}
exit;
}
It prints endless streams of garbage, which is not the intended
result. :^)
Elijah
------
"cat < /dev/modem" also prints that endless garbarge
------------------------------
Date: 11 May 1997 02:31:24 GMT
From: simonson@skopen.dseg.ti.com (Kevin M Simonson)
Subject: How do You use perl to Permanently Change a Directory?
Message-Id: <5l3b1s$4fq@sf18.dseg.ti.com>
Keywords: change directory permanent
As you can see below, I'm trying to use the Unix "cd" command inside a
"perl" script to change my default directory. I want to do this because
there are a lot of commands I want to execute in the directory I'm "cd"ing
to. However, whether I try to execute the "cd" using the "system ()" com-
mand, or within a couple of backtics, the "cd" doesn't appear to take per-
manent effect, since the "pwd" afterwards shows I'm still in the directory
I started out with.
Does anyone out there know why this is happening? And/or what I can
do to change my default directory so that it will _stay_ changed? Thanks
in advance.
---Kevin Simonson
,---------------------------------------------------------------.
| i32^simonson/Chs} pwd |
| /tmp_mnt/user/simonson/Chs |
| i32^simonson/Chs} ls -l Cd |
| -rwxrw-r-- 1 simonson c70 114 May 10 21:11 Cd* |
| i32^simonson/Chs} cat Cd |
| #!/usr/local/bin/perl |
| |
| system ("pwd"); |
| system ("cd .."); |
| system ("pwd"); |
| print `pwd`; |
| print `cd ..`; |
| print `pwd`; |
| i32^simonson/Chs} Cd |
| /tmp_mnt/user/simonson/Chs |
| /tmp_mnt/user/simonson/Chs |
| /tmp_mnt/user/simonson/Chs |
| /tmp_mnt/user/simonson/Chs |
| i32^simonson/Chs} |
`---------------------------------------------------------------'
------------------------------
Date: Sun, 11 May 1997 04:02:19 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: How do You use perl to Permanently Change a Directory?
Message-Id: <EA00Jv.9yw@presby.edu>
Keywords: change directory permanent
In article <5l3b1s$4fq@sf18.dseg.ti.com>,
Kevin M Simonson <simonson@skopen.dseg.ti.com> wrote:
> However, whether I try to execute the "cd" using the "system ()" com-
>mand, or within a couple of backtics, the "cd" doesn't appear to take per-
>manent effect, since the "pwd" afterwards shows I'm still in the directory
>I started out with.
That's because both the 'system' command and backticks start up a
separate process in which the 'cd' command runs. The 'cd' command
changes the current directory only within that process. If you want
to change the current directory within your Perl program, use Perl's
built-in 'chdir' function.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
[for beginner's Usenet info, see http://web.presby.edu/~jtbell/usenet/ ]
------------------------------
Date: 10 May 1997 17:07:27 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Incorrect warning?
Message-Id: <5l2a0f$u7p$4@dartvax.dartmouth.edu>
In article <5ku8fv$15nm@yuma.ACNS.ColoState.EDU>
steffend@lamar.colostate.edu (Dave Steffen) writes:
> #!/usr/bin/perl -w
>
> use Getopt::Std;
> getopts ('x:y:w:');
> print "$opt_x $opt_y $opt_w\n"; # these are set in the getopt module
>
> Executing `testbug -x1 -y2 -w3` gives
>
> Identifier "main::opt_w" used only once: possible typo at testbug line 12.
> Identifier "main::opt_x" used only once: possible typo at testbug line 12.
> Identifier "main::opt_y" used only once: possible typo at testbug line 12.
> 1 2 3
>
> Now, it's clear that the $opt_n variables are getting used
> twice (once when they're set and once when they're printed), but
> apparently the -w switch can't catch that.
>
> The program works fine, and AFAIKT is correctly written. If I
> don't use the -w switch, all is well... except that I dislike _not_
> using the -w switch. Perl seems to think there's a possible error
> here, and I'm inclined to think that Perl knows more about Perl than I
> do! ;-) ;-)
>
> So the question is: why am I getting this warning, and is
> there really something wrong with my code?
Yes, those variables are also used when they're set, *but* they're set
in GetOpt. That means they only appear once in your code.
It's possible to turn off the -w effect for specific parts of your
code, using the $^W variable. That's probably what you want to do.
Or you could be cheesy and use the variables somewhere else in your
code. (Make sure it's not in a void context, though, cause then you'll
get a different warning.)
Chipmunk
------------------------------
Date: 13 May 1997 07:59:33 GMT
From: Torsten Naumann <Torsten.Naumann@informati.tu-chemnitz.de>
Subject: Re: Memory Clearing
Message-Id: <5l9715$sci$1@narses.hrz.tu-chemnitz.de>
In article <EA3FrI.2r6@nonexistent.com>,
abigail@fnx.com (Abigail) writes:
...
> Related (?) question:
>
> I have a couple of programs that use Sybase::DBlib to access a
> database. The entire database contains less than 20 Mb data.
> But if the program does many queries to the database, it will
> run out of memory. In about 100.000 queries it will use over
> 150 Mb of memory. I've no idea what is leaking the memory.
> All my variables are my()ed (running with -wT & use strict;),
> and the few global variables are assigned to only once.
>
> Is this a known bug in Sybase::DBlib?
> Are there methods to find out which module uses so such memory?
I think you are using hashs (a very great thing I know) but the
problem is that such data structures need more memory than a simple
array. I had the same problem. My perl script scaned a file of 250kb
an the used memory was over 9mb - oops ! So I changed to use arrays
instead of hashs an the used memory was only 5mb for the same
datafile (2.5mb of this are perl self and his modules).
I declared glogbal vars (constants) for indices such
my $SOURCEPEERADDRESS = 1;
my $SOURCEPEERTYPE = 2;
...
Access the elements looks like a hash access
hash: $hash{sourcepeeraddress}
array: $array[$SOURCEPEERADDRESS]
In my case the problem were the very long keys (such as the thing
above).
--
mfg Torsten
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
/ Torsten Naumann +49-177-2382319 tna@informatik.tu-chemnitz.de /
/ TU Chemnitz - Fakultaet Informatik http://www.tu-chemnitz.de/~tna /
/ PGP-public-key available via finger on email-address /
/---------------------------------------------------------------------/
/ Freunde muss man suchen, Feinde sammeln sich an. -- Murphy /
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
------------------------------
Date: Tue, 13 May 1997 00:23:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Memory Clearing
Message-Id: <EA3FrI.2r6@nonexistent.com>
On 12 May 1997 21:38:02 GMT, Torsten Naumann wrote in comp.lang.perl.misc
URL: news:5l82jq$nch$1@narses.hrz.tu-chemnitz.de:
++ I filling a very big hash and then deleting every entry, but the ps -u
++ shows me no change in the momory allocation of my perl program.
++ How can I check that perl is freeing the memory ?
As far as I know, it isn't giving the memory back to the OS.
It will reuse the memory though.
Related (?) question:
I have a couple of programs that use Sybase::DBlib to access a
database. The entire database contains less than 20 Mb data.
But if the program does many queries to the database, it will
run out of memory. In about 100.000 queries it will use over
150 Mb of memory. I've no idea what is leaking the memory.
All my variables are my()ed (running with -wT & use strict;),
and the few global variables are assigned to only once.
Is this a known bug in Sybase::DBlib?
Are there methods to find out which module uses so such memory?
Abigail
------------------------------
Date: 10 May 1997 23:59:45 GMT
From: ouster@tcl.eng.sun.com (John Ousterhout)
Subject: New draft of scripting white paper
Message-Id: <5l325h$41h$1@engnews2.Eng.Sun.COM>
This is to announce that I've posted a new revision of my scripting white
paper. You can get HTML and PostScript versions at the following URLs:
http://www.sunlabs.com/people/john.ousterhout/scripting.html
http://www.sunlabs.com/people/john.ousterhout/scripting.ps
There is also a new Web page that provides more detailed information
such as the complete MFC and Java implementations of the button example
and more descriptive data for the comparisons in Table 1:
http://www.sunlabs.com/people/john.ousterhout/scriptextra.html
If you hated the first version then you aren't likely to be satisfied
with the new version either, but I've toned down the section on objects
a bit, mentioned the "L" word, and made various other small changes.
------------------------------
Date: 12 May 1997 23:56:21 -0400
From: Barry Margolin <barmar@bbnplanet.com>
Subject: Re: New draft of scripting white paper
Message-Id: <5l8op5$dc4@pasilla.bbnplanet.com>
In article <3377A4F1.72C6@dis.org>, Cimarron Taylor <cimarron@dis.org> wrote:
> SQL is a example
> of a domain-specific language where the domain is managing
> data.
Well, my preferred way of interfacing with our Informix databases is with
isqlperl. It uses SQL to interface with the database, but then lets me use
Perl's control structures, pattern matching, output formatting, etc. for
the rest of the program. Thus, Perl is providing glue between the database
and other parts of the system, just as a good scripting language should.
--
Barry Margolin
BBN Corporation, Cambridge, MA
barmar@bbnplanet.com
(BBN customers, call (800) 632-7638 option 1 for support)
------------------------------
Date: Tue, 13 May 1997 15:34:25 +1000
From: Graham Matthews <graham.matthews@maths.anu.edu.au>
Subject: Re: New draft of scripting white paper
Message-Id: <3377FD61.44DF@maths.anu.edu.au>
According to Cimarron Taylor <cimarron@dis.org>:
> :To me the main difference between Tcl bindings to domain-specific
> :API libraries and a true domain-specific language is that the fundamental
> :execution model of a Tcl binding cannot differ from the semantics forced
> :on you by the Tcl interpreter whereas the execution model of a domain-specific
> :language can adopt the semantics most appropriate to the problem.
lvirden@cas.org wrote:
> Can you provide specific examples of the types of things you believe one
> cannot do in Tcl but which would be required to be able to be done to
> be able to create domain specific APIs?
I don't think thats the point. I think the point is that if you wanted
for example lazy evaluation in your domain specific application, then
you can't get lazy evaluation just by cobbling together Tcl bindings to
domain specific API libraries, since the Tcl interpreter itself is not
lazy.
graham
--
We have not succeeded in answering all of our problems. Indeed, we
often feel we have not completely answered any of them. The answers
we
have found only serve to raise a whole set of new questions. In some
ways we feel we are as confused as ever, but we believe we are
confused
on a much higher level and about more important things.
------------------------------
Date: Sun, 11 May 1997 04:13:22 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: openning a file like readonly...
Message-Id: <5l3fth$38n$1@news3.microserve.net>
Sergio Stateri Jr <serginho@usa.net> wrote:
>Hi! I'd like to know how can I do to open a read only file in Perl. I
>think that if I use open(FILE,"<file.dat");
This open will allow you to read the file.
> other user may read the file, aren't they ?
Yes other user may read file also.
> I'd like to know too how I modify a line of the
>file...
I generally read the old file and write a new file.
Then when both file are succefully closed then
I remove the old file (unlink) and rename the new
file to the original name.
If anyone else may also be doing this at the same time,
read up on flock.
>If a use print FILE "hahaha"; it sum this bytes on the file, and
>I'd like to change a line of the file...
> please help me :))
> Thanks!!
> Sergio Stateri Jr
> e-mail : serginho@usa.net
------- signature ----------
Check out the Perl site!
http://www.microserve.net/~soccer/
use password perlmisc
Geat tool for Developers>
------------------------------
Date: Tue, 13 May 1997 07:55:54 GMT
From: Gordon McDorman <gordon.leslie.mcdorman@sap-ag.de>
To: jkhuon@athena.mit.edu (Jenny Khuon)
Subject: Re: Perl on Windows NT4.0
Message-Id: <uaflz4xh1.fsf@sap-ag.de>
>>>>> "Jenny" == Jenny Khuon <jkhuon@athena.mit.edu> writes:
Jenny> Does anyone can give me a pointer where I can get perl's
Jenny> Windows NT version.
<URL:http://www.activeware.com>
You may also consider using DejaNews to search for already answered
questions. An invaluable resource:
<URL:http://www.dejanews.com>
--
--------------------------------------------------------------
The opinions expressed above are mine, not my employer's.
gordon.leslie.mcdorman@sap-ag.de
------------------------------
Date: 10 May 1997 15:23:54 GMT
From: jdr@sloth.mlb.semi.harris.com (Jim Ray)
Subject: Re: Perl5.003 (released) under HPUX 9.07
Message-Id: <5l23ua$487@hearye.mlb.semi.harris.com>
Keywords: hpux,perl5
Amazing -- 5.004 (5.003_93) works just fine.
Anyone have a clue? Anyone seen this?
Thanks,
--
Jim Ray Harris Semiconductor
Internet: jdr@semi.harris.com PO Box 883 MS 62B-022
Phone: (407) 729-5059 Melbourne, FL 32901
------------------------------
Date: Sat, 10 May 1997 19:06:42 GMT
From: sam@deletethis.serve.com (Sam Schlansky)
Subject: Pre-made script to search FTP sites and display HTML indexes?
Message-Id: <5l2h01$3js$1@news.nyu.edu>
Hiya.
One quick question...
Anyone in here know of a pre-written script (or set of scripts) that will
index several (up to 2-300 max) FTP sites, and present a searchable index
through form input in HTML? I have checked out FTPSearch, and it is quite
complex and much too powerful for my needs.
I just wanted to know if its been done already so I don't have to do it
myself. I'm lazy and proud of it!
thanks,
Sam Schlansky
--
/| Sam Schlansky <sam@serve.com>
/| http://b52-78.datanet.nyu.edu/ (currently defunct)
/| PGP Key ID: 0x63A9D707
/| I speak with my voice only, nobody else's!
/| NOTE: email "sam@serve.com", not "sam@deletethis.serve.com"
------------------------------
Date: Sat, 10 May 1997 17:57:15 -0700
From: James Kass <jbrandon@cats.ucsc.edu>
Subject: Problem using variables as filenames.
Message-Id: <3375196B.1B4B@cats.ucsc.edu>
Hello:
I am trying to write a simple CGI for a website here and I keep running
into an ugly problem. I know there is a simple solution for this... so
I thought someone might be able to provide it on the newsgroup.
My code looks like this:
$text="some text";
$filename = "/cats/fvweb/public_html/bbs/msg$ID";
open (TEXTFILE, ">$filename") || &write_err;
print TEXTFILE "$text\n";
close (TEXTFILE);
It is being run via a CGI on the web... the directory for the bbs is
given full
write permissions... but I keep getting the error sub that I wrote.
using:
open (TEXTFILE, "$filename") || &write_err;
works without error... but it's the writing (">") that is causing
problems. How
do I fix that?
Thanks for any help... I know it's Saturday and all. I prefer email
response.
-Jim
jbrandon@cats.ucsc.edu
------------------------------
Date: Sat, 10 May 1997 21:12:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: James Kass <jbrandon@cats.ucsc.edu>
Subject: Re: Problem using variables as filenames.
Message-Id: <Pine.GSO.3.96.970510210620.3856B-100000@kelly.teleport.com>
On Sat, 10 May 1997, James Kass wrote:
> I am trying to write a simple CGI for a website
Actually, you're writing a CGI program or a CGI script. CGI stands for
"Common Gateway Interface", and you certainly don't need to (re)write the
interface! :-)
> $text="some text";
> $filename = "/cats/fvweb/public_html/bbs/msg$ID";
What's $ID set to? Is it what you want?
> open (TEXTFILE, ">$filename") || &write_err;
> print TEXTFILE "$text\n";
> close (TEXTFILE);
> I keep getting the error sub that I wrote.
Does the error sub report the current value of $! , which should be the
error message such as "permission denied"? That would be a valuable clue.
> using:
>
> open (TEXTFILE, "$filename") || &write_err;
>
> works without error... but it's the writing (">") that is causing
> problems.
Yes; in the one case you're reading a file, in the other you're writing
it. Permissions for one aren't necessarily the same as permissions for the
other. I suspect that your process doesn't have the needed write
permission.
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on the perl.com web pages. Hope
this helps!
http://www.perl.com/perl/
http://www.perl.com/perl/faq/
http://www.perl.com/perl/faq/idiots-guide.html
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Tue, 13 May 1997 04:03:30 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Randal Schwartz
Message-Id: <tcyangEA3pxu.HA4@netcom.com>
It must be a tough Perl question to write a pattern for all the
permutations of your name which people have used ..... :)
=================================
Randal Schwartz (merlyn@stonehenge.com) wrote:
: Well, at least he-she spelled my name right. You wouldn't believe the
: number of incorrect ways to spell either Randal or Schwartz, and
: therefore the number of permutations of both.
: Of course, some would argue that my first name is spelled wrong
: anyway. :-)
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.clever.net/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Tue, 13 May 1997 04:19:39 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: REQ: Perl obfuscator
Message-Id: <EA3qos.LtI@nonexistent.com>
On 13 May 1997 01:05:50 GMT, Salve J Nilsen wrote in comp.lang.perl.misc
URL: news:5l8epe$hll@due.unit.no:
++
++ # ##############################
++ # Remove text from q|#| to end of line, exept when q|\#|, q|'#'|
++ # or q|"#"|.
++ # Look out for \\# and similar cases (q|\\\\#| etc).
++ # Remove excess (two or more) whitespaces plus newlines/returns.
++ #
++ warn "Pass 4... Whitespace and comments\n" unless $QUIET;
++ s/(
++ (?:\\\\)*(?!\\)?([\"\'])[^\1]*(?:\\\\)*[^\\]\1|
++ # We don't want to touch strings
++ ([\"\'])\2|
++ # - not even empty ones!
++ (?:\\\\)*\\\#.*?$|
++ # and we're aware of escaped hashes
++ \$\#.*?$)|
++ # and the length-of-array index ($#foo)
++ \#.*?$|
++ # ... so let's keep this stuff!
++ \s{2,}|
++ # We want to remove all excess whitespace (but leave one though)
++ [\r\n]|
++ # and the newlines
++ \#.*?$/$1/gmx;
++ # and the comments!
++
++ # Bugs:
++ # Can't remove comments from inside regular expressions
++ # with the /x modifier, unless they are on a seperate line.
++ # Can't remove comments from inside RE of the (?#comment) type.
++ # Doesn't recognize "print << EOT;" constructs.
++ # The \\\\\# comment construct is not tested (yet)
++ # A tab whitespace ("\t") won't be substituted with a space (' ')
Hmmm, you can't remove '#' from m #plugh#, s#foo#bar#, qq #foo#, qx #bar#,
q #baz#, qw #bar foo#, tr #xyz#zy@# or y #123#321# either.
And strings can be delimited by more than quotes. q <foo # bar> doesn't
contain a comment start.
As for whitespace, page 77 of the Camel suggests that putting a newline
between the function name and the left parenthesis can change the
behaviour - though I've never managed to find an example.
It seems that here documents can be really screwed up (by all of the
modify sections).
------------------------------
Date: 10 May 1997 06:24:37 GMT
From: zbaker@venom.st.hmc.edu (Zach Baker)
Subject: Re: scalar holds compiled code
Message-Id: <5l14b5$9v4$1@cinenews.claremont.edu>
In article <01bc573a$6aac7ce0$228118ac@mtn_view_guffey>,
Tom Vaughan <guffey@anpi.com> wrote:
>
>given:
>
>$stuff = << 'END_OF_STUFF';
>[compiled program, eg. C]
>END_OF_STUFF
>
>how do I execute what $stuff holds?
Well, I can't even imagine a POSIX (or otherwise portable) way of
executing program data from out of the blue, so it has to be in a file.
Since I believe that you indicated elsewhere you want to avoid writing
out the data for some reason, I suppose you can fork off a process
that writes that data to a named pipe and execute that (?!?) if your
system supports it and you're really determined. Or you could write
an interface to a C function that does something really raunchy. =^)
---
Zach Baker <zbaker@venom.st.hmc.edu>
"Flavour Mother Nature Never Intended"
------------------------------
Date: Sat, 10 May 1997 11:26:57 +0100
From: Kurt Lawlor <kurt@enterprise.net>
Subject: Re: sendmail script
Message-Id: <33744D71.26A0@enterprise.net>
Geoffrey V. Brown wrote:
>
> I am looking for a way to use perl as a mailing list script.
> What I would like to do is open a file that contains email addresses,
> read each line into an array, then use foreach to send information to
> each person on the list. The function I have seems to work, but the
> script for sendmail doesn't work properly and gives a ton of errors. I
> am using digital unix with perl 5. I'd perfer not to use a module since
> I am unfamiliar with this and fairly new to perl.
Not that I know much about it, but mail does work as well. Use -t (i
think) which
scans for to:'s. Mail is a bit simpler.
This is not what you asked but cats can be skined many ways.
Kurt
------------------------------
Date: 11 May 1997 03:38:33 GMT
From: comdog@computerdog.com (brian d foy)
Subject: Re: sendmail script
Message-Id: <comdog-2604721321370001@nntp.netcruiser>
In article <337340D6.6EBD@traverse.lib.mi.us>, "Geoffrey V. Brown"
<an745@traverse.lib.mi.us> wrote:
> I am looking for a way to use perl as a mailing list script.
> What I would like to do is open a file that contains email addresses,
> read each line into an array, then use foreach to send information to
> each person on the list. The function I have seems to work, but the
> script for sendmail doesn't work properly and gives a ton of errors. I
> am using digital unix with perl 5. I'd perfer not to use a module since
> I am unfamiliar with this and fairly new to perl.
what sorta errors?
well, modules are good, but sometimes it's good exercise to do it
yourself :) (then use the modules).
you can try something like:
# -odq will save your life in a mailing list
open(MAIL, "| /path/to/sendmail -oi -t -odq")
print MAIL "$sendmail_headers\n$sendmail_data";
close MAIL;
--
brian d foy <http://computerdog.com>
------------------------------
Date: 10 May 1997 20:23:21 GMT
From: neilb@zetnet.co.uk (Neil Briscoe)
Subject: Re: sendmail script
Message-Id: <memo.19970510212338.29685C@skep.compulink.co.uk.cix.co.uk>
In article <337340D6.6EBD@traverse.lib.mi.us>, an745@traverse.lib.mi.us
(Geoffrey V. Brown) wrote:
> I am looking for a way to use perl as a mailing list script.
> What I would like to do is open a file that contains email addresses,
> read each line into an array, then use foreach to send information to
> each person on the list. The function I have seems to work, but the
> script for sendmail doesn't work properly and gives a ton of errors. I
> am using digital unix with perl 5. I'd perfer not to use a module since
> I am unfamiliar with this and fairly new to perl.
>
Yup - piece of trivia. I did exactly that using the tools that came my
way by using the Net::SMTP module. You need to get libnet and mailtools -
both available from CPAN. If you're not happy about navigating CPAN yet,
then you can get these modules by ftp'ing to anorak.fourthnet.co.uk and
looking in /pub/perl/modules - note that anorak isn't updated very often -
the CPAN is always up to date.
Regards
Neil
------------------------------
Date: Sun, 11 May 1997 04:21:18 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: sendmail script
Message-Id: <5l3gcc$38n$2@news3.microserve.net>
You can look at (and use) my script that does email as
you describe.
Follow signature instructions. Use password perlmisc.
This is my test site. Follow path to perl cross reference
and look up email.cgi. Works for me.
Hope this helps.
"Geoffrey V. Brown" <an745@traverse.lib.mi.us> wrote:
>I am looking for a way to use perl as a mailing list script.
>What I would like to do is open a file that contains email addresses,
>read each line into an array, then use foreach to send information to
>each person on the list. The function I have seems to work, but the
>script for sendmail doesn't work properly and gives a ton of errors. I
>am using digital unix with perl 5. I'd perfer not to use a module since
>I am unfamiliar with this and fairly new to perl.
------- signature ----------
Check out the Perl site!
http://www.microserve.net/~soccer/
use password perlmisc
Geat tool for Developers>
------------------------------
Date: Sat, 10 May 1997 22:07:17 -0400
From: Bill Cowan <billc@tibinc.com>
To: Michael Limprecht <admiral@eng.sun.com>
Subject: Re: Show variables during debug?? Debuggers in general.
Message-Id: <337529D5.5643@tibinc.com>
Michael Limprecht wrote:
>
> Being new at this I was wondering if there's anyway to
> show the variable values during a trace or debug session?
>
> Something similar to "#!/bin/csh -xv".
>
> Example:
> System::submit_lb_job(/vobs/tools/src/run/lib/System.pl:193):
> 193: open(JOB,"/import/camelot/tools/lsf/lsf,v2.2a/sun4-5/bin/bsub.exec $job_queue_string -J $job_name $ENV{'LB_FLAGS'} cleartool setview -exec \"$job_text\" $job_view |");
>
> I want to see the value of $job_text during the trace and not just
> that it was executed.
>
You might try the "a" command ("action") in the debugger. When certain
line of code is executed, this command will take some action such as
conditionally printing $job_text and then continue execution. Quite
useful without having to use breakpoints.
FYI: I think newer versions of man perldebug have much better
descriptions of debugger commands than available previously.
-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com> Voice:919-490-0034 Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707
------------------------------
Date: Mon, 12 May 1997 23:58:38 -0400
From: Eddie Chang <edchang@ix.netcom.com>
Subject: Similiar Function for getspnam( ) ?
Message-Id: <3377E6EE.56FC@ix.netcom.com>
Hi all,
All my PERL scripts using function getpwnam() in my Linux machine have
problem now. Since I installed Shadow Password, this function retures
"X" as encripted password. Every scripts broke down.....
Is there anything like C getspnam() I can use for PERL?
Thank you in advance.
Eddie
------------------------------
Date: 10 May 1997 15:15:49 -0400
From: Tom Fawcett <fawcett@nynexst.com>
Subject: Re: Something I'm missing
Message-Id: <8jvi4r9lzu.fsf@nynexst.com>
Aaron Bennett <abennett@stonehill.edu> writes:
> I was hoping the program below would put <TR><TD></TR></TD> around every
> line that has no tab characters in it. Instead is matches every line in
> the file.
>
> The file is like this:
> [cut to the chase]
> while ($textline=<INPUT>) {
> $textline =~ s/(.+\t{0}.+)/<TR><TD>$1<\/TD><\/TR>/sg;
\t{0} matches the null string, so it's a no-op here.
You can't test for non-existence of a pattern element this way.
I'd do:
$textline = "<TR><TD>$textline</TD></TR>" unless $textline =~ /\t/;
-Tom
PS. comp.lang.perl is long dead, replaced by comp.lang.perl.misc.
------------------------------
Date: Sat, 10 May 1997 01:29:30 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: split problem
Message-Id: <E9xyt6.6Fr@bcstec.ca.boeing.com>
In article <3370B395.690A@russiamail.com>,
Slava V Bereza <vvbereza@russiamail.com> wrote:
>
>Does anybody knows how to split lines if I have a number of
>delimiters in row? If I have two or more whitespaces, I get
>whitespaces in my array after splitting. I do not what it.
>Also how is it possible to give different delimiters in one split?
>
Splitting on the pattern /\s/ will produce the unwanted
results you describe.
Either of these will eat adjacent whitespace, e.g.,
@parts = split(/\s+/,$string);
@parts = split(" ",$string); # like awk's split
You can split on multiple delimiters with something like
this, e.g.:
@parts = split(/!|:/, $string); # splits on either ! or :
or, if you don't want empty fields, just change
to:
@parts = split(/!+|:+/, $string);
Check perl manpage for more info on split.
HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com
------------------------------
Date: 10 May 1997 23:34:57 GMT
From: ljz@asfast.com (Lloyd Zusman)
Subject: Re: system () won't execute the called program.
Message-Id: <slrn5na12i.uoe.ljz@ljz.asfast.net>
On Wed, 07 May 1997 13:01:50 GMT, SJK <knetsch@golden.net.no.spam> wrote:
> On 06 May 1997 12:24:31 -0400, Ken Anderson <anderson@necsys.gsfc.nasa.gov>
> wrote:
>
> >
> >Hi again,
> >
> >I have a perl program which has to execute an external
> >c program, so i am using
> >
> >
> > system("cprog -p prog.par") && die "cprog failed. $!\n";
> >
>
> Ummm.... I'm just a newbie, but I think I see something here. You're asking the
> program to call the system AND die. Don't you want it to die only if the system
> call fails? ie
>
> system("cprog -p prog.par") || die "cprog failed. $!\n";
Normally, you would be correct. However, the 'system' call is a
special case: it returns the exit code that the program it runs passes
to the operating system. In Unix, MS-DOS, and Windows NT systems,
this exit code is 0 on success and non-zero on failure.
Therefore, in the example above, you need to 'die' if system returns
a non-zero error code. Hence, the '&&'.
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: Tue, 13 May 1997 13:10:09 +0800
From: Benny Chee <chchee@iti.gov.sg>
Subject: Timer on my perl script
Message-Id: <Pine.SOL.3.91.970513130304.13682A-100000@hercules.iti.gov.sg>
Hi,
Was trying to set a timer for my
script to execute certain applications
during a certain time.
I've written a script (rather clunky) on it.
What i wanted to do is to make it do
2 jobs in a day. At 7:30am, copy a file.
At 12 midnight, delete a file.
I ran my program, and i saw my load
went straight up.
Need help in correcting my script.
I guess my problem is, when i run it now,
the load will shoot up till the time
either reaches 7:30am or 12am.
Well, here's the script.
#!/usr/local/bin/perl
#
use File::Copy;
($sec,$min,$hour,$monthday,$month,$year,$weekday,$yearday,$isdaylight)
=localtime(time);
while(1) {
DOIT:
while(($hour==7 && $min==30 && $sec==0)||
($hour==23 && $min==59 && $sec==0)) {
if ($hour==7) {
copy ("file1.txt", "file2.txt");
sleep 59398; #i calculated this..it will sleep till 11:59pm
last DOIT;
}
elsif ($hour==23){
open(DELETE, ">file2.txt");
print DELETE "";
close DELETE;
sleep 26998; #sleep till 7:29am
last DOIT;
}
}
}
Benny Chee :) | "I used to have a life,
chchee@iti.gov.sg | but now I have a T1."
------------------------------
Date: 10 May 1997 19:31:14 -0500
From: Tushar Samant <scribble@wwa.com>
Subject: What is the context of $a->m1 in $a->m1->m2 ?
Message-Id: <5l340j$c9t@shoga.wwa.com>
I would like to make constructions like $a->m1->m2.
My thinking went like this: for "->m2" to work in the above,
$a->m1 would have to return a package or object reference.
Which means, the "->m2" expects a scalar. So, in particular,
it's enough for the "m1" method to return the proper object
IN A SCALAR CONTEXT.
But this did not work (5.003); it went like this. (One reason
for such code could be: to cascade several simple substitutions
on one string and keep printing them without typing too much).
#!/usr/local/bin/perl5/perl -w
package String;
use strict;
use vars qw($WRITE);
$WRITE = sub {@_};
sub new {
my($class, $string) = @_;
bless \$string, $class;
}
sub s {
my($self, $re, $s, $flags) = @_;
$re = "(?$flags)$re" if $flags;
$$self =~ s{$re}{$s};
$self;
}
sub write {
my($self, $continue) = shift;
$continue ||= $WRITE;
my @ret = &$continue($$self);
## PROBLEM SPOT ##
wantarray ? @ret : $self;
}
package main;
no strict;
$String::WRITE = sub { print "$_[0]\n" };
$a = new String "abcdefg";
$a->s("[e-z]", "A", "g")->s("a", "z", "ig")->write;
#works
$a->s("[e-z]", "X", "g")->write->s("x", "y", "ig")->write;
|
#produces error here ----------+
__END__
But the most amazing thing is, it works as expected when
I switch the legs of the "wantarray"! So what is going on
here?
--
Sober, ballsy, moving poems. <http://i-2.com:8080/~tushar/Poems/>
------------------------------
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 465
*************************************