[6828] in Perl-Users-Digest
Perl-Users Digest, Issue: 453 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 8 19:07:23 1997
Date: Thu, 8 May 97 16:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 8 May 1997 Volume: 8 Number: 453
Today's topics:
Re: "Bad free() ..." message from perl v4.036 (I R A Aggie)
A Perl Question <ranjbar@cig.mot.com>
Re: A Perl Question (Kelly J. Humbert)
Re: A Perl Question <stranw@gte.net>
Re: closed filehandle error ("John Dallman")
Re: FormMail & NT Server (EMWAC Internet Mail Services (Neil Briscoe)
Re: Half of GD.pm working with Perl 5.003_07 (Steven Galfano)
Have a question? Post it here at the CGI Discussion For (TOTO)
mount problem on install <geoff@opcom.ca>
Re: mount problem on install <bpatil@cup.hp.com>
Re: Notice to antispammers - is there a list of spammer <dorman@s3i.com>
Re: Perl auto-replier (rga)
Re: possible typo warning (Tad McClellan)
Problem compiling DBI-0.77 with gcc <rcastill@icix.net>
Problem with "print <<EOM; " statement (Scott Wiersum)
Re: Problem with "print <<EOM; " statement (Mike Stok)
problem with split() or bug in a2p ? (saj6u)
Re: program for perl? (Craig Berry)
Re: replacing escape characters in a text file. (Tung-chiang Yang)
Re: scrambling the elements of any array?? <spammers_suck@[127.0.0.1]>
Re: scrambling the elements of any array?? (Tim Smith)
Re: Sending e-mail from within a perl script - help <usenet-tag@qz.little-neck.ny.us>
Re: variable names <rstar@ramworks.com>
Re: What is the rationale for this calling convention? (Ilya Zakharevich)
Re: What is the rationale for this calling convention? (Terrence M. Brannon)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 08 May 1997 16:20:08 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: "Bad free() ..." message from perl v4.036
Message-Id: <fl_aggie-ya02408000R0805971620080001@news.fsu.edu>
In article <5kt1ll$bv8@news.service.uci.edu>, ehood@medusa.acs.uci.edu
(Earl Hood) wrote:
+ on economics, business politics, and human resource management, so
+ if you (and others) do not know an answer to the original question,
+ please do not respond.
Several of us have provided you with the correct answer: upgrade to
v5. That the answer does not solve your problem to your satisfaction
is not our problem.
+ BTW, I am well aware of the status of Perl 4.
Then you are aware that Perl 4 is unsupported and that you are on your
own.
James
--
Consulting Minister for Consultants, DNRC
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Thu, 08 May 1997 13:07:15 -0500
From: Ali Ranjbar <ranjbar@cig.mot.com>
Subject: A Perl Question
Message-Id: <33721653.41C67EA6@cig.mot.com>
Hello there;
I am new to Perl. I am trying to search for parentheses in a string and
then get read of them. Getting read of them should not be difficult.
However; sounds like Perl is using () for memory in regular expressions.
How do I do that. I tried:
if ($summary=~ /\(/{ # where $summary has the string I am searching in.
I also tried:
if ($summary=~ /(/{ # where $summary has the string I am searching in.
and
if ($summary=~ /(|)/{ # where $summary has the string I am searching in.
Every time I get a syntax error.
--
Ali N. Ranjbar Motorola CIG, IL75-3J5
Phone:(847)435-9797 Fax:(847)632-5959 E_mail:ranjbar@cig.mot.com
I will not let anyone walk through my mind with their dirty feet.
Mahatma Gandhi
------------------------------
Date: Thu, 08 May 97 22:06:36 GMT
From: khumbert@mail.sdsu.edu (Kelly J. Humbert)
Subject: Re: A Perl Question
Message-Id: <5ktisl$jp7$1@hole.sdsu.edu>
You forgot the final / to end the regex.
$summary =~ / \( / { /;
Don't forget the s in front of the regex if your substituting, or a g at the
end if you want to replace globally (more than one per line).
In article <33721653.41C67EA6@cig.mot.com>, Ali Ranjbar <ranjbar@cig.mot.com>
wrote:
>Hello there;
>
>I am new to Perl. I am trying to search for parentheses in a string and
>then get read of them. Getting read of them should not be difficult.
>However; sounds like Perl is using () for memory in regular expressions.
>How do I do that. I tried:
>if ($summary=~ /\(/{ # where $summary has the string I am searching in.
>
>I also tried:
>if ($summary=~ /(/{ # where $summary has the string I am searching in.
>
>and
>if ($summary=~ /(|)/{ # where $summary has the string I am searching in.
>
>Every time I get a syntax error.
------------------------------
Date: 8 May 1997 22:32:29 GMT
From: "William Stranathan" <stranw@gte.net>
Subject: Re: A Perl Question
Message-Id: <5ktk9t$d8m$1@news7.gte.net>
try:
$summary =~ s/(.*)\((.*)/\1\2/;
I know that's weird looking, but...
Search for 0 or more of any kind of character, followed by an open paren
followed by any number of chars. Replace with the first set of chars, then
the second.
Ooops! Gurus: with regexps being as greedy as they are, would the
following happen?
$summary = "foo((bar";
$summary = s/(.*)\((.*)/\1\2/;
print "$summary";
would that give foo(bar ?
Hmmm...
Will Stranathan
stranw@gte.net
Ali Ranjbar <ranjbar@cig.mot.com> wrote in article
<33721653.41C67EA6@cig.mot.com>...
> Hello there;
>
> I am new to Perl. I am trying to search for parentheses in a string and
> then get read of them. Getting read of them should not be difficult.
> However; sounds like Perl is using () for memory in regular expressions.
> How do I do that. I tried:
> if ($summary=~ /\(/{ # where $summary has the string I am searching in.
>
> I also tried:
> if ($summary=~ /(/{ # where $summary has the string I am searching in.
>
> and
> if ($summary=~ /(|)/{ # where $summary has the string I am searching in.
>
> Every time I get a syntax error.
> --
> Ali N. Ranjbar Motorola CIG, IL75-3J5
> Phone:(847)435-9797 Fax:(847)632-5959 E_mail:ranjbar@cig.mot.com
>
> I will not let anyone walk through my mind with their dirty feet.
> Mahatma Gandhi
>
------------------------------
Date: Thu, 8 May 1997 20:39:48 GMT
From: jgd@cix.compulink.co.uk ("John Dallman")
Subject: Re: closed filehandle error
Message-Id: <E9vqqD.6rI@cix.compulink.co.uk>
In article <r5d8r3h5ze.fsf@tvmaster.turner.com>,
mcampbel@tvmaster.turner.com (Mike Campbell) wrote:
> Scott Blanksteen <sib@worldnet.att.net> writes:
> > You probably also want to check the return value of 'close'.
>
> I've often wondered about this practice. Other than for reporting
> purposes, of what value is checking to see whether or not a 'close'
> was successful? I mean, what would you do if it weren't?
Depends what you're doing - I have some scripts that need to create a file
successfully and abort if a close fails. It's rare to encounter it, but if
you do, a common cause is a full disk - by default, small files won't have
been written to disk until they're closed. Until then, they will have been
sitting in the buffers of the stdio library linked with the perl
executable.
---
John Dallman, jgd@cix.co.uk. A micro-FAQ on things I keep getting asked:
#!perl is at ftp://.../CPAN/ports/msdos/tips-tricks/hbp_403.zip, Perl for
NT/Win 95 can be found at http://www.activeware.com, with an excellent FAQ
file at http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
and no, I don't have the slightest idea what's wrong with your CGI script.
Try http://www.perl.com/perl/faq/idiots-guide.html
------------------------------
Date: 8 May 1997 19:45:59 GMT
From: neilb@zetnet.co.uk (Neil Briscoe)
Subject: Re: FormMail & NT Server (EMWAC Internet Mail Services for Windows NT Version 0.8x
Message-Id: <memo.19970508204616.29685C@skep.compulink.co.uk.cix.co.uk>
In article <3371ECEB.5D9A@berlin.snafu.de>, merath@berlin.snafu.de (Stefan
Merath) wrote:
> Hi,
>
> anybody knows a FormMail-Port for the above named Mailserver? Or maybe
> something else with the function to send formated mail with a cgi-call?
>
> Please reply to my e-mail-adress too
>
Regrettably, this client won't let me mail and news at the same time, so,
since you took the trouble to post, take the trouble to read, just as I
did in responding.
I unmercifully hacked the mail bits out of Net:SMTP into a usable form for
windows NT. It certainly works with our Purveyor web server (which was
developed from EMWAC) so I doubt you'll have any problems. Then I
modified the form2mail script to use the hacks I made. If you want it,
you can come ask for it.
I've set the Reply-To: address appropriately. If you want the stuff, mail
me at work and I'll be happy to pass the stuff along.
Regards
Neil
------------------------------
Date: Thu, 08 May 1997 10:20:01 -0700
From: galfano@ucla.edu (Steven Galfano)
Subject: Re: Half of GD.pm working with Perl 5.003_07
Message-Id: <galfano-0805971020010001@164.67.58.21>
I did some more research, although the results were somewhat predictable...
I telnetted to the HTTP port on the server, and did a GET on the test2.pl
script. All I get is:
Content-type: image/gif
Connection Closed...
So the script is spitting out the MIME header, but none of the good stuff.
Hmmm....
-Steve
P.S. I should also mention that Perl scripts not using GD.pm work
perfectly on the server. Even a Perl script that just spits out a GIF file
(not using GD) works, too. (Just in case there is any doubt in your mind)
:)
In article <galfano-0705971929560001@164.67.58.21>, galfano@ucla.edu
(Steven Galfano) wrote:
> I am using:
> ----------
> PERL 5.003_07 (Build 306) on an NT 4.0 Server.
> Got the latest GD.pm and GD.pll (from ftp.roth.net)
>
> What works
> ----------
> When I am working directly from the server, the test perl scripts spit out
> the nice GIF binary code just perfectly (and saves GIFs to files). This
> indeed makes me happy.
>
> What annoys me
> --------------
> However, when I use the same script as a CGI on the WWW, I get "Document
> contains no data" and a broken image. It almost seems like GD.pm is
> trying to create a temp file somewhere that the INET_** user does not have
> permission to write.
>
> Any insight?
>
> Thanks!!
>
> -Steve
------------------------------
Date: Thu, 08 May 1997 20:34:17 GMT
From: sorry@no.can.do (TOTO)
Subject: Have a question? Post it here at the CGI Discussion Forum.
Message-Id: <337538b9.6505373@news.enterprise.net>
Hi,
For any questions regarding CGI & PERL, please refer to the new
message board at
http://www.netforward.com/cryogen/?toto
Please pass the word around and lets see if we can all help each
other.
My apologies if you feel this should not be posted to this group.
Regards
TOTO
------------------------------
Date: Thu, 8 May 1997 12:18:53 -0400
From: "Geoff Fry" <geoff@opcom.ca>
Subject: mount problem on install
Message-Id: <5kta8k$3453@news.ott.opcom.ca>
I'm installing Redhat off CD-ROM. The CD gets detected and everything runs
smooth during install(setup) until it trys to mount the file system. Here
is the error:
- mount. wrong fs type or bad superblock on /dev/hda2
- mount -t ext2 /dev/hda2/mnt/
- exited with code 1
I re-partitioned my drive because I thought there was a problem having the
second partition as a linix partition. I had a 250 meg, type 83 partition
and a 30 meg, type 82 swap partition. No other file system was present the
second time I tried this.
My CD-Rom is the second device on IDE interface #1, with the HD as the
first one. My system is a Cyrix 150+ with 32 megs of RAM.
I'm pretty sure the file types are not the problem, what is this
superblock?
Geoff Fry
------------------------------
Date: Thu, 08 May 1997 14:12:44 -0700
From: Bapu Patil <bpatil@cup.hp.com>
Subject: Re: mount problem on install
Message-Id: <337241CB.EB4@cup.hp.com>
Geoff Fry wrote:
>
> I'm installing Redhat off CD-ROM. The CD gets detected and everything runs
> smooth during install(setup) until it trys to mount the file system. Here
> is the error:
>
> - mount. wrong fs type or bad superblock on /dev/hda2
> - mount -t ext2 /dev/hda2/mnt/
> - exited with code 1
>
> I re-partitioned my drive because I thought there was a problem having the
> second partition as a linix partition. I had a 250 meg, type 83 partition
> and a 30 meg, type 82 swap partition. No other file system was present the
> second time I tried this.
> My CD-Rom is the second device on IDE interface #1, with the HD as the
> first one. My system is a Cyrix 150+ with 32 megs of RAM.
> I'm pretty sure the file types are not the problem, what is this
> superblock?
> Geoff Fry
Unix File System on disk is devided into
- Boot Block - Bootable stuff are kept
- Superblock
- I Node - Information about I node is kept
- Data Block - User data ...etc
Superblock : holds the information about file system.
State of the File system, How large is the file system, How many files
can store, no of blocks, also
i-node information.
I-Node - For each file, there well be a uniq I-node
Number. Check "ls -i" for i nodes.
--
-----------------------------------------------
Bapu Patil
E Mail: bpatil@cup.hp.com
---------------------------------------------------
------------------------------
Date: 07 May 1997 10:34:18 -0400
From: Clark Dorman <dorman@s3i.com>
Subject: Re: Notice to antispammers - is there a list of spammers to pluginto procmail?
Message-Id: <d67wvfj11.fsf@s3i.com>
Note that I've added comp.mail.misc to this thread.
regan@ao.com (Dave Regan) writes:
> In article <336f1c67.116909796@news.diac.com>,
> sitaram@diac.com (Sitaram Chamarty) writes:
> >My question, for Nathan or Tom or anyone else who knows, is: is there
> >a frequently updated list of spammers that I can periodically plug
> >into my procmail recipe as an include file? (I do use procmail, but I
> >got tired of constantly adding addresses to it, hence this question).
> >
> >If there was, I'd delete the no-spam junk in my email address. I
> >don't mind having to download something once a week (using LWP) (and
> >that takes care of making this post on-topic for c.l.p.m :-).
>
> There is a list that AOL maintains. It isn't necessarily in a format
> for directly plugging into procmail. See:
> http://www.idot.aol.com/preferredmail/
>
> With a short Perl program I'm sure you can remove the HTML wrapping
> and get straight to the addresses. From there it should be easy
> to add the wrapping to make it fit into procmail. Then you can fire
> the whole mess off with cron and not have to worry about it anymore
> (except for when AOL changes the format of the file. :))
>
> Once done, you can advertise your hack in all of the appropriate places.
>
> The version I am looking at was updated on 5 May 1997, so it
> appears that they keep it up to date. AOL is also the target of
> lots of spammers so they probably get notified promptly when there
> is abuse.
Ok, I've just started using procmail, and have had the same problem,
namely that spammers come from many addresses. Here's a first cut
script. Procmail gurus please let me know how to improve the procmail
file format. If there is a better or additional source of spammers, I
can add that to the script as well.
----------------------------------------------------------------------
#!/home/dorman/bin/perl -w
# This script creates a procmail file from the AOL list of spammers:
# http://www.idot.aol.com/preferredmail/
# Save the info in HTML format into "index.html" and run this script
# Add the following line to your .procmailrc
# INCLUDERC=$PMDIR/rc.fromaol
# I'm using a (likely-poor) method of procmail commands. Suggestions
# appreciated. Obviously, if you are not dorman, you'll need to
# change the perl source above and dir/file names.
use strict;
my ($proc_file);
$proc_file = "/home/dorman/.procmail/rc.fromaol";
if (-e $proc_file) {
unlink $proc_file or die "cannot delete old procfile \n";
}
open(AOLPAGE, "index.html") or die "Cannot open index file";
open(PROC_ALT, ">$proc_file") or die "Cannot create new procmail file";
# Strip off the top HTML stuff
while (<AOLPAGE>) {
last if /^<MULTICOL COLS=3/;
}
# Make the proper procmail file. Note the lack of chop of $_ and
# resulting non-use of \n when printing $_ into the file.
while (<AOLPAGE>) {
last if /^<\/MULTICOL>/;
print PROC_ALT ":0:\n";
print PROC_ALT "* ^From:.*$_";
print PROC_ALT "IN.SPAMMER\n\n";
}
close AOLPAGE or die "Huh? Cannot close index file";
close PROC_ALT or die "Cannot close procmail file";
----------------------------------------------------------------------
--
Clark Dorman "Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
------------------------------
Date: Thu, 08 May 1997 20:06:03 GMT
From: rga@io.com (rga)
Subject: Re: Perl auto-replier
Message-Id: <33723054.27411311@news.io.com>
Ronald.J.Kimball@dartmouth.edu (Chipmunk) wrote:
Olay, since this is still going on
Here's a cute addition.
Dear G*d, I know it doesn't belong here, BUT ..
found in the best of internet newsgroup.
Subject: Light bulbs
From: Birmingham City Council EDD Training Services
<training@bcceddts.demon.co.uk>
Newsgroups: uk.net.news.config
I hope this will help remind people to temper discussion of newsgroup
names and charters with a little humour and consideration (I found it
quoted on Usenet; the author was not credited) :
Q: How many internet mail list subscribers does it take
to change a light bulb?
A: 1,331:
1 to change the light bulb and to post to the mail
list that the light bulb has been changed
14 to share similar experiences of changing light
bulbs and how the light bulb could have been
changed differently.
7 to caution about the dangers of changing light bulbs.
27 to point out spelling/grammar errors in posts about
changing light bulbs.
53 to flame the spell checkers
156 to write to the list administrator complaining about
the light bulb discussion and its inappropriateness
to this mail list.
41 to correct spelling in the spelling/grammar flames.
109 to post that this list is not about light bulbs and
to please take this email exchange to alt.lite.bulb
203 to demand that cross posting to alt.grammar,
alt.spelling and alt.punctuation about changing
light bulbs be stopped.
111 to defend the posting to this list saying that we
are all use light bulbs and therefore the posts
**are** relevant to this mail list.
306 to debate which method of changing light
bulbs is superior, where to buy the best light bulbs,
what brand of light bulbs work best for this
technique, and what brands are faulty.
27 to post URLs where one can see examples of
different light bulbs
14 to post that the URLs were posted incorrectly, and
to post corrected URLs.
3 to post about links they found from the URLs that
are relevant to this list which makes light bulbs
relevant to this list.
33 to concatenate all posts to date, then quote
them including all headers and footers, and then
add "Me Too."
12 to post to the list that they are unsubscribing
because they cannot handle the light bulb
controversey.
19 to quote the "Me Too's" to say, "Me Three."
4 to suggest that posters request the light bulb FAQ.
1 to propose new alt.change.lite.bulb newsgroup.
47 to say this is just what alt.physic.cold_fusion
was meant for, leave it here.
143 votes for alt.lite.bulb.
RGA Home Pages and Rainbow Garden !
Stories, Inspiration, Morning Thought.
http://www.io.com/~rga/rainbow.html
------------------------------
Date: Thu, 8 May 1997 13:31:17 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: possible typo warning
Message-Id: <l56tk5.5k.ln@localhost>
the count (eglamkowski@hotmail.com) wrote:
: this may be a newbie-ish question, but i am getting a possible typo
: warning and have no idea what is causing it. it has the unfortunate
: result of leaving the variables in question with a value of undef.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
You have the cause and the effect reversed. The fact that they are
undef is what is causing the error messages.
: i have never seen this warning before, and there is nothing in the
: "Programming Perl" book about it (chapter 9 is a whole chapter on
: nothing
: but diagnostic messages, and this one isn't in there).
I assume you have the 2nd edition of the Camel, which is updated
to perl 5.
You are using perl 4, yes?
: % perl -w tickler.pl
: Possible typo: "caseID" at tickler.pl line 75
: Possible typo: "endOfWindow" at tickler.pl line 77
: [lots of 'Use of uninitialized variable' warnings deleted]
: while (<CASELIST>) {
: chop;
: @caselist_tmp__fields = split;
foreach (@caselist_tmp__fields) {
print "'$_'\n"; # lets see if they are undef (or null string)
# at this point
}
: $caseID = $caselist_tmp__fields[0]; <-- line 75
: $startOfWindow = $caselist_tmp__fields[1];
: $endOfWindow = $caselist_tmp__fields[2]; <-- line 77
: i am not getting the warning on line 76, which is the same format.
: any idea why lines 75 & 77 are a problem?
Are $caseID and $endOfWindow used at least one other time somewhere
in your program? If a variable is used only once, perl guesses that
it might be a typo since there isn't much point in remembering something
in a variable if you're never going to use it...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Thu, 08 May 1997 13:45:44 -0400
From: Ramon Castillo <rcastill@icix.net>
Subject: Problem compiling DBI-0.77 with gcc
Message-Id: <33721148.7ECE@icix.net>
I installed perl5.003 in a ultra 1 with Solaris 2.5 but the C compiler
resides in other server running Solaris 2.4 and the path is
/usr/share/bin/gcc I had the same problem instalin perl5 I get tired and
mounted the bin, everything is running normal in my local machine but
the gcc still is in other machine.
Now when I do "make test" I get this:
ramonc#make test
gcc -c -O -DVERSION=\"0.77\" -DXS_VERSION=\"0.77\"
-I/opt/GNUperl5/lib/sun4-solaris/5.003/CORE -Wall -Wno-comment DBI.c
gcc: installation problem, cannot exec cpp: No such file or directory
make: *** [DBI.o] Error 1
Thanks in advance
------------------------------
Date: Thu, 08 May 1997 21:23:50 GMT
From: scott@smartgate.com (Scott Wiersum)
Subject: Problem with "print <<EOM; " statement
Message-Id: <3372437c.80207727@news.xnet.com>
I'm running perl v4 on a BSD machine and experiencing the following
error:
print <<EOM;
print "hello";
EOM;
unix# perl test.pl
EOF in string at test.pl line 1.
What am I doing wrong?
Scott
scott@smartgate.com
------------------------------
Date: 8 May 1997 22:09:40 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Problem with "print <<EOM; " statement
Message-Id: <5ktiv4$ag6@news-central.tiac.net>
In article <3372437c.80207727@news.xnet.com>,
Scott Wiersum <scott@smartgate.com> wrote:
>I'm running perl v4 on a BSD machine and experiencing the following
>error:
>
> print <<EOM;
> print "hello";
> EOM;
The print <<EOM; is equivalent to print <<EOM ; (i.e. perl sees the ; as a
separate token) so it's looking for EOM alone on a line to terminate the
string. In 5.003_99 it says:
[mike@localhost tmp]$ ./try.pl
Can't find string terminator "EOM" anywhere before EOF at ./try.pl line 3.
removing the ; from the terminating token line should fix it.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 8 May 1997 21:15:58 GMT
From: sjanet@unagi.cis.upenn.edu (saj6u)
Subject: problem with split() or bug in a2p ?
Message-Id: <5ktfqe$smu@netnews.upenn.edu>
[perl5 (5.0 patchlevel 3 subversion 0) under SunOS 4.1.1]
Is this a bug in a2p, or a bug in split()? I think it's the latter
based on the split() function's documentation that states that
split(' ',...) should emulate awk's behavior. It appears from the
process output below that split() is getting confused by trailing
whitespace after a "word", and it finds an extra one in those cases.
Below, I translate the blanks in my test datafile to hyphens for
readability. Thanks in advance for any insight.
-Stan
========================================
% tr ' ' '-' < /tmp/nf.dat
-
a
-b
c-
-d-
e-f
-g-h
i-j-
-k-l-
% echo '{ print NF }' | a2p > /tmp/a2p.pl
% cat /tmp/a2p.pl
#!/usr/local/bin/perl
eval 'exec perl -S $0 "$@"'
if $running_under_some_shell;
# this emulates #! processing on NIH machines.
# (remove #! line above if indigestible)
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
# process any FOO=bar switches
$[ = 1; # set array base to 1
$, = ' '; # set output field separator
$\ = "\n"; # set output record separator
while (<>) {
chop; # strip record separator
@Fld = split(' ', $_, 9999);
print $#Fld;
}
% chmod 755 /tmp/a2p.pl
% awk '{ print NF }' /tmp/nf.dat
0
0
1
1
1
1
2
2
2
2
% /tmp/a2p.pl /tmp/nf.dat
0
0
1
1
2
2
2
2
3
3
Perl version 4 even differs from version 5 by finding words in
the empty line and the single-blank line:
% perl_v4.0 /tmp/a2p.pl < /tmp/nf.dat
1
1
1
1
2
2
2
2
3
3
------------------------------
Date: 8 May 1997 19:03:58 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: program for perl?
Message-Id: <5kt82u$rs8$1@marina.cinenet.net>
Richard K. Downer (rkd7949@ballard.ca.boeing.com) wrote:
: Kyzer wrote:
: > But the $64000 question is, if you write it in antelope blood on a cave wall,
: > can you get perl to execute it afterwards? :)
: >
: No. Now how do I collect the $64000?
You don't, because you're wrong. Here's how to use the Perl "Antelope
Blood on Cave Wall" (soon to be released by Microsoft as "Antelope '97")
IDE:
1. Print Perl code *neatly* on cave wall in antelope blood.
2. Take picture of coded wall with a digital camera.
3. Run results of step 2 through an OCR system.
4. Submit results of step 3 to Perl.
And voila! One can even imagine a system that would track how pixels map
to line/char positions forward through steps 2-3; using this information,
a servo-controlled mirror, and a small laser, one could highlight syntax
errors in the code.
Erasing antelope blood from the cave wall to revise these errors is left
as an exercise for the student.
---------------------------------------------------------------------
| 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: Thu, 8 May 1997 19:02:29 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: replacing escape characters in a text file.
Message-Id: <tcyangE9vM85.AC@netcom.com>
Many people followed up this thread, but am I right that "*" has a special
meaning for Perl pattern matching (0 or more counts) so we have to
escape it?
--
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: 8 May 1997 12:21:58 -0700
From: zeadeATstanford.edu <spammers_suck@[127.0.0.1]>
Subject: Re: scrambling the elements of any array??
Message-Id: <5kt94m$eli@epic15.Stanford.EDU>
In comp.lang.perl.misc, Jong (jong@mrc-lmb.cam.ac.uk) blibbers...
> Hi,
>
> I have made a subroutine which does the job, but I
> am sure there are faster and different ways of
> doing it. Can you think of the fastest way possible
> in Perl
>
> Thanks a lot,
>
> Jong
>
> #___________________________________________________________________
> # Title : scramble_array
> # Usage : @out=@{&scramble_array(\@in)};
> # Function :
> # outs line numbers with lines
> # Example :
> # Warning :
> # Keywords :
> # Options :
> # Version : 1.0
> #---------------------------------------------------------------
> sub scramble_array{
> srand(time()|$$); # or use srand(time^$$);
> my ($i, $k, $len, $ran_pos, @scrambled_out_array, $ran_num, @random);
>
> for($i =0; $i< @_; $i++){
> my @each_array = @{$_[$i]};
> my $len=@each_array;
>
> for($k=$len; $k > 0 ; $k--){
> my $ran_pos = int(rand($k));
> my $ran_num=splice(@each_array, $ran_pos, 1);
> push(@random, $ran_num);
> }
> my $random=join("", @random);
> push(@scrambled_out_array, $random);
> undef(@random);
> }
> return(\@scrambled_out_array);
> }
Hmmm, this seems overly complicated, although I think you are on
target with using splice. Would seem much easier to just scramble one
array at a time instead of passing in several references (and then
also returning an array instead of references). It's just my take on
it though.
## untested!
sub scramble_array
{
my @array = @_;
my (@new_array, $offset);
srand(time()|$$);
while (@array) {
$offset = rand($#array);
push(@new_array, splice(@array, $offset, 1));
}
return (@new_array);
}
'luck,
Micah
(note: lame-o spam block, reply to zeade...)
--
:: Micah Jaffe :: http://www-leland.stanford.edu/~zeade ::
:: "The dead are rising and they're voting Republican!!" - Bart Simpson ::
------------------------------
Date: 8 May 1997 12:39:19 -0700
From: trs@azstarnet.com (Tim Smith)
Subject: Re: scrambling the elements of any array??
Message-Id: <5kta57$hrs@web.azstarnet.com>
In article <33722146.41C6@mrc-lmb.cam.ac.uk>,
Jong <jong@mrc-lmb.cam.ac.uk> wrote:
>Hi,
>
>I have made a subroutine which does the job, but I
>am sure there are faster and different ways of
>doing it. Can you think of the fastest way possible
>in Perl
>
>Thanks a lot,
I don't know how much faster this is:
#!/usr/bin/perl -w
my @sorted = qw(one two three four five six seven eight nine ten);
print "Sorted:\n", map({"\t$_\n"} @sorted);
print "Scrambling...";
my @scrambled = @{scramble_array(\@sorted)};
print "ok.\n";
print "Sorted:\n", map({"\t$_\n"} @sorted);
print "Scrambled:\n", map({"\t$_\n"} @scrambled);
exit 0;
sub scramble_array {
my ($array) = @_;
my @sorted = @$array; # local copy - don't mess up caller's array
srand(time ^ $$);
my @scrambled = ();
while (@sorted) {
my $ran_pos = int(rand(@sorted));
push @scrambled, splice @sorted, $ran_pos, 1;
}
\@scrambled;
}
__END__
Tim
------------------------------
Date: 8 May 1997 19:05:37 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Sending e-mail from within a perl script - help
Message-Id: <5kt861$c70$1@news.netusa.net>
John Sheehy <jsheehy@trintech.com> wrote:
>For some unknown reason (at least to me) /bin/mail starts reading from
>standard input. This results in the script hanging and waiting for keyboard
>input. I have verified this by sending a message to myself. I also replaced
>/bin/mail with the cat command and watched the lines bounce back at me as I
>typed.
I don't know what is up there. Can you do things like this?
cat file bile tile | /bin/mail -s "some subject" user
Maybe your mail likes to read from /dev/tty.
>Is there an alternative to this method? Perhaps
>open(MAILPIPE, "|telnet mailhost 25");
I use sendmail directly myself. I like to control headers. You
shouldn't rely on mail being on port 25 anyway. Have telnet look
it up from /etc/services by using the service name (smtp) instead.
>
>
Why do you have those <ctrl-Z>s there?
Why do you have a 31 line signature?
Elijah
------
"telnet 127.1 telnet" is fun obscurity
------------------------------
Date: Thu, 08 May 1997 15:00:57 -0400
From: Ron Starling II <rstar@ramworks.com>
To: eglamkowski@hotmail.com.OBLIGATORY.ANTI.SPAM.FILTER
Subject: Re: variable names
Message-Id: <337222E9.6CDF6BE8@ramworks.com>
use an array
for ($i = 1; $i <= $X; $i++) {
$a[$i] = some_expression;
if that's too simple, i'm sure eval could prove useful
the count wrote:
>
> it is possible to create variable names on the fly?
> for example, i want a series of variables a1, a2, a3... up to aX where
> X is a user defined variable.
> i.e. is there any way concatenate together two or more variables
> to create a new variable name?
>
> i'd like to be able to do something like:
> for ($i = 1; $i <= $X; $i++) {
> $a."$i" = some_expression;
> }
>
> and end up with:
> $a1 = something
> $a2 = something_else
> $a3 = something_else_yet_again
> etc.
>
> is this legal? if not, is there any other way to do this?
>
> --
> "The gods themselves struggle in vain against stupidity." - Schiller
--
+--------------------+-------------------------------+
Ron Starling II net: rstar@ramworks.com
Web Engineer web: http://www.ramworks.com
RAMWORKS fon: 904.778.8568
Jacksonville, FL 32210 fax: 904.778.0081
+--------------------+-------------------------------+
------------------------------
Date: 8 May 1997 21:07:21 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: What is the rationale for this calling convention?
Message-Id: <5ktfa9$1pq$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Terrence M. Brannon
<brannon@bufo.usc.edu>],
who wrote in article <ysizn2q6hha9.fsf@bufo.usc.edu>:
> Given the following sub which exists in PDL/Core.pm
>
> sub zeroes {
> my $class = shift;
> print "zeroes rec'd ", $class, " as class", $/;
> my $nelems = 1; my @dims;
> for (@_) {
> croak "Dimensions must be positive" if $_<=0;
> $nelems *= $_; push @dims, $_
> }
> my $pdl = bless {}, $class;
> $$pdl{Data} = "\0"x($nelems*howbig($PDL_F));
> $$pdl{Datatype} = $PDL_F;
> $$pdl{Dims} = [@dims];
> return $pdl;
> }
>
> Is there some utility in it sending in a different first argument
> depending on whether I use absolute or relative addressing to invoke
> the function?
>
> main::(-e:1): 42
> DB<1> use PDL
>
> DB<2> $a = zeroes(10)
> zeroes rec'd PDL as class
>
> DB<3> $a = PDL::Core::zeroes(10)
> zeroes rec'd 10 as class
Looks like a bug. Does it behave the same without debugger?
Ilya
------------------------------
Date: 8 May 1997 15:51:31 -0700
From: brannon@bufo.usc.edu (Terrence M. Brannon)
Subject: Re: What is the rationale for this calling convention?
Message-Id: <ysizohalfuhb.fsf@bufo.usc.edu>
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
>
> Looks like a bug. Does it behave the same without debugger?
It's actually not a bug. PDL just does some things to functions before
you call them. It's a PDL feature, not a bug.
--
o============o Sending unsolicited commercial e-mail (UCE) to this address
Legal Notice is indication of your consent to pay me $120/hour for 1 hour
o============o minimum for professional proofreading & technical assessment.
terrence brannon * brannon@rana.usc.edu * http://rana.usc.edu:8376/~brannon
------------------------------
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 453
*************************************