[6378] in Perl-Users-Digest
Perl-Users Digest, Issue: 3 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 24 12:17:35 1997
Date: Mon, 24 Feb 97 09:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 24 Feb 1997 Volume: 8 Number: 3
Today's topics:
*perlxstut error : Embedding C/C++ into Perl 5.003 <john.carter.3320157@nt.com>
ANNOUNCE: MailTools-1.09 <gbarr@ti.com>
Re: Append to 1st line only variable (Tad McClellan)
DB_File on Solaris / Netscape BSD dbm databases <steveg@metrosol.demon.co.uk>
Re: efficiency of many fixed strings vs one regex (Jeffrey)
Error in PERLXSTUT - Embedded C/C++ Help required. <john.carter.3320157@nt.com>
Re: Executing a DOS command in PERL? (The next Pele)
Re: for god sake (Jagadeesh Venugopal)
forward Url <russ@eastland.net>
Re: futur de perl et java-script (Nathan V. Patwardhan)
Re: futur de perl et java-script (Bennett Todd)
gdbm on AIX <P.C.vanderWekken@siep.shell.com>
Re: how long before I can put down the books? (Scott McMahan - Softbase Systems)
How to override "open" function correctly <cedar.w.milazzo@boeing.com>
Re: How to spam - legitimately <merlyn@stonehenge.com>
Inline packages <mconley@pms110.pms.ford.com>
Multi-line processing <dmills@riag.com>
Perl Reference (Clay Irving)
Q: Free PERL Database Tools? <dlorenso@afai.com>
Re: Sending long file names to NT Perl <mchase@ix.netcom.com>
test <dmills@riag.com>
Uniqing an array (John Day)
uniqing an array (John Day)
Re: Uniqing an array (Mike Stok)
using sockets <vivaldi_jorge@info.upf.es>
Re: Which one is the best (pattern matching) (Nathan V. Patwardhan)
Re: YANQ (yet another newbie question) (Tad McClellan)
Re: YANQ (yet another newbie question) (Nathan V. Patwardhan)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 24 Feb 1997 15:54:10 +0000
From: John Carter <john.carter.3320157@nt.com>
Subject: *perlxstut error : Embedding C/C++ into Perl 5.003
Message-Id: <3311B9A2.2D5@nt.com>
Hi All,
Can anyone help me with embedding C/C++ functions into Perl. Currently I
am using the perlxstut man page (Written by Jeff Okamoto 29/10/96) but
the examples don't work. I am running Perl 5.003 on Solaris 5.5.
After running 'h2xs -A -n <Test1>' followed by the transcript below, I
get an error outlining that the C module cannot be found.
I have entered the script plus .xs file as specified by the guide, but
no joy. Has anyone had any problems with this in the past, or does
anyone have any alternatives??
Regards
John.
john.carter@3320157.nortel.com.
------------------------------------------------
Shell Transcript
perl Makefile.PL
Writing Makefile for Test1
/* Run make */
npgts143 28: make
cp test1.pl ./blib/lib/test1.pl
gcc -c -O -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fpic
-I/opt/perl/lib/su
n4-solaris/5.003/CORE Test1.c
Running Mkbootstrap for Test1 ()
chmod 644 Test1.bs
LD_RUN_PATH="" gcc -o blib/arch/auto/Test1/Test1.so -G -L/opt/gnu/lib
Test1.o
chmod 755 blib/arch/auto/Test1/Test1.so
cp Test1.bs ./blib/arch/auto/Test1/Test1.bs
chmod 644 blib/arch/auto/Test1/Test1.bs
Manifying ./blib/man3/Test1.3
/* Run the script and get the
error!!! */
npgts143 30: test1.pl
Can't find loadable object for module Test1 in @INC (./blib
/opt/perl/lib/sun4-s
olaris/5.003 /opt/perl/lib /opt/perl/lib/site_perl/sun4-solaris
/opt/perl/lib/si
te_perl .) at Test1.pm line 18
BEGIN failed--compilation aborted at test1.pl line 5.
----------------------------------------------------
Script file - test1.pl
#!/opt/perl/bin/perl
use lib './blib';
use Test1;
----------------------------------------------------
.xs file - Test1.xs
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif
MODULE = Test1 PACKAGE = Test1
void
hello()
CODE:
printf ("Hello World!\n");
------------------------------------------
.pm file as created by 'make'
------------------------------
Date: 24 Feb 1997 15:53:25 GMT
From: Graham Barr <gbarr@ti.com>
Subject: ANNOUNCE: MailTools-1.09
Message-Id: <5esdhl$q1c$1@nadine.teleport.com>
I have just uploaded to CPAN a new release of the MailTools distribution.
The MailTools distribution is a set of perl modules related to mail
applications. They allow reading, creation, manipulation and sending
(to some extent) of RFC822 compilant Email messages. The distribution
also contains a module which can parse Email addresses.
This release contains the following Changes
o Mail::Header
Fixed a de-reference problem in unfold()
_fold_line will no longer fold the From line that gets added by
the user mail agent.
o Mail::Internet
Added DESTROY, to stop AutoLoader errors
o Mail::Mailer
Fixed an undef problem in new
o Tests
Added t/send.t and t/mailer.t
It should be avaliable on mirror sites soon.
Comments are always very welcome.
Copyright 1996-7 Graham Barr. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Share and Enjoy!
Graham <gbarr@ti.com>
--
Graham Barr <gbarr@ti.com>
"Only two things are infinite, the universe and human stupidity, and
I'm not sure about the former."
--Albert Einstein
------------------------------
Date: Mon, 24 Feb 1997 06:45:37 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Append to 1st line only variable
Message-Id: <hh2se5.1q.ln@localhost>
Carl Payne (cpayne@xmission.xmission.com) wrote:
: Trying to open a datafile, append the day to ONE LINE of the file and
: read in the rest.
: I have a file. Let's say it charts the snacks I sell each day, and it looks
: like this:
: 17,18,19,20,21 #these are the days the file covers
: 5,2,1,383 #the # of apples, cakes, pies and Jolts sold on the 17th
: 13,0,1,426 #18th
: 8,2,2,0,360 #and so on
: 2,1,5,1,225
: 9,0,1,2,135
: It's kind of archaic because the total of snacks is tabulated automatically
: each day and appended to this file in this awkian format. Right now, that
: first line in the file with the days it covers isn't edited automatically,
: only the data lines below it.
: What I want to do:
: each day, append today's number to the end of the first line of the file.
: As long as perl can handle it, this line can go on ad nauseum. While the
: datA lines in my example will always be 5 fields long, the datE line can be
: 45, 60, however many fields.
: The end result is that I will have a routine that can tell me how many of
: what snack were sold on what day. I think I can handle that part. What has
: me stuck is opening the file, appending the day (with a comma) to that one
: line, adding that day's totals (the way it already does) to the end of the
: file and closing the file without harming all that data.
: Would something like this work:
: {
: open(SNACKFILE," >$snackdata");
^^^^^^^^^^^
Oops. Bye bye datafile. Hope you had a backup ;-)
You should also check to see if the open() call actually worked...
: $newdline=$firstline,$currdate(day)
: print SNACKFILE <<EOF;
: $newdline;
: $the_rest_of_snackdata_without_the_first_line;
: $todaysnacks;
: EOF
: }
: What is that variable I don't yet know? If $1 is the first field, what is
: the first line?
: $^ ??
: $seen{$^} ??
: This seems like it could be simpler, and it also seems like pulling that
: file in has to be done through a pipe. I think I've been at this too long
: today
As the file I/O seems to be the part you are asking about, I'll
help with that. How to find out the date is left as an exercise
for the reader (I use a system dependant call). Adding the
cumulative totals is also left as an exercise.
The simple approaches to changing a file are either:
1) write to temp file, then rename() the temp file over the original
2) pull the entire file into memory, modify it, then write it back out.
to do #1:
-----------------
#! /usr/bin/perl -w
$snackfile = 'snackfile';
open(SNACKFILE, "$snackfile") || die "could not open '$snackfile' $!";
open(OUT, ">tempfile") || die "could not open 'tempfile' $!";
chomp($date_line = <SNACKFILE>); # get the first line, remove the newline
$date = `date +%d`; # find out today's date, leave the newline
$date_line .= ",$date"; # append date to line
print OUT $date_line;
while (<SNACKFILE>) {
# do stuff to $_
print OUT $_;
}
close(SNACKFILE);
close(OUT);
rename("tempfile", $snackfile);
-----------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Mon, 24 Feb 1997 15:30:58 +0000
From: Steve Gailey <steveg@metrosol.demon.co.uk>
Subject: DB_File on Solaris / Netscape BSD dbm databases
Message-Id: <3311B432.50F1@metrosol.demon.co.uk>
I am trying to access Netscape DBM databases on a Solaris 2.4 system. It
would appear that Netscape have changed dbm format since I last did this
and now use the BSD DBM stuff.
I don't seem to have these libraries on my Solaris box, and hence I
don't
have DB_File. Should I be getting them for Solaris, or is there
something
I should be doing in perl to make it work?
Steve
------------------------------------------------------------------------
Steve.Gailey@nomura.co.uk Nomura London
------------------------------------------------------------------------
The views expressed herein do not necessarily reflect the views of
Nomura
International plc and cannot be relied upon by any other party.
Nomura
International plc is a member of the London Stock Exchange and is
regulated by The Securitites and Futures Authority
----------------------------------------------------------------------
------------------------------
Date: 23 Feb 1997 12:49:03 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: tchrist@mox.perl.com (Tom Christiansen)
Subject: Re: efficiency of many fixed strings vs one regex
Message-Id: <JFRIEDL.97Feb23214903@tubby.nff.ncl.omron.co.jp>
[mail and post]
Tom Christiansen <tchrist@mox.perl.com> wrote:
|> :According to Jeffrey, p.284, the Benchmark module in not appropriate
|> :for use with regexps due to "problems" with $&.
Actually, just to be a bit more clear, it's not that Benchmark was bad to
use with regexes, but that it contaminated all regexes in the whole script
to always make a post-match copy of the matched string. If the regex uses
capturing parens, the post-match copy is done anyway, so the use of
Benchmark (which used Carp, which used $&, which then contaminated the
whole script) for such regex uses is ok.
Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
See my Jap<->Eng dictionary at http://www.wg.omron.co.jp/cgi-bin/j-e
O'Reilly's Regular Expression book: http://enterprise.ic.gc.ca/~jfriedl/regex/
------------------------------
Date: Mon, 24 Feb 1997 15:29:26 +0000
From: John Carter <john.carter.3320157@nt.com>
Subject: Error in PERLXSTUT - Embedded C/C++ Help required.
Message-Id: <3311B3D6.800@nt.com>
Hi All,
I am attempting to embed C functions into Perl 5.003 running on Solaris
5.5. I am using the perlxstut man page (produced by Jeff Okamtoto
29/10/96). However things go wrong with the first example.
After runnung 'h2xs -A -n <test dir>' followed by the transcript taken
from my shell below, I get an error complaining it can't find the 'C'
module.
I have entered both the script and xs file as specified, but no luck
Anyone have any ideas or alternatives.......
Cheers
John Carter
john.carter.3320157@nortel.com
------------------------------------------
Shell Transcript
/* Run Makefile.pl */
npgts143 27: perl Makefile.PL
Writing Makefile for Test1
/* Run Make */
npgts143 28: make
cp test1.pl ./blib/lib/test1.pl
gcc -c -O -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fpic
-I/opt/perl/lib/su
n4-solaris/5.003/CORE Test1.c
Running Mkbootstrap for Test1 ()
chmod 644 Test1.bs
LD_RUN_PATH="" gcc -o blib/arch/auto/Test1/Test1.so -G -L/opt/gnu/lib
Test1.o
chmod 755 blib/arch/auto/Test1/Test1.so
cp Test1.bs ./blib/arch/auto/Test1/Test1.bs
chmod 644 blib/arch/auto/Test1/Test1.bs
Manifying ./blib/man3/Test1.3
/*Run my script and get an error!!!!*/
npgts143 30: test1.pl
Can't find loadable object for module Test1 in @INC (./blib
/opt/perl/lib/sun4-s
olaris/5.003 /opt/perl/lib /opt/perl/lib/site_perl/sun4-solaris
/opt/perl/lib/si
te_perl .) at Test1.pm line 18
BEGIN failed--compilation aborted at test1.pl line 5.
-------------------------------------------
Shell Script : test1.pl
#!/opt/perl/bin/perl
use lib './blib';
use Test1;
Test1::hello();
------------------------------------------------
.xs script
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif
MODULE = Test1 PACKAGE = Test1
void
hello()
CODE:
printf ("Hello World!\n");
----------------------------------------------
.pm file is as created by 'make'
------------------------------
Date: 24 Feb 1997 14:48:44 GMT
From: gt1535b@acmey.gatech.edu (The next Pele)
Subject: Re: Executing a DOS command in PERL?
Message-Id: <5es9oc$4r0@catapult.gatech.edu>
Bob Calvert (bob_calvert@hp.com) wrote:
: I have a DOS command, that I would like to execute from a perl script
: running as a CGI program on NT. How do I do this?
: For example, the program is: E:\cgi-bin\myprog.exe and I want to
: redirect input into this program from a file E:\temp\myfile.
: At a DOS prompt, I simply type:
: E:\cgi-bin\myprog < E:\temp\myfile
: and it works fine. Any idea how I do this in a Perl script?
: e-mail always appreciated.
Have you tried backticks?
`E:\cgi-bin\myprog < E:\temp\myfile`;
: Bob Calvert
: roc@atl.hp.com
--
<>< Daryl Bowen <><
Georgia Institute of Technology
Internet: gt1535b@prism.gatech.edu
Siemens Stromberg-Carlson Co-op
------------------------------
Date: 24 Feb 1997 14:54:18 GMT
From: jvenu@ctp.com (Jagadeesh Venugopal)
Subject: Re: for god sake
Message-Id: <5esa2q$3iu@concorde.ctp.com>
In article <5emri6$p2q$1@csnews.cs.colorado.edu> tchrist@mox.perl.com (Tom Christiansen) writes:
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, nvp@shore.net (Nathan V. Patwardhan) writes:
>:Totally. :-) You should be looking at http://www.activeware.com for
>:the Perl 5.003_07 NTPerl port (both in Intel binaries and source).
>
>Well, for now. It's possible that 5.004 will compile under Windoze.
>
>--tom
>--
Hallelujah! Finally we are looking at being able to compile Perl on
Windows!
Any more detailed news on when this might happen?
Jagadeesh
--
/\/\ |Jagadeesh K. Venugopal, jvenu@ctp.com |http://w3.ctp.com/~jvenu
/ /_.\|Cambridge Technology Partners, Inc. |http://www.ccs.neu.edu/home/jkvg
\ /./|304 Vassar St. Cambridge, MA 02139 |
\/\/ |Phone: 617.374.2028 FAX: 617.374.8300 +
------------------------------
Date: 24 Feb 1997 16:17:17 GMT
From: "Russ Verner" <russ@eastland.net>
Subject: forward Url
Message-Id: <01bc2264$e6ee9280$024a65cf@two.eastland.net>
Hello,
I was looking for a cgi script that would let you forward someone to a new
url. I plan to use a drop box for a pick list and from the user input then
send them to another url. All I need is the part to auto forward someone.
Thanks,
Russ
------------------------------
Date: 24 Feb 1997 14:04:42 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: futur de perl et java-script
Message-Id: <5es75q$t13@fridge-nf0.shore.net>
Tim Pierce (twpierce+usenet@mail.bsd.uchicago.edu) wrote:
: Speaking for myself, a monoglot, I would far rather see people
: hold conversations regularly in languages I do not know, than see
: one more fucking CGI question. If you asked me, which you have
: not, I would recommend evaluating the priorities of your battles
: more carefully.
What?!?! And I thought CGI was the "language of love" in these parts. :-)
--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
--Charles Demar from _Better Off Dead_
------------------------------
Date: Mon, 24 Feb 1997 15:29:51 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: futur de perl et java-script
Message-Id: <slrn5h3cve.ktu.bet@onyx.interactive.net>
On Mon, 24 Feb 1997 05:19:47 GMT, Tim Pierce <twpierce+usenet@mail.bsd.uchicago.edu> wrote:
>A corollary to your final observation. If the state of affairs on
>Usenet is that only people who know English can use it to any
>effectiveness, then Usenet has failed by any useful definition of
>``communication.'' Surely you don't define operational success as
>``being able to communicate with Americans?''
Come now, Americans aren't the only people who can speak english. In fact, the
English do an OK job, even if they do talk funny. Where do you get the idea
that english is some kind of private, secret code for communication between
Americans?
>If we have reached the point where it is not necessary to know English in
>order to use the net productively, then I contend that the grand experiment
>has been an unconditional success.
We've been there for a long while. There are heirarchies dedicated to
discussions in various languages. In fact, my news server claims to know about
an fr.comp.lang.perl --- and posting a note in english there wouldn't be
particularly gracious. You ought to assume that people are reading
comp.lang.perl and not fr.comp.lang.perl iff they aren't interested in
french-language postings. Posting something to a major newsgroup that cannot
be read by a large proportion of readers of that group isn't cute, it isn't
clever, and it isn't even courteous. It's just plain stupid and rude. The
volume of inappropriate traffic in netnews groups is growing, and it is making
those newsgroups less useful over time. This is not good.
>[...] I would far rather see people hold conversations regularly in languages
>I do not know, than see one more fucking CGI question.
So if you want to read articles in languages you don't understand, then there
are plenty of newsgroups that should help; a simple "newsgroups|grep perl"
turned up (among others):
de.comp.lang.perl
fj.lang.perl
fr.comp.lang.perl
no.perl
pl.comp.lang.perl
Use USENET effectively. Save your time. Save ours, too.
-Bennett
------------------------------
Date: Mon, 24 Feb 1997 14:36:36 +0100
From: "Peter.van.der.Wekken" <P.C.vanderWekken@siep.shell.com>
Subject: gdbm on AIX
Message-Id: <33119964.685B@siep.shell.com>
Does anyone of you have problems with gdbm on AIX.
I have:
This is perl, version 5.003 with EMBED
built under aix at Feb 24 1997 12:04:45
+ suidperl security patch
Copyright 1987-1996, Larry Wall
and during 'make test' all goes fine but
lib/gdbm.......FAILED on test 5
Peter
--
Peter van der Wekken <mailto:P.C.vanderWekken@siep.shell.com>
Software Support Engineer, EPT-IS
Shell International Exploration and Production B.V.
Volmerlaan 8, 2288 GD Rijswijk, The Netherlands
Telephone : +31(0)70 3112124
Fax : +31(0)70 3112166 / +31(0)70 3113110
------------------------------
Date: 24 Feb 1997 13:20:18 GMT
From: softbase@mercury.interpath.com (Scott McMahan - Softbase Systems)
Subject: Re: how long before I can put down the books?
Message-Id: <5es4ii$flh@news.interpath.net>
Richard Morin (qnc496@joanrich.kite.ml.org) wrote:
: Hi folks, Sorry for the non-specific question, but I'm kinda
: curious about something. How long before most folks felt even
: slightly proficient and could take the llama and camel books
: off the desk beside them?
We'll let you know if it ever happens.
I use C, Java, JavaScript, perl, several shell languages, and Delphi.
Now, I'm having to relearn C++. It's almost impossible not to have to
re-learn any individual language every time you sit down to use it.
Scott
------------------------------
Date: Mon, 24 Feb 1997 15:28:49 GMT
From: Cedar Milazzo <cedar.w.milazzo@boeing.com>
Subject: How to override "open" function correctly
Message-Id: <3311B3B1.2925@boeing.com>
Can anyone tell me how to override the "open()" function correctly?
I'd like to have a function called open which prepends a path to a
filename, then calls the regular open with the new filename. I have the
function which prepends the path defined as open now, but I can't make
the second part (calling the builtin open) work. Any ideas?
Thanks
Cedar Milazzo
cedar.w.milazzo@boeing.com
------------------------------
Date: 24 Feb 1997 08:43:31 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: carroll@tjc.com (Terry Carroll)
Subject: Re: How to spam - legitimately
Message-Id: <8cvi7itdjw.fsf@gadget.cscaper.com>
>>>>> "Terry" == Terry Carroll <carroll@tjc.com> writes:
Terry> On 22 Feb 1997 05:09:42 GMT, Tom Christiansen <tchrist@mox.perl.com>
Terry> wrote:
>> [courtesy cc of this posting sent to cited author via email]
>>
>> In comp.lang.perl.misc, Valdis Kletnieks <valdis.kletnieks@vt.edu> writes:
>> :> All of these emails will be different based on user preferences.
>> :Well.. if you have 18,000 different emails,
>>
>> Why does this sound wrong to my ear?
Terry> Because you haven't noticed the adaption of the English language?
Terry> It's pretty common now to hear "email" as a noun. "eletter" would be an
Terry> abomination.
If I know Tom, that's not what he's complaining about. In some minds,
"email" is an aggregate noun, like "people". So, you can get a huge
influx of "email", you just can't get 37 new "emails" (ugh, it even
hurts my ears while I'm typing it). I suppose that's because "mail",
at least in the US, is *also* an aggregate noun. The postman brings
"the mail" for the day. I get a "piece of mail". I don't get 12
"mails" in one day. Since email is derived from mail, I can see why I
have the same weird reaction to "emails". (Ugh... just reacted
again. :-)
So, there's no such word as "emails".
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Mon, 24 Feb 1997 09:13:02 -0500
From: Mike Conley <mconley@pms110.pms.ford.com>
Subject: Inline packages
Message-Id: <3311A1EE.6DCA@pms110.pms.ford.com>
I am trying to use a package inline and can't figure out why
it won't work. I can't get functions in my package exported so
that they can be called without qualification. The output of the
example is:
MyTest::myfunc called ...
Undefined subroutine &main::myfunc called at ./test2.pl line 18.
If I move MyTest to it's own MyTest.pm file, and include it with
a "use MyTest;" it works just fine.
Why won't myfunc import? How do I get it imported?
#!/usr/local/bin/perl -w
{ package MyTest;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(myfunc);
sub myfunc {
print "MyTest::myfunc called ...\n";
}
1;
}
BEGIN { MyTest->import(); } # doesn't help
MyTest::myfunc(); # 1. works
myfunc(); # 2. doesn't work, why?
--
Mike Conley
mconley@ford.com
------------------------------
Date: Mon, 24 Feb 1997 11:33:04 -0800
From: Daniel Mills <dmills@riag.com>
Subject: Multi-line processing
Message-Id: <3311ECF0.5B60@riag.com>
Hello,
How would I set up the following example to strip out all comments from
a C program including those that extend over multiple lines of the input?
I can't seem to make /m modifier work.
open(FILEIN,'program.c');
while(<FILEIN>){
if(/(\*)(.*?)(\*)/){
$comment_buf = $2;
}
}
Much Thanks.
Dan.
--
------------------------------------------------
The opinions expressed here are those of the author only.
------------------------------------------------
------------------------------
Date: 24 Feb 1997 16:00:51 GMT
From: clay@panix.com (Clay Irving)
Subject: Perl Reference
Message-Id: <5esdvj$q5t$1@nadine.teleport.com>
With great trepidation, I announce the Perl Reference (written in
Perl, of course.). The URL is:
http://www.panix.com/~clay/perl
It works for me -- Maybe it will work for you. :)
--
See the happy moron,
He doesn't give a damn, Clay Irving N2VKG
I wish I were a moron, clay@panix.com
My God! Perhaps I am! http://www.panix.com/~clay
------------------------------
Date: 24 Feb 1997 14:40:54 GMT
From: "Dante Lorenso" <dlorenso@afai.com>
Subject: Q: Free PERL Database Tools?
Message-Id: <01bc2257$f5c419e0$02151ecf@krypton.afai.com>
Question:
Does anyone know of some free Database engine/tools for PERL? Preferably
one that understands SQL-like commands?
-------> I don't want to pay for sybase or Oracle or Informix or ... BUT, I
want to manage databases...and I want to do it in PERL. I have written a
simple module that will implement a table by using dbm files and storing
all my fields in the value by delimiting by '\e'. However, this is
tedious, and still lacks some valuable functionality.
Dante
dlorenso@afai.com
http://www.afai.com/~dlorenso/
------------------------------
Date: 24 Feb 1997 14:12:39 GMT
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: Sending long file names to NT Perl
Message-Id: <01bc2210$02bb9440$LocalHost@mchase.ix.netcom.com>
There is a Win32::GetShortPathName(), but no Win32::GetLongPathName() in
Perl for Win32.
For Perl for Win32 specific questions, you should try the following
sources:
Home Site: http://www.ActiveWare.com/
Mail List: perl-win32-users@ActiveWare.com (subscribe at home site)
Archive: http://www.divinf.it/PERL-WIN32/
FAQ: http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
Mac :})
Mr Green <sspraggs@bridges.com> wrote in article
<5eqjgs$65j@fountain.mindlink.net>...
> I'm looking to send the full name of a file to a perl script using the
"right
> click" feature in Windows 95.
>
> Background:
> - The perl script is on a NT box.
> - Win 95 users need to access the script
> - Uses associations to make use of the Win 95 Right click
> (ie:perl.exe script.pl "%1")
> - Currently passes 8,3 file names and those STUPID ~1's
> if it's any longer.
> - Long filenames can be passed to it using the msdos prompt.
------------------------------
Date: Mon, 24 Feb 1997 11:24:39 -0800
From: Daniel Mills <dmills@riag.com>
Subject: test
Message-Id: <3311EAF7.7C2E@riag.com>
--
------------------------------------------------
The opinions expressed here are those of the author only.
------------------------------------------------
------------------------------
Date: Mon, 24 Feb 1997 14:26:57 GMT
From: johnday@sinbad.nsc.com (John Day)
Subject: Uniqing an array
Message-Id: <E642sy.5G9@nsc.nsc.com>
Hi,
whats the best way to do a unix uniq on an array from
within perl ?
Cheers
John
------------------------------
Date: Mon, 24 Feb 1997 14:31:31 GMT
From: johnday@sinbad.nsc.com (John Day)
Subject: uniqing an array
Message-Id: <E6430L.5n3@nsc.nsc.com>
Hi,
whats the best way to do a unix type uniq on an
array from withing perl ?
Cheers
John
------------------------------
Date: 24 Feb 1997 16:03:54 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Uniqing an array
Message-Id: <5ese5a$88u@news-central.tiac.net>
In article <E642sy.5G9@nsc.nsc.com>, John Day <johnday@sinbad.nsc.com> wrote:
> Hi,
> whats the best way to do a unix uniq on an array from
> within perl ?
The perl Frequently Asked Questions (FAQ) list (available at
http://www.perl.com/FAQ) says:
Perl FAQ 5.4
How can I extract just the unique elements of an array?
There are several possible ways, depending on whether the array is
ordered and you wish to preserve the ordering.
a) If @in is sorted, and you want @out to be sorted:
$prev = 'nonesuch';
@out = grep($_ ne $prev && (($prev) = $_), @in);
This is nice in that it doesn't use much extra memory, simulating
uniq's behavior of removing only adjacent duplicates.
b) If you don't know whether @in is sorted:
undef %saw;
@out = grep(!$saw{$_}++, @in);
c) Like (b), but @in contains only small integers:
@out = grep(!$saw[$_]++, @in);
d) A way to do (b) without any loops or greps:
undef %saw;
@saw{@in} = ();
@out = sort keys %saw; # remove sort if undesired
e) Like (d), but @in contains only small positive integers:
undef @ary;
@ary[@in] = @in;
@out = sort @ary;
There's a stack of goodies on www.perl.com along with links to
Comprehensive Perl Archive Network (CPAN) sites which contain useful
source and pointers.
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: Mon, 24 Feb 1997 15:50:41 +0100
From: Jordi Vivaldi <vivaldi_jorge@info.upf.es>
Subject: using sockets
Message-Id: <3311AAC1.7687@info.upf.es>
Hi
We're trying to implement client and server perl programs using sockets.
The client should sent text to the server, which should be sent back after
processing.
Since we don't have any experience using sockets, we have taken the
examples below (Perl man pages). Unfortunately, we have found some
problems:
- Print in line 88 (print "hello there ...") does not work (Nothing
shows up in client's screen).
- We do not know how to modify the client in order to pass parameters to
the server.
- Client requests work like an on/off switch.
Note: we're using Perl 5.002.
Anybody can help us ? Thanks in advance,
Best,
Jorge Vivaldi
Toni Tuells
##########################################################################
## server.pl
#!/usr/bin/perl -Tw
require 5.002;
use strict;
use Socket;
use Carp;
my $waitedpid = 0;
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
my $NAME = '/tmp/catsock';
my $uaddr = sockaddr_un($NAME);
my $proto = getprotobyname('tcp');
sub spawn; # forward declaration
sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }
sub ctime { scalar localtime(shift) }
sub REAPER {
$SIG{CHLD} = \&REAPER; # loathe sysV
$waitedpid = wait;
}
sub spawn {
my $coderef = shift;
unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') {
confess "usage: spawn CODEREF";
}
my $pid;
if (!defined($pid = fork)) {
logmsg "cannot fork: $!";
return;
} elsif ($pid) {
logmsg "begat $pid";
return; # i'm the parent
}
# else i'm the child -- go spawn
open(STDIN, "<&CLIENT") || die "can't dup client to stdin";
open(STDOUT, ">&CLIENT") || die "can't dup client to stdout";
#open(STDERR, ">&STDOUT") || die "can't dup stdout to stderr";
exit &$coderef();
}
socket(SERVER,PF_UNIX,SOCK_STREAM,0)|| die "socket: $!";
unlink($NAME);
bind(SERVER, $uaddr)|| die "bind: $!";
listen(SERVER,5)|| die "listen: $!";
logmsg "server started on $NAME";
my ($tt,$aux);
$SIG{CHLD} = \&REAPER;
for ( $waitedpid = 0;
accept(CLIENT,SERVER) || $waitedpid;
$waitedpid = 0, close CLIENT)
{
next if $waitedpid;
logmsg "connection on $NAME";
spawn sub {
print "Hello there, it's now ", scalar localtime, "\n";
#exec '/usr/games/fortune' or die "can't exec fortune: $!";
#while ($tt = <SERVER>) {print $tt;}
exec 'ls -l' or die "can't exec ls: $!";
};
}
##########################################################################
## client.pl
#!/usr/bin/perl -w
require 5.002;
use strict;
use Socket;
my ($rendezvous, $line);
my ($aux,$remote);
$remote = shift || 'localhost';
$rendezvous = shift || '/tmp/catsock';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "socket: $!";
connect(SOCK, sockaddr_un($rendezvous)) || die "connect: $!";
while ($line = <SOCK>) {
print $line;
}
close(SOCK);
exit;
##########################################################################
------------------------------
Date: 24 Feb 1997 14:17:09 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Which one is the best (pattern matching)
Message-Id: <5es7t5$t13@fridge-nf0.shore.net>
Bertrand Le Guen (b.leguen@ctr.renault.fr) wrote:
: to do a pattern matching in a string i use
: if ($page !~ m/\.html/g) {
: }
Might not be the best, but you can do:
$pagename = 'test.html';
if($pagename =~ /\.html$/) {
### page matches -> do something
} else {
### page doesn't match -> fails
}
--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
--Charles Demar from _Better Off Dead_
------------------------------
Date: Mon, 24 Feb 1997 06:17:33 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: YANQ (yet another newbie question)
Message-Id: <ts0se5.tl.ln@localhost>
[ emailed, posted ]
Peter Petto (ppetto@apk.net) wrote:
: I'm just getting started with Perl and want to write some directory
: synchronization routines peculiar to my needs.
: I'm looking for the best way to read the output of a (DOS) system
Me no speaky DOS, but the below should work...
(BTW: The "best" way to do this is probably opendir()/readdir()
and friends. Why build in OS dependencies when they can be avoided? ;-)
: directory command such as
: system("dir \\synchdir");
@dir_output = `dir \\synchdir`; # backwards single quotes
: directly into an array, without having to create/delete an
: intermediate file.
: I'd appreciate any and all advice. I will summarize & repost any I
: receive by email here.
As this (running external programs) seems to be covered in Perl FAQ
#5.15, I don't think summarizing will be necesary...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 24 Feb 1997 14:09:43 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: YANQ (yet another newbie question)
Message-Id: <5es7f7$t13@fridge-nf0.shore.net>
Peter Petto (ppetto@apk.net) wrote:
: I'm looking for the best way to read the output of a (DOS) system
: directory command such as
: system("dir \\synchdir");
Arggh, man! It's like running around the block to go next door. Don't
do it this way if you don't have to. :-)
Although the solution seems a little longer than using a system call or
backticks, you'll find that you have more options this way.
Why not try:
$dirname = "c:\\synchdir";
opendir(DIR, "$dirname") || die("No: $!\n");
@files = sort(readdir(DIR));
closedir(DIR);
foreach $file (@files) {
print("$file\n");
}
--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
--Charles Demar from _Better Off Dead_
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 3
***********************************