[6300] in Perl-Users-Digest
Perl-Users Digest, Issue: 923 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 10 17:59:22 1997
Date: Mon, 10 Feb 97 14:00:19 -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, 10 Feb 1997 Volume: 7 Number: 923
Today's topics:
Re: [Q] C++/perl interface <tchrist@mox.perl.com>
Re: CGI & Oraperl together ?? (Scott Chilcote)
Compact perl FAQ/manpage HTML page <nmljn@wombat.staff.ichange.com>
Re: Compiling strings at runtime (bill davidsen)
Cookies and Website 1.1 <ross@tdrl.demon.co.uk>
Re: Emulating 'script' with perl (Kevin Buhr)
Re: Fast list search (John Heidemann)
File Tests for Directory not working under NT4.0 <kevin.smith@citicorp.com>
Re: File::Find vs. find.pl (Ric Steinberger)
Get filename from variable-length path? (Carl Payne)
Re: HELP!Telnet process in perl Basic PROBLEM! (Ric Steinberger)
Re: HELP: Pattern Matching Problem <harald.joerg@mch.sni.de>
Re: HELP: variable interpretation?? <ragoff@sandia.gov>
Increasing variable names (ie - $line1,$line2, etc) basslerp@musu2.slu.edu
Re: Loops in perl (Dave Thomas)
Re: Loops in perl (Abigail)
Re: need a simple script (Jonathan Peterson)
non programmer...on 'if'.. (Zlatko Ivanagic)
Re: Perl rand() function on solaris SPARC <mkonopka@mkonopka.isp.ford.com>
piping input to a perl script (Holly Harper)
Re: piping input to a perl script (Dave Thomas)
Re: printing to a file (Jonathan Peterson)
Re: Review date notifier (Jagadeesh Venugopal)
Subroutine Prototypes, Hard References and Maintainable <franko@sequent.com>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Feb 1997 15:28:10 GMT
From: <tchrist@mox.perl.com>
Subject: Re: [Q] C++/perl interface
Message-Id: <5dneqa$qnl$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Wade Holst <wade@cs.ualberta.ca> writes:
:I am having problems finding (or just verifying that what I have is) the
:latest and greatest in perl documentation for various problems. I have been
:perusing the CPAN sites, and it appears that almost all of the files under
:CPAN/doc were last modified in Jan-Feb of 1996. Are these truly the latest
:versions?
No, they aren't the newest versions. The newest versions are
included with 5.003_25.
Here's something from the perlxs page you might like:
Using XS With C++
If a function is defined as a C++ method then it will assume its first
argument is an object pointer. The object pointer will be stored in
a variable called THIS. The object should have been created by C++
with the new() function and should be blessed by Perl with the
sv_setref_pv() macro. The blessing of the object by Perl can be
handled by a typemap. An example typemap is shown at the end of
this section.
If the method is defined as static it will call the C++ function
using the class::method() syntax. If the method is not static the
function will be called using the THIS->method() syntax.
The next examples will use the following C++ class.
class color {
public:
color();
~color();
int blue();
void set_blue( int );
private:
int c_blue;
};
The XSUBs for the blue() and set_blue() methods are defined with
the class name but the parameter for the object (THIS, or "self")
is implicit and is not listed.
int
color::blue()
void
color::set_blue( val )
int val
Both functions will expect an object as the first parameter. The
xsubpp compiler will call that object `THIS' and will use it to call
the specified method. So in the C++ code the blue() and set_blue()
methods will be called in the following manner.
RETVAL = THIS->blue();
THIS->set_blue( val );
If the function's name is DESTROY then the C++ `delete' function will be
called and `THIS' will be given as its parameter.
void
color::DESTROY()
The C++ code will call `delete'.
delete THIS;
If the function's name is new then the C++ `new' function will be
called to create a dynamic C++ object. The XSUB will expect the
class name, which will be kept in a variable called `CLASS', to be
given as the first argument.
color *
color::new()
The C++ code will call `new'.
RETVAL = new color();
The following is an example of a typemap that could be used for this C++
example.
TYPEMAP
color * O_OBJECT
OUTPUT
# The Perl object is blessed into 'CLASS', which should be a
# char* having the name of the package for the blessing.
O_OBJECT
sv_setref_pv( $arg, CLASS, (void*)$var );
INPUT
O_OBJECT
if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) )
$var = ($type)SvIV((SV*)SvRV( $arg ));
else{
warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
XSRETURN_UNDEF;
}
If you look at http://www.perl.com/CPAN/authors/Dean_Roehrich/CookBook*,
you'll find more as well.
--tom
--
Tom Christiansen tchrist@perl.com
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
--Larry Wall in the perl man page
------------------------------
Date: 10 Feb 1997 20:36:55 GMT
From: src@nt.com (Scott Chilcote)
Subject: Re: CGI & Oraperl together ??
Message-Id: <5do0t7$erq@nrtphc11.bnr.ca>
On 10 Feb 1997 16:17:59 GMT, Thomas Armstrong Kobrich <tarmstro@caleuche.inf.UDEC.CL> put forth:
> When I run the scrip offline (from command line)
^t
> it works ok, but when called from the browser, everything
> printed after the call to ora_login() vanishes...
>
> Any ideas??
Check the permissions on all parts of your scripts, and all parts of your
Perl DBI and DBD libraries. You have to have world-read on your .pm files
and their directories, and world execute on your Perl executables in order
for them to be run by httpd or whatever http server you're using.
You also need to make sure you have CGI enabled and set up properly, or
SSI, whatever method you're using to put this on your page. Good Luck.
Scott Chilcote
scotty@pagesz.net
--
,____________________________________________________________________________,
||Disclaimer: These opinions / LINUX:\\ "/^\|^\ /\ |\ /| is not a ||
|| are my own. Sales have // Where \\ `-.|_//__\ | V | family ||
|| been down lately. // Freedom Isn't\\ \_/| / \| | value!" ||
`-------------------------==> Virtual! <==-----------------------------------'
------------------------------
Date: 10 Feb 1997 15:07:45 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Compact perl FAQ/manpage HTML page
Message-Id: <w106800juge.fsf@wombat.staff.ichange.com>
Given the number of answered-by-the-FAQ questions that have been
posted lately, I thought I'd post a reference to my own consolidated
all-in-one-place collection of perl resources:
http://www.amherst.edu/~ljnelson/perl.html
It ain't pretty, and it uses frames, but it's all there. Note that
the "captions" for each frame will load that frame in the main window.
Hope this helps,
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: 10 Feb 1997 20:47:24 GMT
From: davidsen@tmr.com (bill davidsen)
Subject: Re: Compiling strings at runtime
Message-Id: <5do1gs$401u@usenet1y.prodigy.net>
Thanks to those who replied. The answers seem sufficiently complex
that some other solution seems better fitted to a production
environment. I have done things of this level of obscurity before;
they always come back to haunt me when someone needs a change and no
one can understand the code.
I'm really impressed!
--
bill davidsen (davidsen@tmr.com)
Company policy prevents me from commenting on the performance of
this distributed database. However, the machines on which it runs
are called bottleneck and roadblock.
------------------------------
Date: Mon, 10 Feb 1997 20:47:03 +0000
From: Ross Lloyd <ross@tdrl.demon.co.uk>
Subject: Cookies and Website 1.1
Message-Id: <32FF8947.2F17@tdrl.demon.co.uk>
Can anyone help me, I am trying to use access the HTTP_COOKIE
environment variable using website 1.1e. As this is a initial local
development area for a linux server, I am attempting to maintain
complience, is it me or is it Website but this environment variable does
not appear to be set properly (Netscape is fine if I do not name the
cookie, Explorer fails whatever.
------------------------------
Date: 10 Feb 1997 14:54:58 -0600
From: buhr@stat.wisc.edu (Kevin Buhr)
Subject: Re: Emulating 'script' with perl
Message-Id: <vbazpxcpejh.fsf@mozart.stat.wisc.edu>
npekyong@mercury.starnet.gov.sg (Ng Pek Yong) writes:
>
> Q1. I am trying to figure out a way to control a arbitrary child process
> via perl script by taking control of the child's STDIN.
[ . . . ]
> Q2. A more complicated scenario: Bi-directional communication
Both these questions are answered in the perlipc(1) manpage. In
particular, read the section "Using open() for IPC". The start of
this section answers your first question, and the subsection titled
"Bidirectional Communication" answers your second.
Kevin <buhr@stat.wisc.edu>
------------------------------
Date: 10 Feb 1997 10:50:03 -0800
From: johnh@dash.isi.edu (John Heidemann)
Subject: Re: Fast list search
Message-Id: <johnh.855600496@dash.isi.edu>
Russ Allbery <rra@cs.stanford.edu> writes:
>Tom Christiansen <tchrist@mox.perl.com> writes:
>> I think we should add a new perl built-in called faq(). For example,
>> faq("string in list") might return:
>> 5.5) How can I tell whether an array contains a certain element?
>You know, that might not be that bad of an idea, actually. use FAQ
>anyone?
That would certainly be better
than telling them all ``FAQ use''.
-John Heidemann
--
John Heidemann johnh@isi.edu <URL:http://www.isi.edu/~johnh/> PGP mail OK
------------------------------
Date: Mon, 10 Feb 1997 16:09:39 -0500
From: Kevin Smith <kevin.smith@citicorp.com>
Subject: File Tests for Directory not working under NT4.0
Message-Id: <32FF8E93.2DE3@citicorp.com>
I can't get the directory test (-d $name) to work under NT 4.0 Server,
works fine under 95. It fails to recognize directories, except for the
. and .. directories. What's wrong with my logic here? The file system
on my drive is NTFS but it don't seem to matter as other FAT drives
yield the same problem.
Here's a code snippet:
$SHARENAME = "C:\\";
if (opendir(DD,$SHARENAME))
{
foreach $name (sort readdir(DD)) {
if (-d $name) {
print "$name was a directory\n";
} else {
print "$name was not a directory\n";
}
}
}
The version I am using is:
This is perl, version 5.001
Unofficial patchlevel 1m.
Copyright 1987-1994, Larry Wall
Win32 port Copyright (c) 1995 Microsoft Corporation. All rights
reserved.
Developed by hip communications inc., http://info.hip.com/info/
Perl for Win32 Build 110
Built Aug 13 1996@08:18:50
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.
------------------------------
Date: 10 Feb 1997 17:13:44 GMT
From: ric@isl.sri.com (Ric Steinberger)
To: fpostma@inter.nl.net
Subject: Re: File::Find vs. find.pl
Message-Id: <5dnl08$mk4@unix.sri.com>
[Posted and mailed]
In article <32fbae69.9608114@news.nl.net>,
F.Postma@inter.NL.net (Frans Postma) writes:
>
> Anyway, the following questions remain:
> 1) What is the prefered method to prevent File::Find from crossing
> file-systems? Or is the $dev eq $topdev in &wanted the 'right' way
> to do it, it works for now...(we don't use NFS)
> 2) Will find2pl be update to produce File::Find output
>
>
Here's an example that works for me...
# based on find2perl -xdev -type f
sub wanted_altsys {
my($dev, $ino, $mode, $nlink, $uid, $gid);
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
!($File::Find::prune |= ($dev != $File::Find::topdev)) &&
-f _ &&
push(@wanted_files_altsys, $File::Find::name);
}
Note that find2perl doesn't really generate the "right stuff" to
use with the Find::File module. You need to put $File::Find qualifiers
in front of non-local variables. Above, I added the push statement
to save the results of the search, as there appears to be no way to
get them passed back through the API.
--
Ric Steinberger Email: ric@sri.com
SRI Consulting Phone: 415.859.4300
333 Ravenswood Ave AH301 Pager: 415.907.4598
Menlo Park CA 94025 FAX: 415.859.2986
------------------------------
Date: 10 Feb 1997 14:48:00 -0700
From: cpayne@xmission.xmission.com (Carl Payne)
Subject: Get filename from variable-length path?
Message-Id: <5do52g$709@xmission.xmission.com>
Hello, wise folk,
I have a situation where I'm given up to several hundred MB
of directory listings and I need to parse the filenames
(and ONLY the filenames) from those lists for a seperate routine.
The problem is, some files have very short paths, like:
80/product.list
and some have very long paths, like this:
datashop/desktop/routine.registered/objwires/SET/xx291970/AN-12_dv2363.x
(gee, I hope that line isn't >80 cw)
The file records these in a huge blob, several dozen MB a day. I can't
exactly just print "the filename column" because it's in a different
place each line. I also can't search based on the "." because some
directories have periods in them.
The question is: how do I extract *JUST* the filename and send it
to a seperate file where all the filenames live for future processing?
Is there a way to reach a delimiter and count backwards? This file
has each full path terminating in a )-- (paren,dash,dash), so if I
could find )--and count back to the next slash, might that do it?
Thanks in advance.
Carl
------------------------------
Date: 10 Feb 1997 17:17:54 GMT
From: ric@isl.sri.com (Ric Steinberger)
To: jakob himmelman <jakob@jake.hule.harryda.se>
Subject: Re: HELP!Telnet process in perl Basic PROBLEM!
Message-Id: <5dnl82$mk4@unix.sri.com>
[Posted and mailed]
In article <32FD2F0A.7762@jake.hule.harryda.se>,
jakob himmelman <jakob@jake.hule.harryda.se> writes:
>Is there a better way to open the telnet process for
> reading and writing?Maybe there is a timing problem to?
Well, you could use the Socket module and just open a client
connection on the telnet port. This would be more straight-forward
and probably easier to debug. The Camel Book and the POD docs on
Socket are worth looking at in this regard.
--
Ric Steinberger Email: ric@sri.com
SRI Consulting Phone: 415.859.4300
333 Ravenswood Ave AH301 Pager: 415.907.4598
Menlo Park CA 94025 FAX: 415.859.2986
------------------------------
Date: Mon, 10 Feb 1997 18:23:58 -0100
From: Harald Joerg <harald.joerg@mch.sni.de>
To: Geert Nijs <geert.nijs@fys.kuleuven.ac.be>
Subject: Re: HELP: Pattern Matching Problem
Message-Id: <32FF75CE.44F2@mch.sni.de>
Geert Nijs wrote:
> [...] The sting I want to examine is:
>
> "\Title{This is the title}\Address{This is an address}"
> I want to extract the title, so I thought this would work:
> /\\Title{(.*)}/
> But no: PERL takes the last curly bracket, and gives as Title:
> This is the title}\Address{This is an address
> How can I make PERL search until the FIRST } and then ignore the rest ?
/\\Title{(.*?)}/
...makes PERL less greedy.
--
Cheers,
--haj--
------------------------------
Date: Mon, 10 Feb 1997 13:01:14 -0700
From: "Robert A. Goff" <ragoff@sandia.gov>
Subject: Re: HELP: variable interpretation??
Message-Id: <32FF7E8A.6201@sandia.gov>
> Can anyone point me in the right direction? I've searched my O'Reilly
> books, but haven't ferreted out the answer...
The perlref man page has a fascinating discussion of this.
--
=================================================
Robert Goff email: ragoff@sandia.gov
Sandia National Labs Phone: (505)284-3639
------------------------------
Date: Mon, 10 Feb 1997 15:01:14 -0600
From: basslerp@musu2.slu.edu
Subject: Increasing variable names (ie - $line1,$line2, etc)
Message-Id: <855607859.23313@dejanews.com>
Question: I have a situation where I there are to be a varied number of
lines to be read in, but then for each line to be split up and defined as
associative arrays ($line1{URL}, $line1{TITLE}, etc). The problem is
trying to define such initial variables names (like $line1, $line2). The
easiest way would be to simply create an array @line, and then just go
$line[1], $line[2], etc. However, as far as I know, you couldn't create
associative arrays out from these array values. If possible, then
problem solved. If not, what would be the easiest way to go about
defining/creating these variables?
Hope I gave enough info. Thanks in advance for the help.
Ryan Bassler -> basslerp@musu2.slu.edu
LMP home page > http://www.prairienet.org/~bassler
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 10 Feb 1997 20:38:35 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Loops in perl
Message-Id: <slrn5fv1l4.2vu.dave@fast.thomases.com>
On 10 Feb 1997 17:18:53 GMT, Brian Wheeler <bdwheele@indiana.edu> wrote:
> In article <5dnf43$ktv$1@ftp.ampersand.com>,
> jason@ampersand.com (Jason Brazile) writes:
> >In article <5dj1ls$1p4$1@newshound.csrv.uidaho.edu>,
> >Thomas Patrick Bailey <baile934@harrier.csrv.uidaho.edu> wrote:
> >> I am fairly new to perl, but I have been doing ok in it. What I need to
> >> know is how to do a simple loop.
> >>
> >> A simple example would be very helpful.
> >
> >No problem. Loops are pretty simple in perl:
>
> Oh, for the love of God, are you a scheme programmer? :)
I think it was a joke....
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Mon, 10 Feb 1997 20:06:34 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Loops in perl
Message-Id: <E5EL6y.64A@nonexistent.com>
On 10 Feb 1997 17:18:53 GMT, Brian Wheeler wrote in comp.lang.perl.misc:
++ In article <5dnf43$ktv$1@ftp.ampersand.com>,
++ jason@ampersand.com (Jason Brazile) writes:
++ >In article <5dj1ls$1p4$1@newshound.csrv.uidaho.edu>,
++ >Thomas Patrick Bailey <baile934@harrier.csrv.uidaho.edu> wrote:
++ >> I am fairly new to perl, but I have been doing ok in it. What I need to
++ >> know is how to do a simple loop.
++ >>
++ >> A simple example would be very helpful.
++ >
++ >No problem. Loops are pretty simple in perl:
++
++ Oh, for the love of God, are you a scheme programmer? :)
++
++ seems alot easier to do:
++
++ #!/usr/bin/perl
++ for($i=1;$i<6;$i++) {
++ print "hello, world\n";
++ }
And you must be a C programmer?
#!/usr/local/bin/perl -w
my $line = "x" x 5;
print "hello, world\n" while chop $line;
Or a more traditional one:
#!/usr/bin/local/perl -w
foreach (1 .. 5) {print "hello, world\n";}
Abigail
------------------------------
Date: 10 Feb 1997 09:48:38 GMT
From: jon@amxdigital.com (Jonathan Peterson)
Subject: Re: need a simple script
Message-Id: <jon-1002970945340001@amx11.amxdigital.com>
In article <erich-0902970008170001@ppp-207-104-16-7.snrf01.pacbell.net>,
erich@powerwareintl.com (Eric Harley) wrote:
> In article <5dga2t$3fa@news.xmission.com>, scotkris@aros.net (scott
> mcgrew) wrote:
>
> > could anyone tell me where to get a script that does the following.
> >
> > takes form input and writes it to a txt file.
> >
> > I want to update a java applet text ticker without going in and
> > writing the new data in notebook, ftp'ing etc.
> >
> > it would be simpler to just go to a webpage and type it in.
> > but I don't write cgi.
> >
I wrote this little thing for exactly the same purpose that you describe above.
All you do is call the cgi program, and it will generate a web page with a
textarea and a submit button. Type in the text, hit submit, and it will
_overwrite_ the text file with your new text. This can then be read in by
the Java applet.
Since you (seem) new to this, I'd better say that a cgi program can't
write to a file unless that file has write permissions set for the cgi
user. This isn't the nmewsgroup to get into file permissions, so email me
if you have problems.
#!/usr/bin/perl
#
#
require('cgi-lib.pl');
&ReadParse;
## Set next line to point to the file that is read by the applet
## Note that you will need this file to be writeable by the cgi user
$TextFile = "/htdocs/brats/ticker.txt";
$CurText = $in{Text};
print "Content-type: text/html \n\n";
unless ($CurText eq ""){
open (OUT,">$TextFile")|| print "eek $!";
print OUT "$CurText";
close OUT;
}
print <<"EOF"
<html>
<body>
<center>
<h2>Type in text for ticker tape. Current text is shown.</h2>
<P><br><hr>
</center>
<form action=/cgi-bin/brats/ticker.cgi method=post>
<textarea name=Text cols=60 rows=6>
$CurText
</textarea>
<p>
<input type=submit value=Apply>
</form>
</body>
</html>
EOF
------------------
Opinions expressed above are not necessarily those of AMXdigital ltd.
Jonathan Peterson || jon@amxdigital.com || (+44) 0171 613 5300
"You wouldn't believe the things I've seen with your eyes."
------------------------------
Date: 10 Feb 1997 17:55:33 GMT
From: zivanag@jagor.srce.hr (Zlatko Ivanagic)
Subject: non programmer...on 'if'..
Message-Id: <5dnnel$81b@bagan.srce.hr>
how would i define output of a perl script in cgi bin (html doc)
that would include picture (gif)
chosen depending on html form radio button state (yes/no type)
???
thankyou
zlatko
ps. please email
--
-----------------------------
------------------------------
Date: Mon, 10 Feb 1997 14:28:28 -0500
From: Michael Konopka <mkonopka@mkonopka.isp.ford.com>
To: paustin@gw.ford.com
Subject: Re: Perl rand() function on solaris SPARC
Message-Id: <32FF76DC.5D22@mkonopka.isp.ford.com>
Paul Austin wrote:
>
> Hi,
>
> I am trying to use the rand() function to obtain a random number between
> 0 and 39. This works fine on a HP UX system but when I run it on
> solaris the numbers being returned are in the order of 100,000's
> any ideas why this occurs?
>
> The command I am using is:
>
> $index = int(rand(39));
>
> regards,
> paul
> ------------------------------------------------------------------
> Paul Austin, Analyst, WPPS Supplier Data.
> 40/432, Trafford House, 8 Station Way, Basildon, Essex SS16 5XX
> PROFS: PAUSTIN, INTERNET: paustin@gw.ford.com, UNI: pda1@ukc.ac.uk
> Tel.44-1268-703016/718-3016 Fax.44-1268-703673/718-3673
Paul
Try something like the following to get a random digit between 0 & 39
#!/usr/local/bin/perl
srand (time); # Sets a random seed for rand...
$rand_digit = int (rand (40)); # get a random digit between 0 & 39.
This works just fine for me. Do remember to run srand, which sets the
random
seed generator.
Mike
--
Michael Konopka
mkonopka@isp.ford.com
(p) 313-248-8121 (f) 313-248-8111
------------------------------
Date: 10 Feb 1997 19:51:12 GMT
From: hharp@arches.uga.edu (Holly Harper)
Subject: piping input to a perl script
Message-Id: <5dnu7g$m65@hobbes.cc.uga.edu>
Hey, I am curious as if to whether (and how) it is possible
to send a stream of data through a pipe and have it be used on
the other end by a perl script.
For instance, I want to be able to do something like
cat filename | perlscript.pl
Any particular way i should approach this? Send responses
to splat@felix.cc.gatech.edu. Thanks.
------------------------------
Date: 10 Feb 1997 20:45:49 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: piping input to a perl script
Message-Id: <slrn5fv22m.2vu.dave@fast.thomases.com>
On 10 Feb 1997 19:51:12 GMT, Holly Harper <hharp@arches.uga.edu> wrote:
> Hey, I am curious as if to whether (and how) it is possible
> to send a stream of data through a pipe and have it be used on
> the other end by a perl script.
Read about the STDIN file handle and <> (angle operator).
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 10 Feb 1997 16:51:57 GMT
From: jon@amxdigital.com (Jonathan Peterson)
Subject: Re: printing to a file
Message-Id: <jon-1002971648550001@195.224.3.140>
In article <32F26512.41B8@pobox.upenn.edu>, rebecc60@pobox.upenn.edu wrote:
> Can anybody help me figure out while the following subroutine creates a
> file Master.txt that seems to have no information in it?
>
> {open(MASTERFILE, ">Master.txt");
> print MASTERFILE "$input{first_name}\n";
> print MASTERFILE "$input{last_name}\n";
> close (MASTERFILE);}
>
> The program runs without any errors, the file is created in the same
> directory the html form and perl script are, but when I enter data in
> the form and process it the text file appears empty.
Are you _sure_ that the text file is empty? If it has a couple of blank
lines, then it suggests that the print statements are working (putting in
those \n linebreaks) but the variables are empty.
Otherwise, I'm out of ideas, because that snippet looks good to me.
Unless your disk is VERY full, I suppose :)
------------------
Opinions expressed above are not necessarily those of AMXdigital ltd.
Jonathan Peterson || jon@amxdigital.com || (+44) 0171 613 5300
"You wouldn't believe the things I've seen with your eyes."
------------------------------
Date: 10 Feb 1997 20:19:45 GMT
From: jvenu@ctp.com (Jagadeesh Venugopal)
Subject: Re: Review date notifier
Message-Id: <5dnvt1$msm@concorde.ctp.com>
In article <32FF2CFA.2847@mitchell.hitc.com> Drew Firment <firment@mitchell.hitc.com> writes:
>I am new to the world of PERL, but know enough to come here for help.
>For ISO compliance, I need a script that will check the dates on a set
>of documents and send an email notification to an individual stating
>which documents are 11 months old.
>
>Any suggestions?
Yes. But it will require that you do your homework yourself. The
answers are to be found if the Camel and the Llama books are
diligently perused. Especially, pages 85 and 224 of the second
edition Camel.
Jag
--
/\/\ |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: Mon, 10 Feb 1997 12:07:27 -0800
From: Frank Opila <franko@sequent.com>
Subject: Subroutine Prototypes, Hard References and Maintainable Code
Message-Id: <32FF7FFF.3A08@sequent.com>
My main concern is developing Perl code that can be maintained without
too much difficulty by other programmers who may not be Perl guru's.
Given this, here are several examples dealing with the use of
subroutine prototypes for routines, which each have a parameter which
is a hard reference to a hash. Example 1 is an introduction and example
2 shows my maintainability issue.
#-------------------------------------------------------------------
#
# Example 1.
#
# The MAIN block calls routine1, passing a hard reference to a hash.
# Routine1 then calls routine2.
# In order for routine1 to pass the same hard reference to routine2,
# it MUST pass it as a scalar.
use English;
# Subroutine Prototypes
sub routine1(\%);
sub routine2($$);
MAIN: {
my %hash1();
routine1(%hash1);
}
sub routine1 {
my ($hash_ref) = @ARG;
routine2($hash_ref, $var);
}
sub routine2 {
my ($hash_ref, $var) = @ARG;
}
#-------------------------------------------------------------------
#
# Example 2.
#
# Now, in addition to calling routine1, let's say that the MAIN block
# also needs to calls routine2, again passing a hard reference to a
hash.
# This code looks confusing since routine1 and routine2 are called
# differently, even though the same hard reference is passed as a
# parameter.
use English;
# Subroutine Prototypes
sub routine1(\%);
sub routine2($$);
MAIN: {
my %hash1();
routine1(%hash1);
routine2(\%hash1, $var1);
}
sub routine1 {
my ($hash_ref) = @ARG;
routine2($hash_ref, $var);
}
sub routine2 {
my ($hash_ref, $var) = @ARG;
}
#-------------------------------------------------------------------
#
# Example 3.
#
# Now make the calls to the routines consistent.
# Both routines now accept a scalar, which is really a
# hard reference to a hash.
# Note that the code for routine1 and routine2 do not change at all.
#
# My complaint about this example is that we are no longer making
# significant use of Perl's type checking with the prototypes.
# Also, this calling scheme is inconsistent with the way that
# built-in Perl functions are called.
#
use English;
# Subroutine Prototypes
sub routine1($);
sub routine2($$);
MAIN: {
my %hash1();
routine1(\%hash1);
routine2(\%hash1, $var1);
}
sub routine1 {
my ($hash_ref) = @ARG;
routine2($hash_ref, $var);
}
sub routine2 {
my ($hash_ref, $var) = @ARG;
}
#-------------------------------------------------------------------
#
# Example 4.
#
# Now, let's make the calling method consistent from MAIN.
# Let's make 2 versions of routine2: routine2 and routine2_r:
# routine2 would accept a hard reference to a hash as its 1st
argument.
# routine2_r would accept a scalar as its 1st argument.
# routine2 would always call routine2_r.
#
# Yuk!
use English;
# Subroutine Prototypes
sub routine1(\%);
sub routine2(\%$);
sub routine2_r($$);
MAIN: {
my %hash1();
routine1(%hash1);
routine2(%hash1, $var1);
}
sub routine1 {
my ($hash_ref) = @ARG;
routine2_r($hash_ref, $var);
}
sub routine2 {
my ($hash_ref, $var) = @ARG;
routine2_r($hash_ref, $var);
}
sub routine2_r {
my ($hash_ref, $var) = @ARG;
}
#-------------------------------------------------------------------
Any suggestions?
------------------------------
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 923
*************************************