[11410] in Perl-Users-Digest
Perl-Users Digest, Issue: 5010 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 1 10:07:31 1999
Date: Mon, 1 Mar 99 07:00:43 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 1 Mar 1999 Volume: 8 Number: 5010
Today's topics:
arithmetic <michael.cameron@nospam.net.ntl.com>
Re: Array question. (Ronald J Kimball)
Re: Can I do this w/ Perl? (Ronald J Kimball)
FAQ 7.21: What's the difference between calling a funct <perlfaq-suggestions@perl.com>
FAQ 7.8: How do I declare/create a structure? <perlfaq-suggestions@perl.com>
Re: Getting a Unix script running on NT? <gellyfish@btinternet.com>
Re: Getting user ID and password in perl script <gellyfish@btinternet.com>
Re: Help, stop memory leak <gellyfish@btinternet.com>
Re: how do I wildcard within eq '***' ? <mig@isis.ie>
Re: how do I wildcard within eq '***' ? (Ronald J Kimball)
Re: how to make a character recognized without "enter" <gellyfish@btinternet.com>
Re: how to make a character recognized without "enter" (Ronald J Kimball)
Re: Image handling with Perl? (Clay Irving)
Re: Insert newline into long string <gellyfish@btinternet.com>
Re: Logging time on SUnix <gellyfish@btinternet.com>
Re: lwp client needs to accept cookies <jdhunter@nitace.bsd.uchicago.edu>
Re: Newbie : bash doesn't want to run my script ! kkivi@chat.ru
Re: Perl comment <jdf@pobox.com>
Re: Perl on Windows NT <ihm@allgemeine-kredit.de>
Re: perl open function <jdf@pobox.com>
Re: Perl REQUIRE question (Ronald J Kimball)
Re: Problem with opendir when running as CGI on NT!!!! <gellyfish@btinternet.com>
Re: regex poll results (Paul J. Schinder)
Re: regexp help <gellyfish@btinternet.com>
Re: sort a list returned from a subroutine (M.J.T. Guy)
Re: strip first character of string? (M.J.T. Guy)
Re: SYNTAX ERROR REVISITED (Ronald J Kimball)
Re: Test file <ihm@allgemeine-kredit.de>
Re: The truth about the Pentium III chip and ID --- **b <keith@cs.oswego.edu>
Re: The truth about the Pentium III chip and ID --- **b <johndoh@home.com>
Re: URGENT help required!! <zozulak@point.sk>
Re: Using a glob with sort (Larry Rosler)
Re: Using a glob with sort (M.J.T. Guy)
Re: Which IPC module do I need? (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 01 Mar 1999 13:58:12 +0000
From: Michael Cameron <michael.cameron@nospam.net.ntl.com>
Subject: arithmetic
Message-Id: <36DA9CF3.A1AD3FFE@nospam.net.ntl.com>
I have a problem where I have a string for which I want to calculate a
checksum. The checksum is defined (not by me) as the sum of longs in
network (big-endian) order with some padding if the number of bytes is
not a multiple of 4 (eg x becomes 000x).
I came up with the following but am convinced there is something
easier. Any suggestions?
sub CalcCheckSum {
# Calculate a checksum for a string as the sum of the 4 byte longs in
network (bi my ($buffer)=@_;
my ($buffer)=@_;
my ($count)=length($buffer);
my ($checksum)=0;
for ($i=0; $i < $count; $i += 4) {
if ($count - $i >= 4) {
$checksum=fix_overflow($checksum +
unpack("N",substr($buffer,$i,4)));
} else {
# if there is less than 4 bytes at the end of the string then pad them
with zeroes:
# eg x is 000x, xx is 00xx and xxx is 0xxx.
$checksum=fix_overflow($checksum + unpack("N", pack("B32", substr
(unpack("B32",substr
($buffer,$i,4)) . "0" x 32, 0, 32))));
}
}
return($checksum)
}
sub fix_overflow {
# I can't see a better way of doing this just now.
my ($x)=@_;
if ( $x > 0x7FFFFFFF ) {
$x -= 0xFFFFFFFF + 1
} elsif ( $x < -0x7FFFFFFF) {
$x += 0xFFFFFFFF - 1
}
return $x;
}
TIA,
Michael Cameron
Synteks Computing Ltd
------------------------------
Date: Sun, 28 Feb 1999 18:41:59 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Array question.
Message-Id: <1dny7nx.1ob1euj1i0wuquN@bay2-242.quincy.ziplink.net>
Larry Rosler <lr@hpl.hp.com> wrote:
> That is true, and similarly for a hash. No definition, or even
> declaration (without "use strict 'vars';"), is necessary. But using an
> undefined or uninitialized scalar does give warnings.
>
> This seems weird and scary, to me. Why is it so?
Because defined() does not currently have a useful or permanent meaning
for arrays and hashes, I expect. So an "undefined" array or hash is
equivalent to an empty array or hash. An empty array has well-defined
values in scalar and string contexts. In a scalar context, @ary is the
number of elements, which for an empty @ary is 0. In a string context,
@ary is join($", @ary), which for an empty @ary is ''. No uninitialized
values.
That's sort of just hand-waving, though. :-)
--
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-
------------------------------
Date: Sun, 28 Feb 1999 18:42:00 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Can I do this w/ Perl?
Message-Id: <1dny7ul.pwdg8rox63eoN@bay2-242.quincy.ziplink.net>
Ken <cant_take@thespam.com> wrote:
> I'm not going to ask users to write HTML. I just want them to fill in
> little boxes. What I want the data to do is stay right there in the
> box and not move! It should become a permanent part of the webpage.
I think you want to have one part of the page display the previously
entered data on the calendar, and another part of the page contain the
form for entering new data.
When the form is submitted, the input should be added to the previously
entered data in whatever file(s) you store it in.
When the page (with the form) is created, the data from the file(s)
should be read in and included in the page.
You might have a separate file for each date, or each month, or maybe
just one big file for all of eternity.
You could keep the file sorted, with new data inserted by date, or keep
the file unsorted, appending new data at the end and sorting each time
you read it in for display.
That should give you an idea of what your program needs to do.
--
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
perl -e'for(sort keys%main::){print if $$_ eq 1}
' -s -- -' Just' -' another ' -'Perl ' -'hacker
' http://www.ziplink.net/~rjk/ [rjk@linguist.dartmouth.edu]
------------------------------
Date: 28 Feb 1999 16:33:04 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 7.21: What's the difference between calling a function as &foo and foo()?
Message-Id: <36d9d230@csnews>
(This excerpt from perlfaq7 - Perl Language Issues
($Revision: 1.24 $, $Date: 1999/01/08 05:32:11 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq7.html
if your negligent system adminstrator has been remiss in his duties.)
What's the difference between calling a function as &foo and foo()?
When you call a function as `&foo', you allow that function access to
your current @_ values, and you by-pass prototypes. That means that the
function doesn't get an empty @_, it gets yours! While not strictly
speaking a bug (it's documented that way in the perlsub manpage), it
would be hard to consider this a feature in most cases.
When you call your function as `&foo()', then you *do* get a new @_, but
prototyping is still circumvented.
Normally, you want to call a function using `foo()'. You may only omit
the parentheses if the function is already known to the compiler because
it already saw the definition (`use' but not `require'), or via a
forward reference or `use subs' declaration. Even in this case, you get
a clean @_ without any of the old values leaking through where they
don't belong.
--
Heavy, adj.:
Seduced by the chocolate side of the force.
------------------------------
Date: 27 Feb 1999 08:02:22 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 7.8: How do I declare/create a structure?
Message-Id: <36d808fe@csnews>
(This excerpt from perlfaq7 - Perl Language Issues
($Revision: 1.24 $, $Date: 1999/01/08 05:32:11 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq7.html
if your negligent system adminstrator has been remiss in his duties.)
How do I declare/create a structure?
In general, you don't "declare" a structure. Just use a (probably
anonymous) hash reference. See the perlref manpage and the perldsc
manpage for details. Here's an example:
$person = {}; # new anonymous hash
$person->{AGE} = 24; # set field AGE to 24
$person->{NAME} = "Nat"; # set field NAME to "Nat"
If you're looking for something a bit more rigorous, try the perltoot
manpage.
--
As of next week, passwords will be entered in Morse code.
------------------------------
Date: 28 Feb 1999 23:29:12 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Getting a Unix script running on NT?
Message-Id: <7bcjg8$17e$1@gellyfish.btinternet.com>
On Wed, 24 Feb 1999 20:52:51 GMT Brent Singers wrote:
>
> 2) The mail thing. Obviously endmail is not an option - the server
> the scripts are being moved too has had Blat set up for him. Are
> there any differences between using this and sendmail?
>
You *can* get sendmail for NT - there is at least one commercially
supported version and there is one that is available from the MS ftp
site.
Blat is fairly dissimilar to sendmail - probably the easiest thing to
do it to run blat.exe from the command line to get the summary of its
options.
Possibly a better option if you are going to shift between NT and Unix is
to use on of the Mail::* modules as described in perlfaq9 - however this
comes with the caveat that you really do need to have a reliable SMTP
mail relay on your network.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 28 Feb 1999 22:56:51 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Getting user ID and password in perl script
Message-Id: <7bchjj$16f$1@gellyfish.btinternet.com>
On 26 Feb 1999 15:55:32 GMT Seshu Madhavapeddy wrote:
> Thanx for the info. But this does not seem to work. Earlier, I
> was trying getting the environment variable 'REMOTE_USER' which
> used to return nothing. The method 'remote_user' also returns
> nothing. Here is my code:
>
> use CGI;
> $query=new CGI;
> $userid = $query->remote_user();
> print "UserID:$userid\n";
>
> Is ther anything wrong with this?
>
>From the CGI man page:
remote_user ()
Return the authorization/verification name used for
user verification, if this script is protected.
^^^^^^^^^^^^^^^^^^^^^^^^^^^
So one would assume that unless access to your program is subject to
authentication then you cannot rely on this value being set. If you
want to cause the server to request user credentials then you will
have to discover how to do this from its documentation. There is also
an item on this in the CGI faq.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 28 Feb 1999 22:03:43 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Help, stop memory leak
Message-Id: <7bcefv$12b$1@gellyfish.btinternet.com>
On 26 Feb 1999 01:26:55 GMT NOSPAMjroy@Eng.Sun.COM wrote:
>
> Hi,
>
> I hope someone out there can help me. I'm running a
> 200Mhz pc, 128MB ram with the following software:
>
> windows nt4 service pack 1a
> sql server 6.5
> internet information server 2.0
> activestate's perl 507 distribution
>
Whatever the rest of the problem might be caused by - I would go for
Service Pack 4 and whatever the latest version of IIS4 - however this
is not really a Perl problem and if the problem doesnt go away after that
I would suggest that you ask in a group that knows about MS servers.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 1 Mar 1999 14:47:00 -0000
From: "Mig" <mig@isis.ie>
Subject: Re: how do I wildcard within eq '***' ?
Message-Id: <7be97s$1c6$1@news1.news.iol.ie>
Hi,
I've replaced it with the line you suggested below and ran 'perl -c' on the
file. It gives the error "/.*?\.aol$/: nested *?+ in regexp at line blah" .
Is there something slightly amiss here?
if ($ENV{REMOTE_HOST}=~/.*?\.aol$/i) {$HostRedirector =
"http://mydomain/aolusers.html"}
Also if I wanted to direct UK users to our UK web, how would I wildcard the
bit before '.uk' within the expression? Many thanks for your help.
Mig.
Philip Newton wrote in message <36DA99A4.64F65C3B@datenrevision.de>...
>Heiko Marschall wrote:
>>
>> > How do I modify the line below to accept a wildcard before 'aol.com' ?
I
>> > want to re-direct AOL users to another URL but, like most ISPs, the
front
>> > end changes dynamically. I can't simply put '*.aol' in there. Anyone
help?
>> >
>> > if ($ENV{'REMOTE_HOST'} eq 'aol.com') {$HostRedirector =
>> > "http://mydomain.com/aolusers.html}
>>
>> if ($ENV{REMONTE_HOST}=~/.*?\.aol$/i) {...}
> ^
>
>The $ at the end is wrong -- the address will, presumably, end in
>"aol.com", not just in "aol".
>
>Cheers,
>Philip
------------------------------
Date: Sun, 28 Feb 1999 18:42:01 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: how do I wildcard within eq '***' ?
Message-Id: <1dny8ix.14fn977znzhpyN@bay2-242.quincy.ziplink.net>
Mig <mig@isis.ie> wrote:
> if ($ENV{'REMOTE_HOST'} eq 'aol.com') {
if ($ENV{'REMOTE_HOST'} =~ /aol\.com$/) {
Refer to the perlre documentation.
--
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
perl -s -e'print sort grep { /\s/ } keys %main::
' -- -is -' Just' -' another ' -'Perl ' -'hacker
' http://www.ziplink.net/~rjk/ [rjk@linguist.dartmouth.edu]
------------------------------
Date: 28 Feb 1999 21:15:04 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: how to make a character recognized without "enter" ?
Message-Id: <7bcbko$121$1@gellyfish.btinternet.com>
On Sat, 27 Feb 1999 14:58:50 -0500 navid atoofi wrote:
> Hello:
>
>
> I have a program .It needs to recognize letters (e.g. "a", "b") without
> pressing "enter".
> Or in the other word It has to take action without pressing enter, Or
> recognize key stroke without enter.
>
The module Term::ReadKey available from CPAN will allow you to do this.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 28 Feb 1999 18:42:02 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: how to make a character recognized without "enter" ?
Message-Id: <1dny8lr.22l1xs1nhnmzpN@bay2-242.quincy.ziplink.net>
navid atoofi <natoofi@dac.neu.edu> wrote:
> I have a program .It needs to recognize letters (e.g. "a", "b") without
> pressing "enter".
> Or in the other word It has to take action without pressing enter, Or
> recognize key stroke without enter.
Or it has to read the perlfaq.
perlfaq5:
How can I read a single character from a file? From the keyboard?
You can find the answer with your Perl installation, or at
http://language.perl.com/nmanual/pod/perlfaq.html
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
perl -e'$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'
------------------------------
Date: 1 Mar 1999 09:11:39 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Image handling with Perl?
Message-Id: <slrn7dl80q.5as.clay@panix.com>
On Mon, 01 Mar 1999 14:25:02 +0100, Magnus Flysjo
<Magnus.Flysjo@emw.ericsson.se> wrote:
>Does anyone know any freeware script that can
>create charts from some kind of database files?
>
>Or does anyone know any script that
>can create GIF/JPG files?
Check the `graphics' section of Perl Reference:
http://reference.perl.com/query.cgi?graphics
--
Clay Irving <clay@panix.com>
Mediocrity requires aloofness to preserve its dignity.
- Charles G. Dawes
------------------------------
Date: 28 Feb 1999 23:16:06 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Insert newline into long string
Message-Id: <7bcinm$16r$1@gellyfish.btinternet.com>
On Wed, 24 Feb 1999 21:50:34 GMT Sun Qinghe wrote:
> A few weeks I asked a question: how can I insert a newline at certain intervals
> in a long string. One of your great guys replied: Use
>
> $longstring =~ s/.{0,70}/$1\n/g;
>
> That is rather good. But I met a new problem: sometimes it simply insert
> a newline in the middle of a word. How can I avoid this ?
>
> Any help will be appreciated !
>
Somewhat simplemindedly:
$longstring =~ s/(.{0,70}) +/$1\n/g;
But of course you really want to be using Text::Wrap if you want to do it
nicely.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 28 Feb 1999 22:44:37 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Logging time on SUnix
Message-Id: <7bcgsl$161$1@gellyfish.btinternet.com>
On 25 Feb 1999 15:20:30 -0500 Shapeshifter wrote:
> Hallo,
>
> I have an account on our school Unix system. Does anyone know of a method
> of logging time spent on a Unix system throught Perl? I'd like to be able
> to see my total time online for the day, week, and month. It's a
> glorification of the "last" command, essentially. If you have any ideas,
> please let me know!
>
If you want to implement 'last' in Perl then you might look at a small
script I posted here in response to a request for implementation of 'who'
in Perl - on my system it would simply read /var/log/wtmp rather than
/var/run/utmp, however on other systems it might work differently.
Of course this may not give you the type of information you want - you
might want to look at implementing process accounting.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 27 Feb 1999 15:42:09 GMT
From: John Hunter <jdhunter@nitace.bsd.uchicago.edu>
Subject: Re: lwp client needs to accept cookies
Message-Id: <1rsobr97la.fsf@cace.bsd.uchicago.edu>
My apologies; I should have read deja news first! In any case, I have
since read deja news and am now using HTTP::Cookies and LWP::UserAgent
and still am encountering the problem. Here is a script which
replicates the problem:
#!/usr/bin/perl -w
use LWP::UserAgent;
use HTTP::Cookies;
my $url = 'http://ojps.aip.org/journal_cgi/getpdf?KEY=PRLTAO&cvips=PRLTAO000077000019004098000001';
open(PDF_FILE, ">temp.pdf");
my $ua = new LWP::UserAgent;
$ua->agent("$0/0.1 " . $ua->agent);
my $req = new HTTP::Request 'GET' => "$url";
$req->header('Accept' => 'text/html');
# send request
my $cookie_jar = HTTP::Cookies->new;
$cookie_jar->add_cookie_header($req);
my $res = $ua->request($req);
$cookie_jar->extract_cookies($res);
$cookie_jar->save("temp.cookie");
# check the outcome
if ($res->is_success) {
print PDF_FILE $res->content;
} else {
print "Error: " . $res->status_line . "\n";
}
Thanks again for any advice,
JDH
------------------------------
Date: Sat, 27 Feb 1999 14:14:12 GMT
From: kkivi@chat.ru
Subject: Re: Newbie : bash doesn't want to run my script !
Message-Id: <7b8ujf$d78$1@nnrp1.dejanews.com>
In article <7b6upl$r8k$1@front5.grolier.fr>,
"Patrick Fichou" <fichou@club-internet.fr> wrote:
> Hi,
>
> Bash answers : unknown command os something like that...
>
> Patrick
Patrick, why don't you bother to reproduce
bash's answer exactly, while about half a dozen people
are trying to help you? Why don't you read the faq? I bet the answer
is on the first two pages.
what is the output of "which perl" command?
does it match your #!/tra-la-la statement?
what your script permissions (did you try chmod +x your_script)?
Is current directory in the path?
Isn't you program called 'test' (I think not)
does perl work at all? can you run "perl your_script"
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 27 Feb 1999 10:28:42 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: dubing@lisco.com
Subject: Re: Perl comment
Message-Id: <m3n21zsw5x.fsf@joshua.panix.com>
dubing@lisco.com writes:
> Is there any easy way to comment out a block of Perl code (like how
> /*....*/ is used in C) instead of putting '#' at the beginning of
> each line line by line?
You can use pod directives (perldoc perlpod), but I wouldn't recommend
it. Any reasonable text editor will make it a no-brainer to prepend
an octothorpe [heh] to each line in a selected region.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 1 Mar 1999 14:57:12 +0100
From: "Marc-Oliver Ihm" <ihm@allgemeine-kredit.de>
Subject: Re: Perl on Windows NT
Message-Id: <7be6jn$urg$1@news.online.de>
Term::ReadKey should allow you to control your terminal (raw, cbreak,
noecho, etc.)
I don't knwo if there is a solution without ...
regards, Marc-Oliver Ihm
Jean-Daniel Bonjour schrieb in Nachricht <36DA5311.F209436C@epfl.ch>...
>Within a Perl script written on Windows NT4 (using ActiveState Perl),
>I want to enter a pasword without echoing the password-string
>on the Command-Prompt Window (DOS Window).
>
>On Unix, the solution is to execute a "stty -echo" before reading
><STDIN>, and a "stty echo" after reading <STDIN>, like that :
>
> system "stty -echo" ;
> print "Enter password : " ;
> chomp ($password = <STDIN>) ;
> system "stty echo" ;
>
>So, how can I get the same result on Windows NT ?
>( using Windows commands equivalent to "stty -echo" ??? )
>
>---
>Jean-Daniel BONJOUR (Jean-Daniel.Bonjour@epfl.ch)
>SI-DGR, EPFL
>CH-1015 Lausanne
------------------------------
Date: 27 Feb 1999 10:42:33 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: RS <rajshreesankaran@hotmail.com>
Subject: Re: perl open function
Message-Id: <m3k8x3sviu.fsf@joshua.panix.com>
RS <rajshreesankaran@hotmail.com> writes:
> $DIR = E:\\Inetpub\\dir1;
This shouldn't even compile.
> open (WR, ">$DIR\\reg.htm$VAR1") || die "cannot open reghtmval";
Your error message is unhelpful to you. First, you'd better *prove*
that $VAR1 contains something meaningful.
my $path = "$DIR\\reg.htm$VAR1";
print "\$path is <$path>\n"; #debug
open(WR, "> $path") || die "Can't write $path: $!\n";
Also, using backwhacks as path separators leads to mental confusion.
Forward slashes work just dandy under NT, and you don't have to worry
about interpolation.
open(CRUFT, 'c:/windows/system32/universe.ini') || die ...
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sun, 28 Feb 1999 18:42:03 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl REQUIRE question
Message-Id: <1dny8rt.1gz5eh01je4sfaN@bay2-242.quincy.ziplink.net>
John <john@terminalreality.com> wrote:
> Newsgroups: comp.lang.perl,comp.lang.perl.misc
comp.lang.perl is dead! Long live comp.lang.perl.misc!
> How does the Perl REQUIRE function work? Is the file listed in the require
> function loaded when the line that contains the REQUIRE function is reached
> or as soon as the PERL file that contains the REQUIRE function is loaded?
'require' is a run-time directive. The file will be loaded when the
'require' statement is reached during the program's execution.
A related statement, 'use', is a compile-time directive. With 'use',
the file will be loaded while the script is being compiled.
> The reason I ask is that I was wondering if I could speed up the
> performance of a perl script by not having the whole script loaded at
> once. If I break up the script into commonly used and non-commonly used
> parts and if I only load the parts that are in demand it might speed
> things up???
Yes, you could definitely do that. You might want to look into
AUTOLOAD, a standard way for loading parts only when needed.
Refer to the perlsub documentation and the AutoLoader module.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 28 Feb 1999 21:26:30 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Problem with opendir when running as CGI on NT!!!!
Message-Id: <7bcca6$124$1@gellyfish.btinternet.com>
On Fri, 26 Feb 1999 19:25:24 GMT Gregg Seiler wrote:
> I'm getting a message in the log file (running a perl script as CGI on
> a web server). Here's the message:
>
> *** 'D:\html\bkcomputerscom\html\cgi-bin\bkerror.pl' error message at:
> 1999/02/24 19:23:38
> Undefined subroutine &main::opendir called at
> D:\html\bkcomputerscom\html\cgi-bin\bkerror.pl line 7.
>
> That's right. Undefined subroutine "opendir"!
>
Hmm. Does your script work from the command prompt ? There doesnt
appear to be anything particularly wrong with it that I can see and
opendir is a builtin that has been in Perl since the dawn time (or my
remembrance) so I would doubt it to be a version problem. It might
be some typo that isnt in your example.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 27 Feb 1999 15:10:04 GMT
From: schinder@leprss.gsfc.nasa.gov (Paul J. Schinder)
Subject: Re: regex poll results
Message-Id: <7b91sc$1he$1@callisto.clark.net>
In <7b8n2u$k1n$1@client2.news.psi.net> abigail@fnx.com (Abigail) writes:
>Uri Guttman (uri@home.sysarch.com) wrote on MMVI September MCMXCIII in
><URL:news:x7d82wgs8h.fsf@home.sysarch.com>:
>##
>## 5.005_03 2
>Over 5% of the responders uses a non-existing version of Perl?
It exists:
linux% perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
Platform:
osname=linux, osvers=2.1.127, archname=ppc-linux
[snip]
Characteristics of this binary (from libperl):
Locally applied patches:
MAINT_TRIAL_5 - 5.005_03 maintenance trial 5
Built under linux
>Abigail
>--
--
Paul J. Schinder
NASA Goddard Space Flight Center
schinder@leprss.gsfc.nasa.gov
------------------------------
Date: 28 Feb 1999 21:10:41 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: regexp help
Message-Id: <7bcbch$11u$1@gellyfish.btinternet.com>
On Sun, 28 Feb 1999 19:18:43 GMT Mark P. wrote:
> Well, yeah, not trying to, but the documentation for URL.pm seems to
> be lacking in examples. It would be nice to get a few examples and
> then I would have no problems.
> URL.pm shows how to get a relative URL, but when I try to do it like
> this, it shows the full url.
>
> $file = "$url->rel($ENV{'HTTP_REFERER'})";
>
> I know its because I'm using the module wrong, but without
> proper documentation including examples, its hard for a non-programmer
> like me to pick up on it. Given a few examples I can pretty much
> handle it.
>
If I get meaning of your original post right then this little snippet
should get you going:
#!/usr/bin/perl
use URI::URL;
my $url = new URI::URL 'http://localhost/manual/index.html';
my @path = $url->path_components();
@path[$#path] = 'index.txt';
$url->path_components(@path);
print $url->as_string,"\n";
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 27 Feb 1999 14:58:32 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: sort a list returned from a subroutine
Message-Id: <7b916o$ehi$1@pegasus.csx.cam.ac.uk>
Steve van der Burg <steve.vanderburg@lhsc.on.ca> wrote:
>use strict;
>
>sub blah {
> my @things = ( 5,4,3,2,1 );
> return @things;
>}
>
>foreach ( sort blah() ) {
> print "thing: $_\n";
>}
>
>After a bit of experimentation, and running with perl -w (which reported
>nothing), it finally occurred to me that sort was using blah() as its
>comparison routine.
>
>Also, the only way I can find to fix this is to explicitly define a sort
> sort { $a <=> $b } blah()
>which defeats my ability to get sort's default behaviour.
Err... sort's default behaviour is 'cmp', not '<=>'.
And my preferred disambiguation is to insert a '+':
foreach ( sort +blah() ) {
Mike Guy
------------------------------
Date: 27 Feb 1999 15:14:04 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: strip first character of string?
Message-Id: <7b923s$fc0$1@pegasus.csx.cam.ac.uk>
Steven T. Henderson <stevenhenderson@prodigy.net> wrote:
>$blah =~ s/^.//
That won't work if the first character is "\n".
Add a /s modifier.
Mike Guy
------------------------------
Date: Sun, 28 Feb 1999 18:42:05 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: SYNTAX ERROR REVISITED
Message-Id: <1dny8yu.3jv8r2mhpcxcN@bay2-242.quincy.ziplink.net>
J. Daniel Paxton <paxtond@ix.netcom.com> wrote:
> syntax error in file WPS2.cgi at line 3, next 2 tokens "use DB_File"
> syntax error in file WPS2.cgi at line 29, next token "or"
You're executing this script with perl4, which included neither 'use'
nor 'or' as parts of the language.
> #!/usr/local/bin/perl -w
Ask your sysadmin whether perl5 is installed on your system, and if so,
what the path to it is.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
perl -le 'print "Just another \u$^X hacker"'
------------------------------
Date: Mon, 1 Mar 1999 14:52:01 +0100
From: "Marc-Oliver Ihm" <ihm@allgemeine-kredit.de>
Subject: Re: Test file
Message-Id: <7be69s$uom$1@news.online.de>
-e "Filename"
will evaluate to true, if "Filename" exists.
Other options for testing files can be found through "man perlfunc"
regards, Marc-Oliver Ihm
Antsnio Almeida schrieb in Nachricht <7be0jn$phi$1@sagan.global-one.pt>...
>How can i test the existence of a file ?
>
>Thank you.
>
>
------------------------------
Date: Sun, 28 Feb 1999 18:41:21 -0500
From: "Kano" <keith@cs.oswego.edu>
Subject: Re: The truth about the Pentium III chip and ID --- **boycott info**
Message-Id: <7okC2.5036$r7.6986@newsr2.twcny.rr.com>
Oh come on. Many other standard devices (ethernet cards, for example) have their
own unique serial numbers that software can use at will. Get over it.
-kl
Boycott Swintel <swintel@badchips.com> wrote in message
news:36ddc0ca.4718754@news.earthlink.net...
>Take the Pentium III Boycott Survey
>http://mail.infotrieve.com/isurvey/index.cfm?vendorid=6045&formid=F0006045
>
>
> Pentium III chip with the individual serial number that can
>track your web surfing and buying habits can now have the ID number
>turned on and off by software. Following some links I found the
>www.fightdivx.com website and noticed that they have a Intel Boycott
>page with links, quotes and info on why you should boycott the
>invasion of privacy Pentium III chips. Just like everyone suspected,
>the ID number can be taken without a customers knowledge. Just like
>cellular phone fraud, once someone has your unique ID number, they
>could pose as you on the internet. Do not be fooled by reports that
>this problem is fixed because Intel disabled this feature by software
>on their up coming chips. Information is power. They want to know
>your surfing and buying habits. That is what this is all about. Here
>is the link to the page with the boycott info and links.
>
>http://www.fightdivx.com/intelboycott.htm
>
>Also you will find a Boycott Intel screen saver and banner on their
>page above. Spread it around.
>
>
>
>
>
>
>
------------------------------
Date: Sun, 28 Feb 1999 23:50:15 GMT
From: JoHn DoH <johndoh@home.com>
Subject: Re: The truth about the Pentium III chip and ID --- **boycott info**
Message-Id: <36D9D5CE.D39B0338@home.com>
I beg to differ but MAC addressess are not made for spying on us they
are for network location and such. No on knows that I own a certain
MAC address (unlike Intel that wants you to register after getting the
PIII). I think it is a bad move on intel's part but those that accept
it are doomed to get shafted. Your ass not mine (I will keep my PI any
day running). Sorry for the crossposting just got a little annoyed and
wanted it to be righted in all places of being.
-DoH
Kano wrote:
>
> Oh come on. Many other standard devices (ethernet cards, for example) have their
> own unique serial numbers that software can use at will. Get over it.
>
> -kl
>
> Boycott Swintel <swintel@badchips.com> wrote in message
> news:36ddc0ca.4718754@news.earthlink.net...
> >Take the Pentium III Boycott Survey
--
JoHn 'DoH' KeLm
http://www.johndoh.cjb.net
"People are too stupid to realize they are" - DoH
------------------------------
Date: Mon, 1 Mar 1999 15:01:37 +0100
From: "Peter Zozulak" <zozulak@point.sk>
Subject: Re: URGENT help required!!
Message-Id: <7be6k9$nir@gringo.somi.sk>
Richard Partridge wrote in message <36da9341.0@nnrp1.news.uk.psi.net>...
>
>I want my perl script to open a data file on a seperate webserver...
>so I thought I could use something like
>
>(filehandle,">> http://www.somewhere.com/cgi-bin/datafile.txt");
>
>Is this legal perl as it doesn't seem to be working for me.....
>
>Regards
>
>Richard
>
>r.partridge@dewnters.com
>
>
no way this way !!! It'll not work (for sure)
You have to look at FTP (maybe something else)
Peter
------------------------------
Date: Sat, 27 Feb 1999 07:00:54 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Using a glob with sort
Message-Id: <MPG.1141a8773b008e8e9896a3@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <F7tBLG.JBw@world.std.com>, on Sat, 27 Feb 1999 12:20:04 GMT
aml@world.std.com says...
...
> {
> local(*sub_sort);
> die "Invalid sort criteria\n" unless exists $sortroutines{$sortby};
> *sub_sort = $sortroutines{$sortby};
> @sorted = sort sort_sub keys %students;
> }
>
> Much more efficient than Larry Rosler's suggestions, which perform a
> extra dereference for each comparision. (I wonder why he posted a URL
> to a thread in Deja News and only repeat the slowest solutions?)
In one word, forgetfulness! <blush> More explicitly, your post
<URL:http://x10.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=401799053>
didn't stick in my head. I have yet to play symbol-table typeglob games
in my own code, so I simply didn't 'learn' the technique. Maybe now I
will.
Your post (on October 16, 1998, almost a week after the rest of the
thread) is short enough to warrant repeating once again here:
lr@hpl.hp.com (Larry Rosler) writes:
>my $sortsub = eval "sub { $sorteq }"; # Note double-quotes to cause
> # substitution here for $sorteq.
># Now 'sortsub' points to the equivalent of your sort comparison.
>print sort { &$sortsub } 'a' .. 'z', "\n";
A simple optimization on this, which will avoid the overhead a
coderef dereference on every comparison would be:
{
# temporarily define a subroutine named "sortsub"
local(*sortsub) = eval "sub { $sorteq }";
# and give that name as the comparison routine.
print sort sortsub 'a' .. 'z', "\n";
}
--
Andrew Langmead
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 27 Feb 1999 15:22:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Using a glob with sort
Message-Id: <7b92iq$frv$1@pegasus.csx.cam.ac.uk>
Larry Rosler <lr@hpl.hp.com>, quoting Andrew Langmead quoting Larry Rosler
wrote:
>
>A simple optimization on this, which will avoid the overhead a
>coderef dereference on every comparison would be:
>
>{
> # temporarily define a subroutine named "sortsub"
> local(*sortsub) = eval "sub { $sorteq }";
> # and give that name as the comparison routine.
> print sort sortsub 'a' .. 'z', "\n";
>}
If you're in the optimisation business, what's that eval "" doing there?
Make it just
local *sortsub = sub { whatever };
Mike Guy
------------------------------
Date: Sun, 28 Feb 1999 18:42:06 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Which IPC module do I need?
Message-Id: <1dny926.drp1l7heq857N@bay2-242.quincy.ziplink.net>
Wade T. Funk <wfunk@dev.tivoli.com> wrote:
> I am wanting to use the 'open3' function but don't have an IPC module.
> Which one do I need, what is it called and where can I get that?
The module is IPC::Open3, and is included in the standard Perl
distribution. It should already be on your system.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
perl -e 'for(@ARGV){require $_;print "$_\n $INC{$_}\n"}' IPC/Open3.pm
------------------------------
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 5010
**************************************