[17781] in Perl-Users-Digest
Perl-Users Digest, Issue: 5201 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 26 16:13:17 2000
Date: Tue, 26 Dec 2000 11: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: <977857508-v9-i5201@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 26 Dec 2000 Volume: 9 Number: 5201
Today's topics:
Re: Active Perl/Windows ME problem? <jbailey@cyberconnect.com>
Re: Any good Perl books? fudokai@my-deja.com
Re: Any good Perl books? <uri@sysarch.com>
Re: Any good Perl books? (Tad McClellan)
Re: convert string to command? (Greg Bacon)
Re: convert string to command? (Tad McClellan)
Re: converting code to mod perl (should I use globals?) egwong@netcom.com
Re: Does anyone know hoe to get sendmail to work on web <fire@bahl.hot>
Re: Error from MIME::Lite <harrisr@bignet.net>
Re: Getting a file submitted with <input type=file> eric@taedium.com
Re: Getting around the @#$@ DOS backslash! <m.koskamp*NOSPAM*@chello.nl>
Re: Getting around the @#$@ DOS backslash! (Garry Williams)
Re: Getting around the @#$@ DOS backslash! <garryknight@bigfoot.com>
Re: Help: modulus problem, docs confusing richardstands@my-deja.com
Re: Help: modulus problem, docs confusing richardstands@my-deja.com
Re: heredoc within heredoc <joe+usenet@sunstarsys.com>
Re: HTML parse (Jerome O'Neil)
Re: my cgi scripts starts a download? urgent help neede egwong@netcom.com
Net::DNS and NT Permissions mrfreeze_2000@my-deja.com
Problems with Archive::Tar <stuart@numpty.www>
Re: regexp with NULLs (Garry Williams)
subroutines and references <bh_ent@my-deja.com>
Re: subroutines and references egwong@netcom.com
Re: Text Conversion in Perl egwong@netcom.com
TFrame's and grid's <shurst@wencor.com>
Thanks! Re: Syntax for "eq" and "||" <paul_wasilkoff@ucg.org>
Re: Where can I get CRYPT for DOS/WIN? (Martin Vorlaender)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 26 Dec 2000 10:28:59 -0600
From: "Scuttlebutt" <jbailey@cyberconnect.com>
Subject: Re: Active Perl/Windows ME problem?
Message-Id: <92ah60$kaq$1@news.chatlink.com>
John - Windows ME definitely uses autoexec.bat! If you want to establish a
new path for Windows (really DOS) to search for executables, add a line to
your autoexec.bat file:
SET PATH=C:\PERL\BIN\;%PATH%
This will add C:\PERL\BIN to the search path array.
"John Roth" <johnroth@ameritech.net> wrote in message
news:t49bc6muif4s19@news.supernews.com...
> I've heard that Windows ME does not use the Autoexec.bat
> file any more. Your best bet is to set up a batch file that sets
> the path to the Perl executable, execute a DOS session,
> invoke that first, and then invoke your Perl script. It's a pain,
> but it works for me.
>
> There's supposed to be a Registry key with the global path
> information, but I don't know where it is.
>
> The reason that double-clicking works is that Windows knows
> where .pl is supposed to go - however, there doesn't seem to be
> any way of making the DOS session stay around after the command
> finishes executing.
>
> John Roth
>
> Buck <mrsnitch@ksc.co.th> wrote in message
> news:3a44a699.16102894@news.ksc.co.th...
> > I've just installed the latest version of Active Perl on my Windows ME
> > operating system but when I run the "example.pl" file in a DOS window,
> > I get "Bad Command or File Name".
> > When I installed, I chose the "add to path" option, etc. Funny thing
> > is that it will work if you double-click the example.pl file but the
> > "Hello World" message only flashes in a DOS window for a second.
> > Can't understand why I can't run the files from a command line in DOS.
> > I've moved to the correct directory and even tried the "perl -v"
> > command. Still, that same "Bad Command or File Name" message.
> > Is it a Windows ME problem? Any help would be greatly appreciated!
>
>
------------------------------
Date: Tue, 26 Dec 2000 13:56:11 GMT
From: fudokai@my-deja.com
Subject: Re: Any good Perl books?
Message-Id: <92a81q$bl3$1@nnrp1.deja.com>
In article <92a09u$1v$1@mango.singnet.com.sg>,
"Peter Lai" <javakit@singnet.com.sg> wrote:
> Any recommendations for good reference
> books on Perl?
>
> Thanks
>
>
2 books i've found highly useful as reference books - both o'reilly are 'Perl
Cookbook' and 'Perl in a Nutshell'. I'm no Perl guru and i've found the
cookbook has saved me from re-inventing a lot of wheels and since i'm not
full-time in Perl i'm forever checking the nutshell for exact syntax for
functions and what's in the standard packages - Alan
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 26 Dec 2000 15:51:02 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Any good Perl books?
Message-Id: <x7elyvb2qj.fsf@home.sysarch.com>
>>>>> "f" == fudokai <fudokai@my-deja.com> writes:
f> full-time in Perl i'm forever checking the nutshell for exact syntax for
f> functions and what's in the standard packages - Alan
which is all in the standard FREE docs that come with perl and they are
also searchable. the nutshell is not worth it IMO as it doesn't add anything.
get the camel, cookbook, effective perl programming, mastering regular
expressions, object oriented perl. not all of those are o'reilly.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 26 Dec 2000 09:15:34 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Any good Perl books?
Message-Id: <slrn94ha06.btt.tadmc@magna.metronet.com>
Peter Lai <javakit@singnet.com.sg> wrote:
> Any recommendations for good reference
> books on Perl?
perldoc -q book
perldoc perlbook
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 26 Dec 2000 15:05:20 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: convert string to command?
Message-Id: <t4hctgre7e91c8@corp.supernews.com>
In article <i3Y16.153304$_5.34321651@news4.rdc1.on.home.com>,
S51 <sdfg@asd.g> wrote:
: > I might try to just use the paths as hash keys directly:
: > $cat{'Books/Antiques'} = {auctions => $auctions};
:
: That would be harder to print out like so:
:
: Books
: - Fiction
: - Nonfiction
: Computers
: - Hardware
: - Storage
: - Display
: - Software
: - Games
: Sports
: - Football
:
: And harder to easily tell how many sub directories are in any given path.
Arrange your data in a tree, and you get those (plus lots of other
nice features) easily.
: [code]
:
: The part it prints out that I'm most concerned with is:
:
: Antiques: 0
: Fiction: 0
: Antiques:
: Fiction: 0
:
: Notice that the first time it prints "Antiques:" it gets the right value -
: 0. The second time it gets nothing because it doesn't exist. I'm clueless as
: to why this data is accessable only within that one block, especially when
: other data (Fiction) is accessable outside the block as well, and I can't
: see how the 2 are different.
That's because you were clobbering your data. You processed the
Books/Antiques category first and then Books. (If you transpose the
first two elements of @arrayref, you'll see the result you want.)
Note that you should let the "container" categories be implied by the
paths to the other categories. That way, the auction totals can
bubble up. I reworked your code:
#! /usr/bin/perl -w
use strict;
my (%field,%cat,%actions,$dbh);
# note that all categories are below the first
# level, i.e., they have non-empty paths
my @arrayref = [
[ 'Antiques', '/Books', 'no', '7' ],
[ 'Cards', '/Collectables', 'yes', '0' ],
[ 'Equipment', '/Sports', 'yes', '0' ],
[ 'Fiction', '/Books', 'no', '0' ],
[ 'Games', '/Computers/Software', 'yes', '2' ],
[ 'Lego', '/Toys', 'yes', '0' ],
[ 'Motherboards', '/Computers/Hardware', 'yes', '0' ],
[ 'Nonfiction', '/Books', 'no', '5' ],
[ 'Office', '/Computers/Software', 'yes', '0' ],
[ 'Storage', '/Computers/Hardware', 'yes', '3' ],
[ 'Stuffed toys', '/Toys', 'yes', '0' ],
];
sub do_insert {
my $root = shift;
my $path = shift;
if (@$path == 0) {
my $name = shift;
my $aucs = shift;
$root->{$name}{auctions} = $aucs;
}
else {
my $step = shift @$path;
$root->{$step} ||= {};
do_insert($root->{$step}, $path, @_);
}
}
sub insert {
my $root = shift;
my $name = shift;
my $path = shift || '';
my $auctions = shift || 0;
$path =~ s|^/||;
my @path = split /\//, $path;
do_insert $root, \@path, $name, $auctions;
}
sub sum_auctions {
my $root = shift;
my $sum = exists $root->{auctions}
? $root->{auctions}
: 0;
foreach my $kid (grep $_ ne 'auctions', keys %$root) {
$sum += sum_auctions($root->{$kid});
}
$sum;
}
sub print_tree {
my $root = shift;
my $name = shift || '';
my $pre = shift || '';
if ($name) {
if (exists $root->{auctions}) {
print $pre, "$name ($root->{auctions})\n";
}
else {
my $sum = sum_auctions $root;
print $pre, "$name ($sum)\n";
}
}
$pre .= ' ' if $name;
foreach my $kid (grep $_ ne 'auctions', keys %$root) {
print_tree($root->{$kid}, $kid, $pre);
}
}
foreach my $rowref (@arrayref) {
foreach my $row (@$rowref) {
my($name,$path,undef,$auctions) = @$row;
insert \%cat => $name, $path, $auctions;
}
}
print "Antiques: $cat{Books}{Antiques}{auctions}\n",
"Fiction: $cat{Books}{Fiction}{auctions}\n\n";
print_tree \%cat;
__END__
The output:
Antiques: 7
Fiction: 0
Computers (5)
Software (2)
Office (0)
Games (2)
Hardware (3)
Motherboards (0)
Storage (3)
Sports (0)
Equipment (0)
Collectables (0)
Cards (0)
Books (12)
Antiques (7)
Fiction (0)
Nonfiction (5)
Toys (0)
Stuffed toys (0)
Lego (0)
Producing HTML is left as an exercise for the reader.
Enjoy,
Greg
--
Now, it might be true that www.mtv.com attracts more visitors and gets
more "hits" than a site that makes RFCs available. But who the fuck cares?
-- Abigail
------------------------------
Date: Tue, 26 Dec 2000 09:13:10 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: convert string to command?
Message-Id: <slrn94h9rm.btt.tadmc@magna.metronet.com>
S51 <sdfg@asd.g> wrote:
>> Take that out, and replace it with something else that populates
>> @arrayref, so we can run your code:
>
>Done, with the data dumper it was easy, I just dumped, cut, paste.
And it paid off too.
Look back at the spinning wheels above here in this thread...
<time passes while you go do that >
... that sure does represent *a lot* of time where we didn't get very far.
If you had factored-out your app-specific stuff and made a short
and complete program that we can run in the first place, the
thread leading to your answer would have been one followup
long!
This is the first post with code we could run, and your problem
can now be solved! See below.
>I called this through a web browser,
That is not an accurate representation of how the program is executed.
"This program runs in a CGI environment" is how you say that :-)
This too, besides the DBI involvement, is another of your app-specific
things that could have been factored out.
( I can't remember if anybody has said this yet, but just to be sure:
You are using taint checking in your forms-processing CGI
program, aren't you?
)
>so for
>readability you may want to replace <BR> with \n.
Err, it is _your_ program. If you want be able to "eat your own dogfood",
then _you_ s/<BR>/<BR>\n/g and then *both* you and the browser
will be able to look at the output :-)
And, since you are using the CGI.pm module for your CGI application,
you can test things out from the command line before making it "live"
on a web server. That (getting it to work from the command line)
should be your *primary* mode of troubleshooting problems with
CGI programs. Only after you have things working well from the
command line do you move to a real CGI environment.
>#!/usr/bin/perl -w
Errr, I guess I should have said instead:
Enable warnings, and then never ignore the warnings that are issued!
This code makes about a dozen warning messages...
For a short and complete program that we (and you!) can run,
the messages would have been readily apparent as they scrolled
by on STDERR.
If you want to see them when running in a CGI environment, then
see the Perl FAQ, part 9:
"How can I get better error messages from a CGI program?"
>print "content-type: text/html\n\n";
app-specific cruft that does not need to be here to duplicate your problem.
>use DBI;
more cruft that we don't (now) need.
> if ($path eq "") {
> $cat{$name} = {auctions => $auctions};
^
^
Right there is the cause of the problem you are asking about.
If $cat{$name} happens to already have something in it, it will
be discarded and replaced with the new anon hash. That is where
Antiques "went".
If you want to _add to_ a hash instead of replacing a hash, then use:
$cat{$name}{auctions} = $auctions;
there instead.
>print "Antiques: ".$cat{'Books'}{'Antiques'}{'auctions'}."<BR>";
I guess you didn't pick up on this in my earlier post, you can
interpolate scalars into double-quoted strings. It is usually
easier to read (your own dog food again) if you use interpolation
rather than concatenation.
You also do not need to quote the hash keys (if they are "words",
as yours are).
print "Antiques: $cat{Books}{Antiques}{auctions}<BR>\n";
>I'm clueless as
>to why this data is accessable only within that one block
Because it ends up getting overwritten before the block exits.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 26 Dec 2000 18:37:18 GMT
From: egwong@netcom.com
Subject: Re: converting code to mod perl (should I use globals?)
Message-Id: <yz526.23438$bw.1592656@news.flash.net>
Yes and yes. You are making a mistake using so many globals and you
should pass all of your variables to your functions. It makes writing,
maintaining, debugging and sharing code between programs much easier
since you can test and apply each function individually.
If there are too many variables, wrap them up in an object and pass
that around.
Alex Hart <news@#nospam#althepal.com> wrote:
> I just want to say that after coding Perl for over a year now, I just
> learned the difference between a global and a lexical variable. At least
> I think I understand.
> I have some code that I want to convert to mod perl, but I would also
> like it to work outside of mod perl.
> I use a whole bunch of lexical variables in the code that are used in
> several subroutines. This works fine outside of mod perl, but since mod
> perl puts my code inside another subroutine, I get closure in places
> that I don't want it.
> To fix this I figure I need to either use global variable, or pass all
> the variables to all of the functions. Passing all the variables seems
> like a lot of work, and too easy to make a mistake with. There are about
> 30 variables that are shared by the subroutines.
> Can someone tell me if I am making a mistake using so many globals? I
> realize that lexical variables are a little faster, but I don't expect
> to overlap namespace with anyone. Are there other considerations I
> should think about??
> I can't believe there's not a switch so that nested subroutines can
> share lexical variables. That would make life so much easier for people
> switching to mod perl. Is this a silly idea?
> --
> - Alex Hart
> $j="592888088758319859281631592858792919873179698955";
> $p="push\@_,";$c="chop(\$_)";$_="$p$p($c.$c)+19;eval;
> +".$j;eval;%_=map{chr}reverse@_;foreach(sort+keys%_){print$_{$_}}
------------------------------
Date: Tue, 26 Dec 2000 15:23:59 GMT
From: Fireball€XL5 <fire@bahl.hot>
Subject: Re: Does anyone know hoe to get sendmail to work on webprovider.com?
Message-Id: <261220000724119604%fire@bahl.hot>
Thanks David - I just neglected to include the first "/" on my post, it
is in fact '/usr/lib/sendmail' in the sript.
Thanks
fb
In article <slrn94d9gc.mbt.efflandt@efflandt.xnet.com>,
efflandt@xnet.com (David Efflandt) wrote:
> On Sun, 24 Dec 2000, FireballXL5 <isithotinhere@orisitjustme.com> wrote:
> >I am trying to setup a simple mailform page using formmail.cgi, and the
> >script seems to be working fine, but the emails are never processed by
> >the server (or if they are, they go nowhere)
> >Supposedly, the host states that the path to sendmail is:
> >usr/lib/sendmail
>
> You are confused about system paths, apparently fail to test your open(),
> and therefore fail to check the variable $! that would tell you why it
> failed. Sendmail is likely at the absolute path /usr/lib/sendmail, NOT
> the relative path usr/lib/sendmail. A missing slash can totally ruin your
> day.
------------------------------
Date: Tue, 26 Dec 2000 13:57:36 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Error from MIME::Lite
Message-Id: <t4hqfsjbpbnj7f@corp.supernews.com>
Abigail <abigail@foad.org> wrote in message
news:slrn94guj0.3un.abigail@tsathoggua.rlyeh.net...
> Randy Harris (harrisr@bignet.net) wrote on MMDCLXXIV September
MCMXCIII
> in <URL:news:t4gcgvl9orb148@corp.supernews.com>:
> `' The code and sub below are from MIME::Lite 2.104, file Lite.pm.
When it
> `' is run with the -w switch it generates the following warning:
> `'
> `' Unrecognized escape \s passed through at (eval 2) line 11
> `'
> `' Simply having "use MIME::Lite ;" in the program causes it to report
the
> `' warning. The warning is coming from this line:
> `'
> `' my $SEP = "(?:^\\s*|\\s*,\\s*)"; ### before elems in a
list
> `' How can I correct this, or, should I simply ignore the warnings?
>
> Change the double quotes to single quotes.
Should this error be reported to someone?
------------------------------
Date: Tue, 26 Dec 2000 18:50:18 GMT
From: eric@taedium.com
Subject: Re: Getting a file submitted with <input type=file>
Message-Id: <KL526.23445$bw.1592656@news.flash.net>
Ronomics <usequity@mindspring.com> wrote:
> I have a form that allows users to submit a file (with the input tag
> type=file). How do I get, rename, and save the file to a directory?
> TIA
> Henry
If you're using CGI.pm then just read the param returned as a filehandle.
my $uploaded_file = $cgi->param('uploadedFile');
open( FH, ">$renamed_file" ) or die "$!";
while( <$uploaded_file> ) {
print FH;
}
close( FH );
Look for "CREATING A FILE UPLOAD FIELD" in the CGI.pm perldocs.
If you're not using CGI.pm . . ..
------------------------------
Date: Tue, 26 Dec 2000 15:40:39 GMT
From: "M.W. Koskamp" <m.koskamp*NOSPAM*@chello.nl>
Subject: Re: Getting around the @#$@ DOS backslash!
Message-Id: <XZ226.188472$%C1.2347879@Flipper>
Try : my @parts= split($variable, "\\")
<elvis@chowtech.cuug.ab.ca> schreef in bericht
news:91i67s$527$1@chowtech.cuug.ab.ca...
> Hi All,
>
> I have little project in which I need to extract info from a DOS string
> of type C:\dos\command\fruitcake.exe. How can I extract all the sections
> between the backslashes and determine how many sections I can extract
without
> actually knowing anything about the string submitted? Can anyone help?
>
> Elvis
>
> --
> --------------------------------------------------------------------------
---
> Elvis Chow elvis@chowtech.cuug.ab.ca "If you don't ask questions, it
could
> echow@rockyview.ab.ca mean you are afraid to learn ......"
> --------------------------------------------------------------------------
---
------------------------------
Date: Tue, 26 Dec 2000 16:17:14 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Getting around the @#$@ DOS backslash!
Message-Id: <ew326.1366$Kk5.64916@eagle.america.net>
[ Re-ordered upside-down follow-up ]
[ Fixed broken line wrapping ]
[ Trimmed sig from follow-up ]
On Tue, 26 Dec 2000 15:40:39 GMT, M.W. Koskamp
<m.koskamp*NOSPAM*@chello.nl> wrote:
><elvis@chowtech.cuug.ab.ca> schreef in bericht
>news:91i67s$527$1@chowtech.cuug.ab.ca...
>> I have little project in which I need to extract info from a DOS
>> string of type C:\dos\command\fruitcake.exe. How can I extract all
>> the sections between the backslashes and determine how many
>> sections I can extract without actually knowing anything about the
>> string submitted? Can anyone help?
>Try : my @parts= split($variable, "\\")
$ cat x
#!/usr/local/bin/perl
use warnings;
use strict;
my $variable = 'C:\dos\command\fruitcake.exe';
my @parts= split($variable, "\\");
print join '-', @parts;
__END__
$ perl -l x
\
$
Hmmm. Your suggestion doesn't seem to produce the desired results. I
guess you didn't test it before posting it. :-(
You were (in some sense) close, though:
$ cat x
#!/usr/local/bin/perl
use warnings;
use strict;
my $variable = 'C:\dos\command\fruitcake.exe';
my @parts= split(/\\/, $variable);
print join '-', @parts;
__END__
$ perl -l x
C:-dos-command-fruitcake.exe
$
See the split() section of the perlfunc manual page.
But why reinvent the wheel? See the File::Basename manual page for
the already-been-tested-and-most-probably-correct solution.
--
Garry Williams
------------------------------
Date: Tue, 26 Dec 2000 18:10:36 +0000
From: "Garry Knight" <garryknight@bigfoot.com>
Subject: Re: Getting around the @#$@ DOS backslash!
Message-Id: <92amus$jog$1@taliesin.netcom.net.uk>
In article <XZ226.188472$%C1.2347879@Flipper> "M.W. Koskamp"
<m.koskamp*NOSPAM*@chello.nl> wrote:
[post unjeopardised]
> <elvis@chowtech.cuug.ab.ca> schreef in bericht
> news:91i67s$527$1@chowtech.cuug.ab.ca...
>> I have little project in which I need to extract info from a DOS
>> string of type C:\dos\command\fruitcake.exe. How can I extract all
>> the sections between the backslashes
> Try : my @parts= split($variable, "\\")
Try: my @parts = split(/\\/, $variable); It works better.
--
Garry Knight
garryknight@bigfoot.com
------------------------------
Date: Tue, 26 Dec 2000 18:49:18 GMT
From: richardstands@my-deja.com
Subject: Re: Help: modulus problem, docs confusing
Message-Id: <92ap7d$o82$1@nnrp1.deja.com>
In article <977599047.656@itz.pp.sci.fi>,
Ilmari Karonen <usenet11314@itz.pp.sci.fi> wrote:
> 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
>
>
Yea, the part about integer args is there in the docs, I just read it
and it didn't sink in - pre-xmas brain fart I'd say. Thanks.
-Rich
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 26 Dec 2000 18:47:46 GMT
From: richardstands@my-deja.com
Subject: Re: Help: modulus problem, docs confusing
Message-Id: <92ap4g$o79$1@nnrp1.deja.com>
In article <t49u2no05fn0f1@corp.supernews.com>,
"Randy Harris" <harrisr@bignet.net> wrote:
> <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':
> ^^^^^^^
>
>
My bad, I just hope my mouth stops tasting like my foot soon. Integers,
you'd think I'd know all that by now... :o(
-rich
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 26 Dec 2000 12:45:54 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: heredoc within heredoc
Message-Id: <m3r92vaxf1.fsf@mumonkan.sunstarsys.com>
"John Lin" <johnlin@chttl.com.tw> writes:
> parse(<<HTML,<<RULE,<<EMAIL);
^
>
> works, but
>
> parse(
> <<HTML, # my boss asked me to separate
> <<RULE, # them into 3 lines and add
> <<EMAIL # comments to explain them
> );
^
Not a statement terminator- just a separator.
Hence it's totally useless for telling perl
when your statement has ended and the HERE-DOC's
should begin. I think you're stuck leaving
everything on one line until/unless perl developers
can appreciate the advantage of having a statement
terminator for situations like yours, or an even
more convoluted and evil thing like:
my $sth = $dbh->prepare(<<SQL)
or die "prepare failed: $DBI::errstr: " . <<SQL;
SELECT * FROM blah
WHERE foo='bar'
SQL
which IMHO is preferable to
my $sth = $dbh->prepare($_=<<SQL)
SELECT * FROM blah
WHERE foo='bar'
SQL
or die "prepare failed: $DBI::errstr: $_";
--
Joe Schaefer
------------------------------
Date: Tue, 26 Dec 2000 17:23:15 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: HTML parse
Message-Id: <7u426.432$e6.141721@news.uswest.net>
Jeff Helman <jhelman@wsb.com> elucidates:
> Jerome O'Neil wrote:
>
>> It would seem also that you are a newbie to development and programming
>> in general. When you are no longer a newbie, you will know that
>> re-inventing a wheel (especialy a hard wheel) is rarely good programming
>> practice.
>
> For what it's worth, this is generally a true statement, but there are
> exceptions. For example, a few threads ago there was a discussion about
> how to add the number of days in a month to a date string in the format
> of YYYYMM. One poster pointed out that using the Date::Manip module
> made this a trivial exercise (which it did), but Abagail posted a rather
> elegant one-liner that did the same thing.
There are two points I should make here. First, is that manipulating dates
isn't a complex task. Manipulating HTML is a complex task. Second is that
I think you will find that Abigail has a one line solution to almost any
problem you can describe. I never cease to be amazed. :)
>> No. If your goal is to learn about manipulating HTML, then use the
>> tools available to you to do so. If your goal is to learn about
>> regular expressions, there are better academic excercises than
>> parsing HTML.
>
> Again, I respectfully disagree. As HTML is such a forgiving language,
> there are almost an infinite number of gotchas that one might have to
> catch, which forces the novice programmer to really explore the power of
> Perl regexes.
HTML is not a forgiving language. It is well described. There are many
forgiving browsers available that will display poorly formed HTML, but
that isn't the same thing. All those infinite number of "gotchas" do is
provide an infinite number of frustrations to a novice attempting to complete
their task, and an infinite number of ways to break their hack.
If learning regex syntax is realy the goal, creating mail filters is
a much more worthwhile excercise.
> And, not really having played with the HTML::* modules
> myself, if I were in a similar spot with the same requirements, I'd
> spend less time writing my own trivial hack than researching how to do
> it with those modules.
This is where you are mistaken. You might spend time on the learning
curve to pick up the HTML::* packages, but that time would be rewarded
over and over again because you won't have to go back an infinite number
of times to adjust for all those "gotchas." Its a case of being
penny wise and pound foolish.
> Would it be as robust? Of course not. Would it get the job done? Yes.
There is an inherent contradiction in this statement. The job isn't done
if it isn't a robust solution. A product that sometimes works is a broken
product.
--
If men could learn from history, what lessons it might teach us! But
passion and party blind our eyes, and the light which experience gives
is a lantern on the stern, which shines only on the waves behind us.
--Samuel Taylor Coleridge, "Recollections"
------------------------------
Date: Tue, 26 Dec 2000 18:55:42 GMT
From: egwong@netcom.com
Subject: Re: my cgi scripts starts a download? urgent help needed
Message-Id: <OQ526.23447$bw.1592656@news.flash.net>
Create232 <create232@aol.com> wrote:
> This sounds like a permissions problem. You must make sure the script(s) are
> set as executable..
I haven't seen the original post, but if your cgi script is starting
a download then it sounds like you're sending the wrong mime-type in
your header. If you're using CGI.pm, it's just
print $cgi->header(); # if using objects
or
print header(); # if not (:standard)
If you're not using CGI.pm (you should be) it's
print "Content-type: text/html\x0d\x0a\x0d\x0a";
------------------------------
Date: Tue, 26 Dec 2000 15:30:59 GMT
From: mrfreeze_2000@my-deja.com
Subject: Net::DNS and NT Permissions
Message-Id: <92adjj$fdi$1@nnrp1.deja.com>
Anyone now what permissions are necessary to
allow this module to work properly under Windows
NT 4 Workstation w/SP6a? If I am logged in on the
machine as an admin, my script returns the
expected output, but if I attempted to access it
via the web server running on my machine (PWS
4.0), I get something like the following:
;; query(bluestar.net, MX, IN)
;; send_tcp(209.119.96.2:53) (src port = 0)
;; ERROR: send_tcp: connection failed: Unknown
error
;; send_tcp(209.119.96.3:53) (src port = 0)
;; ERROR: send_tcp: connection failed: Unknown
error
Since this script is run as the IUSR user on my
machine by PWS, that is the only difference I can
think of, since when I am logged into my machine,
I have admin rights and can run the script
normally. This is driving me up a wall... I'm
pretty sure this is a permissions issue, would
appreciate any insight anyone can provide.
Stephen Leavitt
stephen(underscore)j(underscore)
leavitt@nospam.hotmail.com
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 26 Dec 2000 18:39:59 GMT
From: "Stuart" <stuart@numpty.www>
Subject: Problems with Archive::Tar
Message-Id: <3C526.60087$2L2.4635126@news3.cableinet.net>
Hi folks,
I'm new to the world of perl, so if I seem wet behind the ears, that's
because I am!!
What I'm trying to do is copy my web server's access-log file to a new
directory, compress it using Archive::Tar, then delete the non-compressed
version. Here's what I've come up with so far:
___________________
#!/usr/local/bin/perl -wT
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:all);
use File::Copy;
use strict;
my $logfile='';
my $newfile='';
my $compressed='';
my $compressedfile='';
$logfile = '/home/servername/access-log';
$newfile = '/home/servername/www/archives/access-log';
copy($logfile, $newfile);
use Archive::Tar;
$compressedfile = Archive::Tar->new();
$compressed = '1';
$compressedfile->add_files('/home/servername/www/archives/access-log');
$compressedfile->write('/home/servername/www/archives/access-log.tar'
,$compressed);
unlink($newfile);
print header;
print qq(Job Done!);
___________________
I get the feeling I'm close to achieving what I want, but what I actually
get in "/home/servername/www/archives/" is a file called "access-log.tar"
with a zero-byte size. It seems I'm moving the original file successfully,
and creating the "tar" file successfully, but the command to write the
logfile to the "tar" file is failing...
Can anyone see what's wrong with the above?
Thanks and Merry Christmas!
------------------------------
Date: Tue, 26 Dec 2000 15:53:57 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: regexp with NULLs
Message-Id: <pa326.1364$Kk5.64613@eagle.america.net>
On Tue, 26 Dec 2000 14:02:50 +0000, Steven Fletcher <flec@flec.co.uk>
wrote:
> I attempted to write a function that would
>strip anything following a \00 from the data supplied, which went
>something like this:
>
>sub read_memo_sender {
> ($string) = @_;
> if ($string =~ /^(\w+)\00/) {
> return($1);
> } else {
> return($string);
> }
>}
sub read_memo_sender {
if ($string =~ /^(.*?)\0/) {
return $1;
}
return $string;
}
Or just:
sub read_memo_sender {
my $string = shift;
$string =~ s/^(.*?)\0.*$/$1/;
return $string;
}
Either of these will also handle the null string case. I.e., the
value passed to the subroutine is "\0...".
See the perlre manual page.
--
Garry Williams
------------------------------
Date: Tue, 26 Dec 2000 17:02:12 GMT
From: Drew Myers <bh_ent@my-deja.com>
Subject: subroutines and references
Message-Id: <92aiuh$jdp$1@nnrp1.deja.com>
First off, I'm a newbie to Perl.
In this program, I have several subroutines that build data, usually in
the form of scalars. I want to pass that information to the format
that exists in the Main portion of the program. I am getting an
unitialized value at <CHUNK> 124 error. I cannot determine which
subroutine is not functioning correctly, but I suspect this one.
Please review and let me know how I might optimize/correct it.
Thank you!
P.S. I am running with strict and warnings enabled.
code:
sub SarData {
foreach my $file(my @safilelist) {
my $low=99999;
my ($total,$high,$n)=0;
open(SARFILE, "sar -u -f /var/adm/sa/$file|")
|| die "Can't open $file $!\n";
foreach my $sarinfo (<SARFILE>) {
next if ($sarinfo=~/^$/);
next if ($sarinfo=~/Average/ || $sarinfo=~/usr/);
chomp($sarinfo);
if ($sarinfo=~/HP/) {
my ($name,$date)=(split' ',$sarinfo)[1,5];
return \$name,\$date;
}
my ($time,$user,$sys,$idle)=(split' ',$sarinfo)[0,1,2,4];
if ($idle > $high) { $high = $idle; }
if ($idle < $low) { $low = $idle; }
$total += $idle;
++$n;
}
my $avg = $total / $n;
return \$high, \$low, \$avg;
close(SARFILE) || die "Can't close $file $!\n";
}
}
--
Drew Myers
perotsystems
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 26 Dec 2000 18:27:02 GMT
From: egwong@netcom.com
Subject: Re: subroutines and references
Message-Id: <Wp526.23435$bw.1592656@news.flash.net>
Drew Myers <bh_ent@my-deja.com> wrote:
> First off, I'm a newbie to Perl.
> In this program, I have several subroutines that build data, usually in
> the form of scalars. I want to pass that information to the format
> that exists in the Main portion of the program. I am getting an
> unitialized value at <CHUNK> 124 error. I cannot determine which
> subroutine is not functioning correctly, but I suspect this one.
> Please review and let me know how I might optimize/correct it.
> Thank you!
> P.S. I am running with strict and warnings enabled.
> code:
> sub SarData {
> foreach my $file(my @safilelist) {
> my $low=99999;
> my ($total,$high,$n)=0;
Here's your problem. Both $high and $n are unitialized (i.e. undef.)
This is because you have an array on the left and a scalar on the right,
so only the first element of the array is actually assigned. What you
probably want to do is
my ($total, $high, $n) = (0, 0, 0);
[ cut ]
> return \$high, \$low, \$avg;
> close(SARFILE) || die "Can't close $file $!\n";
THis is also wrong. The 'close' will never be called since the sub
returns before it's ever encountered. You should probably switch these
two lines. This probably isn't a problem, though, unless your program
is persistant (i.e. daemon or something) and you're locking files.
Also, do you have any particular reason why you're returning a list of
references to scalars rather than just a list of scalars themselves?
Something like
return ($high, $low, $avg);
seems a bit more readable to me.
HTH
[cc'd]
------------------------------
Date: Tue, 26 Dec 2000 18:44:14 GMT
From: egwong@netcom.com
Subject: Re: Text Conversion in Perl
Message-Id: <2G526.23443$bw.1592656@news.flash.net>
Mario Thomas <mario@alamar.net> wrote:
> I thought about using tr/// the problem with that is that i will have to
> create the mappings as they happen. I would prefer to find out what
> character sets i am translating between. Is there a way to do this or is
> there a list of character sets somewhere?
Yes, you call up the person from the other department and say, "Hey,
what character mapping are you using?" Then you can go to somewhere
like
http://www.unicode.org/Public/MAPPINGS/
and create your tr/// (or maybe s/// if you're going to convert to
HTML character entities). Then take the rest of the day off.
------------------------------
Date: Tue, 26 Dec 2000 10:58:16 -0700
From: "Steve Hurst" <shurst@wencor.com>
Subject: TFrame's and grid's
Message-Id: <92alua$i9a$1@news.xmission.com>
Hi, I am having trouble making TFrame work correctly with the grid geometry
manager, for example
$mw = MainWindow->new();
$f = $mw->TFrame();
for my $i (0 .. 4) {
$f->gridColumnconfigure($i,-minsize,20);
$f->gridRowconfigure($i,-minsize,20);
}
$b = $f->Button(-text,'yak');
$b->grid(-row,4,-column,4);
$f->pack();
MainLoop;
does not behave as expected ( a button in the bottom right of a 100 by 100
window) , but simply using Frame instead of TFrame does.
$f = $mw->TFrame();
$f->gridRowconfigure(0);
DOES return the expected setable options?
Any help much appreciated!
Steve
------------------------------
Date: Tue, 26 Dec 2000 10:18:11 -0500
From: "Paul Wasilkoff" <paul_wasilkoff@ucg.org>
Subject: Thanks! Re: Syntax for "eq" and "||"
Message-Id: <t4hdo98359ob79@corp.supernews.com>
Thanks all!
PAW
------------------------------
Date: Tue, 26 Dec 2000 18:42:41 +0100
From: martin@radiogaga.harz.de (Martin Vorlaender)
Subject: Re: Where can I get CRYPT for DOS/WIN?
Message-Id: <3a48d891.524144494f47414741@radiogaga.harz.de>
Studio 51 (leekembel@hotmail.com) wrote:
: "Tad McClellan" <tadmc@metronet.com> wrote...
: > Vitaly Tkachenko <virtualvat@yahoo.com> wrote:
: > >It just doesn't work correctly.
: >
: > Yes it does.
:
: Just 30 minutes ago I was reading about how crypt() doesn't work properly in
: ActiveState Perl (windows). I WISH I could find the page to show you, but
: unfortunately I can't :(
As far as I remember, ActiveState Perl was the first Win32 port to have
a fully functional crypt.
Anyway, if you need a replacement, as always, look in CPAN. The module
is called Crypt::UnixCrypt. Quoting from the README:
Crypt::UnixCrypt - perl-only implementation of the crypt(3) function.
This module is for all those poor souls whose perl port answers to the
use of crypt() with the message `The crypt() function is unimplemented
due to excessive paranoia.'.
cu,
Martin
--
One OS to rule them all | Martin Vorlaender | VMS & WNT programmer
One OS to find them | work: mv@pdv-systeme.de
One OS to bring them all | http://www.pdv-systeme.de/users/martinv/
And in the Darkness bind them.| home: martin@radiogaga.harz.de
------------------------------
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 5201
**************************************