[11904] in Perl-Users-Digest
Perl-Users Digest, Issue: 5504 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 28 10:07:18 1999
Date: Wed, 28 Apr 99 07:00:19 -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 Wed, 28 Apr 1999 Volume: 8 Number: 5504
Today's topics:
Seeking Perl course info <onecor@hotmail.com>
Re: "learning perl" does not seem to be written well <bowman@montana.com>
BUGS or FEATURES in perl5.006? paulclinger@my-dejanews.com
Re: Confused about s/// example in the Camel book (Tad McClellan)
Re: count associate array (Randal L. Schwartz)
Re: count associate array (Bart Lateur)
Re: Help reading directories and displaying contents <vvb@ibm.net>
Re: Help reading directories and displaying contents (Tad McClellan)
Re: How do i print something using perl? smnayeem@my-dejanews.com
Re: MacPerl to AS (well, vice versa) (Chris Nandor)
Re: newbie: Replace \n with <br>\n <vvb@ibm.net>
Re: Parsing query strings (Tad McClellan)
Re: Perl Weekday Script <sb@sdm.de>
Re: Problem with DBV::CSV <jeff@vpservices.com>
Re: Script Help (Clinton Pierce)
Re: Simple if syntax Question <nospam.newton@gmx.net>
String conversions (a different angle!?) ralawrence@my-dejanews.com
Re: String conversions (a different angle!?) (Larry Rosler)
Re: stupid single quote " wipes out REST OF TEXT NOSPAMcrstlblu@planet.eon.net
Re: SYSTEM call from Perl under Windows95CGI??? <carcudi@eli.net>
Re: Using string content as an a variable name (Tad McClellan)
Re: What does this error message mean? (Bart Lateur)
Re: What does this error message mean? paulclinger@my-dejanews.com
Re: What does this error message mean? (Larry Rosler)
Re: What does this error message mean? (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 Apr 1999 12:22:21 GMT
From: "Not So Newbie" <onecor@hotmail.com>
Subject: Seeking Perl course info
Message-Id: <FAwFp9.2oJ@news2.new-york.net>
Am working through the Llama book, with the Camel book;
Does anyone know of any decent courses in Perl that are
given in the greater NYC area?
------------------------------
Date: Wed, 28 Apr 1999 06:58:07 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <fCDV2.1140$Sx.5778@newsfeed.slurp.net>
David Cassell <cassell@mail.cor.epa.gov> wrote in message
news:37267167.E811BAB@mail.cor.epa.gov...
> When I first started tinkering with Perl, I wrote down a lot of the
> cute idioms that I saw, and sort of used that as a cheat-sheet for
> a bit. I wonder what happened to it...
I definitely see that in my life. What the little ORA handbook needs is
fifty or so blank pages for user notes. I'm reminded of learning natural
languages and the little opaque idioms one must master to insure the waiter
brings a mug of beer and not a bowl of Cream of Octopus soup.
------------------------------
Date: Wed, 28 Apr 1999 12:08:07 GMT
From: paulclinger@my-dejanews.com
Subject: BUGS or FEATURES in perl5.006?
Message-Id: <7g6tn4$u6a$1@nnrp1.dejanews.com>
Hello, Perl folks!
Script in this letter show some undocumented {BUGS|FEATURES} in perl.
Tested under Win32 with
version 5.005_02 built for MSWin32-x86
version 5.004_02
I don't have 5.006 executable, but scan all documentation for 5.006.
Can somebody comment it? Please, send comment on paulclinger@yahoo.com too, I
read news unregulary.
Best wishes,
Paul.
#--------------------------------------------------------------------------
#!perl -w
=begin autovivification from perlfunc [5.006]
if (exists $ref->{A}->{B}->{$key}) { }
if (exists $hash{A}{B}{$key}) { }
Although the last element will not spring into existence just because
its existence was tested, intervening ones will. Thus C<$ref-E<gt>{"A"}>
and C<$ref-E<gt>{"A"}-E<gt>{"B"}> will spring into existence due to the
existence test for a $key element.
=cut
# --------------------------------------------------------
# BUG #1: code
$hash{key}{subkey} = "value";
print "Hash 1: ", scalar(%hash), " ", scalar(keys %hash), "\n";
() = %{$hash{otherkey}}; # warning here, as expected
print "Hash 2: ", scalar(%hash), " ", scalar(keys %hash), "\n";
() = keys %{$hash{otherkey}}; # oops, somebody put key in my hash here
print "Hash 3: ", scalar(%hash), " ", scalar(keys %hash), "\n";
=begin BUG #1: output
Hash 1: 1/8 1
Use of uninitialized value at bugs.pl line [somenumber].
Hash 2: 1/8 1
Hash 3: 2/8 2
=cut
# --------------------------------------------------------
# BUG #2: code
my(%hash);
$hash{undef} = undef; # no warning about uninitialized value, DWIM
%hash = (undef, 1); # oops, warning here
=begin BUG #2: output
[perl 5.004 only]
Ambiguous use of {undef} resolved to {"undef"} at bugs.pl line
[number of line with '$hash{undef}'].
[both 5.004 and 5.005]
Use of uninitialized value at bugs.pl line
[number of line with '%hash = '].
=cut
# --------------------------------------------------------
# BUG #3: code
my(%a); # now %a is DEFINED and it's documented ONLY in perltrap
my %b; # now %b is UNDEFINED and it's documented NOWHERE
() = my %c; # same as my(%a), but more tricky :)) and %c is DEFINED
print defined(%a) == defined(%b) ? "my(%a) == my %b"
: "my(%a) != my %b", "\n";
=begin BUG #3: output
my(%a) != my %b
=cut
# --------------------------------------------------------
# BUG #4: code
$_ = 2.99999999999999;
print "1..", $_, ": ";
for (1..$_) {print}; print "\n";
$_ = 2.9999999999999999;
print "1..", $_, ": ";
for (1..$_) {print}; print "\n";
$_ = 2.999999999999999;
print "1..", $_, ": ";
for (1..$_) {print}; print "\n"; # opps, where is 3?
=begin BUG #4: output
1..2.99999999999999: 12
1..3: 123
1..3: 12
=cut
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 28 Apr 1999 04:15:15 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Confused about s/// example in the Camel book
Message-Id: <j2g6g7.er5.ln@magna.metronet.com>
Brian Peisley (bdp@mutagenic.org) wrote:
: I am confused about an example of s/// on page 74 of the Camel book (2nd
: ed.).
: I understand what this is doing, I just don't understand why
: length($`)%8 is being subtracted. I wrote the simple script below to see
: what this does and then I took out the length($`)%8 part to see what the
: difference was, but the output was them same.
: tab.txt is just a text
: file with varying numbers of tabs on each line, I trust you can make one
: up for yourself if you want to run this. :-)
I trust you could have just given us the data you used in
a DATA filehandle :-)
: #!/usr/bin/perl -w
: use strict;
Kudos!
: If somebody could explain why that is there I would greatly appreciate
: it.
Because if you type three characters then hit TAB, the tab
should be replaced with 5 spaces, not 8 spaces.
------------------------------------
#!/usr/bin/perl -w
use strict;
while (<DATA>) {
s/\t+/'~' x (length($&)*8 )/e;
# s/\t+/'~' x (length($&)*8 - length($`)%8)/e;
print;
};
__DATA__
one
two
one again
two again
foo foo-1
------------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Apr 1999 03:34:27 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: count associate array
Message-Id: <m1iuahnido.fsf@halfdome.holdit.com>
>>>>> "Jason" == Jason <robobob@blech.mindwell.com> writes:
Jason> $count = scalar(keys %hash);
Useless use of "scalar".
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 28 Apr 1999 12:17:01 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: count associate array
Message-Id: <3727fc18.3870894@news.skynet.be>
Randal L. Schwartz wrote:
>Jason> $count = scalar(keys %hash);
>
>Useless use of "scalar".
Not (quite) "useless". Redundant.
Bart.
------------------------------
Date: Wed, 28 Apr 1999 14:30:12 +0200
From: "Vincent Vanbiervliet" <vvb@ibm.net>
Subject: Re: Help reading directories and displaying contents
Message-Id: <3726fea8@news.uk.ibm.net>
Max Calvo <mcalvo@maxcalvo.net> wrote in message
news:yivV2.155$VW1.25132@news.uswest.net...
> Hi all;
>
> I need some help here folks. I am trying to get a perl script that will
read
> the contents of directory then I need the content displayed in a HTML
> document. This directory has lots of jpegs and I need then to display in
> aweb page. I am trying to automated webpages dinamically instead to
created
> a webpage each time there is an update. Here is the script that I am
> currently workign with.
>
> any help or pointers will be greatly appreciated.
>
> Thank you very much
> -Max
>
> #!/usr/bin/perl -w
>
> pendir (DIRLIST,"../wwj/data/sm");
I think this is a typo and you wanted: opendir
> @dirlist = readdir(DIRLIST);
>
> print ("content-type:image/jpeg\n\n");
Why are you doing this? I thought you wanted an HTML page, not an image...
The print content-type tells the server what kind of page he is going to
serve. As you want it to be an HTML page, you should use
print "Content-type: text/html\n\n";
instead.
> print ("<HTML><HEAD><TITLE>Directory Listing</TITLE></HEAD>\n");
> print ("<BODY>");
> print ("<TABLE BORDER=0><TR>\n");
# (first table started)
>
> foreach $x(@dirlist) {
>
> print ("<TD><IMG SRC=\"../wwj/data/sm/$x\"></TD>\n");
>
> }
>
> print ("</TABLE>");
# (fist table ended)
> print ("</TABLE>");
# (second table ended... but where did it start??)
> print ("</BODY>");
> print ("</HTML>\n");
>
And why are you using print ( "..."); ? It would save you a lot of typing if
you ommited the '(' and ')' .
Of course, you could have the server configured to give you a directory
listing when there's no index document...
Vincent
------------------------------
Date: Wed, 28 Apr 1999 04:24:42 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help reading directories and displaying contents
Message-Id: <akg6g7.er5.ln@magna.metronet.com>
Max Calvo (mcalvo@maxcalvo.net) wrote:
: Hi all;
: I need some help here folks. I am trying to get a perl script that will read
: the contents of directory then I need the content displayed in a HTML
: document. This directory has lots of jpegs and I need then to display in
: aweb page. I am trying to automated webpages dinamically instead to created
: a webpage each time there is an update. Here is the script that I am
: currently workign with.
: any help or pointers will be greatly appreciated.
: Thank you very much
: -Max
: #!/usr/bin/perl -w
: pendir (DIRLIST,"../wwj/data/sm");
Perl does not have a pendir() function.
If you wanted opendir(), then you should be sure to check
the return value in case you were not able to open the
directory.
Asking to open a directory does not guarantee that it will
actually be opened...
: @dirlist = readdir(DIRLIST);
: print ("content-type:image/jpeg\n\n");
You are telling the browser that you are going to send
it a JPEG file...
: print ("<HTML><HEAD><TITLE>Directory Listing</TITLE></HEAD>\n");
... then you don't send a JPEG file, you send it HTML.
If you lie to the browser like that then things probably
won't work right.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 28 Apr 1999 12:40:36 GMT
From: smnayeem@my-dejanews.com
Subject: Re: How do i print something using perl?
Message-Id: <7g6vk4$1j$1@nnrp1.dejanews.com>
In article <3726D0B9.EF843CF@gmx.net>,
"Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net> wrote:
> Greg McCann wrote:
> >
> > If that doesn't print out a page with the word "test" at the top, you
> > need to review your assumptions about the printer.
>
> It might, for example, be a "pure PostScript" printer. Or some weird
> WinPrinter with absolutely no DOS support[1]. But we can't tell from
> here.
>
> Cheers,
> Philip
i have an HP LaserJ6MP
do u think theres any way to print the postscript fonts?
i can only print the normal fonts...
smnayeem
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 28 Apr 1999 09:46:13 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: MacPerl to AS (well, vice versa)
Message-Id: <pudge-2804990946130001@192.168.0.77>
In article <cwstern-2704991614100001@sparrow.riken.go.jp>,
cwstern@mitXYZZY.edu (Carl Stern) wrote:
# In article <pudge-2604990959050001@192.168.0.77>, pudge@pobox.com (Chris
# Nandor) wrote:
# > In article <cwstern-2504992100220001@sparrow.riken.go.jp>,
# > cwstern@mitXYZZY.edu (Carl Stern) wrote:
# >
# > # The problem is passing the variables along. Do Script doesn't appear to
# > # permit any ARGV
# >
# > It does.
# >
# > tell app "MacPerl"
# > Do Script {"MacPerl::Reply(join ':', @ARGV)", 0, 1, 2, 3, 4, 5, 6, 7, 8}
# > end
# >
#
# Ah, I see. That works fine, thank you.
#
# Is this documented somewhere, though? I looked through all the
# associated MacPerl PODs, and your very helpful book, but was unable to
# find any reference to this.
Ack, it wasn't in the book. Should've been. It is in the MacPerl docs,
but not the POD. In MacPerl.Frontend:
> As opposed to the standard "Do Script" event, MacPerl's "Do Script"
> accepts a list as the direct parameter and stuffs all further elements into
> @ARGV. The mode parameter has a major influence on the way the script is
> executed:
The modes are then discussed.
# It wasn't even mentioned that you could pass
# a file name through Do Script and have that script execute, instead of
# passing raw text -- something I only found via a experimentation on a
# whim. The Applescript Dictionary is (as usual) somewhat terse.
The documentation needs to get cleaned up a little. Making a note of it
now. MacPerl.Frontend needs to get integrated into the rest of the docs.
Also, there is macperlcat.pod (Apple Event tutorial) which should at least
make reference to some of this in the other PODs (it also needs some
serious updating).
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 28 Apr 1999 15:32:21 +0200
From: "Vincent Vanbiervliet" <vvb@ibm.net>
Subject: Re: newbie: Replace \n with <br>\n
Message-Id: <37270d30@news.uk.ibm.net>
Larry Rosler <lr@hpl.hp.com> wrote in message
news:MPG.118fcbca99e8f06e989958@nntp.hpl.hp.com...
> [Posted and a courtesy copy mailed.]
>
> In article <7g56tg$fu1@news.dns.microsoft.com> on Tue, 27 Apr 1999
> 16:27:52 -0700, Scott Oseychik <scott@simsbury.com> says...
> > I would like to pre-pend every newline character (\n) with <br>, so the
> > final result would be: <br>\n
>
> OK, good. We answer Perl questions even when they deal with HTML. :-)
>
> > Here's my code so far, but I can't seem to get it to work:
> >
> > #!c:\perl\bin -w
>
> Good. Next add 'use strict;'
Am I missing something here, oris c:\perl\bin a good program?
>
> > print ("Type in a file name: ");
> > chomp($file = <STDIN>);
> > open(FILEHANDLE,"+<$file") || die "Can't find $file!!\n";
>
> Do you really want to open that file with write permission also?
> Also, include $! in your error message, to see why the open fails.
>
> > # for every newline character, replace it with
> > # <br>, then a newline character
> >
> > while (<FILEHANDLE>)
> > {
> > $_ =~ s/\\n/<br>\\n/;
>
> '$_ =~' is the default, and looks jarring to an experienced Perl
> programmer. Just 's/\n/<br>\n/;' will do fine.
>
> > }
> >
> > close(FILEHANDLE);
> >
> > This script doesn't seem to do anything, but doesn't generate any
errors,
> > either. Sorry if this is a dumb question...
>
> It is an easy question. It isn't a dumb question, because you tried to
> solve it first before asking.
>
> 1. I hope your code does more than you show, because changing $_ every
> time through the loop affects nothing after the loop is completed. You
> have to do something with the result each time (print it, store it in an
array,
> whatever).
>
> 2. Your regex is trying to match the two characters backslash-n. To
> match the single character \n (newline), just use \n. Also in the
> substitution side.
>
> An even shorter way would be:
>
> s/$/<br>/;
>
> because '$' matches before the \n at the end of the string.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Company
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
Vinc
------------------------------
Date: Wed, 28 Apr 1999 04:28:20 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Parsing query strings
Message-Id: <4rg6g7.er5.ln@magna.metronet.com>
pnguyen@aracnet.net wrote:
: I have a question I'd like to ask the Perl e-community out there. It
: is as follows:
: 1. Given a query string from any search engines out there on
: the Web eg.
: http://www.altavista.com/cgi-bin/query?pg=q&kl=XX&q=online+community
: or
: http://netfind.aol.com/search.gw?search=online+community&lk=excite_netfind2_us&nm=aol&pri....
: 2. How would I parse the search string from the rest of URL
The same way that you would if you were using C or Visual Basic
for your CGI programs.
How URLs are encoded has nothing to do with Perl, and so is
off-topic for a Perl newsgroup.
The CGI.pm Perl module will do all the decoding of URLs for
you.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Apr 1999 11:24:54 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: Perl Weekday Script
Message-Id: <7g6r66$65c$1@solti3.sdm.de>
In article <19990428001755.24458.00000460@ng98.aol.com>,
Cyberine2k <cyberine2k@aol.com> wrote:
> Has anyone had experience writing a script to return relative dates? I'm
> attempting to write a simple Perl script that when given the arguments:
> <specific date>, <offset in days>
> it will return the non-Saturday/Sunday date.
> For example, given '4/27/99' and an offset of 3, it should return '4/22/99'.
> Any ideas appreciated. I'm writing this for HP/UX OS, but I would expect the
> solution would work on most UNIX platforms.
Perl Modules are your friend.
See Date::Manip or Date::Calc on CPAN, for instance.
See http://www.perl.com/CPAN/modules/by-module/Date/ for download
or the URLs given in my sig below.
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/
http://www.engelschall.com/u/sb/download/
http://www.perl.com/CPAN/authors/id/STBEY/
http://www.oreilly.de/catalog/perlmodger/bnp/
------------------------------
Date: Wed, 28 Apr 1999 04:51:50 -0700
From: Jeff Zucker <jeff@vpservices.com>
To: smnayeem@my-dejanews.com
Subject: Re: Problem with DBV::CSV
Message-Id: <3726F656.B9CBE2F7@vpservices.com>
smnayeem@my-dejanews.com wrote:
>
> ive been trying to use the DBV::CSV for reading in a comma seperated file and
> reading data from it
> ...
> my $dbh = DBI->connect("DBI:CSV:") ...
Should be:
my $dir = "./"; # (or any other directory
path)
my $dbh = DBI->connect("DBI:CSV:f_dir=$dir") ...
> ive tried changing the 'file' option to g:\agni\user.csv
>From the docs for DBD::CSV -
"Currently it is not possible to use files with names like names.csv."
Change the name from "user.csv" to just plain "user".
--
jeff
------------------------------
Date: Wed, 28 Apr 1999 13:37:07 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Script Help
Message-Id: <372c0b05.84027084@news.ford.com>
[poster cc'd in e-mail]
On Tue, 27 Apr 1999 23:40:25 GMT, jddemme@technologist.com (JDDemme)
wrote:
>I'm working on a script o control what the user sees when the site lists the
>midis in a directory. each midi has a
You didn't ask a question! So I'll take this opportunity to hone some
constructive-criticism skills all over your program.
>#!/usr/bin/perl
There's no "-w" switch on this line. Newbies should have perl's warnings
turned on at all times.
>$DR = $ENV{'QUERY_STRING'};
Ick. Processing CGI stuff by hand is dangerous and stupid unless you know
exactly what you're doing. It's really easy to screw up. Try: "perldoc
CGI" and go from there.
> opendir(DIR, $DR);
Always, always check the exit status from system calls. You meant:
opendir(DIR, $DR) || die "Cannot open directory $DR: $!";
You don't do any valiidation on the directory name. In theory someone
could look at your ".mid" files anywhere on your system.
>print "Content-type:text/html\n\n";
You've typo'd your content type header. Another reason to use the CGI
module.
> open(mid,"$DR/$mid.txt);
>open(top,"top.txt");
> open(mid,"$DR/$mid.txt);
*sigh* Always, always check the exit status from system calls. Oh yeah,
and the first one doesn't compile at all.
> $mid = "<a href=\"data.cgi?$DR/$mid.txt\">$name</A><br>\n";
Are you sure that $DR and $mid are URL safe? Think about this, what if
$mid contains an ampersand? (i.e. "Sonny&Cher") Or if it contains spaces?
("Green Day") Your CGI will confuse someone's browser, and ruin their
web-experience. Another reason to use the CGI module.
></div>
></body>
></html>
(To go off on an HTML tangent...) Where's the start to these tags?
------------------------------
Date: Wed, 28 Apr 1999 13:54:32 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: Simple if syntax Question
Message-Id: <3726F6F8.2A3E7A0D@gmx.net>
morti_cne@my-dejanews.com wrote:
>
> if ($FORM{'TEAM'} = 'Component') {
> $data_file = "component.db";
> }
> if ($FORM{'TEAM'} = 'System') {
> $data_file = "system.db";
> }
There's also elsif, you know
Cheers,
Philip
------------------------------
Date: Wed, 28 Apr 1999 11:01:42 GMT
From: ralawrence@my-dejanews.com
Subject: String conversions (a different angle!?)
Message-Id: <7g6pql$r4e$1@nnrp1.dejanews.com>
Can someone help me? I know that:
$thing =~ tr/+/ /;
$thing =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
Turns a line that would be your URL into (vaigue) english but what I need to
do is the _reverse_ ie.
"hello there!" -> "hello+there%44" (or whatever ! is in hex)
I know that the start is (obviously):
$thing =~ tr/ /+/;
but the search and replace has me stumped. Can anyone help?
Cheers
Rich
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 28 Apr 1999 06:02:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: String conversions (a different angle!?)
Message-Id: <MPG.1190a6ab3d5392af989966@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7g6pql$r4e$1@nnrp1.dejanews.com> on Wed, 28 Apr 1999
11:01:42 GMT, ralawrence@my-dejanews.com <ralawrence@my-dejanews.com>
says...
> Can someone help me? I know that:
>
> $thing =~ tr/+/ /;
> $thing =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>
> Turns a line that would be your URL into (vaigue) english but what I need to
> do is the _reverse_ ie.
>
> "hello there!" -> "hello+there%44" (or whatever ! is in hex)
>
> I know that the start is (obviously):
>
> $thing =~ tr/ /+/;
Actually, it wouldn't be the start but the finish, because any '+' in
the URL has to be encoded to hex first.
> but the search and replace has me stumped. Can anyone help?
s/([ "#%&+<=>])/sprintf '%%%.2X', ord $1/eg;
This encodes space as %20, so the 'tr' line is unnecessary. If you
prefer to encode space as '+', leave it out of this character class, and
follow this line with the 'tr' line.
There is a module to do all this also, of course.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 28 Apr 1999 12:31:57 GMT
From: NOSPAMcrstlblu@planet.eon.net
Subject: Re: stupid single quote " wipes out REST OF TEXT
Message-Id: <371b65f6.2164954@news.planet.eon.net>
On Wed, 28 Apr 1999 08:38:33 GMT, aspinelli@ismes.it (Andrea L. Spinelli) wrote:
>On Tue, 27 Apr 1999 11:08:15 GMT, NOSPAMcrstlblu@planet.eon.net wrote:
>>when I OPEN the dbm, extract, and display the text in THE FIRST SCRIPT, no prob,
>>it gets displayed in its' entirety,....
>>when i pass the value into a hidden formfield and forward to the next
>I suspect that you write directly something like
> print "<input type=\"hidden\" name=\"foo\" value=\"$value\">";
>where $value is 5'10".
correct! ALMOST!
actually,
$value = "200 characters, 5'10" followed by another 200 characters";
notice the SOLITARY QUOTATION mark in the center of the VALUE?
>Now, what you'll print is
> <input type="hidden" name="foo" value="5'10"">
>You should see that there is an inconsistency after the 10.
no, what is in the cgi script is:
<input type=\"hidden\" name=\"foo\" value=\"$value\">
if i write a cgi script that says:
print <form method="post"
instead of backslashing the quotes like
print <form method=\"post\"
you will get an ERROR!
and after the SECOND SCRIPT has parsed the values
when $fields{'value'} gets printed, all of the text AFTER THE single
quotation mark in the MIDDLE gets lost?
>I suggest using CGI::hidden instead, which takes care of
>translating " to " and all those nasty details...
> Andrea
but if someone types in a 400 character text into a textfield
and then pushes the SUBMIT button ----
it is NOT FOR THEM to worry about what they type into your
page forms.
What someone did was put a SINGLE QUOTATION mark in
the centre of their text, it got into the database PERFECTLY.
it gets extracted from the database PERFECTLY, and displayed
PERFECTLY!
but if i PASS it to A SECOND script in a HIDDEN form field,
everything after the single quotation mark in the center of the
value gets LOST when the NEXT script displays the value????
ps: I used uppercase NOT to shout, but for explain, I am not arguing,
and I sincerely appreciate your response Andrea - thank you,
wayne.
wj
remove SPAM from email to respond
------------------------------
Date: Wed, 28 Apr 1999 13:40:33 GMT
From: Charles Arcudi <carcudi@eli.net>
Subject: Re: SYSTEM call from Perl under Windows95CGI???
Message-Id: <372710C0.CC631CD5@eli.net>
Boy, that wasn't particularly helpful What might have been more constructive to say
is something like this:
I've run into the same problem on Win32 systems and discovered (in my case) that it
had something to do with the limit of characters Perl will allow you to throw into
the stream when you're making a system call. It seems the string length can only
reach a maximum of about 94 characters before it gets to long for the pipe to handle.
Try something like this:
$statement = "command parm1...parmn";
$rc = 0xffff & system($statement);
($rc == 0 ) || die "Can't run $statement (rc $rc): $!\n";
Matthew Bafford wrote:
> [
> Please read the document at:
>
> http://dragons.home.duesouth.net/clp_FAQ.html
> ]
>
> [
> Followups set to comp.lang.perl.misc
> ]
>
> On Sat, 24 Apr 1999 12:51:33 -0400, TheCure1@mediaone.com <thecure1@mediaone.com>
> lucked upon a computer, and thus typed in the following:
> : I am using FOLKWEB as my Web Server...
> : I can run Perl scripts fine.
> : But the one thing that does not want to work (but works if invoked from
> : the command line!!) is trying to run a system command, neither with:
> : 1. $result = `some_command_here`; or
> : 2."system(some_command_here");".
> :
> : What am I doing wrong???
>
> Not giving us enough information!!!
>
> Try using the variables that are supposed to help with this ($!).
>
> system('foo bar baz') or die "Can't run foo bar baz: $!\n";
>
> : THANK YOU!!!
>
> HTH, HAND,
>
> --Matthew
------------------------------
Date: Wed, 28 Apr 1999 04:20:06 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Using string content as an a variable name
Message-Id: <mbg6g7.er5.ln@magna.metronet.com>
Ronny (ronald_f@my-dejanews.com) wrote:
: When you execute
: $x="y"; $y="abc"; print "$$x\n"
: abc gets printed.
Symbolic references are bad.
You very rarely need to use them with a modern perl.
Don't do that.
See:
http://www.plover.com/~mjd/perl/varvarname.html
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 28 Apr 1999 11:25:07 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: What does this error message mean?
Message-Id: <3727ef38.575778@news.skynet.be>
Blair Kingsland wrote:
>The program output is
>correct, but I always get the following server error (warning)
>message:
>
>Value of <HANDLE> construct can be "0"; test with defined() at
>/usr/local/etc/httpd/htdocs/tigron/cgi-bin/glossary.pl line 65535.
>
>I can't find an explanation of this message anywhere. What does "line
>65535" mean? The program file is only 25 lines long. Any help would be
>appreciated.
That's a bit odd. However, 65535 is FFFF in hex, which is -1 as signed
word. So it's off your script.
Anyway, the error message ususally relates to a line that looks like
while($line = <FILE>) {
....
}
Check if your script contains anything that looks like it. If you do,
change that line so it looks more like:
while(defined($line = <FILE>)) {
i.e. put a "defined()" wrapper between the while() and the assignment.
Bart.
------------------------------
Date: Wed, 28 Apr 1999 11:58:42 GMT
From: paulclinger@my-dejanews.com
Subject: Re: What does this error message mean?
Message-Id: <7g6t5g$tmq$1@nnrp1.dejanews.com>
In article <pdyV2.1156$Ev1.746050@NewsRead.Toronto.iSTAR.net>,
blairk@istar.ca (Blair Kingsland) wrote:
> Value of <HANDLE> construct can be "0"; test with defined() at
It's mean you test, for example, if ($line = <HANDLE>) but this construction
can return string which contain "0" and if will fail. You need to rewrite it
as if(defined($line = <HANDLE>)). BTW, perl do it for you in while and for
loops :)).
Best wishes,
Paul.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 28 Apr 1999 05:45:37 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: What does this error message mean?
Message-Id: <MPG.1190a2b6b1d31ded989965@nntp.hpl.hp.com>
In article <7g6t5g$tmq$1@nnrp1.dejanews.com> on Wed, 28 Apr 1999
11:58:42 GMT, paulclinger@my-dejanews.com <paulclinger@my-dejanews.com>
says...
> In article <pdyV2.1156$Ev1.746050@NewsRead.Toronto.iSTAR.net>,
> blairk@istar.ca (Blair Kingsland) wrote:
> > Value of <HANDLE> construct can be "0"; test with defined() at
>
> It's mean you test, for example, if ($line = <HANDLE>) but this construction
> can return string which contain "0" and if will fail. You need to rewrite it
> as if(defined($line = <HANDLE>)). BTW, perl do it for you in while and for
> loops :)).
You clipped the part of the post which says that the error occurred at
line 65535. This is symptomatic of the dumb warning for 'while' and
'for' introduced in perl 5.004 and removed in perl 5.005.
The same warning still occurs with 'if', even in 5.005. But at least
the line number of the HANDLE makes a bit more sense. And it tells the
user to 'test with defined()' which reduces the mystery somewhat.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 28 Apr 1999 04:33:30 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What does this error message mean?
Message-Id: <q4h6g7.er5.ln@magna.metronet.com>
Blair Kingsland (blairk@istar.ca) wrote:
: I'm running ActivePerl on an Apache server. The program output is
: correct, but I always get the following server error (warning)
: message:
: Value of <HANDLE> construct can be "0"; test with defined() at
: /usr/local/etc/httpd/htdocs/tigron/cgi-bin/glossary.pl line 65535.
You have an old perl.
Consider upgrading to a more modern version.
: I can't find an explanation of this message anywhere.
It should be described in the perldiag.pod standard perl
doc, but I can't check because I don't have an old enough
perl.
: What does "line
: 65535" mean?
It is a bug. perl is reporting the wrong line number.
The bug has been fixed in recent perls.
Consider upgrading to a more modern version.
: The program file is only 25 lines long. Any help would be
: appreciated.
Somewhere you have something like
while ($line = <HANDLE>)
perl is suggesting that you change that to
while ( defined($line = <HANDLE>))
Modern perls automatically apply the defined() test for you.
Consider upgrading to a more modern version.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 5504
**************************************