[6264] in Perl-Users-Digest
Perl-Users Digest, Issue: 886 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 3 09:21:27 1997
Date: Mon, 3 Feb 97 06:00:31 -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, 3 Feb 1997 Volume: 7 Number: 886
Today's topics:
Re: !!!!!!!!Book about Perl <psigurd@io.org>
Re: DOS: Must I stay on clunky old Perl v3.2? <breshear@eonet.com>
Re: DOS: Must I stay on clunky old Perl v3.2? (Brian J. Ritzel)
Re: Filehandle: open(FILE) while{} close(FILE) <hammen@gothamcity.jsc.nasa.gov>
Re: Getting Input (Tad McClellan)
How can I create associative arrays from variables? <noemi@coli.uni-sb.de>
Re: How do I strip out all characters including newline <M.J.Rayson@durham.ac.uk>
Re: How do I strip out all characters including newline (Mike Stok)
Re: Inverse Letters (Tad McClellan)
Re: Invoking Perl program (L.T. Nocella)
Is it able to open .pl from netscape? <nara@usa.net>
JAVA-enabled Browser Detection <roberta@cyberramp.net>
Re: JAVA-enabled Browser Detection (Nathan V. Patwardhan)
Re: JAVA-enabled Browser Detection (Mike Stok)
multi dimensional arrays <russel@let.kun.nl>
Re: parsing problem? <rra@cs.stanford.edu>
Re: perl and signal handling question <rra@cs.stanford.edu>
Perl cgi discussion groups <nbuczek@hotmail.com>
Perl-PVM FAQ or information (John Jennewine)
Re: Perl-PVM FAQ or information <domo@tcp.ip.lu>
Re: printing to a file (L.T. Nocella)
Question from a newbie; RE: File handling chris@fluffyco.demon.co.uk
Re: Question from a newbie; RE: File handling (Mike Stok)
Re: Question from a newbie; RE: File handling <jander@jander.com>
Security and Password <itr@address.net>
Shell "case" command in perl (Jan-Patrick Perisse Sys. Admin)
Re: Starting PERL-script on Frontpage-server <rra@cs.stanford.edu>
Re: unitialized variables?? <rra@cs.stanford.edu>
Where to search for all newsgroup <itr@address.net>
Re: why does this regexp eat a newline?? <rra@cs.stanford.edu>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 02 Feb 1997 07:51:57 -0500
From: Peter Sigurdson <psigurd@io.org>
Subject: Re: !!!!!!!!Book about Perl
Message-Id: <32F48DED.709C@io.org>
------------77F06FCC1FFE1
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
look at http://www.perl.org and http://www.perl.com - theres tons of
faqs and online documents and references
------------77F06FCC1FFE1
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii
<HTML><BODY>
<DT>look at http://www.perl.org and http://www.perl.com - theres tons of
faqs and online documents and references </DT>
</BODY>
</HTML>
------------77F06FCC1FFE1--
------------------------------
Date: 3 Feb 1997 07:05:55 GMT
From: "Doug Breshears" <breshear@eonet.com>
Subject: Re: DOS: Must I stay on clunky old Perl v3.2?
Message-Id: <01bc119f$698aaf20$6b5181ce@janet>
"John Dallman" <jgd@cix.compulink.co.uk> wrote in article
<E4w7A7.M6J@cix.compulink.co.uk>...
> Steve@starbug1.demon.co.uk (Steve Kay) wrote:
>
> > I've downloaded the Win32 version of Perl v5, but when I try running it
> > on my Win3.11 machine I get an error about cannot run in DOS mode. And
> > when I run it from Windows, I get a briefly black screen, then back to
> > Windows.
>
> It won't run on win3.11, even with the Win32S add-on. There's a good port
> of Perl 4.036, BigPerl, in CPAN under .../CPAN/ports/msdos/perl4; the
> alpha-test version of Perl 5.000 in the perl5 directory there seems to be
> much better than the readme with it would lead one to believe.
>
I Have a more recent port (5.003) using the same code of the "alpha-test"
version above,
just diff'ed and patch'ed it to 5.003, fixed a few incompatabilities...
I am not sure where to upload it though, never done it (I assume its ok
with the original author
considering the Artistic license.)
Any way if anybody would like this, let me know and will see where I can
upload it.
Doug Breshears
breshear@eonet.com
------------------------------
Date: Mon, 03 Feb 97 08:55:44 GMT
From: ritzel@prairienet.org (Brian J. Ritzel)
Subject: Re: DOS: Must I stay on clunky old Perl v3.2?
Message-Id: <237cd$23419.2fd@NTNEWS>
In article <01bc119f$698aaf20$6b5181ce@janet>,
"Doug Breshears" <breshear@eonet.com> wrote:
>
>"John Dallman" <jgd@cix.compulink.co.uk> wrote in article
><E4w7A7.M6J@cix.compulink.co.uk>...
>> Steve@starbug1.demon.co.uk (Steve Kay) wrote:
>>
>> > I've downloaded the Win32 version of Perl v5, but when I try running it
>> > on my Win3.11 machine I get an error about cannot run in DOS mode. And
>> > when I run it from Windows, I get a briefly black screen, then back to
>> > Windows.
>>
>> It won't run on win3.11, even with the Win32S add-on. There's a good port
>
>> of Perl 4.036, BigPerl, in CPAN under .../CPAN/ports/msdos/perl4; the
>> alpha-test version of Perl 5.000 in the perl5 directory there seems to be
>
>> much better than the readme with it would lead one to believe.
>>
>
>I Have a more recent port (5.003) using the same code of the "alpha-test"
>version above,
>just diff'ed and patch'ed it to 5.003, fixed a few incompatabilities...
>I am not sure where to upload it though, never done it (I assume its ok
>with the original author
>considering the Artistic license.)
>Any way if anybody would like this, let me know and will see where I can
>upload it.
>
>Doug Breshears
>breshear@eonet.com
There is a DOS port of PERL 5.003 compiled with DJGPP at:
ftp://ftp.delorie.com/pub/djgpp/alpha/p5003*.zip
Last time I checked it was still in alpha, but is being actively developed.
This was announced in the djgpp newsgroup a few weeks ago.
-Bri
[Posted and mailed]
--
Brian J. Ritzel, Springfield, IL USA
ritzel@prairienet.org (preferred)
ritzel@fgi.net
**Newsfeed unreliable. CC your follow-up if you want to be sure I see it.**
------------------------------
Date: 3 Feb 1997 07:52:37 GMT
From: Dave Hammen <hammen@gothamcity.jsc.nasa.gov>
Subject: Re: Filehandle: open(FILE) while{} close(FILE)
Message-Id: <5d45g5$3sd$1@mars.gbtech.net>
[posted and mailed]
Kenneth W. Lee, kenlee@congo.morgan.com writes:
>
>This problematically runs an endless loop when I'd like
>it terminated upon the last line of <INFILE>. Is there
>something I've missed?
>
>---begin code---
>#!usr/bin/perl5 -w
> my $infile = "DATA.TXT";
>
> open ( INFILE, "<$infile" ) or die "Cannot open $infile:$!\n";
> open ( OUTFILE, ">>$infile" ) or die "Cannot create $outfile:$!\n";
~~~~~~~~~~~~ ?????????
Here's your problem -----^
Should $infile ---------^ have been $outfile? -------------^
Think about what you are doing here. You are opening the same
filename for input and append. Suppose there are N lines in the
original file. The processing loop would have read those initial N
lines of the file and appended the translated results to the end of
the same file. So now, after the script has read the first N lines,
there will be N more lines in the file to be processed in place of
the EOF. You've got an infinite loop! Note that this has nothing to
do with Perl. You could have written this same infinite loop in any
language that supports open append mode and the having the same
file open on multiple file handles (or file descriptors, whatever).
Without knowing what you are trying to accomplish, here are some
suggestions:
(1) Create an output file $outfile based on the input file $infile:
open ( OUTFILE, ">$outfile" ) or die "Cannot create $outfile:$!\n";
and then do your processing loop.
Is this what you wanted to do in the first place? That die
message certainly suggests that this is the case.
(2) Replace an input file with an updated version:
open ( INFILE, "<$infile" ) or die "Cannot open $infile:$!\n";
open ( OUTFILE, ">$infile" ) or die "Cannot create $infile:$!\n";
and then do your processing loop.
The original file still exists in an ephemeral form (at least
on most UN*X boxes). The perl script can read the file, but
the original file is history as soon as the script terminates.
This is obviously dangerous. What if something goes wrong?
You'll have incomplete or corrupted output file, and the
input file is gone. It's often better to do something like
open ( INFILE, "<$infile" ) or die "Cannot open $infile:$!\n";
open ( OUTFILE, ">$tempfile" ) or die "Cannot create $tempfile:$!\n";
then do your loop.
At the end, on success, rename the temporary file to $infile.
Now a new problem will pop up: you might find yourself with a
bunch of temporary files lying around because the script was
killed, raised an exception, detected an error and exited, ...
You can write a perl END block to make the script clean up after
itself. Note that this cleanup cannot be perfect. Some signals
(e.g. kill -9) cannot be caught, nor can system crashes (well,
at least not by perl). If you use unique, recognizable names
for the temporary files, then you can add a BEGIN block to
make the script can clean up after itself on startup as well
to get rid of those really pesky cases that the END block
couldn't take care of.
Hope that helps,
Dave
------------------------------
Date: Sun, 2 Feb 1997 22:15:38 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Getting Input
Message-Id: <apo3d5.mr1.ln@localhost>
Steve Johnson (stevej@wco.com) wrote:
: Ok The way I understand it is this
: to get a line of input from standard in you do this
: $input=<STDIN>;
: Simple enough. But i dont want a whole line of input I only want 1 chr.
: kinda like the old basic rout get a$ is there a way JUST to get 1 key
: stroke with perl?
read(STDIN, $input, 1); # see the perlfunc man page for read()
Or, maybe your's is a Question that is Frequently Asked:
4.30) How can I detect keyboard input without reading it?
4.31) How can I read a single character from the keyboard under UNIX and DOS?
4.32) How can I get input from the keyboard without it echoing to the
screen?
(from the fine perl FAQs)
What part of the explanations given there are you having trouble with?
: Oh another thing I want to do is be able to home the curser to the top of
: the screen with out clearing the screen.. is there an easy way to do
: this.. Basicly Im writing a menu program that uses curser keys to move up
: and down a highlighted bar on the menu. Any help would be apreciated.
This part depends on what kind of 'screen' you are using. A TTY?
curses? xterm? window? May also depend on what operating system
or windowing system you are using.
What you want to do is system dependant, but you haven't told us
anything about your system...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 3 Feb 1997 13:11:19 GMT
From: Noemi Preissner <noemi@coli.uni-sb.de>
Subject: How can I create associative arrays from variables?
Message-Id: <5d4o5n$cd@coli-gate.coli.uni-sb.de>
Hi,
the answer might be easy, but after having tried a lot of
things I feel quite helpless now:
How can I create an associative array from variables, i.e.
if I have a variable $1 with value x and another variable $2
with value y, I would like to create an associative array
named after the value of $1 (%x) with the value of $2 as one
of its keys ...
What can I write instead of
$x{y} = "yes";
I am interested in something like ${$2}{$1} = "yes";
(which obviously is not the right way to do it ... )
Thanks,
Noemi
------------------------------
Date: Mon, 03 Feb 1997 11:00:14 +0000
From: Mark Rayson <M.J.Rayson@durham.ac.uk>
Subject: Re: How do I strip out all characters including newlines?
Message-Id: <32F5C53E.36BF@smtphost.dur.ac.uk>
Charles Herold wrote:
>
> This is probably quite simple, but me and a friend with a small book on
> Perl and a big book on regular expressions can't quite figure it out.
>
> I want to strip out everything in a string from </a> to <a>, but I
> can't, a problem I assume with newlines (i.e. s#</a>.*#<a># won't
> work). I tried checking out the Perl FAQ mentioned in the Welcome to
> comp.lang.perl message I got, and got a "can't set guest permission"
> message!
> --
> Best regards,
>
> Charles Herold
> cherold@pathfinder.com
> (212) 522-5190
Charles,
The . matches any character EXCEPT a new line. So you have to use
something like s#</a>[.|\n]*#<a>#
Good luck.
Mark Rayson
------------------------------
Date: 3 Feb 1997 12:15:09 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: How do I strip out all characters including newlines?
Message-Id: <5d4ksd$8s@news-central.tiac.net>
In article <32F5C53E.36BF@smtphost.dur.ac.uk>,
Mark Rayson <M.J.Rayson@durham.ac.uk> wrote:
>The . matches any character EXCEPT a new line. So you have to use
>something like s#</a>[.|\n]*#<a>#
That probably doesn't do what you want, inside a character class the
meanings of various special characters change, you might want
s#</a>(.|\n)*#<a>#;
or
s#</a>[\s\S]*#<a>#;
e.g.
DB<1> $line = "This has </a> and a new line \n in it."
DB<2> $line =~ s#</a>[.|\n]*#<a>#
DB<3> X line
$line = 'This has <a> and a new line
in it.'
DB<4> $line = "This has </a> and a new line \n in it."; $line =~ s#</a>[\s\S]*#<a>#
DB<5> X line
$line = 'This has <a>'
Jeffrey Friedl has just had a book, Mastering Regular Expressions,
published by O'Reilly which is the first book which deals with regular
expressions in reasonable depth and from the regex perspective rather than
a particular language's perspective. A great book which showed me how
much I didn;t know about regexes...
Hope this helps,
Mike
------------------------------
Date: Sun, 2 Feb 1997 22:00:10 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Inverse Letters
Message-Id: <asn3d5.ll1.ln@localhost>
Steve Johnson (stevej@wco.com) wrote:
: How do I print inverse letters in a print statement?
What's an inverse letter?
Do you really mean inverse video?
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 3 Feb 1997 13:34:24 GMT
From: tnocella@outland.cyberwar.com (L.T. Nocella)
Subject: Re: Invoking Perl program
Message-Id: <5d4ph0$de1$2@bandit.cyberwar.com>
Maksym I Panfilov (mpanfilo@newstand.syr.edu) wrote:
: #!/usr/local/bin/perl
: # File: firstscript.perl.cgi
: # (c) 1996 John Desborough
: print "Content-type: text/html\n\n";
: # Because this comes back as HTML we put into a format
: # that is understandable, including a title
: print "<HTML><HEAD><TITLE>First Script Response<\/TITLE><\/HEAD>\n";
: # And now the body of the HTML page we will see returned
: print "<BODY><H1>My First Script</H1><HR>Congratulations! You programmed
: your first CGI script!</BODY></HTML>\n";
: From within Unix this Perl program runs. Tutorial says that when i click
: on a Perl's program link from a browser it should return appropriate
: information in correct HTML format directly to the browser. Unfortunately,
: after invoking the program via link I receive just a text of a program,
: not HTML formatted page. It should be noted that I made Perl's program
: executable.
------------------------------------------------------------------------
Check with your patron GOD (ie. Sys admin) - many times
perl scripts can only run from certain directories, or must
have specific extensions (ex. .CGI) - this is specified in the
server configuration. Otherwize it
would have viewed the file as a text file and not executed it.
-------------------------------------------------------------
------------------------------
Date: 3 Feb 1997 10:58:39 GMT
From: "Kim, Hyun-choul" <nara@usa.net>
Subject: Is it able to open .pl from netscape?
Message-Id: <01bc11c1$0b5bb0d0$23837cd2@nara>
hi.
IIS 3.0 is my server and fixed registry Edit.
HKEY_CLASS_ROOT ; regedit ; shell ; open ; command ; key_value to
Command :REG_SZ : d:\perl5\ntt\perl.exe %1
and HKEY_LOCAL_MACHINE ; SYSTEM ; CurrentControlSet ; Services ; W3SVC ;
Parameters ; Script Map ; key_value to .pl : REG_GZ :
D:\perl5\bin\PERLIS.dll
I think all work done, that I had got from Newsgroup and the Internet.
MS Explorer works well, but Netscape doesn't work at all, all it say is
'Save .pl?'
What is wrong with my server.
Is there anyone who knows it? Let me know.
Thanks.
------------------------------
Date: Sun, 02 Feb 1997 22:17:55 -0600
From: Robert Aldridge <roberta@cyberramp.net>
Subject: JAVA-enabled Browser Detection
Message-Id: <32F566EC.5AA6@cyberramp.net>
I am looking for a CGI script that will detect if a client browser is
capable of displaying a JAVA applet, the direct the java-enabled
browsers to a java savvy page, and the non-java browsers to a non-java
page.
I have looked all over for something like this, but I've only found
browser detectors that determine Netscape or Explorer.
Please let me know if you have a script like this.
Robert
**********************************************************
If you want to fly, dream high.
WebPilot - Your Single Source Guide to the Web!
This is the place youll find most of the interesting and useful pages
on the Web. You can find topics for kids & teens, parents, business
people and much more. Youll find links to your favorite sports and to
your favorite TV show. We have gems of the interent, even the really
smelly ones (real aroma.com), and of course news sites galore.
NEWEST FEATURES:
Chat - Now in beta-testing. Visit our extremely easy to use and
addictively fun chat.
Editorial - Outrageous Punishment in America's Schools
Site of the Week - A movie buff's dream come true. Get the inside
scoop on movies in the works and about to be released.
Fly on over to WebPilot to see more about it!
http://www.cyberramp.net/~roberta/index.html
Non-Frames version is at
http://www.cyberramp.net/~roberta/WebPilot2.html
**********************
------------------------------
Date: 3 Feb 1997 04:52:56 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: JAVA-enabled Browser Detection
Message-Id: <5d3qv8$3k8@fridge-nf0.shore.net>
Robert Aldridge (roberta@cyberramp.net) wrote:
: I am looking for a CGI script that will detect if a client browser is
: capable of displaying a JAVA applet, the direct the java-enabled
: browsers to a java savvy page, and the non-java browsers to a non-java
: page.
Try comp.infosystems.www.authoring.cgi. Some people have actually taken
the time to log various browsers (User Agents) and would be happy to
share the list with you.
--
N Patwardhan
nvp@shore.net
[news:alt.fan.jwz]
------------------------------
Date: 3 Feb 1997 11:43:41 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: JAVA-enabled Browser Detection
Message-Id: <5d4j1d$rv3@news-central.tiac.net>
In article <32F566EC.5AA6@cyberramp.net>,
Robert Aldridge <roberta@cyberramp.net> wrote:
>I am looking for a CGI script that will detect if a client browser is
>capable of displaying a JAVA applet, the direct the java-enabled
>browsers to a java savvy page, and the non-java browsers to a non-java
>page.
Please remember that some of us might bu using a browser which is java
capable but we have the Java (and JavaScript, JScript, whatever...) turned
off...
Mike
------------------------------
Date: Mon, 03 Feb 1997 14:30:28 +0100
From: Albert Russel <russel@let.kun.nl>
Subject: multi dimensional arrays
Message-Id: <32F5E874.41C6@let.kun.nl>
Hi,
How can I print a multi dimensional associative array
with a foreach construction? I think it is something
like:
for ($i=1 ; $i<10 ; $i++) {
foreach $x keys(%aa{}[$i]) {
print $x,$aa{$x}[$i];
}
}
but it does not work.
Please answer by e-mail to d.v.bergem@let.kun.nl
Thanks, Dick
------------------------------
Date: 03 Feb 1997 04:13:20 -0800
From: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: parsing problem?
Message-Id: <qumlo965bq7.fsf@cyclone.stanford.edu>
Greg Hassan <gwhassan@cs.buffalo.edu> writes:
> I ftp a few .tgz files in ascii by mistake, now i cant unzip them
> because it says incorrect gzip format. The bad thing is that I can no
> longer ftp these files correctly as they have been deleted on the other
> server.
> Does anyone have a script that will fix these files so that I can
> uncompress/untar them?
The ASCII conversion done by ftp in ASCII mode is destructive and
irreversible, since it converts line-end markers and a few other
characters to characters which may also be elsewhere in the file, making
it impossible to know which ones to convert back. Without some very
extensive and ugly binary editing, a very strong working knowledge of gzip
and tar formats, and a lot of time and work, I don't know of any way to
get your data back.
This is the sort of situation in which, if the data was truly vital, I
would start contacting data recovery firms who specialize in restoring
such things for a charge.
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 03 Feb 1997 04:16:43 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: Cameron Hart <cam@chch.planet.org.nz>
Subject: Re: perl and signal handling question
Message-Id: <qumiv4a5bkk.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
Cameron Hart <cam@chch.planet.org.nz> writes:
> I have some queries about IPC. I am writing a perl script that one day
> will run continuously reading input data, processing it, and writing to
> a log file. Every now and then I want to rotate the log file. I
> figure, send it a kill -HUP signal to close and reopen the log file.
> Here's where the fun begins. I have some code say
> sub reopen {
> ...
> }
> $SIG{'HUP'} = 'reopen';
> also in the subroutine that writes to the logs the signal HUP is ignored
> so I don't reopen in the middle of a write. Now what is going to happen
> when I receive a signal? Will my program keep going where it was rudely
> interupted after handling the signal? Or is it not quite that simple?
Signal handling is not currently safe in Perl, and you shouldn't attempt
to do anything besides change an already initialized variable within a
signal handler (and even that may not be safe in all instances).
What you want to do is set a flag in the main program:
$reopen = 0;
and then each time through the main loop, frequent enough that you'll
catch the flag fairly fast, check to see if $reopen is 1 and if so reopen
the log and reset it to 0.
Then, use the signal handler:
$SIG{HUP} = sub { $reopen++ };
That's about the best you'll be able to do at the moment. Hopefully in
later versions of Perl some way of addressing this problem will be found.
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Sun, 02 Feb 1997 12:46:27 -0800
From: "nancy" <nbuczek@hotmail.com>
Subject: Perl cgi discussion groups
Message-Id: <01bc114b$01951c60$57032399@nancy>
Hello, I'm a mom who has done enough website work to know that my husband
is usless in helping me with my latest goal for a Mother's Center web page.
I have a service that supports Perl v4 and I want to set up a cgi
discussion group so that mother's can ask questions and other mother's can
answer them. if anyone out there can make this task easy for me or point
me in the direction towards this accomplishment I would greatly appreciate
it. Also if anyone wants to see what I have accomplished (but haven't
necessarily updated) visit my sites at:
http://www.dragonfire.net/~chrissmith/motherscenter
and
http://www/dragonfire.net/~chrissmith/smithfamily
Let me know what you think.....
Nancy
the spiderprincess@msn.com
------------------------------
Date: 3 Feb 1997 04:46:17 GMT
From: jennewin@musashi.msu.edu (John Jennewine)
Subject: Perl-PVM FAQ or information
Message-Id: <5d3qip$d7d@msunews.cl.msu.edu>
Is there any source or location where Perl-PVM is documented and described?
thanks,
-john
------------------------------
Date: Mon, 03 Feb 1997 10:17:57 +0100
From: Dominic Dunlop <domo@tcp.ip.lu>
To: John Jennewine <jennewin@musashi.msu.edu>
Subject: Re: Perl-PVM FAQ or information
Message-Id: <32F5AD38.6B96@tcp.ip.lu>
John Jennewine wrote:
> Is there any source or location where Perl-PVM is documented and described?
A microscopic amount of research with Alta Vista takes me straight to
<http://www.nsrc.nus.sg/STAFF/edward/Pvm.html>. Or you can go to
<ftp://ftp.cs.ruu.nl/users/mirror/CPAN/authors/Edward_Walker> or
similar. (You can get to a CPAN site near you via the multiplexor at
<http://www.perl.com/perl/news/cpan-mux.html>.)
------------------------------
Date: 3 Feb 1997 13:27:38 GMT
From: tnocella@outland.cyberwar.com (L.T. Nocella)
Subject: Re: printing to a file
Message-Id: <5d4p4a$de1$1@bandit.cyberwar.com>
Becky Schonfeld (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.
=====================================================================
99 times out of 10 says this problem is that the
VARIABLES $input{first_name} and $input{last_name} are empty!
If you're using the cgi-lib.pl and &Readparse combo , the output
variables are $in{whatever} , not $input{whatever}, and don't forget
case sensitivity in the html code (others have failed in this way.)
IF you can't figure it out mail me the entire code and html and
we will help you regain your honor.
-----------------------------------------------------------------
$T(HG(F hgkccccccccccc hgtIOXXxxxxxxxxxxtoxrt4o8564^*%(YR(YFDDs
gFODIGHFGIR$O%$#()RG FXOG Xxxxxxxxxx0fgf0g4052349020 9r9d iodsaoi
-t4r9t-45Operations> Did you tell the printer it was a postscript file?
------------------------------
Date: Mon, 03 Feb 1997 08:16:14 GMT
From: chris@fluffyco.demon.co.uk
Subject: Question from a newbie; RE: File handling
Message-Id: <32f59e3f.34325895@newnews.demon.co.uk>
Hi all,
Please forgive the ignorance of a Perl newbie;
Could someone please tell me the easiest way to read in a single line of text
from a file and putting it into a scalar? Or reading in text from a file until a
certain character is reached ('*' for example).
Regards,
Chris.
------------------------------
Date: 3 Feb 1997 12:04:45 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Question from a newbie; RE: File handling
Message-Id: <5d4k8t$st3@news-central.tiac.net>
In article <32f59e3f.34325895@newnews.demon.co.uk>,
<chrisr@fluffyco.demon.co.uk> wrote:
>Hi all,
>
>Please forgive the ignorance of a Perl newbie;
>
>Could someone please tell me the easiest way to read in a single line of text
>from a file and putting it into a scalar? Or reading in text from a file until a
>certain character is reached ('*' for example).
Using the <> operator on a filehandle opened for reading will get the next
record into a scalar if it's used in a scalar context. The next record is
usually the next line of the file including the trailing end of line
characters with perl's defaults.
open (FILE, "<$file") || die "$0: couldn't open $file ($!)\n";
...
$scalar = <FILE>;
In a more recent perl you can do stuff like
use IO::File;
$fh = new IO::File "<$file";
defined $fh or die "$0: couldn't open $file ($!)\n";
$scalar = $fh->getline;
which appeals to the OO crowd. You should check to see that $scalar
contains a defined value before using it.
One way of reading text from a file until a certain character is read is
to read lines and pattern match on them which will let you consume the
file up to and including the line which contains the character e.g.
$found = 0;
while (<FILE>) { # this implicitly loads $_
if (/\*/) { # this implicitly matches against $_
$found = 1;
last;
}
}
As it's perl and there's more than one way to do it you could say
$found = 0;
while (defined ($line = <FILE>)) {
if (index ($line, '*') != -1) {
$found = 1;
last;
}
}
Or you could set perl's input record separator to the character you're
interested in and perl will read records from your file which are
terminated by that character (or the end of file...) e.g.
$/ = '*'; # set input record separator to *
open F, '/etc/passwd'; # no error checking...
$s = <F>;
On my system leaves $s containing
$s = 'root:notTheRealOne:0:1:system PRIVILEGED account:/:/bin/sh
nobody:*'
which has an embedded new line. $/ is perl's name for the input record
separator.
Hope this helps,
Mike
------------------------------
Date: 03 Feb 1997 08:22:47 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Question from a newbie; RE: File handling
Message-Id: <k9oq6n2w.fsf@jander.com>
chris@fluffyco.demon.co.uk writes:
>
> Hi all,
>
> Please forgive the ignorance of a Perl newbie;
>
> Could someone please tell me the easiest way to read in a single line of text
> from a file and putting it into a scalar? Or reading in text from a file until a
> certain character is reached ('*' for example).
#!/usr/bin/perl -w
# read single line into a scalar
my $infile = 'myfile';
open IN, $infile or die "open failed for '$infile': $!\n";
my $line = <IN>;
close IN;
# read until a character is found
my $infile = 'myfile';
open IN, $infile or die "open failed for '$infile': $!\n";
my $somechar = '?';
while (defined ($_ = <IN>) && (index($_, $somechar) == -1)) {}
print;
close IN;
--
Jim Anderson jander@jander.com
PGP Public Key Fingerprint: 0A 1C BB 0A 65 E4 0F CD
4C 40 B1 0A 9A 32 68 44
------------------------------
Date: Mon, 03 Feb 1997 20:59:56 -0800
From: "Kevin E." <itr@address.net>
Subject: Security and Password
Message-Id: <32F6C24C.8F2@address.net>
I'm trying to put a simple security password on my home page. I am not
a programmer. I don't know perl, C, or C++. Is it possible for a
non-programmer like myself to put a password on my home page? If it's
possible, can you show me how?
Thank in advance!
Kevin
------------------------------
Date: 3 Feb 1997 11:55:00 GMT
From: perisse@urbi.com.br (Jan-Patrick Perisse Sys. Admin)
Subject: Shell "case" command in perl
Message-Id: <5d4jmk$onc@leech.urbi.com.br>
How would a bash "case" look like in perl?
I've been reading the book and found nothing about it.
--
/Jan-Patrick Perisse /e-mail: perisse@urbi.com.br
\ Urbi Network \ Url&PGP key:www.urbi.com.br/perisse
\Internet Service Provider\ Voice: +55-21-610-4756 | Fax: +55-21-610-4758
\ System Administrator \ Pager: +55-21-546-1636 #7002196
------------------------------
Date: 03 Feb 1997 04:03:30 -0800
From: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: Starting PERL-script on Frontpage-server
Message-Id: <qumohe25c6l.fsf@cyclone.stanford.edu>
Tom Phoenix <rootbeer@teleport.com> writes:
> On Fri, 31 Jan 1997, Vidar Markussen d2b wrote:
>> I was wondering on who to start a WEB script on a machine running with
>> WIN95 or NT and a Frontpage server.
> The server docs should tell you. If you can't find it there, you might
> be able to find the answer in a newsgroup about servers. Hope this
> helps!
> news:comp.infosystems.www.Servers.ms-windows
^
Careful. The groups:
comp.infosystems.www.Servers.ms-windows
and
comp.infosystems.www.servers.ms-windows
could technically be two different newsgroups. Be careful to always give
all newsgroup names completely in lower case unless the group really does
have uppercase letters (which none of them do, apart from a few strange
alt.* groups).
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 03 Feb 1997 04:17:49 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: pedersen@seas.smu.edu (Ted Pedersen)
Subject: Re: unitialized variables??
Message-Id: <qumeney5biq.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
Ted Pedersen <pedersen@seas.smu.edu> writes:
> I have some fairly simple perl code that runs "without incident" on one
> system - but when I move it over to another system I find that it
> generates massive numbers of unitialized variable messages. The code
> still produces the desired outbut but it generates all these warnings in
> the process.
> I don't change anything in the perl code and the version of perl running
> on both systems is the same. I am using the -w option by the
> way. Anybody experience something similar and have any ideas why this
> happens?
Sounds like you have different versions of Perl on the two systems; the
one generating the warnings is quite possibly newer (although that's not
the only explanation). Are the variables really used uninitialized? If
so, I'd recommend initializing them first as the ideal way to make the
warnings go away.
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Mon, 03 Feb 1997 20:53:10 -0800
From: "Kevin E." <itr@address.net>
Subject: Where to search for all newsgroup
Message-Id: <32F6C0B6.4C5E@address.net>
My question for the experienced newsgroup users are where can you go to
find a whole host of newsgroup channels? Is there a newsgroup listing
of all newsgroup sites? As you can tell, I'm new to the newsgroup
world. So if someone knows, please help!
Thank you
Kevin
------------------------------
Date: 03 Feb 1997 04:38:12 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: fpostma@inter.nl.net
Subject: Re: why does this regexp eat a newline??
Message-Id: <qumafpm5akr.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
Frans Postma <F.Postma@inter.NL.net> writes:
> #!perl
> $x='Subject:
> To: bla@abla
> Date: Sat 01-02-1997';
> $x=~s/Subject:\s*([^\n]*?)\s*\n/Subject: $1\n/im;
> print $x;
> __END__
> Output of this is:
> Subject: To bla@abla
> Date: Sat 01-02-1997
> Question: why does the regexp on $x eat the line on the Subject line?
> $1 should be empty in the s//m in this case but for some reason it grabs
> the next line too, which it shouldn't 'cos I specificly exclude newlines
> (\n)....
Ah, but \s matches a newline. Your regular expression matches like this:
Subject: matches Subject:
\s* matches \n
([^\n]*?) matches To: blah@abla
\s* matches (nothing)
\n matches \n
As I recall, \s is implemented using isspace(), which considers a space, a
tab, a carriage return, a newline, a vertical tab, or a formfeed to be a
whitespace character. Observe:
cyclone:~> perl -e '$_=" \t\r\n\013\f"; s/\s/%/g; print $_, "\n"'
%%%%%%
(\013 is a vertical tab; Perl doesn't support the \v escape C uses.) With
mail headers, all you have to worry about is LWSP (linear whitespace),
which is specifically defined in RFC 822 as only spaces and horizontal
tabs. Therefore, you want a regex more like this to extract the subject:
($subject) = ($header =~ /^Subject:[ \t]+([^\n]*?)[ \t]+\n/im);
However, that doesn't allow for continuation lines, which are defined as a
newline followed immediately by linear whitespace. So what you really
want is something more like this:
($subject) = ($header =~ /^Subject:[ \t]+((?:[^\n]+|\n[ \t]+)*)\n/im);
$subject =~ s/\s+$//;
Note that I've dropped the minimal matching because it's slow and
ineffecient compared to just stripping whitespace afterwards.
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
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 886
*************************************