[25167] in Perl-Users-Digest
Perl-Users Digest, Issue: 7416 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 18 00:05:50 2004
Date: Wed, 17 Nov 2004 21:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 17 Nov 2004 Volume: 10 Number: 7416
Today's topics:
Re: Advice needed: threads and queues <swartz@inbox.ru>
Re: Any Perl that works offline from WinXP desktop? (M.L.)
Re: Any Perl that works offline from WinXP desktop? <emschwar@fc.hp.com>
croak conventions in methods? <postmaster@castleamber.com>
FAQ 9.14: How do I make sure users can't enter values i <comdog@panix.com>
Re: Hash of hash in perl <tadmc@augustmail.com>
Help! Complex Pattern Extraction with Key/Value Pairs a (aekalman)
Re: Help! Complex Pattern Extraction with Key/Value Pai <postmaster@castleamber.com>
Re: Help! Complex Pattern Extraction with Key/Value Pai <aek@respectmyprivacy.com>
perl get crash when using ClearCase::CtCmd::exec (Maverick Ieong)
Re: perl get crash when using ClearCase::CtCmd::exec <1usa@llenroc.ude.invalid>
Re: perldoc problem on linux <glex_nospam@qwest.invalid>
search.cgi <bnbliss@comcast.net>
Re: search.cgi <noreply@gunnar.cc>
Re: search.cgi <postmaster@castleamber.com>
Re: search.cgi <bnbliss@comcast.net>
Re: the antichomp <jwillmore@fastmail.us>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 17 Nov 2004 18:37:35 -0600
From: "Swartz" <swartz@inbox.ru>
Subject: Re: Advice needed: threads and queues
Message-Id: <10pnso144ul7v9c@corp.supernews.com>
Hi.
From: "Vetle Roeim"
[...]
> >
> > if ($song{$song_num}{locked}) {
>
> Your hash contains strings, so what do you expect this to do?
Forgive my ignorance, but so does Ben's (although its hash of hashes that
contain strings)...
Now what do YOU expect this to do?
> my %songs : shared = (
> song1 => {
> name => "Song 1",
> length => 45,
> },
> song2 => ...
> );
I didn't find any docs and my only book is rather outdated(library book), I
assume that {locked} refers to the property of variable/hash/etc its
attached to... ?
And as per
$songs{$song}{locked} = threads->tid;
in request_song should contain the thread-id that locked it... or be
undef-ined.
Thanks.
--
Swartz
------------------------------
Date: 17 Nov 2004 17:13:13 -0800
From: mel2000@hotmail.com (M.L.)
Subject: Re: Any Perl that works offline from WinXP desktop?
Message-Id: <a409d169.0411171713.1de51d5d@posting.google.com>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message news:<Xns95A06263E3ED1asu1cornelledu@132.236.56.8>...
> M.L. <me@privacy.net> wrote in
> news:253cp01ups891n1b0lc8o64ngo95rn6s6s@4ax.com:
>
> > Hi. I haven't used Perl for a while and am just trying to get back
> > into the groove. I'm looking for a Perl program that will allow me to
> > execute Perl scripts offline on my WinXP desktop. I'd like to be able
> > to read and write to files on my desktop without installing a server
> > or being connected to the Internet.
>
> You do not need a web server to be able to execute Perl scripts. If you
> installed ActiveState Perl, it will associate files with .pl extension with
> the perl binary and you will be able to execute them by double-clicking on
> the script's icon or name in Explorer. However, I do not recommend this
> unless your script actually use a GUI to interact with the user. Instead,
> open a command window and execute scripts from there.
>
> You can test CGI scripts from the command line as well but for best
> results, I would recommend installing Apache on your machine. You can
> configure it to only respond to requsts from your machine on a non-standard
> port.
>
> > I looked at the ActiveState Perl program and noticed an implementation
> > of Perlscript via HTML.
>
> http://aspn.activestate.com/ASPN/docs/ActivePerl/Components/Windows/PerlScr
> ipt.html
>
> > Can that Perlscript write to and store files on my desktop?
>
> That would _probably_ require you to lower security settings which I
> wouldn't recommend. But then, I don't really know.
>
> > I remember a program called WinPerl that let me execute Perl
> > from my desktop but I can't find that app anymore.
>
> Maybe you are looking for a Perl IDE. It is not my cup of tea, but I have
> heard people mention Open PerlIDE:
>
> http://open-perl-ide.sourceforge.net/
>
> You might also want to look at:
>
> http://faq.perl.org/perlfaq3.html#How_can_I_get_perl_t
>
> http://faq.perl.org/perlfaq3.html#Can_I_write_useful_P
>
> http://faq.perl.org/perlfaq9.html#My_CGI_script_runs_f
>
> And maybe read the full FAQ if you are trying to become up to date.
>
> Sinan
Hello again. First I'd like to thank everyone who replied. One of the
reasons for my late response is that I only have occasional Internet
access for now. The problem will be fixed in a few months, but for now
I am constrained to work offline most of the time. So I'm trying to do
as much as I can while offline.
What am I trying to do? Simple. I want to use AnyData to slurp my
inventory data from Excel (or jpeg IPTC info) and use it to replace
variables within an HTML catalog template. I want to automate the
process of building a separate web page for each inventory item; I
know from experience that Perl is well-suited for that task. I also
hoped that the project could be built and executed offline. I've
already tried some off-the-shelf Windows programs but they aren't as
flexible as I'd like. Since the project is largely visual, I prefer
not to depend on a command line implementation. It is important that I
see the results on a web page, so yes, I'm trying to run a cgi script
offline.
Based on the advice I've received in this thread I've overcome some of
my fright of installing a server and downloaded the Open Perl IDE and
the Indigostar Perl all-in-one IDE package. I think the Open Perl IDE
is the one I've used before, and found it adequate for my offline
needs. I also need to download nmake, among other things.
Comments:
ActivePerl documentation is too Linux/Unix oriented,and stingy with
info critical to Windows users. FAQ9 is the only one geared toward
Win32 development with Perl. I still have trouble getting Perl to
point to any directory that is off the c:\Perl\site\lib path. I'd like
to run some test files from my external hard drive but can't get the
pointing right.
When I tried to use PPM to install a module it informed me that I must
be connected to the Internet, even though the documentation hinted
that repositories could be located on my hard drive. It didn't mention
anything more on using PPM offline.
The latest version of Perl gave me a "pseudo-hashes deprecated" error
when I ran an AnyData test script that used to work years ago:
**********************************************************
#!/usr/bin/perl5 -w
$| = 1;
use FindBin;
use lib "$FindBin::Bin/perl/site/lib";
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Fcntl qw(:flock);
#use Text::CSV;
use AnyData;
# Create an HTML page to display a message.
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY>";
print "<H1>";
print "TEST";
print "</H1>";
print "<HR>";
print "Hooray! It works!";
print "<HR>";
$category = 'Watches';
$db_file = "bstoredb.csv";
$db_rows = adTie('CSV',$db_file,'r'); # tie database
to hash
$cat_rows = $db_rows->{{category=>$category}};
while(my $row = (each %$cat_rows))
{
print qq|$row<br>\n|; # this line causes pseudo-hash error
}
print "</BODY></HTML>";
*********************************************************
The "Hooray..." part displays on the command line, but the rest of the
display does not. I've downloaded the latest version of AnyData and
hope the POD examples show me how to avoid the pseudo-hashes errors.
Thanks again to all who replied. I'm going to get busy with Perl
tonight :-)
------------------------------
Date: Wed, 17 Nov 2004 19:37:15 -0700
From: Eric Schwartz <emschwar@fc.hp.com>
Subject: Re: Any Perl that works offline from WinXP desktop?
Message-Id: <eto1xersx0k.fsf@wilson.emschwar>
mel2000@hotmail.com (M.L.) writes:
> ActivePerl documentation is too Linux/Unix oriented,and stingy with
> info critical to Windows users. FAQ9 is the only one geared toward
> Win32 development with Perl.
Er, perlfaq9 is all about networking. I don't see anything
Windows-specific in it. And hey, I dunno, having the documentation in
HTML format, accessible right off your Start menu sounds fairly
Windows-ish to me, but then, I don't use it, so perhaps I'm just
biased.
> I still have trouble getting Perl to
> point to any directory that is off the c:\Perl\site\lib path. I'd like
> to run some test files from my external hard drive but can't get the
> pointing right.
I don't understand what you mean by "pointing to a directory" ? If
you mean loading modules, 'use lib' works just as well on Windows as
it does anywhere else. If you mean binaries, well, perl.exe doesn't
care what paths you pass to it, so I'm very confused as to what you
could be having trouble with. A specific command line, or snippet of
code, and the error message it generates would help.
> When I tried to use PPM to install a module it informed me that I must
> be connected to the Internet, even though the documentation hinted
> that repositories could be located on my hard drive. It didn't mention
> anything more on using PPM offline.
I quote, from the ActivePerl FAQ, which took me maybe 20 seconds to
find from the moment I went to http://www.activestate.com/:
"To use these package repositories you start PPM v3 and at the prompt type:
repository add NAME URL
where NAME is a name by which you want to reference the repository
from PPM and URL is the URL to the repository."
Clearly "repository add Local file:///path/to/local/repository/" is
what you'd want.
As for creating a repository, maybe 10 seconds with Google searching
for "ppm create local repository" gave me
http://aspn.activestate.com/ASPN/Mail/Message/ppm/2103534
Which points out that a ppm repository is just a collection of files,
so you just need to fetch all of them somehow (rsync, wget,
LWP::Simple, whatever), and then see above for using them.
No offense intended, but given that it took me less than a minute,
total, to figure out the answers to your questions, and I don't even
use ActivePerl, I can only conclude you didn't look very hard. As a
rule, clpm regulars don't respond well to questions that evince a lack
of effort on the querent's part to answer the questions themselves.
And if you have a problem with something, a specific error message is
worth a thousand times what a vague statement like "I still have
trouble getting Perl to point to any directory that is off the
c:\Perl\site\lib path". Without code, and the actual error message
Perl prints out, we can only guess, and my ESP's been on the fritz for
a few decades now.
I'll let someone more familiar with AnyData critique your code, though
I would point out that these days, you should 'use warnings;' instead
of -w, and you should always 'use strict;'. FWIW, that's a very good
example-- a short snippet of code, and the exact error message it
generates is invaluable.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: 17 Nov 2004 23:55:41 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: croak conventions in methods?
Message-Id: <Xns95A4B65F22648castleamber@130.133.1.4>
I check # of parameters in methods using:
@_ == x or croak 'usage $bla->bla( ... )';
Is there a style guide for the ... part, ie,
VALUE
[ VALUE, ... ]
{ KEY => VALUE, ... }
How about optional things?
[ VALUE* ]
[ VALUE+ ]
[ VALUE{1,9} ]
VALUE?
{ KEY => VALUE {1,9} }
Anyone?
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Thu, 18 Nov 2004 05:03:02 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 9.14: How do I make sure users can't enter values into a form that cause my CGI script to do bad things?
Message-Id: <cnhae6$85i$1@reader1.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
9.14: How do I make sure users can't enter values into a form that cause my CGI script to do bad things?
See the security references listed in the CGI Meta FAQ
http://www.perl.org/CGI_MetaFAQ.html
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Wed, 17 Nov 2004 16:49:10 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Hash of hash in perl
Message-Id: <slrncpnlb6.1pu.tadmc@magna.augustmail.com>
Shashank Khanvilkar <shashank@mia.ece.uic.edu> wrote:
> Can I Do the following:
>
> %graph{$A}{$B} = $int
What happened when you tried it?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Nov 2004 17:10:47 -0800
From: aek@netcom.com (aekalman)
Subject: Help! Complex Pattern Extraction with Key/Value Pairs and Reg Exp?
Message-Id: <e047c470.0411171710.640a28a9@posting.google.com>
I'm really having difficulty with regular expressions -- perhaps
someone can help?
BACKGROUND: The strings:
sfiaravrt-7s-ec-sf-64.r90
sliaravrt-7s-ec-sf-64-i.r90
sfiaravra-6s-ec-sf.r90
sliaravrd-5l-sf-64.r90
sliaravrt-1s.r90
...
are various file names in a group of files.
Within a complex makefile system for generating libraries, I use the
following shell commands and reg exp to extract information from the
file names and pass that onto the compiler (via recursive make) as
command-line arguments, using:
*****
INDEX=$(shell expr '$(1)' : '$(2)')
PAIR=$(filter $(1)@%,$(2))
VAL=$(patsubst $(1)@%,%,$(2))
GETVAL = $(call VAL,$(call INDEX,$(1),$(2)),$(call PAIR,$(call
INDEX,$(1),$(2)),$(3)))
*****
TYPE_VALS = sf@OSF sl@OSL
FAMILY_VALS = iaravr@iaravr
CONFIG_VALS = a@OSA d@OSD e@OSE m@OSM t@OST
CPU_VALS = 0@0 1@1 2@2 3@3 4@4 5@5 6@6 7@7
MODEL_VALS = l@OSL s@OSS t@OST
CORE_VALS = -ec@OSE
FLASH_VALS = -sf@OSS
DOUBLES_VALS = -64@OSD
OPTION_VALS = -i@OSI
$(LIBRARIES):
$(MAKE) -f Makefile2 $@ \
T=$(call GETVAL,$@,\(..\), $(TYPE_VALS)) \
F=$(call GETVAL,$@,..\(......\).*\.r90, $(FAMILY_VALS)) \
C=$(call GETVAL,$@,........\(.\).*\.r90, $(CONFIG_VALS)) \
CPU=$(call GETVAL,$@,..........\(.\).*\.r90,$(CPU_VALS)) \
MODEL=$(call GETVAL,$@,...........\(.\).*\.r90,$(MODEL_VALS)) \
CORE=$(call GETVAL,$@,............\(.*\).r90,$(CORE_VALS)) \
FLASH=$(call GETVAL,$@,............\(.*\).r90, $(FLASH_VALS)) \
DOUBLES=$(call GETVAL,$@,............\(.*\).r90,$(DOUBLES_VALS)) \
O=$(call GETVAL,$@,............\(.*\).r90, $(OPTION_VALS))
*****
When you run make, you get something out like this:
make -f Makefile2 sfiaravrt-7s-ec-sf-64.r90 T=OSF F=iaravr C=OST CPU=7
...
The reg exp patterns are in the calls to GETVAL. This systems works
GREAT for filenames of constant length and format, and was suggest by
Jonathan Kamens to me back in '01.
PROBLEM: Using regular expressions, I am able to find patterns at the
start of the strings (like the (f,l) pair in the second position, or
the (a,d,t) trio in the ninth position) just fine because their
positions are fixed -- easy. The GETVAL macro returns a string (e.g.
OSF) that is passed onto the compiler via MAKE as T=OSF. Note that a
match must occur, and so the variable (in this case, T) is always
defined.
It's starting with the 13th position that I'm having trouble. I can't
seem to build a reg exp that excludes the first 12 characters, and
only searches from the 13th character onwards, up to the .r90 at the
end. I want to search only the 13th through last positions of the
filenames for the patterns:
-ec
-sf
-64
-i
and, if found, set the associated variable (e.g. CORE) to the value in
its key/value pairs list (e.g. CORE=OSE for "-ec is present"), o/wise
leave it undefined or defined to OSNONE (e.g. CORE=OSNONE for "-ec was
not found in the filename").
How do I do that?
Can anyone help? Please?
Thanks,
--Andrew Kalman
aek at pumpkin inc dot com
------------------------------
Date: 18 Nov 2004 01:13:21 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Help! Complex Pattern Extraction with Key/Value Pairs and Reg Exp?
Message-Id: <Xns95A4C387F802Bcastleamber@130.133.1.4>
aekalman wrote:
> I'm really having difficulty with regular expressions -- perhaps
> someone can help?
And your *Perl* question is?
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Thu, 18 Nov 2004 04:33:57 GMT
From: "Andrew E. Kalman" <aek@respectmyprivacy.com>
Subject: Re: Help! Complex Pattern Extraction with Key/Value Pairs and Reg Exp?
Message-Id: <419C281B.1030809@respectmyprivacy.com>
John Bokma wrote:
> aekalman wrote:
>
>
>>I'm really having difficulty with regular expressions -- perhaps
>>someone can help?
>
>
> And your *Perl* question is?
>
>
Where's the best place to ask regexp questions, if not here?
--
------------------------------------------------------
Andrew Kalman
aek ... at ... pumpkininc ... dot ... com
------------------------------
Date: 17 Nov 2004 17:31:22 -0800
From: mluvw47@gmail.com (Maverick Ieong)
Subject: perl get crash when using ClearCase::CtCmd::exec
Message-Id: <d4b6522b.0411171731.6331d8f4@posting.google.com>
Hi, there
I have install perl 5.8.3 and module ClearCase::CtCmd, (1.3.1)
version, when I ran the following code:
use ClearCase::CtCmd;
@test = ClearCase::CtCmd("lsvob");
It got a windows dialog said the Perl Command line Interpreteris
crash ask me to click send. When I click on the detail link I found
there is a appcompat.txt generate on my Temp folder and the contains
the following:
Any idea? TIA. I am using windows XP, SP1, if I typed the command
"lsvob" on cleartool, it does shows all the vobs.
<?xml version="1.0" encoding="UTF-16"?>
<DATABASE>
<EXE NAME="perl.exe" FILTER="GRABMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="perl.exe" SIZE="41015" CHECKSUM="0xCD715891"
BIN_FILE_VERSION="5.8.3.809" BIN_PRODUCT_VERSION="5.8.3.809"
PRODUCT_VERSION="Build 809" FILE_DESCRIPTION="Perl Command Line
Interpreter" COMPANY_NAME="ActiveState, a division of Sophos"
PRODUCT_NAME="ActivePerl" FILE_VERSION="5,8,3,809"
ORIGINAL_FILENAME="perl.exe" INTERNAL_NAME="perl.exe"
LEGAL_COPYRIGHT="Copyright 1987-2004, Larry Wall, Binary build by
ActiveState, a division of Sophos, http://www.ActiveState.com"
VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004"
VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0"
LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="5.8.3.809"
UPTO_BIN_PRODUCT_VERSION="5.8.3.809" LINK_DATE="02/03/2004 08:29:46"
UPTO_LINK_DATE="02/03/2004 08:29:46" VER_LANGUAGE="English (United
States) [0x409]" />
</EXE>
<EXE NAME="libatriaks.dll" FILTER="GRABMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="libatriaks.dll" SIZE="296928"
CHECKSUM="0x5265D468" MODULE_TYPE="WIN32" PE_CHECKSUM="0x4BC9D"
LINKER_VERSION="0x0" LINK_DATE="05/03/2004 16:38:18"
UPTO_LINK_DATE="05/03/2004 16:38:18" />
</EXE>
<EXE NAME="kernel32.dll" FILTER="GRABMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="kernel32.dll" SIZE="930304"
CHECKSUM="0xCBCCF8A9" BIN_FILE_VERSION="5.1.2600.1106"
BIN_PRODUCT_VERSION="5.1.2600.1106" PRODUCT_VERSION="5.1.2600.1106"
FILE_DESCRIPTION="Windows NT BASE API Client DLL"
COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows®
Operating System" FILE_VERSION="5.1.2600.1106 (xpsp1.020828-1920)"
ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32"
LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved."
VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004"
VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xE7ED3"
LINKER_VERSION="0x50001" UPTO_BIN_FILE_VERSION="5.1.2600.1106"
UPTO_BIN_PRODUCT_VERSION="5.1.2600.1106" LINK_DATE="08/29/2002
10:40:40" UPTO_LINK_DATE="08/29/2002 10:40:40" VER_LANGUAGE="English
(United States) [0x409]" />
</EXE>
</DATABASE>
------------------------------
Date: 18 Nov 2004 04:27:41 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: perl get crash when using ClearCase::CtCmd::exec
Message-Id: <Xns95A4EEA9D167Casu1cornelledu@132.236.56.8>
mluvw47@gmail.com (Maverick Ieong) wrote in
news:d4b6522b.0411171731.6331d8f4@posting.google.com:
> Hi, there
> I have install perl 5.8.3 and module ClearCase::CtCmd, (1.3.1)
> version, when I ran the following code:
>
> use ClearCase::CtCmd;
> @test = ClearCase::CtCmd("lsvob");
>
> It got a windows dialog said the Perl Command line Interpreteris
> crash ask me to click send. When I click on the detail link I found
> there is a appcompat.txt generate on my Temp folder and the contains
> the following:
> Any idea?
I don't know anything about the package you mention and I don't have the
faintest idea what Rational ClearCase is.
Looking at the documentation for the module shows no usage examples similar
the one you show above.
Rather, it looks like you need to invoke a sub with a four-letter name in
the ClearCase::CtCmd package rather than calling a sub named CtCmd in the
ClearCase package.
<SNIP>Windows crash information</SNIP>
Oh, by the way, you should
use strict;
use warnings;
and definitely read the posting guidelines for this group.
Sinan.
------------------------------
Date: Wed, 17 Nov 2004 17:22:28 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: perldoc problem on linux
Message-Id: <U2Rmd.45$pp3.4301@news.uswest.net>
Zhiliang Hu wrote:
> All those 3 works:
>
> perldoc -t GD | less
> perldoc -t GD | more
> perldoc -t GD | nroff
>
> but not this one (seen as I described earlier):
>
> perldoc -t GD
>
> I wonder which file/folder I should look at to "check permissions" as
> Anno suggested? (I found all perl related man pages are in
> /usr/share/man/man1 or man3, to which permissions are allowed for all
> users, i.e. 755 or 644 for folders or files respectively).
Maybe try setting your PERLDOCDEBUG environment variable, and then
running perldoc.
My version of perldoc contains:
BEGIN { $^W = 1 if $ENV{'PERLDOCDEBUG'} }
which might give more verbose output.
------------------------------
Date: Wed, 17 Nov 2004 16:39:31 -0800
From: Ken Saunders <bnbliss@comcast.net>
Subject: search.cgi
Message-Id: <bkrnp0ti615ioqn93qttbmur1a8ndet9pr@4ax.com>
I'm writing a script to search through all of my html files and return
the results of the query. I have used an html form file in the past I
want to integrate it all into one cgi file. can someone help here is
the code I've come up with.
#!perl -w
use strict;
use File::Find;
use CGI qw(:standard);
print "Content-type: text/html\n\n";
print "<HTML><HEAD>";
print "<TITLE>Ken's Site Search</TITLE>";
print "</HEAD>";
print "<BODY>";
print <form action="/cgi-bin/assignment_3.cgi" method="post">;
print <input type="text" name="quety" size="40" /> ;
print <input type="submit" /> ;
print </form>;
print "</BODY></HTML>";
my $query = param("query");
print header();
print start_html();
print "\n<p>For the query $query, these results were
found:</p>\n<ol>\n";
undef $/;
find( sub
{
return if($_ =~ /^\./);
return unless($_ =~ /\.html/i);
stat $File::Find::name;
return if -d;
return unless -r;
open(FILE, "< $File::Find::name") or return;
my $string = <FILE>;
close (FILE);
return unless ($string =~ /\Q$query\E/i);
my $page_title = $_;
if ($string =~ /<title>(.*?)<\/title>/is)
{
$page_title = $1;
}
print "<li><a href=\"$File::Find::name\">$page_title</a></li>\n";
},
'/home/ksaund01/public_html');
print "</ol>\n";
print end_html();
End
Were am I going wrong, any help is most appreciated.
bnbliss@comcast.net
------------------------------
Date: Thu, 18 Nov 2004 01:49:08 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: search.cgi
Message-Id: <3029o4F2s4tbeU1@uni-berlin.de>
Ken Saunders wrote:
> Were am I going wrong, any help is most appreciated.
You are not telling us what the script outputs and how that differs from
what you had expected.
Btw, 'quety' ne 'query'.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 18 Nov 2004 01:11:39 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: search.cgi
Message-Id: <Xns95A4C33ECB3Bcastleamber@130.133.1.4>
Ken Saunders wrote:
> #!perl -w
Just some remarks:
put -T there, and remove -w
> use strict;
use warnings; # instead of -w
> use File::Find;
> use CGI qw(:standard);
my $cgi = new CGI;
> print "Content-type: text/html\n\n";
> print "<HTML><HEAD>";
[...]
Uhm, you are already returning a HTML page here, so what you are doing
below is wrong:
Also don't print Content-type: yourself, and read on here doc
if you want to output several lines (ie. print <<"HTML"; )
> my $query = param("query");
check what you get here.
You probably want "if $query is undefined then show the search page (as
given above, otherwise do the following:"
> print header();
Note that CGI defaults to xhtml, is that what you want? (Most of the
time the answer is NO).
> print start_html();
> print "\n<p>For the query $query, these results were
> found:</p>\n<ol>\n";
> undef $/;
>
> find( sub
> {
> return if($_ =~ /^\./);
> return unless($_ =~ /\.html/i);
I prefer more an assertion like style:
/\.html?$/i or return;
note that I check html and htm (case insensitive), and also the file
must end with it (yours matches bla.html.gz too)
> stat $File::Find::name;
Doesn't stat default to $_, and there is no need for $File..etc? (Not
sure)
> return if -d;
> return unless -r;
>
> open(FILE, "< $File::Find::name") or return;
> my $string = <FILE>;
> close (FILE);
I prefer the
open my $html, $File::Find::name or return;
my $string = <$html>;
close $html; # not really needed
way
Or even File::Slurp, in this case.
> return unless ($string =~ /\Q$query\E/i);
$string =~ ... or return;
> my $page_title = $_;
> if ($string =~ /<title>(.*?)<\/title>/is)
> {
> $page_title = $1;
> }
> print "<li><a href=\"$File::Find::name\">$page_title</a></li>\n";
> },
> '/home/ksaund01/public_html');
Note that file path and URL are not the same thing, you need to do some
magic to get an URI in the href part.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Wed, 17 Nov 2004 17:35:38 -0800
From: Ken Saunders <bnbliss@comcast.net>
Subject: Re: search.cgi
Message-Id: <7runp05rhn96js6s3qvpcpn4ib2nehe0jg@4ax.com>
On Thu, 18 Nov 2004 01:49:08 +0100, Gunnar Hjalmarsson
<noreply@gunnar.cc> wrote:
Thanks for replying. I'll try and be more clear. I have two files
right now. I'm trying to merge the two into one script file that will
display the search form with submit button and then will return the
results with links.
The current HTML page is simply
<form action="/cgi-bin/search.pl" method="post">
<input type="text" name="query" size="50" />
<input type="submit" />
</form>
along with background and such.
The other is the search.cgi and is
#!perl -w
use strict;
use File::Find;
use CGI qw(:standard);
my $query = param("query");
print header();
print start_html();
print "\n<p>For the query $query, these results were
found:</p>\n<ol>\n";
undef $/;
find( sub
{
return if($_ =~ /^\./);
return unless($_ =~ /\.html/i);
stat $File::Find::name;
return if -d;
return unless -r;
open(FILE, "< $File::Find::name") or return;
my $string = <FILE>;
close (FILE);
return unless ($string =~ /\Q$query\E/i);
my $page_title = $_;
if ($string =~ /<title>(.*?)<\/title>/is)
{
$page_title = $1;
}
print "<li><a href=\"$File::Find::name\">$page_title</a></li>\n";
},
'/home/username/public_html');
print "</ol>\n";
print end_html();
End
Thanks again for any assistance.
Ken
------------------------------
Date: Wed, 17 Nov 2004 23:29:37 -0500
From: James Willmore <jwillmore@fastmail.us>
Subject: Re: the antichomp
Message-Id: <pan.2004.11.18.04.29.35.485112@fastmail.us>
On Wed, 17 Nov 2004 07:15:55 -0800, wana wrote:
> Is there a better way to it than this?
>
> $_ .= "\n" for @ARGV;
Maybe ...
#append a newline to each element in @ARGV
$_ = join("\n", @ARGV);
(one liner)
perl -e '$_ = join("\n", @ARGV);print "$_\n";' 1 2 3
If all you want to do is append a newline to each element of @ARGV, then
'join' is probably the best way to do it ...but, of course, TMTOWTDI :-)
HTH
Jim
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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.
#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 V10 Issue 7416
***************************************