[17771] in Perl-Users-Digest
Perl-Users Digest, Issue: 5191 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 23 18:05:31 2000
Date: Sat, 23 Dec 2000 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <977612707-v9-i5191@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 23 Dec 2000 Volume: 9 Number: 5191
Today's topics:
Re: FAQ asking madness (was Re: Simple REGEX question) (Tad McClellan)
Re: Help with multipart form <iltzu@sci.invalid>
Re: Help: modulus problem, docs confusing <harrisr@bignet.net>
Re: Help: modulus problem, docs confusing <iltzu@sci.invalid>
Re: Hostname? (Abigail)
Re: infinite loop <wescott@conterra.com>
Re: Need help finding a space in a string with "index" (Abigail)
Re: Perl to ksh question <nospam@nospam.com>
Re: Perl to ksh question <you.will.always.find.him.in.the.kitchen@parties>
Re: REF: Help with Hash in a loop. Desperate! (at 72 w <jhelman@wsb.com>
Re: Reverse "append to file" (Tad McClellan)
use strict (do I have enough hair to use it?) <pat@sluggo.org>
Re: use strict (do I have enough hair to use it?) <jhelman@wsb.com>
Re: use strict (do I have enough hair to use it?) <joe+usenet@sunstarsys.com>
Re: use strict (do I have enough hair to use it?) <abe@ztreet.demon.nl>
Re: use strict (do I have enough hair to use it?) <wescott@conterra.com>
Re: using perl (Abigail)
WBMP Perl script? stephenelliott_2000@yahoo.co.uk
Re: WBMP Perl script? <jhelman@wsb.com>
Re: Where to obtain the perlrtfm podpage? (Tad McClellan)
Re: Why are multiple zeroes true? (Ilya Zakharevich)
Re: Why are multiple zeroes true? (Ilya Zakharevich)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 23 Dec 2000 13:26:49 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: FAQ asking madness (was Re: Simple REGEX question)
Message-Id: <slrn949rj9.akr.tadmc@magna.metronet.com>
Randy Harris <harrisr@bignet.net> wrote:
>Tad McClellan <tadmc@metronet.com> wrote in message
>news:slrn94987d.9m1.tadmc@magna.metronet.com...
>>
>> This thread is a classic example of the global waste of time
>> caused by asking a Frequently Asked Question!
>>
>> 'harrisr' couldn't be troubled to check the Perl FAQ before
>> posting to the Perl newsgroup, and so asked a question that
>> has been asked (and answered) here *hundreds* of times
>> (that in not an exaggeration, it is literal).
>
>Tad, go ahead and killfile me, because your response is bullshit.
You were not in my killfile until you asked to be.
I only killfile FAQ askers when it is evident that they did
not check first, that was not evident in your post.
(because "trim" isn't a useful search term)
In fact, I don't generally killfile even when they _do_ use
a good search term in their post.
It is when they complain about being pointed to the FAQ that
they earn their entry. You didn't do that.
And I see _now_ that you weren't asking about trimming spaces, even
though you were trimming spaces, and your comments mentioned
trimming spaces.
But *all four* of us thought that that was what you were trying to ask.
If four people all draw the wrong conclusion, then perhaps you
were not communicating very clearly?
You've been here long enough to have anticipated that a question
as near to a FAQ as yours would be knee-jerked into a "he wants
to trim spaces". You got four knee-jerk jerks following up...
>Rick Delaney did provide a
>very informative and helpful explanation of the area that had confused
>me, specifically the difference between (.*) and (.*?).
Huh?
Your original post did not have either of those character
sequences in it.
I think you are looking at the subthread that happened after
what I was talking about. I am referring to the first 4 posts
in the thread, where all 3 followups thought you wanted to
know how to trim spaces.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Dec 2000 19:10:13 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Help with multipart form
Message-Id: <977597816.28359@itz.pp.sci.fi>
In article <922lfg$bvi$1@nnrp1.deja.com>, richardstands@my-deja.com wrote:
>
>Turns out that apparently the problem I was having was with the fact
>that the remote CGI was a Java servlet and supposedly "as such you
>can't pass it parameters in the URL"; at least that's what their IT
>people told me. I don't know enough about servlets to doubt their claim
>but considering it worked with my Perl script but not their Java it may
>be the whole problem.
Well, unlike CGI.pm, servlets do not by default treat GET and POST
requests as equivalent. It only takes a few lines of Java to fix
that, but if whoever wrote the servlet didn't understand why this
would be a good idea, it's quite possible that the servlet can't
handle GET requests at all.
(To avoid followups from those who've read the standards: Yes, I do
understand the differences regarding idempotence, but experience has
shown that enforcing them at the receiving end is counterproductive.
If someone wants to send a GET request for a nonidempotent action, it
should be considered their right and their problem.)
[Followups set to comp.infosystems.www.authoring.cgi.]
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Sat, 23 Dec 2000 14:09:47 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Help: modulus problem, docs confusing
Message-Id: <t49u2no05fn0f1@corp.supernews.com>
<richardstands@my-deja.com> wrote in message
news:922rf9$g2m$1@nnrp1.deja.com...
>
> "If $b is positive, then $a % $b is $a minus the largest multiple of
$b
> that is not greater than $a."
>
You chopped off the first part of that sentence from the docs.
Given integer operands `$a' and `$b':
^^^^^^^
------------------------------
Date: 23 Dec 2000 19:20:49 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Help: modulus problem, docs confusing
Message-Id: <977599047.656@itz.pp.sci.fi>
In article <922rf9$g2m$1@nnrp1.deja.com>, richardstands@my-deja.com wrote:
>
>given code:
>print( ( 100.123 % 23 ), "\n" );
>
>I get:
>8
I'd classify this as a misfeature in perl. The modulus operator could
be well defined for all reals, but in the current implementation it
only works for integers. Sorry.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: 23 Dec 2000 19:36:27 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Hostname?
Message-Id: <slrn949vlr.rpg.abigail@tsathoggua.rlyeh.net>
Bernhard Rittirsch (rittirsch@gmx.de) wrote on MMDCLXXI September
MCMXCIII in <URL:news:92275e$5h2e1$1@ID-26625.news.dfncis.de>:
?? Hello!
??
?? I have a script which collects the IP-addresses of my homepage-visitors.
??
?? Can someone tell me how I can automatically (with a perl-script) resolve the
?? hostname of these IPs?
'man perlfunc' starts with a list of available functions. If you had
bothered to browse that list, you would have found a function with a
bloody obvious name.
Abigail
--
split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
------------------------------
Date: Sat, 23 Dec 2000 20:09:30 GMT
From: Mike Wescott <wescott@conterra.com>
Subject: Re: infinite loop
Message-Id: <oszohmew6r.fsf@eriadne.sc.rr.com>
"Jerry F. Davis" <jfdecd@execpc.com> writes:
> learning perl and i have what amounts to an infinite loop here
>
> what is wrong,
> $_ = <LYNX> until /standard\.def/;
This loop exits only on the match. What happens when end of file
is reached?
> how can i code it so that i don't get this infinite loop
Exit the loop on end-of-file. One way is
while(<LYNX>) {
break if /standard\.def/;
}
exit unless $_; # is this eof or /standard\.def/ ?
I think a cleaner way is to do all the reading in the outer loop and
keep track of state inside the loop to determine what processing is to
be done on each line. Here, the .. operator is used:
while(<LYNX>) {
if (/standard\.def/ .. /<A HREF/) {
if (m|^<A HREF=[^>]+>(.*?)</a>|i) {
print "Today's perl headline is: $_";
}
}
}
--
Mike Wescott
wescott@conterra.com
------------------------------
Date: 23 Dec 2000 19:40:30 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Need help finding a space in a string with "index"
Message-Id: <slrn949vte.rpg.abigail@tsathoggua.rlyeh.net>
Ryan & Treena Carrier (ryanc@nci1.net) wrote on MMDCLXXI September
MCMXCIII in <URL:news:3a44b017_1@news.cybertours.com>:
?? I'm trying to determine the first occurrence of a space character in a
?? string. It seems to me
??
?? my $string = "Hello World";
?? my $spaceLocation = index($string, " ");
??
?? should give 5 to $string, but it doesn't work.
"It doesn't work" is a totally useless remark. Do you get an error?
Do you get a result that you didn't expect? Do you get output where
you don't expect any?
Furthermore, you don't have code that shows the problem.
$ perl -w
my $string = "Hello World";
my $spaceLocation = index($string, " ");
print $spaceLocation, "\n";
__END__
5
$
Abigail
--
$_ = "\112\165\163\1648\141\156\157\164\150\145\1628\120\145"
. "\162\1548\110\141\143\153\145\162\0128\177" and &japh;
sub japh {print "@_" and return if pop; split /\d/ and &japh}
------------------------------
Date: 23 Dec 2000 20:16:47 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Perl to ksh question
Message-Id: <92317f$cli$0@216.155.33.144>
In article <6u216.318$U3.28613@news2.voicenet.com>, "Ed Murray"
<unixdude@voicenet.com> wrote:
| Not being a scripter I have a question for the group, is there a
| utility or an easy way to take a script that was written in Perl
| and convert it to run in a ksh enviornment ? I am only a dumb
| systems engineer :-) But I do have extensive knowledge of unix
| only lacking in the scripting enviornment.
at the risk of sounding flip...
set your environment variables so that ksh knows where Perl is installed.
then
% perl yourperlscript
*ducking really fast*
Honestly, Perl is much easier than you think, particularly if you are
already familiar with unix syntax (and possibly awk and sed) .. after
years of putting it off because I couldn't 'grok' it just by looking at
it (like I could with tcl), I picked up a copy of Programming Perl, and
started hanging around in this newsgroup. I learned enough Perl in three
weeks to do something that seemed to me to be impossibly complex (at the
time) and it ran to my satisfaction until the data source changed and I
needed to update my script. The update took a matter of hours instead of
days (incuding teaching myself how to use the HTML::Parser module to my
satisfaction).
And I'm a Mac user :) (using MacPerl) (and programming for Mac- and
Unix- execution)
If you already live in a unix environment and know shell scripting, Perl
is a much simpler jump.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Sun, 24 Dec 2000 11:04:22 +1300
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: Perl to ksh question
Message-Id: <977609193.872136@shelley.paradise.net.nz>
"Ed Murray" <unixdude@voicenet.com> wrote in message
news:6u216.318$U3.28613@news2.voicenet.com...
>
> Not being a scripter I have a question for the group, is there a utility
> or
> an easy way to take a script that was written in Perl and convert it to
run
> in a ksh enviornment ? I am only a dumb systems engineer :-) But I do
have
> extensive knowledge of unix only lacking in the scripting enviornment.
Your question is confusing.
Are you asking for a utility to convert a Perl script into a ksh script, or
are you asking how to run a Perl script from the ksh?
Answer to the first one is no. Answer to the second one is not relevant.
PS: comp.lang.perl went out of existance almost 5 years ago.
------------------------------
Date: Sat, 23 Dec 2000 19:53:51 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: REF: Help with Hash in a loop. Desperate! (at 72 wrap as requested)
Message-Id: <3A4502E9.30D076AA@wsb.com>
angel wrote:
> Good Samaritan:
> I can't seem to understand why the following statement will only
> work once in any loop:
> my $fext = $mime{$ext};
> Anytime I try to print $fext in a loop it will only print once no matter
> the size of the loop. What am I missing here?
> #!/usr/bin/perl5.004
> require "cgi-lib.pl";
> &ReadParse;
> #!/usr/bin/perl5.004
> require "cgi-lib.pl";
> &ReadParse;
Why the duplicative entry here? You only need one copy of each
statement. In fact, if the data was given to you by a POST (rather than
a GET), your second call to ReadParse might very well whack whatever
data you received from the user (I'm not sure about this, as I don't
have a copy of cgi-lib.pl handy to see how it's written.)
> print &PrintHeader;
>
> open(X2,"<X2.txt") || &ShitBiskits;
Lovely...
> @FILELIST = <X2>;
> close(X2);
>
> while (@FILELIST)
> {
I see what you are doing here, but it's rather confusing. By using
while (@FILELIST) you are checking to make sure the list isn't empty,
and then, further down in the loop, you are popping a value off the list
and storing it in $file. For the sanity of the maintainence programmer
who has to work on this (or you, even, six months hence), you might
consider using one of the following...
while (my $file = pop(@FILELIST)) {
or
foreach my $file (@FILELIST) {
This makes it abundantly obvious to everyone what is happening in the
loop (or at least, how long we will be looping for...
> undef $mime{$ext};
> undef $fext;
> undef %mime;
All of these are variables that are lexically scoped within the loop.
They are undefined by default, so there's no need to explicitly do so.
Also, the first of these lines is even more unnecessary, since the third
line accomplishes the same thing (not really, but it accomplishes what
you are trying to do).
> my %mime = (
[SNIP -- VERY, VERY LONG HASH ASSIGNMENT REMOVED]
> );
Is there any particular reason you are doing this assignment within your
loop? While it's true that your computer processor doesn't have
anything better to do than execute statements that you give it, this
just seems cruel. Since %mime doesn't change throughout the loop, this
declaration should happen before the loop. It'll make your script run
faster too.
> my $file = (pop @FILELIST);
> print "<br>File = $file";
> my ($ext) = $file =~ m,\.([^\.]*)$,;
Even though syntactically this line is correct, many people will find it
confusing since you've chosen a rather odd delimiter for the pattern
match. Commas have special significance in Perl commands, and some
people may misinterpret what you are doing here. For readability's
sake, choose another delimiter. If you use /, you can even avoid the m
at the front.
Also, this could well be where your problem lurks. When you slurped the
file, you didn't get rid of the newline character that is at the end of
every line. Thus, all of your file extensions have a newline attached,
which means they won't match any key you defined in %mime
> print "<br>Ext = $ext";
> $ext =~ tr,a-z,A-Z,;
> print "<br>Again, $ext";
> my $fext = $mime{$ext};
> print "---$fext\n";
> }
This block could stand to be rewritten for efficiency since you go
through a whole list of statements even if there is no file extension.
Consider:
print "<br>File = $file";
## NOTE: THE FOLLOWING LINE IS CORRECTED FOR THE NEWLINE PROBLEM
if ($file =~ /\.([^\.]+?)\n?$/) {
my $ext = $1;
print "<br>Ext = $ext";
$ext = uc($ext);
print "<br>again, $ext";
my $fext = $mime{$ext};
print "---$fext\n";
} else {
print "<br>No extension on $file\n";
}
> print "<br>All Done!";
I have no problems with this line. :)
Try fixing the item's I've noted and I think your problem will be
solved.
Hope this helps,
JH
------------------------------
Date: Sat, 23 Dec 2000 12:42:48 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reverse "append to file"
Message-Id: <slrn949p0o.aj1.tadmc@magna.metronet.com>
chr1st1an <cyner.mail@sweden.com> wrote:
>Joe Schaefer wrote:
>
> > http://www.perl.com/pub/doc/manual/html/pod/perlfaq5.html
> >
> > "How do I change one line in a file/delete a line in a file/insert
> > a line in the middle of a file/append to the beginning of a file ?"
>
>I was there before but didn't see that question... Hehe. My mistake.
^^^
Well there is your problem. You *had* a search term (it's in your Subject)
that would have led to the answer, but you did not have a machine
see if it could find it. You relied on your human eyes to do
the searching. They let you down.
Spending brain cycles instead of CPU cycles is an ineffective
use of resources. Have a machine do your routine word-searching
for you.
If you had lurked here a bit (like you are supposed to) before
posting, you would have known how to have a machine do the
cruft work for you.
> >> I still haven't found what I'm looking for. And YES, I've looked. If
>you
> >> don't want to answer my question, give me some hints on what to look
>for
> >> *on the Internet*, not in perldoc/man.
> >
> > You must have no idea how offensive that statement is on most newsgroups
> > in the comp.* heirarchy.
>
>No. I haven't got a clue.
This is the Perl newsgroup. It is pretty much assumed that you
have access to a properly installed perl when you post here.
(unless you are asking how to get perl in the first place,
and you didn't ask that.)
So a one-line followup with 'perldoc' in it is expected to
show you some documentation relevant to your problem.
If you had lurked here a bit (like you are supposed to) before
posting, you would have known that "perldoc -q append" is our
shorthand for:
You can find the answer to your question by searching for
the word "append" in the question text of Perl's Frequently
Asked Questions.
(which we would assume are already installed on your very own hard disk)
Asking for a web location for something that is already on your
hard disk seems a ludicrous request.
> > Learning to locate documentation is step 0 in your development as a
> > programmer. It is the best advice you could have possibly received,
> > and yet you appear uninterested in anything that doesn't amount to a
> > spoon-feeding.
>
>Well, yes. And as I have said I tried, but I didn't have much patience,
>so I asked in here instead (the easier solution).
^^^^^^^^^^^^^^^
Easier for *you*, and harder for the *thousands* of people that
you seemed to expect wouldn't mind reading it to you.
Your time is not thousands of times more important than the
time of the other people here.
A most selfish attitude, eliciting a not unexpected type of response.
If you had lurked here a bit (like you are supposed to) before
posting, you would have known that too.
> >> But, sure, you don't HAVE TO help me.
> >
> > Given the rewarding experience you have made it for anyone
> > that has tried, you can probably take that statement to the
> > bank.
If you had lurked here a bit (like you are supposed to) before
posting, you would know that above is making reference to the
fact that you have likely been entered in some killfiles, by
the folks that _do_ choose to follow your suggestion above.
Such folks have decided not only to not help you with your
current problem, but to avoid helping you with all of your
future Perl problems as well.
>You know, I've been posting messages quite regularly the last few years
And you still don't know about the "lurk before posting" thing?
However did you manage that? :-)
>(mostly in other programming groups), and nowhere have I gotten such a
^^^^^
>harsh response.
If you had lurked here a bit (like you are supposed to) before
posting, you would have known that _this_ "programming group"
is not a typical programming group. A large portion of its
readership are not programmers. This, in turn, leads to lots
and lots of repeats of FAQs.
If you had lurked here a bit (like you are supposed to) before
posting, you would have seen these lots and lots of repeated
FAQs yourself, and would not have been at all surprised at
the responses you got.
Other "programming groups" have their bar set higher than
this newsgroup does (because non-programmers give up trying
to get programs in C++ or Java working, so they don't post).
Perl is so easy to use that even non-programmers can get
stuff done with it, so this newsgroup has a readership
uncharacteristic to most comp.lang.* newsgroups.
The "FAQ density" is untypically high in this newsgroup, with
a corresponding higher "social price" to pay for contributing
to the problem.
>But I'm glad I got response as such, I thought it'd take
>days for anyone to answer. But since you all seem bound not to help me
>ever again, I feel somewhat uneasy.
Now there we have something rather uncommon, a FAQ-asker who
is worried about their potential for getting future help.
Most just cuss us out and are too dense to discern the
longer-lasting effects of their actions.
I think there is probably hope for you though :-)
>Was I really that rude?
I think what lit us off was the "change your attitude" bit, when
it was obvious that you do not know the least little bit about
clpmisc society, and so cannot know what attitudes are approriate.
>I'm sorry
Me too, but you'll only be in my "special file" for a few weeks.
>for whatever I did.
^^^^^^^^^^^^^^
That would be not lurking before posting (but you've probably
already picked up on that theme, being a discerning poster :-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 23 Dec 2000 21:54:16 GMT
From: "Pat J. Magnan" <pat@sluggo.org>
Subject: use strict (do I have enough hair to use it?)
Message-Id: <ca916.54404$Z9.3286931@news1.rdc1.mb.home.com>
I'll be honest, i've been naughty in the past and not bothered with the
following two good practices:
1 - #!/usr/bin/perl -w
2 - use strict;
But, I'm trying to be good in one CGI project i'm working on. I'm getting a
warning from the following chunk of code that is driving me nuts. I get:
Use of unitialzied value at ... line ...
Is Perl so unlike other languages that $varname = ""; (or $varname = 0;)
doesn't count as explicit initialization? I know this is not the case, but
why is my poor web server log filling up with this unreasonable warning? Or
is my code unreasonable?
here's the code snippet that's doing the damage
==============================================
sub html_header
{
my ($title, $css, @scripts) = @_;
my $script;
my $header = "";
## this is the line perl bitches about:
$header = qq!
<html>
<head>
more of the HTML i Want to puke out here !;
return $header;
}
TIA,
Pat
------------------------------
Date: Sat, 23 Dec 2000 22:15:43 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: use strict (do I have enough hair to use it?)
Message-Id: <3A452429.A1C5662D@wsb.com>
"Pat J. Magnan" wrote:
> I'll be honest, i've been naughty in the past and not bothered with the
> following two good practices:
> 1 - #!/usr/bin/perl -w
> 2 - use strict;
Well, better late than never. :)
> But, I'm trying to be good in one CGI project i'm working on. I'm getting a
> warning from the following chunk of code that is driving me nuts. I get:
> Use of unitialzied value at ... line ...
>
> Is Perl so unlike other languages that $varname = ""; (or $varname = 0;)
> doesn't count as explicit initialization?
No, that counts. But that's probably not what you're doing...see below.
> here's the code snippet that's doing the damage
> ==============================================
>
> sub html_header
> {
> my ($title, $css, @scripts) = @_;
> my $script;
> my $header = "";
The actual discussion is below, but this last line is unnecessary.
Delete it and add a 'my' to the start of the next line defining $header.
> ## this is the line perl bitches about:
> $header = qq!
> <html>
>
> <head>
> more of the HTML i Want to puke out here !;
>
> return $header;
> }
I think there's something that you aren't tellings us here.
Specifically, I would guess that in the place of "more of the HTML i
Want to puke out here", you are explicitly using $title, $css or one or
more elements of @scripts.
Say you call this routine with just one paramater for the title. The
first line of your script would then set $title to your single passed
parameter, $css to undef and @scripts to an empty state. Thus, when you
explicitly include $css or an element of @scripts in your definition of
$header, since it is undefined, the warning is issued.
You can fix this problem (at least for $title and $css) by adding the
following lines before you define $header (If you explicitly use any
elements of @scripts in the header, you should do the same for those
elements.):
$title = "" unless (defined($title));
$css = "" unless (defined($css));
Hope this helps,
JH
------------------------------
Date: 23 Dec 2000 17:27:39 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: use strict (do I have enough hair to use it?)
Message-Id: <m31yuydb8k.fsf@mumonkan.sunstarsys.com>
"Pat J. Magnan" <pat@sluggo.org> writes:
> here's the code snippet that's doing the damage
> ==============================================
>
> sub html_header
> {
> my ($title, $css, @scripts) = @_;
Are you always calling html_header with 3+ arguments like
print html_header( "blah", "", "");
or occasionally just using
print html_header( "blah");
An easy way to find out is to add a prototype like
vvvvv
sub html_header ($$@)
{
my ($title, $css, @scripts) = @_;
> my $script;
= ""; # initialize it ?
> my $header = "";
^^^^^^^^^^^^^^^^
unnecessary- just put "my" in front of your
$header definition below.
> $header = qq!
> <html>
>
> <head>
> more of the HTML i Want to puke out here !;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Where's $title, $css, $script and @scripts? Trying
to stick an undef'd variable (like $script here)
inside qq() can generate an error message quite
similar to the one you are getting.
btw- the code you posted generates no warning
messages. It might be a good idea to check
that your code snippet is representative
of the problem you're having before posting
it next time.
HTH
--
Joe Schaefer
------------------------------
Date: Sat, 23 Dec 2000 23:45:39 +0100
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: use strict (do I have enough hair to use it?)
Message-Id: <qfaa4tku7k5hfmqcdn879ugvfvi8i67c1k@4ax.com>
On Sat, 23 Dec 2000 21:54:16 GMT, "Pat J. Magnan" <pat@sluggo.org>
wrote:
> I'll be honest, i've been naughty in the past and not bothered with the
> following two good practices:
> 1 - #!/usr/bin/perl -w
> 2 - use strict;
>
> But, I'm trying to be good in one CGI project i'm working on.
...
> sub html_header
> {
Then you should probably read about the start_html() method in CGI.pm as
it already seems to do what you try to do ...
perldoc CGI
--
Good luck,
Abe
perl -wle '$_=q@Just\@another\@Perl\@hacker@;print qq@\@{[split/\@/]}@'
------------------------------
Date: Sat, 23 Dec 2000 22:23:45 GMT
From: Mike Wescott <wescott@conterra.com>
Subject: Re: use strict (do I have enough hair to use it?)
Message-Id: <oselyy3hfh.fsf@eriadne.sc.rr.com>
"Pat J. Magnan" <pat@sluggo.org> writes:
> I get:
> Use of unitialzied value at ... line ...
> here's the code snippet that's doing the damage
> ==============================================
>
> sub html_header
> {
> my ($title, $css, @scripts) = @_;
> my $script;
> my $header = "";
>
> ## this is the line perl bitches about:
> $header = qq!
> <html>
>
> <head>
> more of the HTML i Want to puke out here !;
>
> return $header;
> }
Compiles OK for me.
Perhaps there's a typo in the original script not reproduced here or
more likely "more of the HTML i Want to puke out here " contains the
uninitialized variable.
--
Mike Wescott
wescott@conterra.com
------------------------------
Date: 23 Dec 2000 19:48:56 GMT
From: abigail@foad.org (Abigail)
Subject: Re: using perl
Message-Id: <slrn94a0d8.rpg.abigail@tsathoggua.rlyeh.net>
karthy muthiah kasi (kasi@students.uiuc.edu) wrote on MMDCLXXI September
MCMXCIII in <URL:news:Pine.GSO.4.10.10012221940480.4256-100000@ux7.cso.uiuc.edu>:
`' Hi,
`' I am new to the Perl language and I have a question regarding its
`' use. I am thinking of using perl to do the database processing and
`' using visual c++ as a front end to an application. Is there an advantage
`' in terms of speed of using perl to do the database processing? Thanks for
`' any help.
If it's a comparison of Perl vs C++, with all other things equal
(same algorithms, good programmers), the speed of Perl will be a
disadvantage - C++ ought to be (much) faster than Perl.
But you say you want to do 'database processing'. Are you talking
about letting Perl do work instead of you database? If you have a
decently written database server, you are probably better off in
letting the database server do the work - it's my experience that
trying to outsmart a database server seldomly pays off.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Sat, 23 Dec 2000 19:53:23 GMT
From: stephenelliott_2000@yahoo.co.uk
Subject: WBMP Perl script?
Message-Id: <922vri$j9j$1@nnrp1.deja.com>
Does anyone know of a perl script that will take a GIF, JPG, etc. image
and convert it to WBMP instantly?
Cheers,
Stephen
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 23 Dec 2000 20:14:32 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: WBMP Perl script?
Message-Id: <3A4507C2.78853B48@wsb.com>
stephenelliott_2000@yahoo.co.uk wrote:
>
> Does anyone know of a perl script that will take a GIF, JPG, etc. image
> and convert it to WBMP instantly?
Dunno about the "instantly" part, by take a look at the ImageMagick
package at http://www.simplesystems.org/ImageMagick/
JH
------------------------------
Date: Sat, 23 Dec 2000 13:41:03 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Where to obtain the perlrtfm podpage?
Message-Id: <slrn949sdv.akr.tadmc@magna.metronet.com>
Brad Bollenbach <bbollenbach@homenospam.com> wrote:
>
> I've seen Tom Christiansen mention his newly penned "perlrtfm" podpage.
>Where can I obtain this? I've search clpm on deja
Eh?
A deja "power search" in clp.misc for 'perlrtfm' finds this:
>I
>wanted to play around with it recently but have been unable to connect
>to the URL you had posted earlier
>(doriath.perl.com/misc/perlman-alpha0.tar.gz)
Glunk! I can't even get there myself. The whole network seems
hosed today. I'll see what I can see.
Tom wrote that last paragraph on Dec 19th. Guess it's not fixed yet...
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Dec 2000 20:45:47 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Why are multiple zeroes true?
Message-Id: <9232tr$ft8$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Bart Lateur
<bart.lateur@skynet.be>],
who wrote in article <uv294t47jqb8l3fqngurl5vd5a62o98tu7@4ax.com>:
> >The current semantic of trueness allowed the "sane numberics"
> >semantic. [As a minimum, "sane" means no change of value via
> >read-only access.] Thus *there is* at least ONE argument in favor of
> >the current semantic. ;-)
>
> Wishful thinking. There ARE cases, where using a scalar in an expression
> changes the nature of the scalar.
Right. But these cases are at least *documented*.
> I think that this is a bug.
If you want to preserve this, prepare your asbesto suit.
> The whole thing of bitwise operations acting differently on strings
> an on numbers, is dubious.
IFAIU, most DWIM things in Perl fascinate newbies only. When you
become fluent, all what DWIM starts doing is getting in your way...
Ilya
------------------------------
Date: 23 Dec 2000 20:48:07 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Why are multiple zeroes true?
Message-Id: <923327$fuh$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Ilmari Karonen
<usenet11314@itz.pp.sci.fi>],
who wrote in article <977576019.3933@itz.pp.sci.fi>:
> >As you can see, if I calculate $a | $b, that changes the nature of $a
> >from a string to number, which modifies the result for $e.
>
> Yes, but bitwise ops belong to the dark side of DWIM anyway. Ilya was
> talking about boolean context, where his claim is in fact true.
... in 5.6. I do not remember, but it may be so that the
"bugs/features" of conversions in earlier Perls can manifest
themselves in boolean context too...
Ilya
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 5191
**************************************