[6345] in Perl-Users-Digest
Perl-Users Digest, Issue: 967 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 18 17:37:25 1997
Date: Tue, 18 Feb 97 13:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 18 Feb 1997 Volume: 7 Number: 967
Today's topics:
[Q] Perl in win3.11? (Ric Harwood)
Re: Attatch Mail Script? <eryq@enteract.com>
Can you parse a context-free grammar with perl regexps? <ray@westlake.com>
Class library to make C++ more Perlish? <brj@doc.ic.ac.uk>
debugging perl & html (Paul S. Cutt)
Deleting files in perl <borisz@lsil.com>
Re: difference btw s/// & tr/// (Bertil Wennergren)
Extending Perl with C library - HELP! <zucchini@cts.com>
Re: extra spaces (Dave Thomas)
Re: Get filename from variable-length path? (Carl Payne)
Installing modules <santiago@gambito.com>
IPC::SysV and semaphores <beaumoaj@cs-ultra.aston.ac.uk>
Job opportunities in Milan <livio@sinapsi.com>
Missing POSX (Ric Harwood)
Re: My first PERL cgi, please critique <pauls@silverplatter.com>
Re: PERL CGI problem, writing files (Honza Pazdziora)
Re: perl script bug <nmljn@wombat.staff.ichange.com>
PerlWin32-95:Yes-NT4:No <mjsmith@isr.umd.edu>
Re: Pig Latin (Will Morse)
Re: Pig Latin (William R. Somsky)
PRE-ANNOUNCE and RFC for new module File::Vpp <domi@marlis.grenoble.hp.com>
Re: problem writing to files (Honza Pazdziora)
Re: Program wrapper ? (Honza Pazdziora)
Re: Q: how best to share a hash between packages <nmljn@wombat.staff.ichange.com>
reduce length <jjune@midway.uchicago.edu>
Re: regex and looping problem (Honza Pazdziora)
Re: regex and looping problem (Abigail)
Re: RegEx, Email & Friedl's "Mastering..." Book (Abigail)
Returning values using perl_call_pv (Premkumar Natarajan)
Re: Saving Complex Data Structures to disk, how best? (Jan Schipmolder)
Re: Screen I/O library <seay@absyss.fr>
Re: split an array? (Honza Pazdziora)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 18 Feb 1997 15:32:17 GMT
From: ric@discoveryinternational.com (Ric Harwood)
Subject: [Q] Perl in win3.11?
Message-Id: <3309c8ca.1163915@news.demon.co.uk>
I am just making my first foray into the joys of Perl.
Judging from the lack of posts perhaps it is herecy to run perl under
windoze3.11, but as I have not yet moved up to NT it is what I am
trying to do. [For construction purposes. When complete the program
will run on a connected linux box.]
I have the perl 4 distribution from /CPAN/ports/win31/ which is the
perl32.exe for NT/dos/win32. Naturally this does not like to run
under 16bit windows, or a dos shell. It runs OKish [see other post]
in dos, but when working mainly in windows this is a pain.
The dos shell prompt returns "windpm.386 not correctly installed."
It is in \perl\ but I can't find anything that tells me what to do
with it.
Can someone please point me in the right direction, or at the
appropriate manual to read in order to get perl32 running in at least
a dos shell, or even a 16bit windows version?
[I checked the FAQs on CPAN, but found no mention of win3.1]
MTIA
Ric.
--
"Big whorls have little whorls that feed on their velocity,
and little whorls have lesser whorls and so on to viscosity."
-- L.F.Richardson
PGP id:0766ABE5 http://www.discoveryinternational.com/ric/
------------------------------
Date: Tue, 18 Feb 1997 11:26:58 -0600
From: Eryq <eryq@enteract.com>
To: sy94jma@blg.du.se
Subject: Re: Attatch Mail Script?
Message-Id: <3309E662.3668322@enteract.com>
Jonas Mensson wrote:
>
> Does anyone know where I can get a script that sends a user defined
> file from a webpage as an attachment?
>
> /Jonas
MIME-tools (contains MIME:: modules) in the CPAN allows you
to create MIME messages with attachments (actually, multipart
messages). See MIME::Entity for details.
--
___ _ _ _ _ ___ _ Eryq (eryq@enteract.com)
/ _ \| '_| | | |/ _ ' / Hughes STX, NASA/Goddard Space Flight Cntr.
| __/| | | |_| | |_| | http://www.mcs.net/~eryq
\___||_| \__, |\__, |__
|___/ |___/ Make $$$ easy! Just hit shift, then 444!
------------------------------
Date: Tue, 18 Feb 1997 12:10:20 -0500
From: Ray Cromwell <ray@westlake.com>
Subject: Can you parse a context-free grammar with perl regexps?
Message-Id: <3309E27C.C6@westlake.com>
I've been coding templates in my CGI scripts for a long time now,
using something like the following simple substitution:
$bigfilestring =~ s/\[(.*?)\]/&substitute($1)/ges;
sub substitute { return $substitution_array{$_[0]}; }
so that in a file, I can put [keyname] and have it replaced with
a corresponding associative array value or DBI database lookup.
I can even parse "container" like tags, e.g.
<foo> ... </foo>
can be parsed via
$filestr =~ s/<([a-z]+)>(.*?)<(\/\1)>/&do_stuff($1)/ges;
The problem arises when you want to parse
<foo>
<foo>
<foo>
</foo>
If you change the (.*?) in the above to a greedy match, you can
parse this via recursion because $1 will be equal to the inner
<foo> </foo>
But
<foo>
</foo>
<foo>
</foo>
Will fail to parse because $1 will be equal to "</foo><foo>"
The reverse problem happens with a stingy match.
The way I have solved this for the time being is to allow an extra
"nesting" number to be added to tags, almost like Fortran identations
(yikes!) so you must use
<foo>
<foo2>
<foo3>
</foo3>
</foo2>
</foo>
But this is ugly.
What I want to do is retain what I think is the efficiency of
the s/pattern/routine/ges parsing paradigm, rather than use a real
perl-yacc, or scanning parser with stack.
I realize that you cannot parse a context-free grammar using only
regular expressons, but perl regular expressions are slightly more
powerful and have the added bonus of being able to execute perl
statements on match. For instance, a^n b^n is not recognizable by
a regular language, however using s/a(.*)b/&recurse($1)/ge you can
recognize it with perl regular expressions.
So has anyone written a simple parser that uses
the s/// paradigm rather than doing the type lex->token->shift/reduce
method? I want to match a grammar of the following form:
S: -> S TAG-PAIR | Text
TAG-PAIR: -> OPEN-TAG S CLOSE-TAG
OPEN-TAG: 'foo'
CLOSE-TAG: '/foo'
Text: any alphanumeric | empty
If this is not possible, is there a parser module out there that will
do it, and which is only a few lines of code, rather than a huge
yacc/lex skeleton?
Thanks,
-Ray
------------------------------
Date: Tue, 18 Feb 1997 13:44:59 +0000
From: Ben Jefferys <brj@doc.ic.ac.uk>
Subject: Class library to make C++ more Perlish?
Message-Id: <3309B25B.47EB@doc.ic.ac.uk>
Hi I'm looking for a class library to give C++ some of the cool
functionality in Perl. Ideally it'd have scalar, array,
associative array classes and overload standard operators
as per C++. It should also have search, pattern matching
and so on as functions in the scalar class.
My reason for wanting this is that I'm find my Perl programs
are too slow :( So I see C++ classes as the solution. If
there is another way I kind find out WHY my Perl is so slow
(ie. which bits are taking a long time) then I'd appreciate
a pointer.
Sorry if this is in the FAQ (I doubt it is?) but www.perl.com
seems to be "unavailable" at the moment.
Thanks!
Ben.
------------------------------
Date: Tue, 18 Feb 1997 18:31:26 GMT
From: cutt@netcom.com (Paul S. Cutt)
Subject: debugging perl & html
Message-Id: <cuttE5tA4E.5vM@netcom.com>
I wonder what people are using to debug perl scripts when called from an
html page ? I know about perl debugger but this is run from the command
line. If my html page calls my perl script how can I get the debugger at
that point to execute so I can continue debugging ?
Thanks,
paul
------------------------------
Date: Tue, 18 Feb 1997 18:36:26 +0200
From: Boris Zemlyak <borisz@lsil.com>
Subject: Deleting files in perl
Message-Id: <3309DA8A.462D@lsil.com>
Hello!
I have the following problem and maybe you can help
me to solve it.
I want to delete file from my current working
directory from the perl script. Is there any
function which can allow me to do so. I can
use:
system("rm $file");
but I don't want to use system for such trivial
task.
Thank you,
Boris.
--
**********************************************************
* Boris R. Zemlyak LSI Logic ISRAEL *
* Senior Software Engineer VLSI Development Center *
* Phone +972-9-8633777 1 Ha'Omanut Str. *
* Direct +972-9-8633727 Bldg A2 Narkis *
* Fax +972-9-8657194 New Industrial Zone *
* POB 8134, 42160 Netanya *
* mailto:borisz@lsil.com ISRAEL *
**********************************************************
------------------------------
Date: 18 Feb 1997 17:49:46 GMT
From: bw@mail2.tripnet.se (Bertil Wennergren)
Subject: Re: difference btw s/// & tr///
Message-Id: <5ecq3q$j37@minox.tripnet.se>
Honza Pazdziora skribis:
: bw@mail2.tripnet.se (Bertil Wennergren) writes:
:
: > My first reaction to the tr-function was to try something like this, which
: > would be ideal for a lot of my text work:
: >
: > tr/(ab)(cd)(ef)(gh)/ijkl/;
: >
: > The idea was to translate certain character combinations into single
: > characters (ab -> i, cd -> j...). I doesn't work however. :-( I had to use
: > more cumbersome s-functions.
:
: I hope you can still do
:
: tr/abcdefgh/iijjkkll/;
:
: Hope this helps.
That would translate:
a -> i
b -> i
c -> j
d -> j
e -> k
f -> k
g -> l
h -> l
What I wanted was this:
s/ab/i/g;
s/cd/j/g;
s/ef/k/g;
s/gh/l/g;
----------------------------------------------
Bertilo Wennergren
<bw@tripnet.se>, <bertilow@hem1.passagen.se>
<http://hem1.passagen.se/bertilow/bertilo.htm>
----------------------------------------------
------------------------------
Date: Mon, 17 Feb 1997 15:10:14 -0800
From: "George A. Lippert" <zucchini@cts.com>
Subject: Extending Perl with C library - HELP!
Message-Id: <3308E556.6027F285@qualcomm.com>
Perl Experts,
I've read through perlcall, perlxs, and perlxstut but am still quite
confused about the whole process. I am but an egg when it comes to
this, but I must confess that the docs seem to be way too scatalogical
to be of use. I've gone through the examples but applying them to my
real-world problem fails in a few ways. For example, there seems to be
no support for parameters of type "short *". Or using a parameter of
type "unsigned long *" produces an unsatisfied linkage for XFree(). (Is
this the X11 XFree()? Really!?)
Is there a concise description of how, given a foo.h and libfoo.a, one
can create a fooperl, that is, an extended perl? This really shouldn't
be this hard.
Many thanks,
George Lippert
glippert@qualcomm.com
------------------------------
Date: 18 Feb 1997 17:24:51 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: extra spaces
Message-Id: <slrn5gjpa1.d0f.dave@fast.thomases.com>
On Tue, 18 Feb 1997 14:53:46 GMT, Steve <spoors@rl.af.mil> wrote:
> open (OUT, ">>newfile");
> print OUT "128.132.$subnet.$ip,$net,$hinfo,$mx10\n"
> close (OUT);
> Each time a record is appended to the file it adds an extra space. My
> question is how do you get rid of that extra space? Or is space being
> added for each of the variables? If so how do I fix this problem?
What's in the $mx10 variable - try changing you script to someline like:
print OUT "128.132.$subnet.$ip,$net,$hinfo,<$mx10>\n"
and see if there are spaces or newlines between the <>'s. It might be you
got $mx10 from a line that you forgot to chomp, or that was padded with
trailing blanks.
Regards
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 18 Feb 1997 12:24:42 -0700
From: cpayne@xmission.xmission.com (Carl Payne)
Subject: Re: Get filename from variable-length path?
Message-Id: <5ecvlq$s9l@xmission.xmission.com>
Tad McClellan <tadmc@flash.net> wrote:
> I'm going to read it anyway. So there!
Well, go ahead, neener neener...
> -------------
> #! /usr/bin/perl -w
> foreach (
> '80/product.list)--',
> 'datashop/desktop/routine.registered/objwires/SET/xx291970/AN-12_dv2363.x)--'
> ) {
> print "$_\n";
> print "$1\n" if m#.*/(.*)\)--#;
> }
> -------------
The only problem with this is that each filename has to be hand-entered?
Doesn't that defeat the purpose of the search?
I tried something similar to this, the problem is getting the field
into the script correctly.
Imagine this is something more generic, like a WWW log file. Imagine
I need to tell the marketing department what the top 10 downloads are,
and imagine I need to tell the development department what file-type
(by extension) is in demand most (because for whatever reason they
make their files based on what little-ol-me says).
NOW, imagine that log file is...say...250MB (no typo)in size, and you are
me and have to do those two things. That's as generic as I can put it.
But, thanks a lot for the reply.
Carl
------------------------------
Date: 18 Feb 1997 09:20:59 GMT
From: "Santiago Alvarez Rojo" <santiago@gambito.com>
Subject: Installing modules
Message-Id: <01bc1d6c$23430700$7131a8c0@sg059pcs>
I'm trying to build a perl module and when making the makefile:
perl Makefile.PL
I get the messages below.
Could anyone give me any hint?
TIA.
Santiago Alvarez (santiago@gambito.com)
Ps. Please drop my a mail if you have any idea.
------------------------------------------
C:\Perl5\lib\libnet-1.04>perl Makefile.PL
"my" variable %all masks earlier declaration in same scope at
C:\Perl5\lib/ExtUt
ils/Manifest.pm line 131.
"my" variable $mfile masks earlier declaration in same scope at
C:\Perl5\lib/Ext
Utils/Manifest.pm line 222.
Name "File::Basename::VERSION" used only once: possible typo at
C:\Perl5\lib/Fil
e/Basename.pm line 121.
Ambiguous use of prompt => resolved to "prompt" => at Configure line 7.
Ambiguous use of {prompt} resolved to {"prompt"} at Configure line 34.
Ambiguous use of {prompt} resolved to {"prompt"} at Configure line 52.
Ambiguous use of {prompt} resolved to {"prompt"} at Configure line 62.
Ambiguous use of {prompt} resolved to {"prompt"} at Configure line 72.
Name "File::Basename::VERSION" used only once: possible typo at
C:\Perl5\lib/Fil
e/Basename.pm line 121.
Name "main::file" used only once: possible typo at Configure line 79.
Unquoted string "dd" may clash with future reserved word at Net/Config.pm
line 4
--
Santiago Alvarez Rojo
santiago@gambito.com
http://www.gambito.com/santiago
------------------------------
Date: 18 Feb 1997 09:32:35 +0000
From: Tony Beaumont <beaumoaj@cs-ultra.aston.ac.uk>
Subject: IPC::SysV and semaphores
Message-Id: <f8wwws6h32k.fsf@cs-ultra.i-have-a-misconfigured-system-so-shoot-me>
I am trying without success to use semaphores from within perl
(5.002). If anyone can provide any help/solutions for the following two
problems, please email me (a.j.beaumont@aston.ac.uk).
Attempt 1.
----------
I tried to use semget and semop directly but when I did h2ph
to create the headers, I get an error when I try to use sem.ph.
For example, this file:
> #! /usr/local/bin/perl
>
> require "sem.ph";
gives this error and hangs when run:
> Number found where operator expected at (eval 14) line 1, near ")0"
> (Missing operator before 0?)
> Scalar found where operator expected at (eval 58) line 3, near "*($p"
> (Missing operator before $p?)
Can anyone tell me why? There were no errors from h2ph, so I assume
all the ph files were created ok.
Attempt 2.
----------
Use the IPC::SysV module. I got some success here. The module test
program works but I want to do something slightly different. The
module semtest program creates a semaphore, forks a child process and
the child and the parent use the same semaphore.
However, I would like to have 2 or more completely separate processes
use the same semaphore. In C I can do this:
program1 creates a semaphore (eg. WMODE is 644):
> sid = semget(getkey(SEMAPHORE), 1, IPC_CREAT|IPC_EXCL|WMODE)
program2 uses the same semaphore:
> sid = semget(getkey(SEMAPHORE),1,0)
However, when I do much the same thing in perl, I get two different
semaphores created. I call
> $semid = IPC::SysV::semget($mysemkey, 1, $mode)
with prog1 using:
> $semkey = "0x1234";
> $mymode = mode_string_2_num('rw-rw-rw-');
> $semmode = IPC_CREAT | IPC_EXCL | $mymode;
and prog2 using:
> $semkey = "0x1234";
> $semmode = 0;
My understanding is that if the key is the same, program2 should get
the $semid of the semaphore created by program1. This does not happen
and program2 gets its own different semaphore. Do I need to specify a
key differently? If I use a numeric value for the key instead of a
string I get this error:
> semget: 2 No such file or directory
Help?
-Tony Beaumont
Computer Science and Applied Mathematics
Aston University
Aston Triangle
Birmingham
B4 7ET
UK
Tel. +44 (0)121 359 3611 x4655
------------------------------
Date: Tue, 18 Feb 1997 18:14:35 +0100
From: Livio Scandella <livio@sinapsi.com>
Subject: Job opportunities in Milan
Message-Id: <3309E37B.15D5@sinapsi.com>
Sinapsi is looking for PEARL developers. Please contact me via e-mail.
==============================================
Livio Scandella
SINAPSI S.r.l., via Vigevano 15, 20144 Milano
Tel. 02 8392554 - portatile: 0335 6357222
Fax: 02 58105293 - web: http://www.sinapsi.com
==============================================
------------------------------
Date: Tue, 18 Feb 1997 15:32:25 GMT
From: ric@discoveryinternational.com (Ric Harwood)
Subject: Missing POSX
Message-Id: <3309c886.1096028@news.demon.co.uk>
I am just making my first foray into the joys of Perl, currently
running under dos for construction and testing purposes. When
complete the program will run on a connected linux box.
I am completely new to Perl, and not much of a programmer to start
with, but my hand is being held by someone with far more experience,
who is working directly on the linux machine.
I have the perl 4 distribution from /CPAN/ports/win31/
When I 'compile' under dos the program it fails with:
I can't compile wavey.pl:
Syntax error at line 3, next 2 tokens use POSX
Syntax error at line 124, next 2 tokens use sinh(
Syntax error at line 131, next 2 tokens use asine(
Syntax error at line 147, next 2 tokens use oneplace(
Syntax error at line 148, next 2 tokens use oneplace(
Syntax error at line 150, next 2 tokens use oneplace(
It runs OK under linux.
It sounds to us as if I don't have the POSIX library. I don't know
why this would not be included in the distribution, but then I don't
know anything. Can anyone explain to a perl newbie what to get, where
from and what to do with it . If all I need to do is RTFM then
please tell me which one.
MTIA
Ric.
--
"Big whorls have little whorls that feed on their velocity,
and little whorls have lesser whorls and so on to viscosity."
-- L.F.Richardson
PGP id:0766ABE5 http://www.discoveryinternational.com/ric/
------------------------------
Date: Tue, 18 Feb 1997 16:57:16 GMT
From: "Paul Sanders" <pauls@silverplatter.com>
Subject: Re: My first PERL cgi, please critique
Message-Id: <01bc1dbc$ea1fc8e0$3d7182c1@pauls>
It sucks.
------------------------------
Date: Tue, 18 Feb 1997 08:11:50 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: PERL CGI problem, writing files
Message-Id: <adelton.856253510@aisa.fi.muni.cz>
dale@hardlight.com.au (Dale Drechsler) writes:
> Hello all,
>
> I have the following script being called froma form
> ----starts here ------
> #!/usr/bin/perl
I can't see -w over here. Not mentioning use strict. Seems like not
a perl problem. Seems like not-rading-FAQ problem. Did you at least
read The Idiot's Guide to Solving Perl CGI Problems?
(http://www.perl.com/perl/faq/idiots-guide.html)
You better do that. Really.
> push(@INC,"/cgi-bin");
> require("cgi_lib.pl");
> &ReadParse(*input);
> dbmopen(%counters,"/home/web/users/hard/web/counters/counter",0666);
> if (!(defined($counters{'my_counter'})))
> {
> $counters{'my_counter'} = 0;
> }
>
> $counters{'my_counter'}++;
> $count = $counters{'my_counter'};
> dbmclose(%counters);
[...]
> Basically just a simple counter. I can get this to work from the command line,
> eg perl test.pl. But now when It runs from a CGI call. If I take out the
> reference to the DBM file it returns ok, if not the all I get is a server
> error. Is it something to do with locations of files your allowed to write to
> and or write permissions? How do I know where to point the path to?
>
> thanks for any help, Its been a struggle. ;)
Well, you are welcome to ask again after you make sure the permissions
are OK.
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 18 Feb 1997 13:53:29 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: perl script bug
Message-Id: <w10ybcm9c9i.fsf@wombat.staff.ichange.com>
Tom Christiansen <tchrist@mox.perl.com> writes:
> Just what particular part of
>
> Literal @thepoint now requires backslash
>
> don't you understand? JUST PUT IN THE BACKSLASH ***AS IT
> CLEARLY TELLS YOU*** AND ALL WILL BE WELL.
@thep\oint
:-)
{FX: ducks}
Cheers,
Laird
--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html
------------------------------
Date: Tue, 18 Feb 1997 09:12:22 -0500
From: Mj Smith <mjsmith@isr.umd.edu>
Subject: PerlWin32-95:Yes-NT4:No
Message-Id: <3309B8C4.260D@isr.umd.edu>
Simply, I want to delete all the files in a particular directory. So, I
used the glob <*.*> to select all the files. This worked just find
under Win95. But, as soon as I try it in NT4Wkstn (I logged on as full
administrator), the same exact set of lines, give me an error as soon as
I reach the glob. The error states roughly, that "the name specified is
not recoginzed as an internal or external program, function...".
Any thoughts?
-MJ Smith
______________________________________________________
MJ Smith mjsmith@isr.umd.edu
Inst for Systems Research
Univ of Maryland, College Park
------------------------------
Date: 18 Feb 1997 10:39:15 -0600
From: will@Starbase.NeoSoft.COM (Will Morse)
Subject: Re: Pig Latin
Message-Id: <5eclvj$ia1@Starbase.NeoSoft.COM>
In article <3308D415.4BFC@ionaprep.pvt.k12.ny.us>,
Stephen Bornet <99borns@ionaprep.pvt.k12.ny.us> wrote:
>Honza,
> I'm trying to convert text to Pig Latin. You know, Iay owknay igPay
>atinLay! Thanx for the help!
>
>--
>!Stephen!
>Maintainer of the Punk and Metal Midi Archives
> http://www.geocities.com/SiliconValley/4063/index.html
I think what you are looking for is called COBOL. COBOL is the
ultimate pig. I think you can get ISO-PigLatin-1 with it.
Will
--
# Copyright 1997 Will Morse. Internet repost/archive freely permitted.
# Hardcopy newspaper, magazine, etc. quoting requires permission.
#
# Gravity, # Will Morse
# not just a good idea, # Houston, Texas
# it's the law. # will@starbase.neosoft.com
#
# These are my views and do not necessarly reflect anyone else/
------------------------------
Date: 18 Feb 1997 19:55:13 GMT
From: somsky@dirac.phys.washington.edu (William R. Somsky)
Subject: Re: Pig Latin
Message-Id: <5ed1f1$8ms@nntp1.u.washington.edu>
In article <5e7ndt$1jg@fridge-nf0.shore.net>,
Nathan V. Patwardhan <nvp@shore.net> wrote:
>
> Maybe someone will write a pig latin extension to Perl, called PlPerl.
>
> Example:
>
> intpray("atwhay isway ouryay amenay? ");
> opchay(ingstray_amenay = <INSTDAY>);
> intpray("Ellohay, ingstray_amenay.\n");
Hmm... Shouldn't it be called "Erlpay"? :-)
________________________________________________________________________
William R. Somsky somsky@phys.washington.edu
Department of Physics, Box 351560 B432 Physics-Astro Bldg
Univ. of Washington, Seattle WA 98195-1560 206/616-2954
------------------------------
Date: 18 Feb 1997 13:42:14 +0100
From: Dominique Dumont <domi@marlis.grenoble.hp.com>
Subject: PRE-ANNOUNCE and RFC for new module File::Vpp
Message-Id: <vkzwws6guah.fsf@marlis.grenoble.hp.com>
Hello
I've written a module named File::Vpp. Before releasing it, I'd like to submit
the doc for suggestions or any comments on the interface.
I'm wondering whether File::Vpp is a good choice for naming this
module. I don't want to conflict with any other File::xxx module.,
This is my 2nd try for a RFC (I guess that I've badly choosen the post
subject for my first try since I didn't get any reply).
Thanks for any comment.
Here the output from pod2text:
NAME
File::Vpp - Versatile preprocessor
SYNOPSIS
use File::Vpp ;
$fin = File::Vpp-> new('input_file_name') ;
$fin->setVar('one_variable_name' => 'value_one',
'another_variable_name' => 'value_two') ;
$res = $fin -> substitute ;
print "Result is : \n\n",join("\n",@$res) ,"\n";
DESCRIPTION
This class enables to preprocess a file a bit like cpp.
First you create a Vpp object passing the name of the file to process,
then you call setvar() to set the variables you need to process the
file.
Finally you call subsitute on the Vpp object.
NON-DESCRIPTION
Note that it's not designed to replace the well known cpp. Note also
that if you think of using it to pre-process a perl script, you're
likely to shoot yourself in the foot. Perl has a lot of built-in
mechanism so that a pre-processor is not necessary.
INPUT FILE SYNTAX
Comments
Since most of script (perl or ksh) use # as a comment caracter.
File::Vpp uses by default '@' as THE special caracter. I.e. lines
beginning with '#' are skipped.
When setActionChar() is called with '#' as a parameter, Vpp doesn't skip
lines beginning with '#'. In this case, there's no comment possible.
Multi-line input
Line ending with '\' are concatenated with the following line.
Variables substitution
You can specify in your text varaibles beginning with $ (like in perl).
These variables can be set either by the setVar() method or by the
"eval" capability of Vpp (See below).
Setting variables
Line beginning by @ are "evaled" using variables defined by setVar().
You can use only scalar variables. This way, you can also define
variables in your text which can be used later.
Conditional statements
File::Vpp understands @IF, @ELSIF, @ENDIF,and so on. @INCLUDES and @IF
can be nested.
@IF and @ELSIF are followed by a string which will be evaled using the
variable you defined (either with setVar() or in the text).
Inclusion
File::Vpp understands @INCLUDE
Constructor
new(file_name, optional_var_hash_ref, optional_action_char)
Create the file object. The second parameter can be a hash containing
all variables needed for the substitute method.
Methods
setVar( key1=> value1, key2 => value2 ,...) or setVar(hash_ref)
Declare variables for the substitute.
setActionChar(char)
Enables the user to use another char as action char. (default @)
Example: setActionChar('#') will enable Vpp to understand #include,
#ifdef ..
substitute([output_file])
Perform the substitute, inclusion, and so on and write the result in
"output_file". Returns 1 on completion, 0 if the file couldn't be
opened.
If output_file is not specified this function returns an array ref
containing the whole new file.
AUTHOR
Dominique Dumont Dominique_Dumont@grenoble.hp.com
Copyright (c) 1996 Dominique Dumont. All rights reserved. This program
is free software; you can redistribute it and/or modify it under the
same terms as Perl itself.
VERSION
Version 0.1
--
Dominique_Dumont@grenoble.hp.com
------------------------------
Date: Tue, 18 Feb 1997 08:25:22 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: problem writing to files
Message-Id: <adelton.856254322@aisa.fi.muni.cz>
mark@markschneider.com (Mark Schneider) writes:
> I'm running into a problem I've never seen before while reading and
> writing files in Perl. (My operating system is Solaris 2.5.)
>
> My program reads in a sample file, replaces some text as it reads in
> the file, and outputs the replaced text to another file. For some
> reason:
>
> (1) my program isn't writing to the output file until the
> program ends (even though it reaches the "close" command much
> before the program ends.
> (2) although the input file ($generic_analog_Runstats_file) is less
> than 1K, the output file is always 8K in size, and approximately
> the last 7K is filled with what looks like chr$(0)
>
> Has anyone else run into this problem? Where you able to fix it?
[...]
I can't see where the problem is. So let's investigate. What does this
little script print on your system?
$ perl
open OUT, ">test"; # this is written on stdin
print OUT "jezek\n";
close OUT;
system("ls -la test");
sleep 5; # press Ctrl-D here
I get this answer:
-rw-r--r-- 1 adelton student 6 Feb 18 1997 test
How about you?
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Tue, 18 Feb 1997 09:41:24 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Program wrapper ?
Message-Id: <adelton.856258884@aisa.fi.muni.cz>
Euihyun Jung <ehjung@hyuee.hanyang.ac.kr> writes:
> Hi there.
>
> I hava a question.
> I want to make a wrapper program using perl.
> As you know, wrapper program is wraaping a existing program without
> modifying it while adding new facility.
> First, I want to make a password wrapper.
> I have many username & password to be added to /etc/password file.
> but, password program issues me "enter password" twice.
> If you know the solution, please let me know.
Do not write wrapper, write it all in perl, do not call passwd. You
can use crypt function to encrypt the password and directly write to
/etc/passwd.
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 18 Feb 1997 13:46:58 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: Q: how best to share a hash between packages
Message-Id: <w10zpx29ckd.fsf@wombat.staff.ichange.com>
daku@nortel.ca (Mark Daku) writes:
> AGAIN the quick and dirty way to pass around a hash.
> sub func1 {
> my (*localhash) = @_;
> .code.
> }
> my (%globalhash);
> $globalhash{one} = 1;
> $globalhash{two} = 2;
> func1(*globalhash);
>
> The best place to look is in the man pages that come with your perl dist.
Ook! Surely you mean (as the man page you included tells you)
something like this:
sub func1 {
my($local_hash_ref) = shift;
my($local_hash) = %{ $local_hash_ref };
# Code
}
my(%globalhash) = {"one",1,"two",2};
func1(\%globalhash);
Passing globs around is the old perl4 way to do things. It's ugly,
and should only be used in rare emergencies, or by Graham Barr. :-) I
don't see anything in your example that would necessitate
glob-slinging; therefore, it should probably be avoided in favor of
hard references, documented extensively in perlref(1).
Cheers,
Laird
(a worshipper at the shrine of the...um...terse code of Net::*)
--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html
------------------------------
Date: Tue, 18 Feb 1997 17:33:11 GMT
From: Joseph June <jjune@midway.uchicago.edu>
Subject: reduce length
Message-Id: <3309E7D7.42DE@midway.uchicago.edu>
Hi...
I'm very new at perl... and i have a simple question which i've been
losing sleep over...
how do i reduce how many digits a variable will display... for
example... i want to show
40.39
instead of
40.39012938291047239
i thought truncate was the way to do it...
truncate(some variable, 6)
but doesn't seems to be working...
thank you sooo much for your help...
------------------------------
Date: Tue, 18 Feb 1997 08:03:32 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: regex and looping problem
Message-Id: <adelton.856253012@aisa.fi.muni.cz>
jmack@p3.net writes:
[snip]
> I'd like to replace the dashes with a <HR>, easy enough with a
> s/^-{50}$/<HR>/ However, I'd also like to have a "Return to List of
> Questions" internal link (I have all the questions in a <UL> at the top of
> the page, linked the question below) every 10th question or so. I want
> to have a for loop in my perl script that recognizes every 10th instance
> of a line of 50 dashes and replace it with a string like
>
> <A HREF="#top">Return to Top</A>
>
> The files are sometimes long (nearly one hundred questions) so I'd like to
> do a loop that iterates through a file replacing every --- line with <HR>
> and every 10th with the string above until the EOF. I've tried many
> things along the line of:
>
> while (<FILE>){
>
> for ($i=1; $i<= something; $i++){ #how to effectively configure loop?
> foreach (/^-{50}$/){
>
> if ($i divisible by 10) { # how to find 10th dashed line?
> s/^-{50}$/<A HREF="#top">Return to Top</A>/
> else {
> s/^-{50}$/<HR>/
>
> }}}
> with no success.
How about:
$dashes = 1;
while (<FILE>) # read the file
{
if (/^-{50}\n$/) # if this is separator line
{
if (($dashes % 10) == 0) # each 10th
# % does that
{ print "<A HREF="#top">Return to Top</A>\n"; }
else
{ print "<HR>\n"; }
$dashes++; # number of ------ sections
}
else
{ print; }
}
This is a pretty C-ish code but should do what you need.
> Is a loop even the best way to do this? Can I read the file in as an
> array
> and fool around with each array element? Would that be easier? I
> appreciate any ideas
Since you seem to need just filter, I see no reason for array here.
Just do read'n'subst'n'print.
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Tue, 18 Feb 1997 18:31:48 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: regex and looping problem
Message-Id: <E5tA50.Ax5@nonexistent.com>
On Mon, 17 Feb 1997 19:41:05 -0600, jmack@p3.net wrote in comp.lang.perl.misc:
++ Hello, I'd greatly appreciate any assistance to my problem.
++ I have a block of raw text to convert to HTML.
++ The text is a mishmash of questions and answers. Questions and answers
++ are seperated from each other by a line of 50 dashes. So it looks
++ something like this:
++
++ Q1
++ [ . . . ]
++ ---(50 of em)
++ A1
++ --
++ Q2
++ --
++ A2
++ --
++ etc.
++
++ I'd like to replace the dashes with a <HR>, easy enough with a
++ s/^-{50}$/<HR>/ However, I'd also like to have a "Return to List of
++ Questions" internal link (I have all the questions in a <UL> at the top of
++ the page, linked the question below) every 10th question or so. I want
++ to have a for loop in my perl script that recognizes every 10th instance
++ of a line of 50 dashes and replace it with a string like
++
++ <A HREF="#top">Return to Top</A>
++
++ The files are sometimes long (nearly one hundred questions) so I'd like to
++ do a loop that iterates through a file replacing every --- line with <HR>
++ and every 10th with the string above until the EOF. I've tried many
++ things along the line of:
Do it all at once:
my $i = 0;
s[^-{50}$][++$i % 10 ? '<HR>' : '<A HREF="#top">Return to Top</A><HR>']gem;
Abigail
------------------------------
Date: Tue, 18 Feb 1997 17:19:09 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: RegEx, Email & Friedl's "Mastering..." Book
Message-Id: <E5t6rx.6nJ@nonexistent.com>
On 18 Feb 1997 10:47:35 GMT, Jeffrey wrote in comp.lang.perl.misc:
++
[ About reading mail header lines ]
++
++ or even:
++
++ $header =~ s/\n\s+/ /g; ## normalize to one line.
++ %header = $header =~ m/^(^[^:]+):\s+)(.*)/g;
I looked at this expression for a while, but I can't see any reason
why the regex starts with two anchors. Did I miss some deeper magic?
Do I need to read Jeffreys' book again?
Abigail
------------------------------
Date: 18 Feb 1997 07:20:25 GMT
From: pnataraj@emerald.tufts.edu (Premkumar Natarajan)
Subject: Returning values using perl_call_pv
Message-Id: <5ebl7p$qoe@d2.tufts.edu>
I have been trying to use perl_call_pv to work with a character string and
two integers. The code I am using is
static void somefunction(char *string,int a,int b)
{
int length;
int count;
dSP;
ENTER;
SAVETMPS;
PUSHMARK(sp);
XPUSHs(sv_2mortal(newSVpv(string,0)));
XPUSHs(sv_2mortal(newSViv(a)));
XPUSHs(sv_2mortal(newSViv(b)));
PUTBACK;
count = perl_call_pv("SpltWrdsToChars",G_SCALAR);
SPAGAIN;
if (count != 3) printf("sunk\n");
string = POPp;
printf("String is %s\n",string);
printf("Values are %d %d\n",POPi,POPi);
PUTBACK;
FREETMPS;
LEAVE;
}
In the perl sub(routine) the last statement is
($a,$b,$string);
The program seg faults when I try to pop the integers out.
The string comes out fine. Any ideas ?
Thanks,
Prem
------------------------------
Date: 18 Feb 1997 16:54:08 GMT
From: schip@lmsc.lockheed.com (Jan Schipmolder)
Subject: Re: Saving Complex Data Structures to disk, how best?
Message-Id: <5ecmrg$l34@butch.lmsc.lockheed.com>
M Dominic Ryan (ryanmd@phu198.mms.sb.com) wrote:
: If you saw this already, pardon me, but I have evidence it never made it
: off-site, so...
I saw it the first time. Your evidence is a little weak?
--
jan.b.schipmolder@lmco.com
------------------------------
Date: Tue, 18 Feb 1997 19:26:41 +0000
From: Douglas Seay <seay@absyss.fr>
To: root@rostkl.rndavia.ru
Subject: Re: Screen I/O library
Message-Id: <330A0271.3638@absyss.fr>
System Administrator wrote:
>
> Hello everybody,
>
> I want to know if there is any perl package implementing screen input/output
> functions: menus, windowed input controls, etc. for UNIX platforms?
> Any information is welcome.
yes, there are several.
pTk is the port of the TK toolkit of TCL/TK fame.
from my limited experience, it works well. I
had no problems throwing together simple windows
that had gif displayers and menu bars with pull
down menus. worked like a champ. you can get
it from your local CPAN site.
there is also an older SX thingie that I've never
seen. last I heard it was at ftp.pastuer.fr,
but I don't know if it is still maintained.
and there is curses for tty stuff, also at your
neigborhood CPAN site.
doug seay
seay@absyss.fr
------------------------------
Date: Tue, 18 Feb 1997 09:28:17 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: split an array?
Message-Id: <adelton.856258097@aisa.fi.muni.cz>
maclaudi@cps.msu.edu (Claudia Ma) writes:
> Hi,
>
> Does anyone know how to split an array? Say I have an array
> @array = (a
> b
> c);
>
> How to make:
>
> $a = a;
> $b = b;
> $c = c;
>
> I tried ($a, $b, $c) = split (/\n/, @array) but it didn't work. :(
It can't work. My perl says:
$ perl
@array = (a
b
c);
($a, $b, $c) = split (/\n/, @array); # Ctrl-D
Can't call method "a" in empty package "b" at - line 1.
So this is not a perl code. Let's assume you mean
$ perl
@array = (a,
b,
c);
($a, $b, $c) = @array;
print "$a, $b, $c\n";
and the result is a, b, c
Here I _assign_ (not split) array into list. You can split a string,
let's say
$ perl
$string = "a
b
c";
($a, $b, $c) = split (/\n/, $string); # Ctrl-D
and the result will be
a, b, c
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
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 V7 Issue 967
*************************************