[12146] in Perl-Users-Digest
Perl-Users Digest, Issue: 5746 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 21 17:07:17 1999
Date: Fri, 21 May 99 14:00:20 -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 Fri, 21 May 1999 Volume: 8 Number: 5746
Today's topics:
Re: Better solution ? <dhenders@cpsgroup.com>
Re: Better solution ? <uri@sysarch.com>
Re: Can you check this script please? i am a perl newbi <dhenders@cpsgroup.com>
Change File Names Recursively <Nathan.Owen@isocor.com>
Concatenate RTF files (David Beckley)
Re: Copy/paste on Win95 with Tk <erlangen72@hotmail.com>
Re: Dereferencing a filehandle. <juex@my-dejanews.com>
Re: Dereferencing a filehandle. (Charles DeRykus)
Re: Dereferencing a filehandle. (Larry Rosler)
Re: FAQ 4.36: Why don't my E<lt>E<lt>HERE documents wor lvirden@cas.org
GifPrune: de-animate GIF files <ksm+usenet@sas.upenn.edu>
Re: Grab string from STDIN (Tad McClellan)
Re: Grab string from STDIN <anand@my-dejanews.com>
Re: Help.... <uri@sysarch.com>
Re: How do I use a regular expression to ignore Java st <anand@my-dejanews.com>
Passsing Input From Form 2 Form via Perl/CGI <zzzipper@mindspring.com>
Re: Perl "constructors" (Andrew Allen)
perl email (EXCHANGE:BNRTP:0S31)
perl oracle on a hp-ux/64 mark_f_edwards@my-dejanews.com
Re: Regular expression ? <aqumsieh@matrox.com>
Re: Regular expression ? (Larry Rosler)
Simplest question about ChMod. <mrblue@pd.jaring.my>
Re: Simplest question about ChMod. (Tad McClellan)
Re: Web page redirect - Not working ?perl problem? Pls <memberjh@yahoo.com>
Re: while ( <FILE> && /match/ ) (Larry Rosler)
Re: while ( <FILE> && /match/ ) <ychampou@newbridge.com>
Re: Writing a HTML page with perl <jdporter@min.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 May 1999 14:57:13 -0500
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: Better solution ?
Message-Id: <87zp2ytcva.fsf@camel.cpsgroup.com>
>>>>> "tvn007" == tvn007 <tvn007@my-dejanews.com> writes:
tvn007> Hi, Here is the problem:
tvn007> To pad 2000 "X" to thousand of lines
how about:
while(<>){
s/^/"X"x2000/e if (1..2000);
print;
}
change the line numbers to fit.
------------------------------
Date: 21 May 1999 16:30:59 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Better solution ?
Message-Id: <x790ai88sc.fsf@home.sysarch.com>
>>>>> "DH" == Dale Henderson <dhenders@cpsgroup.com> writes:
>>>>> "tvn007" == tvn007 <tvn007@my-dejanews.com> writes:
tvn007> Hi, Here is the problem:
tvn007> To pad 2000 "X" to thousand of lines
DH> how about:
DH> while(<>){
DH> s/^/"X"x2000/e if (1..2000);
DH> print;
DH> }
i don't understand the original problem but your code can be improved.
why do a s/// and the /e when just plain printing will do.
perl -pe 'print "X" x 2000 if ( 1 .. 2000 )'
if the x expression is not constant folded then you could save it in a
BEGIN and print the var:
perl -pe 'BEGIN {$x = "X" x 2000} print $x if ( 1 .. 2000 )'
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 21 May 1999 14:45:32 -0500
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: Can you check this script please? i am a perl newbie!
Message-Id: <871zgaurz7.fsf@camel.cpsgroup.com>
>>>>> "Tim" == Tim Shapcott <m.shapcott@NOSPAMvirgin.net> writes:
Tim> [1 <multipart/alternative>]
Tim> [1.1 <text/plain; iso-8859-1 (quoted-printable)>]
^^ Why MIME?
Tim> Hi folks
Tim> I am completely new to cgi/perl, so i know practically
Tim> nothing about it. I'm trying to learn as i go along. I have
Tim> this script for a guestbook for my site, but as i know
Tim> nothing i don't know whether it is likely to work or not. it
Tim> is basically someone else's script that i downloaded, i just
Tim> modified it to do what i need it to. Do you think that you
Tim> could possibly check it, to see if it would work???
No it won't work. You can verify this by running
perl -c guest.cgi.
I would tell you what is wrong but if you want to learn you
should at least try to run it yourself.
A few suggestions.
use the -w switch
( I also tend to use the -T switch for cgi's. not necessary
really but it does help with security)
use strict.
declare all of you're variables.
use CGI.pm
use CGI::Carp qw/fatalsToBrowser/;
( *sigh* My company paid for code that didn't use -w or strict.)
Tim> TIA
Tim> Tim Shapcott
P.S. I really don't mean to sound harsh. It's just that you're
never going to learn if someone else give's you all the answers.
Tim> [1.2 <text/html; iso-8859-1 (quoted-printable)>]
Please don't use html in usenet. It's very obnoxious.
------------------------------
Date: Fri, 21 May 1999 04:23:09 -0400
From: "Nathan Owen" <Nathan.Owen@isocor.com>
Subject: Change File Names Recursively
Message-Id: <7i4fbq$87a$2@remarQ.com>
I have a Perl newbie question....
I need to write a simple script which needs to be able to change the case of
the filenames in a directory from uppercase / mixed case to strictly lower
case. Additionally, I need this script to work recursively on any
subdirectories in the directory in which the script is being run from.
I have been working with sections 1.9 (changing case) and section 9.7
(processing all files in a directory recursively) from the Perl Cookbook,
but can't seem to put it all together. Any help with this would be greatly
appreciated.
Thanks
nateowen@vramp.net
------------------------------
Date: Fri, 21 May 1999 19:55:51 GMT
From: david@bgraphx.com (David Beckley)
Subject: Concatenate RTF files
Message-Id: <3745b863.316685@news.swcp.com>
The program below works fine as it stands, but when opening the merged
document, Word recognizes only the first of the merged documents.
Apparently it encounters an end of document code. So I guess I need to
grab the guts of each document and keep the document header at the top
of the file and put a document footer at the end of the merged file.
Any ideas, please? I'm running on NT 4.0
TIA,
David
#Program to merge MS Word files
$path = "c:\\Trash\\AJP2\\";
local $/ = undef;
opendir trash, "c:\\Trash\\AJP2" or die "can't find directory!";
open (OUT,">c:\\Trash\\test.rtf") or die "can't make output file!";
binmode OUT;
@all = grep !/^\.\.?$/, readdir trash;
foreach $pname (@all) {
open (IN,"<$path$pname") or die "can't find input file!";
binmode IN;
$data = <IN>; # gets it all at once
print OUT $data;
close IN;
}
close OUT;
------------------------------
Date: Fri, 21 May 1999 12:30:23 -0700
From: "Erlangen" <erlangen72@hotmail.com>
Subject: Re: Copy/paste on Win95 with Tk
Message-Id: <7i4cap$ktj$1@oak.prod.itd.earthlink.net>
Win32::Clipboard hung my system. I had to close
Perl from the Task Manager.
I also tried to access the clipboard using Win32::OLE, with
an acitveX object that worked fine in VBScript, hosted with
WSH. Seemed to work except that Perl wouldn't close. I was
able to GetText from the clipboard and massage it in code.
I sent a report to ActiveState, but never heard back.
I too would like to get this working- has anyone succeeded?
My environment is Win95 OSR2, IE 4.01 SP1, VB5, PWS 4.0
VBScript 5, Perl 5.00502 build 509
Overall Perl works great for me: ASP, CGI, Command Line too.
But, I get IPF's when I run (.pls) files in WSH- no problem
because there are so many other ways to use Perl.
Best Wishes, Mark
Eric Bohlman wrote in message ...
>Patrick Renaud <patrick.renaud@transport.alstom.com> wrote:
>: I'm working with Perl (ActiveState) and Tk on Win95 and don't find in
>: the documentation a way to use the window's clipboard to copy and paste
>: datas beetween 2 applications.
>
>There's a Win32::Clipboard module floating around somewhere (I think
>there's a version on ActiveState's site).
>
------------------------------
Date: Fri, 21 May 1999 12:11:00 -0700
From: "J|rgen Exner" <juex@my-dejanews.com>
Subject: Re: Dereferencing a filehandle.
Message-Id: <7i4avk$9pb@news.dns.microsoft.com>
Keith <keithp@comnet.ca> wrote in message
news:7i3q8b$ccp$1@bmerhc5e.ca.nortel.com...
> Can anyone tell me how to show the value of a filehandle in my output?
> I have something like this:
> print "FILE: $_\n";
>
> Where FILE is the filehandle defined earlier in the program.
> I want FILE to show up as the real file name.
That's impossible.
For one part the file that is the target of the handle might have several
different names (aka hard links).
For the other part there might not be a entry in the file tree at all for
this file any more (and therefore no name) It's a common practise to open a
temporary file and to delete it immediately again, while keeping a private
copy of the file descriptor. That way you can read and write as you wish
without the chance, that any other program/process could interfere with your
data or file.
jue
--
J|rgen Exner
------------------------------
Date: Fri, 21 May 1999 19:28:10 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Dereferencing a filehandle.
Message-Id: <FC3Kqy.Eoy@news.boeing.com>
In article <7i3q8b$ccp$1@bmerhc5e.ca.nortel.com>,
Keith <keithp@comnet.ca> wrote:
>Can anyone tell me how to show the value of a filehandle in my output?
>I have something like this:
>print "FILE: $_\n";
>
>Where FILE is the filehandle defined earlier in the program.
>I want FILE to show up as the real file name.
Don't use a bareword filehandle:
my $fh = '/path/to/file';
open($fh, $fh) or die $!;
print "$fh: $_\n";
hth,
--
Charles DeRykus
------------------------------
Date: Fri, 21 May 1999 13:10:54 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Dereferencing a filehandle.
Message-Id: <MPG.11af5da84f72db7d989add@nntp.hpl.hp.com>
In article <7i4avk$9pb@news.dns.microsoft.com> on Fri, 21 May 1999
12:11:00 -0700, J|rgen Exner <juex@my-dejanews.com> says...
> Keith <keithp@comnet.ca> wrote in message
> news:7i3q8b$ccp$1@bmerhc5e.ca.nortel.com...
> > Can anyone tell me how to show the value of a filehandle in my output?
> > I have something like this:
> > print "FILE: $_\n";
> >
> > Where FILE is the filehandle defined earlier in the program.
> > I want FILE to show up as the real file name.
>
> That's impossible.
> For one part the file that is the target of the handle might have several
> different names (aka hard links).
> For the other part there might not be a entry in the file tree at all for
> this file any more (and therefore no name) It's a common practise to open a
> temporary file and to delete it immediately again, while keeping a private
> copy of the file descriptor. That way you can read and write as you wish
> without the chance, that any other program/process could interfere with your
> data or file.
Warning to the unwary:
This stratagem works on only a very small minority of the computers
functioning in the modern world, namely those whose operating systems
are derived from a particular legacy of about thirty years ago.
For the vast majority of existing computers, an open file cannot be
unlinked or renamed. Assuming that it can is a serious portability bug.
>From perlport.pod (note 'Some platforms ...' :-):
Some platforms can't delete or rename files that are being held open by
the system. Remember to C<close> files when you are done with them.
Don't C<unlink> or C<rename> an open file. Don't C<tie> to or C<open> a
file that is already tied to or opened; C<untie> or C<close> first.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 21 May 1999 19:12:17 GMT
From: lvirden@cas.org
Subject: Re: FAQ 4.36: Why don't my E<lt>E<lt>HERE documents work?
Message-Id: <7i4b6h$dtl$1@srv38s4u.cas.org>
According to John Stanley <stanley@skyking.OCE.ORST.EDU>:
:In article <pudge-1705991856180001@192.168.0.77>,
:Chris Nandor <pudge@pobox.com> wrote:
:>No, E<lt> means to use the less-than symbol. It is POD markup, and is the
:>correct header for that FAQ. There is no syntax error there, it is just
:>POD.
:
:Except this is USENET, and a USENET message header. It is not POD. It is
:simple text. There is no reason to believe that anyone pipes their
Sounds like an exchange on this newsgroup between the 'clueless newbies'
who post in HTML or mime encoded formats and the regulars <grin>...
--
<URL: mailto:lvirden@cas.org> Quote: Saving the world before bedtime.
<*> O- <URL: http://www.purl.org/NET/lvirden/>
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
------------------------------
Date: Fri, 21 May 1999 15:17:41 -0400
From: Ken MacFarlane <ksm+usenet@sas.upenn.edu>
Subject: GifPrune: de-animate GIF files
Message-Id: <3745B155.1A3FCD0A@sas.upenn.edu>
Inspired by the proxy server posted by Tom Christiansen recently, I've made a
first pass at a Perl module which will take a GIF as input, and ouptut a static
GIF of the last frame, without animation. The intent is that this will be useful
when used with a proxy server to "de-animate" animated images.
The module is available at:
http://ccat.sas.upenn.edu/~ksm/Perl/GifPrune.pm
I'll try to make it available through CPAN as well.
There's plenty of room for improvement in the code itself; feedback is welcome.
--
Ken MacFarlane, Systems Programmer
SAS Computing Workstation Services
University of Pennsylvania
http://ccat.sas.upenn.edu/~ksm/
------------------------------
Date: Fri, 21 May 1999 09:58:49 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Grab string from STDIN
Message-Id: <pqo3i7.d1g.ln@magna.metronet.com>
Hall, Johnny (johnny@pahv.xerox.com) wrote:
: O.K. I'm new to perl and this list and almost afraid to ask this
: question after seeing some replies to newby's here. Anyway, here
: goes...
You have entirely the wrong picture there.
The harsh replies are not _because_ they are newbies.
They are because the answers are easily found if looked for.
It is just coincidence that nearly all poster's of such
questions happen to be newbies (because experienced folks
want to get on with thier work, not throw themselves at
the mercy of others and wait hours/days for their answer,
so they see if they can't look it up before posting)
: My first project with perl turned out to be quite complex (for me) as I
: am trying to solve our Y2K situation with it. We are a Sun env and what
: I need to do is run a tool called sunscan, grab the Y2K patches needed
: for $HOST, run wget to "ftp" them from sunsolve, uncompress and untar
: them and install them. Everything here is pretty simple for me except I
: don't know how to (a) open the output of sunscan in the script
perldoc -f open
describes how to associate a filehandle with the output of
a program ( "pipe open").
perldoc -f qx
points to 'perlop.pod' which describes how to snatch all of
the output from a program.
: (b)
: snatch the patch number from the list. Here is a sample from the output
: of sunscan.
: Y2K patches needed for this system
: ----------------------------------
: 104854-02: SunOS 5.5.1: troff macro patch
: 104820-01: SunOS 5.5.1: /usr/lib/saf/listen patch
: 104822-01: SunOS 5.5.1: usr/lib/libadm.so.1 and usr/lib/libadm.a patch
$patch_number = $1 if /^([^:]*)/; # see perlop.pod and perlre.pod
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 21 May 1999 20:12:12 GMT
From: Anand <anand@my-dejanews.com>
Subject: Re: Grab string from STDIN
Message-Id: <7i4emq$bej$1@nnrp1.deja.com>
In article <37459B84.2DE0954D@pahv.xerox.com>,
"Hall, Johnny" <johnny@pahv.xerox.com> wrote:
> I
> don't know how to (a) open the output of sunscan in the script (b)
> snatch the patch number from the list. Here is a sample from the
Warning: Newbie's reply.
open(SCAN, "sunscan|");
while (<SCAN>) {
($patchnum, $os, $patch) = split(/:\s*/);
# Now $patchnum contains the patch number. Ex: 104854-02
# Ex. $os = SunOS 5.5.1
# Ex. $patch = troff macro patch.
}
> output of sunscan.
>
> Y2K patches needed for this system
> ----------------------------------
>
> 104854-02: SunOS 5.5.1: troff macro patch
> 104820-01: SunOS 5.5.1: /usr/lib/saf/listen patch
> 104822-01: SunOS 5.5.1: usr/lib/libadm.so.1 and usr/lib/libadm.a
patch
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 21 May 1999 15:22:36 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help....
Message-Id: <x7d7zu8byb.fsf@home.sysarch.com>
tim> I am really new to cgi/perl and i can't figure out why this
tim> doesn't work.
it fails because perl can't parse this:
M(R$O=7-R+VQO8V%L+V)I;B]P97)L#0H-"B1D:7)E8W1O<GE?9V)O;VL@/2 B
M:'1T<#HO+W=W=RYM;W)E;F\M8F%N9"YF<F5E<V5R=F4N8V\N=6LO9W5E<W1S
don't send attachments to this group. plain text is the only proper
method. ever heard of cut and paste?
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Fri, 21 May 1999 19:41:05 GMT
From: Anand <anand@my-dejanews.com>
Subject: Re: How do I use a regular expression to ignore Java style comments in a file?
Message-Id: <7i4csg$a3d$1@nnrp1.deja.com>
In article <374597b2@news1.us.ibm.net>,
"Jacob Yackenovich" <jyacken@ibm.net> wrote:
> I have close to 30,000 Java files that need to be checked for certain
bits
> of information. If a line of code is commented out (by using // to
comment
> the line), I would like to ignore that line completely, and move onto
the
> next.
unless ($str =~ /\/\//) { print $str; }
or
unless ($str =~ m#//#) { print $str; }
But how about when only part of a line is commented? You didn't ask
about that.
Anand
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Fri, 21 May 1999 13:59:49 -0700
From: "zzzipper" <zzzipper@mindspring.com>
Subject: Passsing Input From Form 2 Form via Perl/CGI
Message-Id: <7i4drj$dl9$1@nntp9.atl.mindspring.net>
Can someone explain how to accomplish or point me in the direction of an
example for doing the following with forms using CGI and a series of Perl
scripts:
I have a form for initial input (name, address, etc). I want to pass this
info between a series of 4 forms as a page header. After the Ist form is
read, I am able to display form 1's input on the second form's header.
However when I submit the 2nd form and try to read the header data inserted
(name, etc) I receive no data.
I am using forms with hidden input fields, but trying to place OnClick
values into these fields seem fruitless. Please help or advise.
Sincerely
Mitch
mward@21stcenturyartists.com
------------------------------
Date: 21 May 1999 18:52:53 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Perl "constructors"
Message-Id: <7i4a25$ngo$1@fcnews.fc.hp.com>
Eric The Read (emschwar@rmi.net) wrote:
: It's not only that, though. Perl really only has one type of exception:
: $@. It's not even *possible* for Perl to automatically propogate
: "uninteresting" exceptions, because there's only one kind. Another
: annoying thing is that a subroutine can raise an exception, and the
: caller is not forced to deal with it. This severely limits the
: usefulness of eval/die as an exception handling mechanism, to my mind.
Baloney. Just takes a little bit of creativity. Graham Barr's Error.pm
wraps the following idea up in a neat little package (along with the
try/catch example from perlsub):
package GoodError;
package MyError;
@ISA=qw(GoodError);
package main;
eval{die bless {},"MyError"};
print $@->isa("GoodError");
Andrew
------------------------------
Date: Fri, 21 May 1999 14:53:32 -0400
From: "Barth, Brian (EXCHANGE:BNRTP:0S31)" <picoop2@americasm01.nt.com>
Subject: perl email
Message-Id: <3745ABAB.2FA179B7@americasm01.nt.com>
how do you send an email from a perl script?
the script is called from another script and i want send an email to an
address which is passed to the script when called.
i have a readparse subroutine to get the info in the call
so i need some sort of format to send it:
to: $address
from : $sender
subject: $description
body: $main_info
is there an easy way of doing this? it doesnt need to be pretty, just
functional
brian barth
picoop2@nortelnetworks.com
------------------------------
Date: Fri, 21 May 1999 20:16:24 GMT
From: mark_f_edwards@my-dejanews.com
Subject: perl oracle on a hp-ux/64
Message-Id: <7i4eum$bob$1@nnrp1.deja.com>
has anyone successfully gotten perl to work with oracle
on an hp 64 bit machine??
the pro*c programs precompile, compile, and link successfully, so that
tells me that it must be possible!
any help will be GREATLY appreciated!
mark.edwards@sunh.com
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Fri, 21 May 1999 13:47:41 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Regular expression ?
Message-Id: <x3yg14q1fib.fsf@tigre.matrox.com>
tvn007@my-dejanews.com writes:
> Would someone help me with the "bug" in this perl script?
A bug, by definition, is a behaviour that is different from what is
documented (or expected). What is it that your little program is doing
that is different from what you expect?
> #!/usr/local/bin/perl -w
You might want to 'use strict;' here.
> $inputfile = $ARGV[0];
>
> unless (open(DATA,$inputfile)){
> die ("ERROR: cannot open input file\n")}
You should stick a $! in that die() statement. Checkout perlvar.
> my @heads = split ' ' , <DATA>; # column headers (names)
The above line doesn't probably do what you want. It reads in all of
your inputfile, and splits it on any combination of white
space. Judging from what you don't say, you want to read a header of
an email message. Then, you'd probably want to have a look at $/ in
perlvar and the following in perlfaq9:
How do I parse an email header?
It will also be good to read about split() in perlfunc too.
> <DATA>; # skip blank line
By this time, your script would've read the whole file already, and
the line above wouldn't do anything.
> my %values;
> ##################################
> $3 if (/^(R\d*)\s*(\w*)\s*(.*)/), <DATA>;
What are you trying to do here? <DATA> will return a false value, and
the match will not succeed.
> #Why $1 not equal to R65000 ?
> #Why $2 not equal to ddc1 ?
> #Why $3 not equal to 1010HLHXX ?
> #why it give me some annoying mesages "use of uninitialized value at .."
Because $_ is undefined. You have read all your lines from <DATA>
already.
You need to read more documentation before you continue any
further. Be sure that each step in your program does what you want it
to do, and then you'll figure out your problems easily.
HTH,
Ala
------------------------------
Date: Fri, 21 May 1999 12:58:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regular expression ?
Message-Id: <MPG.11af5ad0be5ff587989adc@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <x3yg14q1fib.fsf@tigre.matrox.com> on Fri, 21 May 1999
13:47:41 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...
> tvn007@my-dejanews.com writes:
...
> > my @heads = split ' ' , <DATA>; # column headers (names)
>
> The above line doesn't probably do what you want. It reads in all of
> your inputfile, and splits it on any combination of white
> space.
Quite wrong. split() splits a string, not a list. The second argument
(if any) is evaluated in scalar context. So this reads one line only
(if any).
...
> > <DATA>; # skip blank line
>
> By this time, your script would've read the whole file already, and
> the line above wouldn't do anything.
No. If there is a second line in the file, this code will do exactly
what the comment says it will.
<SNIP> all the rest of the analysis, which is based on the original
faulty premise.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 22 May 1999 03:00:39 +0800
From: "Blue" <mrblue@pd.jaring.my>
Subject: Simplest question about ChMod.
Message-Id: <7i4ahc$lj5$1@news6.jaring.my>
First of all, I don't know much about cgi.
First question:
I have this scipt that comes in pair, eg. aaa.pl and bbb.pl. The author said
that these two scripts must be located in the cgi-bin directory and aaa.pl
must be chmod to 755 whereas bbb.pl must be chmod to 777. However, every
time when I have chmod a script, eg. to 777, all my scripts in the same
directory will also be chmod to 777. Have I misunderstood something?
Second question:
What is a Unix prompt? Where can I find it in my FTP programme?
I am using WS_FTP 95 LE.
Thanks.
------------------------------
Date: Fri, 21 May 1999 11:15:57 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Simplest question about ChMod.
Message-Id: <dbt3i7.i9g.ln@magna.metronet.com>
Blue (mrblue@pd.jaring.my) wrote:
: First of all, I don't know much about cgi.
That's OK.
Most of us don't know anything about CGI either.
So asking us is a Bad Idea!
Ask Perl questions here in the Perl newsgroup.
Please ask CGI questions in the CGI newsgroup.
comp.infosystems.www.authoring.cgi
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 21 May 1999 16:37:50 -0400
From: "Jane H." <memberjh@yahoo.com>
Subject: Re: Web page redirect - Not working ?perl problem? Plse help!
Message-Id: <7i4g7k$a4e@sjx-ixn1.ix.netcom.com>
print "Content-type: text/html\n\n";
make this the second line in your script.
------------------------------
Date: Fri, 21 May 1999 13:38:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: while ( <FILE> && /match/ )
Message-Id: <MPG.11af64038e11e13e989ade@nntp.hpl.hp.com>
In article <slrn7kb4qb.aku.fl_aggie@thepentagon.com> on 21 May 1999
17:06:37 GMT, I R A Aggie <fl_aggie@thepentagon.com> says...
> On 21 May 1999 11:58:24 -0400, Victor Eijkhout <eijkhout@prancer.cs.utk.edu>, in
> <omyaiipg7z.fsf@prancer.cs.utk.edu> wrote:
> + Ok, so that doesn't work. Why?
>
> Because you're not understanding how to use while() with filehandles...
>
> + $_=<FILE>;
> + while ( /match/ ) { .... ; $_=<FILE>; }
> +
> + which is ugly.
>
> No kidding. What you mean to say is this:
>
> while(<FILE>) { # primes $_ if <FILE> has something
> if (/match/) {
> #do your match stuff here
> }else{
> last;
> }
> }
>
> Better, yes? If I'm groking your code correctly, if you don't have a match,
> you want to exit the loop? yes? if not, then zap the 'else{ ... }' chunk
> of the if condtional.
One seldom ought to pick on coding style, but as this thread has to do
with ugliness, your attempt to correct that ugliness is fair game.
Style point 1:
When coding a conditional with two consequents, it is nice to put the
shorter one first, so it doesn't get overlooked way down there after the
longer one. So (with improved indenting -- tabs in posted code mess up
awfully when it is quoted):
while (<FILE>) { # primes $_ if <FILE> has something
unless (/match/) {
last;
}else{
#do your match stuff here
}
}
Style point 2:
If you are going to bail out of a loop, you don't need to 'else' and
indent the other consequent. So:
while (<FILE>) { # primes $_ if <FILE> has something
last unless /match/;
#do your match stuff here
}
The second line could also be written as:
/match/ or last;
where I choose 'or' over '||' to emphasize the change of control flow.
I just saved the world a lot of indents, plus the following punctuation:
( ) { } { }
An ecological wonder!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 21 May 1999 16:49:45 -0400
From: Yanick Champoux <ychampou@newbridge.com>
To: Victor Eijkhout <eijkhout@prancer.cs.utk.edu>
Subject: Re: while ( <FILE> && /match/ )
Message-Id: <3745C6E9.8D67AD9B@newbridge.com>
Victor Eijkhout wrote:
>
> Ok, so that doesn't work. Why?
Camel book, page 53:
"If and only if the line input operator is th eonly thing inside the
conditional of a while loop, the value is automatically assigned to the
special variable $_."
> Right now I'm writing
>
> $_=<FILE>;
> while ( /match/ ) { .... ; $_=<FILE>; }
>
> which is ugly.
Well, you could do:
while( ( $_ = <FILE> ) =~ /match/ ){ ... }
or
while( <FILE> ){ last unless /match/; ... }
or
for( $_ = <FILE>; /match/; $_ = <FILE> ){ ... }
Of these three, I guess the second one is the less ugly and easiest to
read.
> (Perl is weird, but I cn see myself getting to like it.)
Amen to that. At first you can't understand for the life of you what
type of madman could have made up such things as the while( <> )
automagical stuff. Then, some time after, you just wonder how you
managed to survice all these years without it. :)
Joy,
Yanick
--------------------------------------------------
|||| ||||| Yanick Champoux
||||\\|||| Analyst, Advanced Technology Support
||||\\\||| Newbridge Networks Corporation
||||\\\\|| More Info? http://www.newbridge.com
|||| \\\\| E-mail: ychampou@newbridge.com
||| ```` Phone: (613) 599-3600 x5423
--------------------------------------------------
------------------------------
Date: Fri, 21 May 1999 19:29:09 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Writing a HTML page with perl
Message-Id: <7i4c62$9if$1@nnrp1.deja.com>
In article <374592DB.A45B2C6E@123_rio.com>,
"Eng. Edilson Francioni Coelho" <efcoelho@123_rio.com> wrote:
> I'm a newbie and I'd like to write a HTML page from perl.
>
> I have once once done it starting with
>
> print "Content-type: text/html\n\n";
>
> It worked fine, but it gave me a lot of work preparing everything. I
> have once seen such a script doing things differently,
You should use the CGI.pm module. I can't emphasize strongly
enough <em><b>use CGI;</b></em>. It will make life worth living again.
my $q = new CGI;
print $q->header; # prints the headers, usually just the Content-type.
print(
$q->table( { -border => 0, -cellpadding => 4 },
$q->Tr(
$q->th( "use CGI;" ),
$q->td( { -bgcolor => '#CCFFFF', -align => 'right' },
"perldoc CGI"
),
),
),
);
> Also, can a block of text be added to the middle of an ordinary HTML
> page in the same way an image can be?
The "correct" way is very painful, exploiting the Document Object
Models of the browsers. Instead, you might want to investigate
the use of frames.
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5746
**************************************