[11976] in Perl-Users-Digest
Perl-Users Digest, Issue: 5576 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 5 23:07:17 1999
Date: Wed, 5 May 99 20:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 5 May 1999 Volume: 8 Number: 5576
Today's topics:
Re: Can a DNS lookup be performed from within perl ? (David Efflandt)
Convert flat data into tree deja_ken@my-dejanews.com
Re: deleting files (Bob Trieger)
Re: Dummy Question about filehandler <walton@frontiernet.net>
Re: embed cgi in HTML (David Efflandt)
Re: Grab the user name under apache? (David Efflandt)
Re: having problems getting this script to work... (Fuzzy Warm Moogles)
Re: having problems getting this script to work... <rick.delaney@home.com>
Re: How do I print "\"? (Bob Trieger)
Re: I can not use cgi in my Hypermart account. <webmaster@chatbase.com>
Looking for Perl Program (Arthur Merar)
Re: matching hyphenated words across line ends (Jed Parsons)
Re: Modulo <walton@frontiernet.net>
Re: Newbie question (Tad McClellan)
Re: Newbie: how do I use modules locally? (Tad McClellan)
Re: OReilly bullshit.... Camel logo trademark <webmaster@chatbase.com>
Re: Perl on NT workstation with PWS <jphillips@va.campuscwix.net>
Re: Please Help (Randal L. Schwartz)
Re: Q: Getting sendmail to work (Bob Trieger)
Re: redirecting w/ apache and SSI (Randal L. Schwartz)
Re: regexp for matching IP address block (Larry Rosler)
Re: regexp for matching IP address block (Benjamin Franz)
Re: SSI perl hit counter (Randal L. Schwartz)
Re: STDOUT ?? <thomas@daimi.au.dk>
using $, (was Re: having problems) <uri@sysarch.com>
Re: Whats wrong? (Jim Richardson)
Re: Whats wrong? <tbsmith@viper.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 May 1999 01:46:20 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Can a DNS lookup be performed from within perl ?
Message-Id: <slrn7j1t0c.he.efflandt@efflandt.xnet.com>
On 22 Apr 1999 07:01:56 GMT, Uri Raz <uraz@iil.intel.com> wrote:
> I'm working on a perl script that analyses a web server's log file.
>
> As part of the script I want to translate an IP address into a host's
> name, using (reverse) DNS lookup.
>
> Is there a way to do this from within perl, as a function and not by
> calling a shell to perform nslookup ?
# Get remote host if server does not
unless ($ENV{REMOTE_HOST} && $ENV{REMOTE_ADDR} ne $ENV{REMOTE_HOST}) {
my $ip_num = pack("C4", split(/\./, $ENV{REMOTE_ADDR}));
$ENV{REMOTE_HOST} = scalar gethostbyaddr($ip_num, 2);
$ENV{REMOTE_HOST} = $ENV{REMOTE_ADDR} unless $ENV{REMOTE_HOST};
}
Apache used to set REMOTE_HOST = REMOTE_ADDR if server was set to NOT
resolve hostnames. However, in recent versions there is no REMOTE_HOST
unless apache is set to resolve hostnames.
>--
> +---------+---------------------------+---------------------------------+
> | Uri Raz | mailto:uraz@iil.intel.com | I speak for myself, not Intel. |
> | Work is what employees do while managers lay down the work plans. ;-) |
> | My home page <URL:http://www.private.org.il> |
> +-----------------------------------------------------------------------+
--
David Efflandt efflandt@xnet.com
http://www.xnet.com/~efflandt/
------------------------------
Date: Thu, 06 May 1999 01:58:39 GMT
From: deja_ken@my-dejanews.com
Subject: Convert flat data into tree
Message-Id: <7gqt0e$obt$1@nnrp1.deja.com>
I'm looking for a (smart) method for converting a flat data structure
(actually being returned from a query to oracle with dbi) into a tree view,
without many recursive queries.
Assuming a data structure like:
ID Parent Data
1 0 "foo"
2 0 "bar"
3 1 "whee"
4 3 "ahh"
5 1 "pop"
6 2 "fuzz"
I'd get back:
foo
whee
ahh
pop
bar
fuzz
There are actually many more fields than just one, and I'd need to be able to
sort/subsort - hopefully that can be taken care of with dynamic 'order by'
within the SQL query. So, in my example, I actually might want 'pop' to appear
above 'whee' and 'bar' above 'foo' because I'd sorted alphabetically within
children.
I came up with a way to do it, by creating a string using regexp
lookup/insert as each successive id came in, thus building a 'order'
delimited string, then splitting it into an array. Now, this works.. but the
kludge-factor of this approach is super high. I've been trying to figure out
how to do this elegantly using nested hashes, but I'm just can't quite get my
brain around a solution that works.
Any ideas would be *most* appreciated!
Thanks,
Ken
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 06 May 1999 00:58:16 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: deleting files
Message-Id: <7gqon9$svg$1@oak.prod.itd.earthlink.net>
[ courtesy cc sent by mail if address not munged ]
"dave" <webmaster@geeks404.com> wrote:
>another really basic question that i can't find the answer to... how can i
>delete a file from a perl script?
>
>sorry if this is really obvious, but i can't find an answer :-P
perldoc -f unlink
HTH
------------------------------
Date: Wed, 05 May 1999 21:38:07 -0400
From: Bob Walton <walton@frontiernet.net>
To: Yu Wang <yuwang@Stanford.EDU>
Subject: Re: Dummy Question about filehandler
Message-Id: <3730F27F.A2A75B31@frontiernet.net>
Use the backtick operator, like in:
$userid=`whoami`;
This returns the standard output of the command into the variable. See
perlop for details (search on qx/). Note that these are backticks, not
apostrophes. The backtick key is in the upper left corner of the main
part of many keyboards.
Yu Wang wrote:
> In my perl program, I want to issue a
> command and then process the output of
> the command.
>
> For example, I use
>
> system lpq;
>
> then I will do some work on it's output.
>
> I have tried to select <STDIN> or <STDOUT>,
> none of them worked.
>
> Thanks a lot for your help.
>
> -- Yu Wang
>
> P.S. Directing the output of the first
> command and then processing the output
> file is NOT an option. Thanks.
------------------------------
Date: 6 May 1999 02:22:20 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: embed cgi in HTML
Message-Id: <slrn7j1v3r.he.efflandt@efflandt.xnet.com>
On Mon, 03 May 1999 00:55:09 GMT, Scruffles
<scruffles*nospam*@geocities.com> wrote:
>I want to inclued a CGI generated peice of HTML into a web page. I
>would like to be able to load the web page into an HTML editor when
>needed, so making the hole thing a Here document is out of the
>question (unless I am missing something).
>
>What I want to do is something like
><!--#exec cgi="/path/to/script.cgi"-->
>to embed the script's output (I got this from
>http://www.inlink.com/support/web/personal/cgi.html )
Note: cgi= uses a URI path and cmd= uses a shell path.
>or
>
>as geocities uses it: <!--#geoguide-->
Probably just a comment or server specific command.
>How do these work? Are they web server specific? Where can I get
>more information?
>From your webserver docs, or a related webserver newsgroup.
For example in Apache, the page name might need to end with '.shtml'
instead of '.html', unless you configure your server or issue .htaccess
directives (if allowed) to make it otherwise. But it is not a perl issue.
--
David Efflandt efflandt@xnet.com
http://www.xnet.com/~efflandt/
------------------------------
Date: 6 May 1999 02:30:24 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Grab the user name under apache?
Message-Id: <slrn7j1vj0.he.efflandt@efflandt.xnet.com>
On Mon, 03 May 1999 20:08:25 +0000, Douglas Nichols <dnichols@fhcrc.org> wrote:
>I would like to grab the name of the user that loggin with a
>valid user_name. I am using perl and have apache 1.3.4.
>
>Since they have logged in through the browser I should be
>able to find this information from apache somewhere?
>
>
>I have a section in httpd.conf:
></directory...>
> .
> .
> require valid-user
>
>So I need somewhere in my perl script to get the user_name..
This is not really a perl issue, but the variable you are looking for is
$ENV{'REMOTE_USER'}. However, if your script is outside of the protected
space (like in cgi-bin) it will be null if it exists at all.
--
David Efflandt efflandt@xnet.com
http://www.xnet.com/~efflandt/
------------------------------
Date: Thu, 06 May 1999 01:18:09 GMT
From: tgy@chocobo.org (Fuzzy Warm Moogles)
Subject: Re: having problems getting this script to work...
Message-Id: <3733e701.112369400@news.oz.net>
On Wed, 5 May 1999 12:00:29 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>In article <7gpdt0$ua6$1@nntp8.atl.mindspring.net> on Wed, 5 May 1999
>08:44:25 -0400, Allan M. Due <Allan@due.net> says...
>...
>> Not that it really matters but replacing that map with a foreach should be
>> quicker.
[snip]
>But neither of them is the fastest, as Bart Lateur's approach is the
>clear winner. I'll have to use it more often.
And faster than fastest is concatenating with 'join':
#!/usr/bin/perl -w
use strict;
use Benchmark;
my @data = (('x' x 50) x 50);
open OUT, '>NUL' or die "Couldn't open 'NUL'. $!";
# Pardon my misspelling of '/dev/null'. :-)
timethese(16384, {
For => sub { print OUT "$_\n" for @data },
Map => sub { print OUT map "$_\n", @data },
Vars => sub { ($,, $\) = ("\n", "\n"); print OUT @data },
Join => sub { print OUT join "\n", @data, '' },
});
__END__
Benchmark: timing 16384 iterations of For, Join, Map, Vars...
For: 7 wallclock secs ( 7.04 usr + 0.00 sys = 7.04 CPU)
Join: 4 wallclock secs ( 4.39 usr + 0.00 sys = 4.39 CPU)
Map: 9 wallclock secs ( 8.63 usr + 0.00 sys = 8.63 CPU)
Vars: 6 wallclock secs ( 6.26 usr + 0.00 sys = 6.26 CPU)
--
Fuzzy | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Thu, 06 May 1999 01:55:10 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: having problems getting this script to work...
Message-Id: <3730F61F.7E150990@home.com>
[posted & mailed]
Fuzzy Warm Moogles wrote:
>
> And faster than fastest is concatenating with 'join':
I was just going to say the same thing.
[snip]
> Vars => sub { ($,, $\) = ("\n", "\n"); print OUT @data },
> Join => sub { print OUT join "\n", @data, '' },
But I was going to add a couple to show that the assignments have
minimal effect.
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my @data = (('x' x 50) x 50);
open OUT, '>NUL' or die "Couldn't open 'NUL'. $!";
# Pardon my misspelling of '/dev/null'. :-)
timethese(1 << (shift || 0), {
For => sub { print OUT "$_\n" for @data },
Map => sub { print OUT map "$_\n", @data },
Vars1 => sub { local($,, $\) = ("\n", "\n"); print OUT @data },
Vars2 => sub { local $, = "\n"; print OUT @data, "" },
Join1 => sub { print OUT join "\n", @data, "" },
Join2 => sub { local($,, $\)=("", "");print OUT join "\n", @data, ""},
});
__END__
Benchmark: timing 8192 iterations of For, Join1, Join2, Map, Vars1,
Vars2...
For: 8 wallclock secs ( 8.02 usr + 0.00 sys = 8.02 CPU)
Join1: 5 wallclock secs ( 5.05 usr + 0.00 sys = 5.05 CPU)
Join2: 6 wallclock secs ( 5.65 usr + 0.00 sys = 5.65 CPU)
Map: 10 wallclock secs (10.71 usr + 0.00 sys = 10.71 CPU)
Vars1: 8 wallclock secs ( 7.42 usr + 0.00 sys = 7.42 CPU)
Vars2: 7 wallclock secs ( 7.14 usr + 0.00 sys = 7.14 CPU)
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Thu, 06 May 1999 01:02:48 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: How do I print "\"?
Message-Id: <7gqovq$svg$2@oak.prod.itd.earthlink.net>
[ courtesy cc sent by mail if address not munged ]
Poohba <poohba@io.com> wrote:
>This is what I have:
>
>#!D:/usr/local/bin/perl/bin/perl
Put a -w in that shebang line right now OR ELSE. :)
To print a backwhack, you escape it with another backwhack, ie: print
"\\"; will print a single backwhack (\).
------------------------------
Date: Wed, 05 May 1999 18:56:21 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: I can not use cgi in my Hypermart account.
Message-Id: <3730F6C5.32B563B7@chatbase.com>
Austin Ming wrote:
>
> I can not use cgi in my Hypermart account.
>
> I do not know if i do the wrong procedure or not.
>
> 1,) i create cgi-bin directory by using FTP,
> 2.) i upload html.pl to cgi-bin directory by using FTP.
> 3.) i chmod of cgi-bin directory to 755 by using FTP
> 4.) i chmod of html.pl file to 755 using FTP
>
> file: html.pl
> ----------------------------------------
>
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "<HTML>\n<HEAD></HEAD>\n<BODY BGCOLOR=\"WHITE\">\nTesting\n";
> print "</BODY>\n</HTML>";
>
> ----------------------------------------
>
> But, I can not run the cgi.
>
> http://heshe.hypermart.net/cgi-bin/html.pl
>
> What's wrong ? Can anyone help me ?
The fact you're running on "hypermart.net" has nothing to do with the
question really. But by any chance, did you bother to click on the link
that says "check your error log"? It shows me this:
Errors:
[Wed May 5 18:37:05 1999] access to
/data1/hypermart.net/heshe/netscape/softupdate.class failed for
205.177.138.27, reason: File does not exist
exec of /data1/hypermart.net/heshe/cgi-bin/html.pl failed, reason: No
such file or directory (errno = 2)
[Wed May 5 18:42:33 1999] access to
/data1/hypermart.net/heshe/cgi-bin/html.pl failed for 209.63.220.201,
reason: Premature end of script headers
That's a big help to you. Being the fact that you have the Content type
right, I'd say either you uploaded this script in binary and didn't know
you needed to do so in ASCII, or the path to perl is wrong. I think
taking a look at the cgi help section of that server may tell you what
the proper path is. Of course, it could be something else, but I doubt
it.
--
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
The Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm: http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!
------------------------------
Date: Thu, 06 May 1999 02:35:24 GMT
From: amerar@unsu.com (Arthur Merar)
Subject: Looking for Perl Program
Message-Id: <3730ff85.177094812@news.chaven.com>
Hello,
I am looking for a Perl program or CGI program that will count the
hits on my web page. I do not want to use any Server Side Includes.
Just something that I can call from my HTML document to increment the
hits and display some GIF images.......
Please e-mail me a response......
Thanks,
Arthur
amerar@unsu.com
------------------------------
Date: 6 May 1999 02:07:17 GMT
From: jed@socrates.berkeley.edu (Jed Parsons)
Subject: Re: matching hyphenated words across line ends
Message-Id: <7gqtgl$sq7$1@agate.berkeley.edu>
In article <NG4Y2.41$zh2.2388@dfw-service1.ext.raytheon.com>,
Tim Armbruster <t-armbruster@ti.com> wrote:
>I shouldn't be doing your homework, but this had me intrigued. Next time
>try to do a little research on your own, and post some code that you've
>tried. I'm probably the only sucker that will reply to a post like this.
Well, fair enough, and thanks for the reply. Your point about context
sensitivity is of course correct. Assuming we're not worried about
context-sensitive cases, I still have a few questions ...
>This works pretty well:
>
>undef $/;
>$glob = <>;
>$glob =~ s/(\w)\-\n(\w+\S?)\s*/"$1$2\n"/eg;
>print $glob;
That's essentially what I came up with. My regex was (is)
s/(\w)-\n(\w)/\1\2\n/g;
Maybe I'm missing something by not including subsequent punctuation
(which is your \S? ?) and whitespace. I also didn't do the groovy
eval---does this serve any special purpose?
I'd still like to do this without undefining $/, though, since I want to
be able to operate on individual lines (as I think of them). For
example, I'd like $. to report line numbers, not paragraph numbers. I
know that one possible way to accomplish this is with two separate
loops, though this seems inefficient. Is there a better way?
Here's a seemingly awkward two-loop (and two-file) version, assuming the
open filehandles IN and TEMP:
$/ = "";
while (<IN>) { # clean up hyphens in paragraph mode
s/(\w)-\n(\w)/\1\2\n/g;
print TEMP;
}
$/ = "\n";
while (<TEMP>) { # operate on hyphen-free lines
chomp;
# print the line number and line that matches $pat
printf ("%4s: %s\n", $., $_) if /$pat/;
}
__END__
Thanks for any advice,
Jed
--
Jed Parsons: ``Lingua balbus, hebes ingenio
Harpsichordist, Classicist, Homebrewer. Viris doctis sermonem facio.''
mailto:jed@socrates.berkeley.edu -- Archipoeta
http://www.OCF.Berkeley.EDU/~jparsons/
------------------------------
Date: Wed, 05 May 1999 22:07:01 -0400
From: Bob Walton <walton@frontiernet.net>
To: Robert E Webb <bwebb@fred.net>
Subject: Re: Modulo
Message-Id: <3730F944.D9E75B4E@frontiernet.net>
Hmm...Standard C (Plauger & Brodie) states that the C operator % computes the
remainder. Perl (see perlop) states that it computes the modulus. These are
not the same thing. If you want perl to compute something like C does with
negative numbers, make the second one negative, not the first one. For example,
in perl:
1%-7
returns -6. The modulus of something base x (for x>0) is always a number from 0
to x-1, even if "something" is negative. This gives a nice progression from
negative through positive. For base 7, for example,
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
gives the sequence
4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3
when applied to x%7. The remainder function does not have this nice bit of
regularity, and so is not as useful for things like computing days of weeks
based on date differences, for example.
Robert E Webb wrote:
> Mathematicians out there I have a question. I am currently in a debate over
> the correct answer to the following: -6 % 7. Perl, and MS Excel give the
> answer of 1. PHP gives the answer of -6. I emailed the developer, and he is
> saying that -6 is correct...
>
> "-6 / 7 = 0, with a remainder of -6. There is no way to get 1 when modulus
> (x % y) is defined as the remainder of the integer division
> (x / y). That is the way it is defined in C, so that its the way it is
> defined in PHP. Perl and Microsoft Excel have obviously chosen
> some other definition for the result of (x % y). This is true in Excel, for
> example -- it defines MOD(x,y) to be x - y*INT(x/y), where INT(x) rounds
> down to the nearest integer. Proper integer division rounds towards zero."
>
> I am developing a calendar program using the formula's I found at the
> following url http://www.smart.net/~mmontes/ushols.html.
>
> In there the author says:
>
> "In all the below formula, the following common-sense relation is used: -1%7
> = 6; -2%7=5; .. -6%7=1, -7%7=0. Also, an N-day is a Sunday (N=0), through
> Saturday (N=6). "
>
> Does Perl use the same c libs? I am pretty sure the correct answer is 1, but
> I am not a mathematician. Can someone help clear this up?
>
> Thanks,
> Bob/
------------------------------
Date: Wed, 5 May 1999 17:00:43 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie question
Message-Id: <rhbqg7.j96.ln@magna.metronet.com>
Gabriel Richards (grichard@uci.edu) wrote:
: <metamorphon@hotmail.com> wrote in message
: news:372E4A1D.84F431DB@hotmail.com...
: > Is there a good book out there for beginners where I could learn Perl or
: > CGI on windows 95.
: I would suggest Perl 5 for Dummies. I'm new to Perl (and programming) too
: and I know all the Perl hackers are going to say that the book sucks and is
: full of bad advice, but this is just their ego talking.
Don't take the advice of professional programmers with years
of Perl experience.
Instead, take the advice of someone who has just learned
some Perl.
That's the ticket.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 5 May 1999 16:55:42 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie: how do I use modules locally?
Message-Id: <e8bqg7.j96.ln@magna.metronet.com>
Andy Georges (andy.georges@village.uunet.be) wrote:
: I hope this is the right place to ask this.
It is.
But it is not the right place to reask Frequently Asked Questions.
It is poor netiquette to post to a newsgroup without checking
the FAQ first.
: and I was told to install them locally, i.e. in the dir where my script
: resides.
: then how do I load them?
Perl FAQ, part 8:
"How do I keep my own module/library directory?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 05 May 1999 19:02:13 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: OReilly bullshit.... Camel logo trademark
Message-Id: <3730F825.C812469C@chatbase.com>
Matt Kruse wrote:
>
> I received this email today, with regard to
> http://mkruse.netexpress.net/perl/
>
> It's unfortunate that O'Reilly feels the need to control the web to this
> extent.
>
> For all of you who might have a camel on your Perl page, watch out.
> Big Brother is watching...
>
> I'm extremely disappointed in O'Reilly.
>
At the bottom of your page, you say:
"The use of a camel image with the topic of Perl is a registered
trademark of O'Reilly & Associates, Inc. Used with permission."
I guess not from the right person...
--
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
The Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm: http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!
------------------------------
Date: Wed, 5 May 1999 21:28:13 -0400
From: "Jim Phillips" <jphillips@va.campuscwix.net>
Subject: Re: Perl on NT workstation with PWS
Message-Id: <7gqr8m$eo1$1@news.campuscwix.net>
Brent,
Thanks. I went through everything I could find up there before I posted the
previous message with no luck. I am probably missing something real obvious
but I can't find it.
Thanks,
Jim Phillips
jphillips@tva.campuscwix.net
Brent Michalski wrote in message <3730AAEC.FEBF380A@technologist.com>...
>Give the FAQ's at http://www.activestate.com/activeperl a chance.
>They'll guide you step-by-step in getting your new system up and running
>in no time! Well, actually it will take you a few minutes...
>
>
>Good luck!
>BRent
>
>
>Jim Phillips wrote:
>>
>> I am developing a web site using Perl. I am running NT workstation,
Personal
>> Web Server and ActiveState Perl. I changed PC and have reset my project
on
>> my new computer. The problem I am having is ever Perl program I try to
link
>> to returns a HTTP error 404. I know I have probably not got something
right
>> in the setup because this was working on my old machine. Any ideas? Any
help
>> you could give me would be greatly appreciated.
>>
>> Jim Phillips
>> jphillips@tva.campuscwix.net
------------------------------
Date: 05 May 1999 19:09:53 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Please Help
Message-Id: <m1k8un7xu6.fsf@halfdome.holdit.com>
>>>>> "Steven" == Steven Scoleri <scoleri@rad.upenn.edu> writes:
Steven> while(<QUE>) {
Steven> ($name,$sex,$patient_id,$series_id,$image_number,$images_in_acq,$modality,$file)=split(":");
I bet $file has a newline on it. Stop that. chomp is your friend.
Steven> $x=$q->Read($file);
Yup. If it has \n, that's not gonna work.
--
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: Thu, 06 May 1999 01:26:38 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Q: Getting sendmail to work
Message-Id: <7gqqcf$2bg$1@oak.prod.itd.earthlink.net>
[ courtesy cc sent by mail if address not munged ]
jschneid@sienahts.edu (Jeff Schneider) wrote:
>On Sat, 01 May 1999 23:38:22 -0400, Amer Neely <aneely@odyssey.on.ca>
>wrote:
>
>Don't you need:
> $mailfrom="aneely\@odyssey\.on\.\ca";
no, especially the \c !!!
only the "@" has to be escaped.
------------------------------
Date: 05 May 1999 19:15:41 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: redirecting w/ apache and SSI
Message-Id: <m190b37xki.fsf@halfdome.holdit.com>
>>>>> "duke" == duke <duke@no.spam.ee> writes:
duke> : print a Location statement. The location statement is correct, but rather
duke> : than redirecting, it prints the URL of the place that I needed it to
duke> : redirect to.
duke> it's quite hard to answer without seeing the code. But it probably
duke> prints a "Content-type" header before the actual "Location" statement.
And that wouldn't matter. I've already answered privately.
--
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, 5 May 1999 17:50:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: regexp for matching IP address block
Message-Id: <MPG.119a87433fbdbb349899d7@nntp.hpl.hp.com>
In article <Yf5Y2.5935$ny.585199@typhoon-sf.snfc21.pbi.net> on Thu, 06
May 1999 00:21:12 GMT, Benjamin Franz <snowhare@long-lake.nihongo.org>
says...
...
+ if ($ip =~ m/^(((0*(25[0-5]|2[0-4]\d|1\d\d|\d\d?)\.){3}
+ 0*(25[0-5]|2[0-4]\d|1\d\d|\d\d?))|
+ ((0*25[0-5]|2[0-4]\d|1\d\d|\d\d?)\.
+ 0*(25[0-5]|2[0-4]\d|1\d\d|\d\d?)\.
+ (\d{1,4}|
+ [1-5]\d{1,9}|
+ 6[0-4]\d{3}|
+ 65[0-4]\d\d|
+ 655[0-2]\d|
+ 6553[0-6]))|
+ (0*(25[0-5]|2[0-4]\d|1\d\d|\d\d?)\.
+ (\d{1,7}|
+ 1[0-5]\d{6}|
+ 16[0-6]\d{5}|
+ 167[0-6]\d{4}|
+ 1677[0-6]\d{3}|
+ 16777[01]\d\d|
+ 1677720\d|
+ 1677721[0-5]))|
+ \d{1,9}|
+ [1-3]\d{9}|
+ 4[01]\d{8}|
+ 42[0-8]\d{7}|
+ 429[0-3]\d{6}|
+ 4294[0-8]\d{5}|
+ 42949[0-5]\d{4}|
+ 429496[0-7]\d{3}|
+ 4294967[01]\d{2}|
+ 42949672[0-8]\d|
+ 429496729[0-5])$/ox) {
Ahem. The /o is superfluous, because there is no interpolation in the
regex. <BIG GRIN>
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 06 May 1999 01:50:32 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: regexp for matching IP address block
Message-Id: <Iz6Y2.5978$ny.595215@typhoon-sf.snfc21.pbi.net>
In article <MPG.119a87433fbdbb349899d7@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>In article <Yf5Y2.5935$ny.585199@typhoon-sf.snfc21.pbi.net> on Thu, 06
>May 1999 00:21:12 GMT, Benjamin Franz <snowhare@long-lake.nihongo.org>
>says...
>...
>+ if ($ip =~ m/^(((0*(25[0-5]|2[0-4]\d|1\d\d|\d\d?)\.){3}
>+ 0*(25[0-5]|2[0-4]\d|1\d\d|\d\d?))|
>+ ((0*25[0-5]|2[0-4]\d|1\d\d|\d\d?)\.
>+ 0*(25[0-5]|2[0-4]\d|1\d\d|\d\d?)\.
>+ (\d{1,4}|
>+ [1-5]\d{1,9}|
>+ 6[0-4]\d{3}|
>+ 65[0-4]\d\d|
>+ 655[0-2]\d|
>+ 6553[0-6]))|
>+ (0*(25[0-5]|2[0-4]\d|1\d\d|\d\d?)\.
>+ (\d{1,7}|
>+ 1[0-5]\d{6}|
>+ 16[0-6]\d{5}|
>+ 167[0-6]\d{4}|
>+ 1677[0-6]\d{3}|
>+ 16777[01]\d\d|
>+ 1677720\d|
>+ 1677721[0-5]))|
>+ \d{1,9}|
>+ [1-3]\d{9}|
>+ 4[01]\d{8}|
>+ 42[0-8]\d{7}|
>+ 429[0-3]\d{6}|
>+ 4294[0-8]\d{5}|
>+ 42949[0-5]\d{4}|
>+ 429496[0-7]\d{3}|
>+ 4294967[01]\d{2}|
>+ 42949672[0-8]\d|
>+ 429496729[0-5])$/ox) {
>
>Ahem. The /o is superfluous, because there is no interpolation in the
>regex. <BIG GRIN>
>
Ah so! But you missed the actual *mistake* in the regex itself that
allows exactly one completely impossible value to pass the test. Can you
spot it?
--
Benjamin Franz
------------------------------
Date: 05 May 1999 19:13:41 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: SSI perl hit counter
Message-Id: <m1g15b7xnu.fsf@halfdome.holdit.com>
>>>>> "mikej" == mikej <mikej@1185design.com> writes:
mikej> Ive been trying to get this hit counter perl script to work on my page
mikej> but it will not print the hits to my page. I know I can use SSI because
mikej> I tried calling one of my other scripts from the same page and it
mikej> worked. Here is the source code I have for the perl:
mikej> #!/usr/local/bin/perl -w
mikej> $font_face = "Arial";
mikej> $font_size = "2";
mikej> print "Content-type: text/html\n\n";
mikej> open (count, 'counter.dat') || print "<font face=\"$font_face\"
mikej> size=\"$font_size\">cant open counter file</font>";
mikej> $new_num = <count>;
mikej> $new_num = $new_num + 1;
mikej> close (count);
mikej> open (count2, '>counter.dat') || print "<font face=\"$font_face\"
mikej> size=\"$font_size\">cant open counter file</font>";
mikej> print count2 "$new_num";
mikej> close (count2);
mikej> print "<font face=\"$font_face\" size=\"$font_size\">$new_num</font>";
Bleh.
use File::CounterFile;
my $number = File::CounterFile->new("/your/path/to/counter.dat",0)->inc;
print "Content-type: text/html\n\n<font face=ariel size=2>$number</font>";
Stop doing things the hard way.
--
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: 06 May 1999 04:03:59 +0200
From: Thomas Jespersen <thomas@daimi.au.dk>
Subject: Re: STDOUT ??
Message-Id: <y4nlnf354z4.fsf@bozeman.daimi.au.dk>
Jimx <jimx@metronet.com> writes:
> how do i print a location command after a content-type?
print "a location command after a content-type?"
------------------------------
Date: 05 May 1999 22:59:18 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: using $, (was Re: having problems)
Message-Id: <x7u2tqykc9.fsf_-_@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> ($,, $\) = ("\n", "\n"); print OUT @data }, });
>> i think those vars should be localized. it might change the
>> benchmark a tad. it would not be nice to have them changed
>> globally in a script!
LR> I deliberately didn't do it in the benchmark, to give you something to
LR> carp about. :-) If one or two localizations were noticeable compared
LR> to printing thousands of characters (even to /dev/null), I'd want to
LR> give up on Perl and use a 'real' language.
as if you don't enjoy using Carp yourself! :-)
>> this is the first time i have seen $, used for good and not for evil.
LR> It works exactly like join(), but for printing (and so does your trick).
LR> It is instructive, because the other approaches involve creating strings
LR> "$_\n" which requires copying of all the data. This approach doesn't.
what is interesting are the other benchmarks posted which show join is
still faster. so i wonder where $, would actually come in handy if you
could just replace the list in print with join( $, , <list of vals>)?
i imagine in some awkish -p or -n loop $, might be useful. has anyone
ever seen or used it in production code?
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 6 May 1999 01:36:11 GMT
From: warlock@eskimo.com (Jim Richardson)
Subject: Re: Whats wrong?
Message-Id: <slrn7ivmgj.il.warlock@gargoyle.myth>
On 04 May 1999 10:26:49 -0400,
Jonathan Feinberg, in the persona of <jdf@pobox.com>,
brought forth the following words...:
>warlock@eskimo.com (Jim Richardson) writes:
>
>> use backtics rather than single quotes would help :)
>>
>> ` rather than '
> ^ Hmm?
>
It's a single quote...
>--
>Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
>http://pobox.com/~jdf
--
Jim Richardson
www.eskimo.com/~warlock
All hail Eris
"Linux, where do you want to go tomorrow?"
------------------------------
Date: Wed, 05 May 1999 18:37:11 -0500
From: Todd Smith <tbsmith@viper.net>
Subject: Re: Whats wrong?
Message-Id: <3730D627.84E32690@viper.net>
Sam Holden wrote:
> On 02 May 1999 23:23:22 -0400, esalmon@packet.net <esalmon@packet.net> wrote:
> >How do I make the following systen command work? And possibly return the
> >results?
> >
> >$userid = 'whoami';
>
> You read the documentation in perlop and use the the quotes it says to use.
oh just answer the guy - it would only have taken two words - "use backticks."
>
>
> --
> Sam
>
> Perl was designed to be a mess (though in the nicest of possible ways).
> --Larry Wall
--
--------------------------
Todd Smith
-Just Another Perl Hacker
ITC^DeltaCom
tbsmith@deltacom.net
------------------------------
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 5576
**************************************