[6618] in Perl-Users-Digest
Perl-Users Digest, Issue: 243 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 6 17:17:09 1997
Date: Sun, 6 Apr 97 14:00:23 -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 Sun, 6 Apr 1997 Volume: 8 Number: 243
Today's topics:
Re: @array as input symbol in <@array> <merlyn@stonehenge.com>
Re: @array as input symbol in <@array> <marti@netrail.net>
Announce VRML-modules <palm@gfz-potsdam.de>
ANNOUNCE: libnet-1.05 PATCH: 02 <gbarr@ti.com>
Graph Maker 1.2 <Fabrizio.Pivari@agip.it>
Re: Help! How do I pass filehandles to subroutines? (Bart Lateur)
Re: How Do You Get User Input? (Billy Chambless)
Re: How to remove a line from a log file <gwhassan@prodigy.net>
Multiple substitution question <mailbox@mongoose.demon.co.uk>
Re: Multiple substitution question <gwhassan@prodigy.net>
Re: newbie question: installation <blueox@mail.cyberhighway.com>
No GUI environment for Perl? <blueox@mail.cyberhighway.com>
Re: No GUI environment for Perl? (Nathan V. Patwardhan)
Re: Ousterhout and Tcl lost the plot with latest paper (Cyber Surfer)
Re: Ousterhout and Tcl lost the plot with latest paper <fritz.heinrichmeyer@fernuni-hagen.de>
Perl 5 for WIN 32 -- Testing HTML and Perl Scripts with <lucido@sonic.net>
Re: Perl for win95 <lucido@sonic.net>
Re: Perl script for UNIX mail to produce web page? lvirden@cas.org
Re: pipes vs. xsubs <vladimir@cs.ualberta.ca>
Replace:How do I emulate it? <steveo@nortel.ca>
Re: running a loop foreach $ARGV? (Bart Lateur)
Re: Serializing Stateless Requests for File Access <gwhassan@prodigy.net>
TCL & interface definitions (was Re: Ousterhout and Tcl <msterin@bmc.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 06 Apr 1997 09:12:58 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: @array as input symbol in <@array>
Message-Id: <8c208of7ud.fsf@gadget.cscaper.com>
>>>>> "Nathan" == Nathan V Patwardhan <nvp@shore.net> writes:
Nathan> Mark-Jason Dominus (mjd@plover.com) wrote:
Nathan> : Someone recently sent me a code sample that included
Nathan> : while (<@array>) {
Nathan> : print $_, "\n";
Nathan> : }
Nathan> Actually, I've seen this mentioned on this newsgroup a whole
Nathan> bunch of times over the last three-four months. Although I
Nathan> don't remember seeing any subject headers like: "Help with $_"
Nathan> I do remember seeing people using (and others abusing) $_;
Nathan> there was a short dialog about using it and abusing it, and
Nathan> which is which.
But this is not an abuse of $_. Rather, it is an abuse and waste of a
perfectly good glob. It's the <> that are in serious question here.
Nathan> It's also documented on page 100 of the blue Camel, not as an
Nathan> example, but in the paragraph which reads something like: "it
Nathan> omitted, $var will be replaced by $_ in foreach." I found
Nathan> this under $_ in the index.
Yes, but this is not a foreach loop.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 512 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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: Sun, 6 Apr 1997 03:29:08 -0400
From: Dennis Marti <marti@netrail.net>
To: Mark-Jason Dominus <mjd@plover.com>
Subject: Re: @array as input symbol in <@array>
Message-Id: <Pine.LNX.3.95.970405234611.16303B-100000@netrail.net>
[mailed and posted]
On 5 Apr 1997, Mark-Jason Dominus wrote:
>
> Someone recently sent me a code sample that included
>
> while (<@array>) {
> print $_, "\n";
> }
>
> and when I saw it, I said, ``Well, no wonder your program doesn't
> work; you can't treat an array like a filehandle.'' But then I tried
> it and it *did* work.
My guess is that the elements of @array don't contain any spaces.
> So I wondered how I could have missed this feature in my extensive and
> dilligent perusal of the manual, and I went back to chack, and I
> couldn't find it in the manual this time either. I have the manual
> that came with 5.003_22, and the blue camel book, and I couldn't find
> it in either place.
I wouldn't use it as a feature.
> Yes, I know about while (<*.c>) ..., but this isn't like that either.
> It's something else.
It is that. The array inside the angle brackets is undergoing double
quotish interpolation then passed to a shell. According to perlop
(which uses "*.c" instead of "your glob") the shell does:
echo your glob | tr -s ' \t\r\f' '\\012\\012\\012\\012'
Which kind of explains it. The while loop is iterating over each
space-separated word passed to the echo. If any of those words contain
shell metacharacters, they get expanded and filename matching is done,
otherwise they get passed back to perl unchanged.
I hope this helps.
Dennis Marti
------------------------------
Date: 6 Apr 1997 16:14:59 GMT
From: Hartmut Palm <palm@gfz-potsdam.de>
Subject: Announce VRML-modules
Message-Id: <5i8i63$431$1@nadine.teleport.com>
This is to announce the availability of VRML-modules. This is still an
beta release. I have only used it in small, toy applications, like
Netscape Bookmark File to VRML converter or thesaurus visualisation,
(http://www.gfz-potsdam.de/drz/VRML/bmvrml.html) so there
are probably bugs in it. Still, it does seem to work well in the cases
I've tested it in, so others may find it useful, and at this point, I
would
like to get some feedback about it.
VRML is a module for dealing with VRML nodes. It is object oriented and
has some added functionality with respect to VRML plugins.
- uses X11(Netscapes) color names
- compact format: $vrml->cube(3,"yellow")
- usefull for dynamic VRML generation with CGIs and HTTP-Server
- respects HTML-Browser, VRML-Viewer, FRAMES
- creates VRML 1.0c or VRML 2.0 with the same script
Modules in the VRML package:
VRML
VRML::VRNL1
VRML::VRML1::Standard
VRML::VRML2
VRML::VRML2::Standard
VRML::Color
VRML::Basic
This module is available from CPAN and also from my home page:
http://www.gfz-potsdam.de/~palm
http://www.gfz-potsdam.de/~palm/software/VRML/VRML-0.97.tar.gz
Hartmut
Example:
use VRML;
VRML->new->browser("LIVE3D")
->background("black", "starbak.gif")
->cube(2,"orange")->print;
*** generate VRML 1.0c ***
#VRML V1.0 ascii
# Set Browser to: 'LIVE3D'
DEF BackgroundColor Info {
string "0 0 0" # black
}
DEF BackgroundImage Info {
string "starbak.gif"
}
Group {
Material {
diffuseColor 1 0.647058823529412 0 # orange
}
Cube {
width 2
height 2
depth 2
}
}
*** or VRML 2.0 ***
#VRML V2.0 utf8
# Set Browser to: 'LIVE3D'
Background {
backUrl "starbak.gif"
bottomUrl "starbak.gif"
topUrl "starbak.gif"
leftUrl "starbak.gif"
rightUrl "starbak.gif"
frontUrl "starbak.gif"
skyColor 0 0 0
}
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0.647058823529412 0 # orange
}
}
geometry Box {
size 2 2 2
}
}
--
__/ __/ __/__/__/ Hartmut Palm
__/ __/ __/ __/ Daten- und Rechenzentrum
__/ __/ __/ __/ GeoForschungsZentrum Potsdam
__/__/__/__/ __/__/__/ Telegrafenberg C6
__/ __/ __/ 14473 Potsdam
__/ __/ __/ TEL.: ..49 (0)331 288/1690
__/ __/ __/ __/ __/ FAX.: ..49 (0)331 288/1703
------------------------------
Date: 6 Apr 1997 16:14:15 GMT
From: Graham Barr <gbarr@ti.com>
Subject: ANNOUNCE: libnet-1.05 PATCH: 02
Message-Id: <5i8i4n$42g$1@nadine.teleport.com>
I have just uploaded to CPAN a patch to libnet-1.05 which fixes a few minor
problems that have been reported.
These fixes are
Net::Domain
- Fixed 'Use of uninitialized value' in _hostdomain()
Configure
- Remove the use of Net::Domain, as this required Net::Config
to be installed before it was created.
- Removed the need for Data::Dumper to be installed for
Configure to be run.
Makefile.PL
- Changed the die to warn if Data::Dumper is not installed
libnet is a collection of perl modules which encapsulate the usage
of various protocols used in the internet community. These include
Net::FTP (RFC959)
Net::SMTP (RFC821)
Net::Netrc
Net::Cmd
Net::Domain
Net::Telnet (RFC854)
Net::Time (RFC867 & RFC868)
Net::NNTP (RFC977)
Net::POP3 (RFC1939)
Net::SNPP (RFC1861)
Net::PH
Net::Config
To install libnet you ***MUST*** have the following modules installed
Data::Dumper
IO::Socket
It should be avaliable on mirror sites soon from
http://www.perl.com/CPAN/authors/Graham_Barr/libnet-1.05_01.pat.gz
Comments are always very welcome.
Copyright 1996 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>
Reality is a figment of the imagination caused by a lack of drink
------------------------------
Date: 6 Apr 1997 16:15:39 GMT
From: Fabrizio Pivari <Fabrizio.Pivari@agip.it>
Subject: Graph Maker 1.2
Message-Id: <5i8i7b$44g$1@nadine.teleport.com>
Hi,
I'm glad to announce the version 1.2 of Graph Maker.
My problem was: I wanted to generate simple graphs (in x the days and in
y the data) to use in
html documents (gif format). Why did I have to use gnuplot and then to
convert the output format
in gif? So I try to make a simple script PERL that use GD.pm library to
generate gif.
These are the new features
1.2 Code of grid more simple
Minor Bugs Fixed
You can find it at
http://www.geocities.com/CapeCanaveral/Lab/3469/
Enjoy it!
--
Fabrizio Pivari
mailto:Pivari@geocities.com
------------------------------
Date: Sun, 06 Apr 1997 16:21:33 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Help! How do I pass filehandles to subroutines?
Message-Id: <3347cd05.1162213@news.tornado.be>
hh@scam.XCF.Berkeley.EDU (Eric Hollander) wrote:
>I'm trying to do something like this:
>foo(<STDIN>);
>
>sub foo {
> my($FD, $byte);
> $FD = $_[0];
> seek(<$FD>, 0, 1);
> read(<$FD>, $byte, 1)
> # ....
>}
>but I can't get it to work!
Try passing the handle as text instead. I haven't tried it on STDIN, but
I *have* used it with handles of ordinary files, before:
foo ('STDIN');
Gent (Ghent, Gand),
Belgium,
Europe,
3rd planet from the sun.
------------------------------
Date: 6 Apr 1997 15:47:39 GMT
From: billy@cast.msstate.edu (Billy Chambless)
Subject: Re: How Do You Get User Input?
Message-Id: <5i8gir$md0$1@NNTP.MsState.Edu>
In article <01bc423a$64942ca0$c8c32581@default>, "Jerome Bradenbaugh" <bradenb@ibm.net> writes:
|> How do you get user input by calling a dialog box after clicking a link?
|> How can you use it once you have it?
Here's some example code:
#!/perl
use Browser;
$netscape = new Browser;
$netscape->read("http://www.perl.com/perl/faq/idiots-guide.html") ||
die "Type error: CGI/JavaScript/Web question asked in Perl group";
|> HotSyte Webmaster
Aren't titles KewL!??!!!
--
"The bottom line on experience is this -- do you get 10 years of experience
or do you get 1 year of experience 10 times?"
--- Steve McConnell in _Code Complete_
------------------------------
Date: Sun, 06 Apr 1997 08:31:14 +0000
From: Greg Hassan <gwhassan@prodigy.net>
Subject: Re: How to remove a line from a log file
Message-Id: <33475F52.1009021B@prodigy.net>
i prefer just a command line:
perl -pi -e 's/^.*pattern.*\n$//g' logfile
--
============================================
Greg Hassan
The Independent Solution
Web Developer (CGI, Java, C, Perl, Oracle)
http://www.hassan.com/
gwhassan@prodigy.net, 1-415-969-5856
============================================
------------------------------
Date: Sun, 06 Apr 1997 16:44:05 +0100
From: Joshua <mailbox@mongoose.demon.co.uk>
Subject: Multiple substitution question
Message-Id: <3347C4C5.6E6B@mongoose.demon.co.uk>
This situation keeps coming up as I write programs to process HTML.
I want to take every src="path/morepath/imagename.xxx", and replace it
with
src="/images/imagename.xxx".
Every time I write something like this I end up using a procedure call
which, in turn, includes a simple substitution. Can someone tell me a
way that doesn't include a procedure call?
Currently the code goes like this
while ($_ = <HFILE>) {
s/src="([^:"]*)"/'src="'.&itr($1).'"'/egi; # Skip any with a colon,
probably
# off-site
print WFILE;
(...)
sub itr {
$_ = $_[0];
s/.*\///; # strip off everything but the actual filename
$imgdir . $_; # return something like /images/filename.gif
}
I'm sure there are multiple silly things in there, feel free to point
them all out.
Joshua Swink
joshua@mongoose.demon.co.uk
------------------------------
Date: Sun, 06 Apr 1997 12:06:14 +0000
From: Greg Hassan <gwhassan@prodigy.net>
Subject: Re: Multiple substitution question
Message-Id: <334791B6.5EFC98B9@prodigy.net>
Joshua wrote:
>
> This situation keeps coming up as I write programs to process HTML.
>
> I want to take every src="path/morepath/imagename.xxx", and replace it
> with
> src="/images/imagename.xxx".
>
>
search and replace is a command line task:
perl -pi -e 's/(src=\")[^\"]+\/(\w+.\w+\")/$1$2/gi' filenames
--
============================================
Greg Hassan
The Independent Solution
Web Developer (CGI, Java, C, Perl, Oracle)
http://www.hassan.com/
gwhassan@prodigy.net, 1-415-969-5856
============================================
------------------------------
Date: 6 Apr 1997 17:11:51 GMT
From: <blueox@mail.cyberhighway.com>
Subject: Re: newbie question: installation
Message-Id: <01bc42ae$62db1940$1eee1ace@jupiter.viser.net>
Many thanks!! I have it installed and running, and I'm programming today.
Is there any gui environment for programming available? I don't mind
working with text files made in dos, but a gui wouldn't hurt. Also, it
seems that if I try to run a .pl file from windows explorer, it just
flashes on the screen for a second. Do I have to keep the dos shell up and
running all the time to be able to run Perl? Are any other shells
available? Again, I might be overlooking something in the FAQ.
Thanks in advance,
blueox
Nathan V. Patwardhan <nvp@shore.net> wrote in article
<5i6as3$ff2@fridge-nf0.shore.net>...
> blueox@mail.cyberhighway.com wrote:
> : this? I have read faq's around the internet on Perl, but I still am in
the
> : dark. A kind of 1,2,3 step process would be beautiful.
> [snip]
>
> Fair enough.
>
> (1) http://www.activeware.com -> follow the links to NTPerl 5.003_07
build
> 303 or 304 (I'm comfortable with 303 for my Win95 needs)
> (2) Download Perl (I think it's called pwi3003.exe).
> (3) Run the .exe file which executes the installer program. Install
> Perl where you want it. Edit your autoexec.bat file to put
c:\perl5\bin
> (or wherever you've put Perl) in your path.
>
> Reboot
>
> --
> Nathan V. Patwardhan
> nvp@shore.net
>
>
------------------------------
Date: 6 Apr 1997 17:13:10 GMT
From: <blueox@mail.cyberhighway.com>
Subject: No GUI environment for Perl?
Message-Id: <01bc42ae$9220d820$1eee1ace@jupiter.viser.net>
Is there any gui environment for programming available? I don't mind
working with text files made in dos, but a gui wouldn't hurt. Also, it
seems that if I try to run a .pl file from windows explorer, it just
flashes on the screen for a second. Do I have to keep the dos shell up and
running all the time to be able to run Perl? Are any other shells
available? Again, I might be overlooking something in the FAQ.
Thanks in advance,
blueox
------------------------------
Date: 6 Apr 1997 17:55:47 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: No GUI environment for Perl?
Message-Id: <5i8o33$qb1@fridge-nf0.shore.net>
blueox@mail.cyberhighway.com wrote:
: Is there any gui environment for programming available? I don't mind
: working with text files made in dos, but a gui wouldn't hurt. Also, it
[snip]
To my knowledge, no - I'm normally a Unix user where I use the command-line,
Emacs, or vi ... no GUI necessary; when I have used "DOS" (Win95 DOS), I
use an MS-DOS shell, and DOS EDIT.
As for a GUI environment and Perl, I'd do a www.dejanews.com search for
GUI, environment, comp.lang.perl.misc, ntperl, and see what comes up. In
terms of your question about the Windows Ahborer, er, I mean Explorer, I
never/rarely ever run Perl scripts from the (Assistant) File Manager, or
the Explorer for just that reason - the output disappears too quickly. I
just open a DOS window, and run: perl scriptname.pl from the command-line.
Nothing will disappear that way. :-)
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Sun, 6 Apr 1997 17:51:44 +0100
From: cyber_surfer@gubbish.wildcard.demon.co.uk (Cyber Surfer)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <MPG.db1e484ebef598298974d@news.demon.co.uk>
With a mighty <5i7euq$cmg@engnews2.Eng.Sun.COM>,
ouster@tcl.eng.sun.com uttered these wise words...
> Wow, there's been quite a party going on over here on comp.lang.scheme!
Not just comp.lang.scheme...
[various arguments and your responses to them deleted]
[MFC code deleted]
While I'm reluctant to defend MFC and C++, I have a few comments to
make.
> I'm not an MFC expert, so I asked someone else, whom I consider to be
> a good Windows programmer, to write this for me. Perhaps there is a
> shorter way than the code I included. However, the 6 lines above
I'm not MFC expert, either, nor do I wish to be one, but I have used
it enoigh to know that I wouldn't write such code to create a button
or two, using a particular font. Instead, I'd create a dialog
resource, and if I wanted to place it within part of a window, then
I'd make it a child of that window and size it accordingly.
> don't seem to be equivalent to the Tcl script. For example, there is
> no code to respond to the button press, and I believe additional code is
> needed to free resources when the button is deleted. Suppose that the
> MFC code I used is off by a factor of two, and that it really only takes
> 12 lines of C++ to duplicate the functionality of one line of Tcl. Doesn't
> that still illustrate my point?
I think it's off by more than a factor of two. The amount of code used
to implement your example, needn't reflect the complexity of the user
interface. IMHO that's what an interface builder is for.
I guess the large number of development tools with interface builders
and their popularity supports my view, but I'm not sure that numbers
are relevant to this thread - if they were, we'd all be talking about
something else. For what it's worth, it's one way of looking at it.
Meanwhile, the code to create this dialog is just a couple of function
calls (one to create the dialog window, another to place it), and the
event handling code may be maintained for you by Class Wizard, if you
use VC++. (Other C++ compilers may provide similar tools.)
Of course, there are MFC features that aren't so easy to use, as the
resource editor won't know about them (e.g. resizable windows).
Buttons are just to trivial for a fair contest. Add some more complex
features, and things should get rather more interesting! The exact
_choice_ of features may favour Tcl or MFC/C++, it's up to you.
In other words, Your Mileage May Vary. A contest between VB and Tcl
might be more realistic, as it seems to me that their strengths are
very similar. However, we're assuming that the code is for Windows. If
you do that, then you've made it easy for a Windows develop to play a
trump card - unless Tcl supports ActiveX (please say that it does!)
and all the other features specific to Win32.
You'd do better by playing Tcl's trump card, which is much greater
portability than VB and VC++ will ever have. Again, YMMV.
Now I have to wash my mouth out for "defending" MFC. ;)
--
<URL:http://www.wildcard.demon.co.uk/> You can never browse enough
Martin Rodgers | Programmer and Information Broker | London, UK
Please remove the "gubbish" if you want to email me.
------------------------------
Date: 06 Apr 1997 18:35:10 +0200
From: Fritz Heinrichmeyer <fritz.heinrichmeyer@fernuni-hagen.de>
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <ufhghkds8x.fsf@jfh01.fernuni-hagen.de>
James Lee <jlee@math.purdue.edu> writes:
> ] 2. Many people objected to the fact that their favorite programming
> ] was left out of the white paper. Yes, I have heard of Scheme,
> ] Smalltalk, ML, etc. I left these languages out because they
> ] didn't seem particularly relevant for the discussion. No offense
> ] intended...
>
> Why were they irrelevant? Your paper concentrates on system and
> scripting languages exclusively while ignoring an entire genre of
> languages that may offer the features you're looking for in both.
I agree! At least ML and Scheme (i dont know smalltalk very well ..) are
particulary relevant to this discussion. They at least are intended to
solve all the mentioned problems (terser code means shorter development
time and less errors, inheritance is not so important, the computer
should look for types etc.).
The last posting of J. Ousterhout is outing him as candidate for getting
an ML-fan!
------------------------------
Date: 6 Apr 1997 19:42:49 GMT
From: "Salvatore A. Lucido" <lucido@sonic.net>
Subject: Perl 5 for WIN 32 -- Testing HTML and Perl Scripts with Netscape
Message-Id: <01bc42c2$b7ed4480$55e5c9d0@cyrix-686-p150>
How do you configure Perl and Netscape under Windows 95 such that you can
test your HTML and Perl scripts before publishing them on your ISP?
I can get Netscape to execute the perl script, but I can't get it to output
the results back into a new Netscape HTML document. (Note: I have a
dial-up connection).
Any suggestions or references?
Sal
----------------------------
Salvatore A. Lucido
lucido@sonic.net
------------------------------
Date: 6 Apr 1997 19:51:40 GMT
From: "Salvatore A. Lucido" <lucido@sonic.net>
Subject: Re: Perl for win95
Message-Id: <01bc42c3$f4920f00$55e5c9d0@cyrix-686-p150>
Dean Ouellette <deano@nh.ultranet.com> wrote:
> I am leaning Perl, Is there anywhere I can download a free version of
Perl
> 5??
>
> Thanks in advance
> Dean Ouellette
I got mine from:
http://www.activeware.com/
------------------------------
Date: 6 Apr 1997 19:09:07 GMT
From: lvirden@cas.org
Subject: Re: Perl script for UNIX mail to produce web page?
Message-Id: <5i8scj$7v0@srv13s4.cas.org>
I've had a problem with Mail::Folder as it requires File::BasicFlock and
that one doesn't work on Solaris.
--
Larry W. Virden INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.
------------------------------
Date: 06 Apr 1997 10:08:14 -0600
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
To: "Annie P. Harding" <amhardin@erols.com>
Subject: Re: pipes vs. xsubs
Message-Id: <om3et45e36.fsf@tees.cs.ualberta.ca>
In article <334662BB.7C5@erols.com> "Annie P. Harding" <amhardin@erols.com> writes:
> It seems relatively simple to create a pipe to pass the variables,
IMHO, usually the easiest way is to use the shell to create the pipe, such as
OPEN(OUT,"|myprog");
print OUT $arg1, $arg2;
However, this doesn't capture th output of myprog. Instead, you may want to
use
OPEN(IN,"echo $arg1 $arg2|myprog|");
print <IN>;
Of course, there are shell quoting and security issues that have to be taken
care of here.
> my question is why would you use XSUBs as opposed to pipes. What are the
> advantages and disadvantages to each?
XSUB:
- it's more efficient to link two pieces of code together and use the memory
to communicate between them instead of starting separate processes and using
pipes.
- you don't need to worry about opening and closing the pipe, possible
deadlock issues, etc.
- there's much richer data types that can be communicated (and xs's typemap
converts between them automatically) and not just strings/streams.
Pipes:
- XS involves initial learning overhead which is not justified in your case.
- it may require modifications to the C program.
> I dont need to return control to the calling program.
Then the easiest is exec("myprog $arg1 $arg2"), but read perlsec about
security issues.
> Also, can anyone point me to doc on using pipes?
man perlipc
In summary: your case probably doens't require pipes, use exec or
open(..,"..|").
------------------------------
Date: Sun, 06 Apr 1997 15:47:21 -0400
From: Steve Oldridge <steveo@nortel.ca>
Subject: Replace:How do I emulate it?
Message-Id: <3347FDC9.6D10@nortel.ca>
I'm currently working on a script that searches all files on a system
and replaces one string with another. I'm fairly new to perl and unix
and I can't figure out how to search the line for instances of the
string and then replace them. I'm also looking for a way to tell
whether what I'm looking at is a file or a directory. Right now I
simply use the fact that files normally have a "." in their name, but
obviouselly this isn't going to be the case all of the time. Any help
would be greatly appreciated.
Thanks in advance
Steve Oldridge
------------------------------
Date: Sun, 06 Apr 1997 15:58:17 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: running a loop foreach $ARGV?
Message-Id: <3347c7d8.11123850@news.tornado.be>
> I need to do a bunch of stuff with every file from the command line.
> foreach (@ARGV) {
> open(FILE, "$_") || die("Can't open $_: $!");
> while(<FILE>) {
> print;
> }
> close(FILE);
> }
The construct I use most in the last months is this:
while ($file=shift) {
open(IN,$file);
while(<IN>) {
#do stuff with line
}
}
This has the advantage of *not* checking if it's a new file for every
line read.
Of coarse you may use this as well:
foreach $file (@ARGV) {
...
}
Gent (Ghent, Gand),
Belgium,
Europe,
3rd planet from the sun.
------------------------------
Date: Sun, 06 Apr 1997 08:08:53 +0000
From: Greg Hassan <gwhassan@prodigy.net>
To: Gabriele R Fariello - 608-576-8660 <gabriele@clotho.com>
Subject: Re: Serializing Stateless Requests for File Access
Message-Id: <33475A15.60BE8C19@prodigy.net>
Gabriele R Fariello - 608-576-8660 wrote:
>
> I would be MOST interested in getting a mechanism to actually serialize
> the requests such that file access is granted on a
> first-come-first-serve basis as opposed to a competative and ramdom
> assignment which uses the whichever-process-happens-to-get-the-
> lock-first when it frees up method.
>
It seems like you just need a daemon process running which
locks files for you. The little cgi's talk to the daemon to
get the file locks. Maybe have a timeout on the lock in case
someone gets disconnected.
-Greg
--
============================================
Greg Hassan
The Independent Solution
Web Developer (CGI, Java, C, Perl, Oracle)
http://www.hassan.com/
gwhassan@prodigy.net, 1-415-969-5856
============================================
------------------------------
Date: 6 Apr 1997 17:20:11 GMT
From: "Mark Sterin" <msterin@bmc.com>
Subject: TCL & interface definitions (was Re: Ousterhout and Tcl lost the plot with latest paper)
Message-Id: <01bc42ae$4fc84940$6b91aac6@odessa.bmc.com>
Jack Jansen <jack@cwi.nl> wrote in article <jack.860328432@news.cwi.nl>...
> ...
> ...With languages like Python or Tcl, with
> no interface definitions whatsoever, you can only *hope* that you use
> every interface correctly. I work on a largish project in Python, and
> the one thing that gives continuous headaches is the lack of interface
> definitions. Whenever you change an interface it is very very
> difficult to check that you haven't inadvertantly broken something.
This what the regression testing is for, isn't it ?
-- Mark
--
Mark Sterin msterin@bmc.com
Patrol Core R&D.
BMC Software Inc. http://www.bmc.com
"Buy a Pentium/Pro 200 to reboot faster !"
------------------------------
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 243
*************************************