[16370] in Perl-Users-Digest
Perl-Users Digest, Issue: 3782 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 24 00:05:46 2000
Date: Sun, 23 Jul 2000 21:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964411510-v9-i3782@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 23 Jul 2000 Volume: 9 Number: 3782
Today's topics:
? User Agent for Pocket IE ? <uctraing@ultranet.com>
Re: ? User Agent for Pocket IE ? <phill@modulus.com.au>
capturing STDERR for later (in an END) processing <jsalmon@thesalmons.org>
Re: Existence of a file on the web server (Abigail)
HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED?? (David Combs)
login help <lihock@pc.jaring.my>
Re: looking to learn perl (Tad McClellan)
Re: LWP::UserAgent Part of Response Missing dcumro@my-deja.com
matching contents of array <scrampton71NOscSPAM@hotmail.com.invalid>
Re: matching contents of array <mbudash@sonic.net>
Re: matching contents of array <scrampton71NOscSPAM@hotmail.com.invalid>
Re: matching contents of array (Tad McClellan)
Re: MySQL and Perl problems dcumro@my-deja.com
Re: NT4-IIS-MSSQL7 <eyalb@aks.com>
Perl 6 page updated (brian d foy)
Re: perl v. tcl <ivler@basecamp1.netquest.net>
Re: perl v. tcl (Cameron Laird)
Re: perl v. tcl (Cameron Laird)
Re: Question on hashes... (Tad McClellan)
Re: Read a file into a hash ? (Abigail)
Re: reading binary and sending it to client browser... <kevinfal+clpm@seas.upenn.edu>
Re: reading binary and sending it to client browser... <uri@sysarch.com>
Re: secure auth trick (Abigail)
Re: secure auth trick <flavell@mail.cern.ch>
string replacement <suj_h@yahoo.com>
Re: string replacement <care227@attglobal.net>
Re: string replacement (Abigail)
Why won't "use strict;" work? (BUCK NAKED1)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 23 Jul 2000 19:27:28 -0400
From: Bob <uctraing@ultranet.com>
Subject: ? User Agent for Pocket IE ?
Message-Id: <6qvmnsgqr5gccmqb09q6alb3do237k82rl@4ax.com>
Anyone have a pointer to where I can get a sample of the
browser ID / User Agent string(s) for "Pocket PC" IE browser ?
I've search around the MS/MSDN site but I can't seem to find a
specific reference to it.
thanks,
bob
------------------------------
Date: Mon, 24 Jul 2000 10:33:14 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: ? User Agent for Pocket IE ?
Message-Id: <397B8ECA.3F69@modulus.com.au>
Bob wrote:
>
> Anyone have a pointer to where I can get a sample of the
> browser ID / User Agent string(s) for "Pocket PC" IE browser ?
>
> I've search around the MS/MSDN site but I can't seem to find a
> specific reference to it.
>
> thanks,
> bob
Try
http://www.cyscape.com/browscap/
hth
--
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/
------------------------------
Date: 23 Jul 2000 15:24:26 -0700
From: John Salmon <jsalmon@thesalmons.org>
Subject: capturing STDERR for later (in an END) processing
Message-Id: <m3bszozdr9.fsf@gw.thesalmons.org>
I am writing a perl script intended to be run via cron. I'd like to
capture the STDERR of the script and any system() or `backtick`
invocations it may perform, and ultimately deliver them to some channel
other than stderr (email, syslog, whatever).
I've appended my current best effort. I redirect STDERR to a tempfile
in a BEGIN block and then rewind it and read it all back in an END
block. The example delivers the output to stderr, but it's clear that
more logic can be added once the END block has @stderrlines in hand.
It works reasonably well, but there are some nagging difficulties:
- the result of "print STDERR "perl to STDERR\n"; appears out of order
in the output. Why didn't calling $stderrfh->autoflush fix this?
- the die argument never appears? I can probably fix this by installing
a $SIG{__DIE__} handler but I'm curious what is going on behind the scenes
that prevents the die() output from being captured in $stderrfh?
- syntax errors or other complaints from perl itself don't show up. For
example, if I uncomment the '#use NotAModule;' line, I don't see anything
in the output. Similarly, if I introduce a syntax error somewhere in the
script.
[jsalmon@gw pull]$ stderr.pl
END - captured STDERR:
system to stderr
backtick to stderr
open to stderr
perl to STDERR
[jsalmon@gw pull]$ cat stderr.pl
#!/usr/local/bin/perl
# Experiment with how to capture stderr
use IO::File;
BEGIN{
my $stderrfh = IO::File::new_tmpfile()
or die "Could not create new_tmpfile: $!\n";
my $stderrfd = $stderrfh->fileno;
$stderrfh->autoflush(1);
close STDERR;
open STDERR, "+>&$stderrfd"
or die "could not open temporary stderr: $!\n";
}
#use NotAModule;
print STDERR "perl to STDERR\n";
system('echo system to stderr 1>&2');
`echo backtick to stderr 1>&2`;
open ECHO, "echo open to stderr 1>&2 |";
while(<ECHO>){}
close ECHO;
die "Die! Die! Die!\n";
exit 0;
END{
seek STDERR, 0, 0;
@stderrlines = <STDERR>;
# ... maybe send @stderrlines to a mailing list, syslog, etc., e.g.,
if( $? ){
print "END - captured STDERR:\n";
print @stderrlines;
}
}
[jsalmon@gw pull]$
------------------------------
Date: 23 Jul 2000 21:23:45 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Existence of a file on the web server
Message-Id: <slrn8nn6ks.vcg.abigail@alexandra.foad.org>
Scott Cale (uo780@vtn1.victoria.tc.ca) wrote on MMDXVIII September
MCMXCIII in <URL:news:397b58e8@news.victoria.tc.ca>:
|| I need to write a little script that will check a url for the existence of
|| a file _without_ actually downloading it. The server won't allow directory
|| listing so I can't just do that :-(
||
|| I tried this...
||
|| use LWP::Simple;
||
|| $url = 'http://www.myserver.com/myfile.exe';
||
|| print "File: ", $url, "\n";
||
|| if ( head( $url ) ){
|| print "Exists\n";
|| } else {
|| print "DnE\n";
|| }
||
|| But it always says the file's there even when I know that it's not. How
|| can I get the information I need? Please help
1) This is not a Perl question.
2) The HTTP protocol doesn't care about files. URLs point to resources,
and it's up to the server to determine the policy to deliver the resource.
3) This is not a Perl question.
4) You ask the server a meta question. You got an answer.
5) This is not a Perl question.
6) RFC 2068.
7) This is not a Perl question.
Did I mention that you don't have a Perl question?
Abigail
--
New email address: abigail@foad.org
------------------------------
Date: 24 Jul 2000 01:44:53 GMT
From: dkcombs@netcom.com (David Combs)
Subject: HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED??
Message-Id: <8lg72l$p3h$1@slb0.atl.mindspring.net>
One syntax (the "standard perl shortcut-syntax for hashes") produces
runtime UNDEFINED error,
, while long-winded explicit deref-of-hashREF + taking a
ref to THAT -- DOES work!
What, please, am I doing wrong?
------- THIS OUTPUT:
[1]: at A
[1]: at B
[1]: at C
[1]: at D: $ref($theWRAINrecordsAryRef) = ARRAY
[1]: at E
[1]: at F
[1]: at G: NOTE: This IS "as expected": $ref($recordHashRef) = HASH
[1]: at G3
Print hash contents via 'each'-loop:
lastName => the lastName2
wholeName => the wholeName2
firstName => the firstName2
emailAddr => the emailAddr2
curLine => the curLine2
[1]: at G5
[1]: at H
[1]: WORKS OK!!!: NOW, TRY FOR x=>{curLine}: "the curLine2"
ERROR!!: in dQuoteit(), $arg1=shift IS UNDEFINED!!!
Use of uninitialized value in concatenation (.) at test4-19jul00.pl line 73.
[1]: FAILS!!!: ""
[1]: at I
[1]: at J
---- COMES FROM THIS PIECE OF CODE:
print(STDERR "[$i]: at F\n");
$recordHashRef = $theWRAINrecordsAryRef->[$i];
# NOTE THIS: says that it IS a REF (to a HASH -- just what we expect!):
print(STDERR "[$i]: at G: NOTE: This IS \"as expected\": \$ref(\$recordHashRef) = ", ref($recordHashRef), "\n");
print(STDERR "[$i]: at G3\n");
# ---------
# THIS WORKS OK!!:
print("Print hash contents via 'each'-loop:\n");
my ($k, $v);
while ( ($k, $v) = each %$recordHashRef ) {
print( " $k => $v\n") } # end-while
print("\n");
# ---------
print(STDERR "[$i]: at G5\n");
if (! defined($recordHashRef->{curLine})) {
print(STDERR "OOPS!!: ERROR!!: ! defined(\$recordHashRef->{curLine}); thus I do a NEXT!\n");
next; }
print(STDERR "[$i]: at H\n");
# NEXT LINE WORKS OK!!
print(STDERR $indentStr, "[$i]: WORKS OK!!!: NOW, TRY FOR x=>{curLine}: ",
dQuoteIt(%{$recordHashRef}->{"curLine"}), "\n");
# BUT NOT THIS ONE!!!!!: "Use of uninitialized value in print at test4-19jul00.pl line 261.":
print(STDERR $indentStr, "[$i]: FAILS!!!: ", dQuoteIt($recordHashRef->{curline}), "\n");
print(STDERR "[$i]: at I\n");
print(STDERR "[$i]: at J\n");
--- Oh, here is my dQuoteIt() (used above):
sub dQuoteIt($) {
my $arg1 = shift;
print(STDERR "ERROR!!: in dQuoteit(), \$arg1=shift IS UNDEFINED!!!\n")
if ! defined($arg1);
"\"$arg1\""; #ie, return("\"$arg1\"");
}
------------------------------
Date: Mon, 24 Jul 2000 10:39:25 +0800
From: "han" <lihock@pc.jaring.my>
Subject: login help
Message-Id: <8lga9m$q7f$1@news6.jaring.my>
Hi everyone...
i have a problem in doing the login form
what i need to do is
first i have a login screen
then after i enter the correct username and password...
my authorisation become true......
if my authorisation become true then i can access to the restricted pages..
but now i cant pass the variable(authorisation) to every page so that the
restricted pages that visited can indicated that my authorissation is true..
it is something like Session in asp but since i'm very new and fresh in cgi
and perl
so i dont know how to code them
so anyone out there can help me or giving me some code to refer?
Thank A lot..
------------------------------
Date: Sun, 23 Jul 2000 21:56:29 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: looking to learn perl
Message-Id: <slrn8nn8id.6gr.tadmc@magna.metronet.com>
On Sun, 23 Jul 2000 19:56:34 GMT, tltt@my-deja.com <tltt@my-deja.com> wrote:
>John Callender <jbc@west.net> wrote:
>--- snip ---
>> Unfortunately, Tom C. is no longer actively involved in this
>> newsgroup, nor does he seem to be doing much Usenetting at all,
>> at least within the limits of my ability to hunt down his
>> writings. I asked him at TPC if there was any chance of his
>> coming back here, and the answer was pretty much, "No, not ever.
>
>I haven't been reading this newsgroup for very long, so I don't know the
>story. What happened with Tom Christiansen that made him so bitter?
Who can know what another person feels or thinks?
We can't know why, unless Tom tells us...
I feel confident in *guessing* that a significant component
was the lack of normal netiquette on this newsgroup.
People won't spend 10 minutes searching the standard docs on
their hard drive before posting.
Posting already answered questions hurts this entire community.
And there are *dozens* of those each and every day!
After tens of thousands of repetitions (and that is only _one_
year's worth) of the same questions, you wear out.
And it seems unlikely to change back to the way it is supposed
to be, so a "not ever" response is not surprising. :-(
So, post a FAQ and drive yet more Question Answerers away...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 23 Jul 2000 23:40:48 GMT
From: dcumro@my-deja.com
Subject: Re: LWP::UserAgent Part of Response Missing
Message-Id: <8lfvq0$jhg$1@nnrp1.deja.com>
Hi
try replacing line :$req->content($parameters);
with: $req->content
("PARAM1=VALUE1&PARAM2=VALUE2");
Dennis L. Cumro
In article <38F5F7BD.F20D68ED@chello.nl>,
Declan Kelly <declan@chello.nl> wrote:
>
> I'm using LWP::UserAgent to request a web page
but part of the page is
> missing
> when I get the reply. The code is as follows:
>
> use LWP;
> use HTTP::Request::Common;
> use LWP::UserAgent;
>
> my $ua = new LWP::UserAgent;
> $ua->agent("AgentName/0.1 " . $ua->agent);
>
> my $req = POST $url;
> $req->content_type('application/x-www-form-
urlencoded');
> $req->content($parameters);
> $req->header('Accept' => 'text/html,
text/plain');
>
> my $res = $ua->request($req);
>
> When I access the page with a browser it
contains links of the form:
> <A HREF=/cgi-bin/demo/request.pl?
PARAM1=VALUE1&PARAM2=VALUE2
> > Name for link </A>
>
> but using the code above $res->content only
contains links of the form:
> <A HREF=/cgi-bin/demo/request.pl> Name for link
</A>
>
> It seems that everything from the question mark
up to and including the
> end of line
> is missing.
>
> Do I need to specify something about the
content type of the page I'm
> requestion
> to avoid this filtering?
>
> Any help would be much appreciated.
>
> Regards,
>
> Declan
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 23 Jul 2000 16:02:28 -0700
From: steve cramton <scrampton71NOscSPAM@hotmail.com.invalid>
Subject: matching contents of array
Message-Id: <00b95d94.cf96c08d@usw-ex0105-036.remarq.com>
Hi, I have a long list of domains in an array which im trying to
match, similar to the following
@providers = qw(aol tweb.net timeweb.net mailhost.sas.net
hotmail digiweb.com) ;
#the regex im using is
if ($host =~ /\$providers\b/i)
But its not working each name in providers is passing as true.
Could anyone point me in the right direction?
Thanks,
Steve C..
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Sun, 23 Jul 2000 16:11:44 -0700
From: Michael Budash <mbudash@sonic.net>
Subject: Re: matching contents of array
Message-Id: <mbudash-BD068C.16114423072000@news.pacbell.net>
In article <00b95d94.cf96c08d@usw-ex0105-036.remarq.com>, steve cramton
<scrampton71NOscSPAM@hotmail.com.invalid> wrote:
> Hi, I have a long list of domains in an array which im trying to
> match, similar to the following
>
> @providers = qw(aol tweb.net timeweb.net mailhost.sas.net
> hotmail digiweb.com) ;
>
> #the regex im using is
> if ($host =~ /\$providers\b/i)
>
> But its not working each name in providers is passing as true.
>
> Could anyone point me in the right direction?
>
>
> Thanks,
> Steve C..
>
this is a FAQ. pls see in the perl FAQ:
How can I tell whether an array contains a certain element?
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sun, 23 Jul 2000 16:23:18 -0700
From: steve cramton <scrampton71NOscSPAM@hotmail.com.invalid>
Subject: Re: matching contents of array
Message-Id: <0b7aa214.d50549f7@usw-ex0105-036.remarq.com>
Michael Budash <mbudash@sonic.net> wrote:
>In article <00b95d94.cf96c08d@usw-ex0105-036.remarq.com>, steve
cramton
><scrampton71NOscSPAM@hotmail.com.invalid> wrote:
>
>> Hi, I have a long list of domains in an array which im trying
to
>> match, similar to the following
>>
>> @providers = qw(aol tweb.net timeweb.net mailhost.sas.net
>> hotmail digiweb.com) ;
>>
>> #the regex im using is
>> if ($host =~ /\$providers\b/i)
>>
>> But its not working each name in providers is passing as true.
>>
>> Could anyone point me in the right direction?
>>
>>
>> Thanks,
>> Steve C..
>>
>
>this is a FAQ. pls see in the perl FAQ:
>
> How can I tell whether an array contains a certain element?
>
>hth-
>--
>Michael Budash ~~~~~~~~~~ mbudash@sonic.net
>
>
Thanks Ive read it, but what Im trying is the oppisate of what
you suggested?
I trying to find any word listed in @providers in $mailhost
Thanks,
Steve C..
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Sun, 23 Jul 2000 22:01:14 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: matching contents of array
Message-Id: <slrn8nn8ra.6gr.tadmc@magna.metronet.com>
On Sun, 23 Jul 2000 16:23:18 -0700, steve cramton <scrampton71NOscSPAM@hotmail.com.invalid> wrote:
>Michael Budash <mbudash@sonic.net> wrote:
>>In article <00b95d94.cf96c08d@usw-ex0105-036.remarq.com>, steve
>cramton
>><scrampton71NOscSPAM@hotmail.com.invalid> wrote:
>>
>>> Hi, I have a long list of domains in an array which im trying
>to
>>> match,
>>>
>>> #the regex im using is
>>> if ($host =~ /\$providers\b/i)
That is too strange to even try and correct.
You don't need a reference.
You haven't put anything into the $providers scalar that we can see
($providers has nothing whatsoever to do with @providers)
You do need to escape metacharacters (the dots) ( see \Q and quotemeta())
>>this is a FAQ. pls see in the perl FAQ:
>>
>> How can I tell whether an array contains a certain element?
>Thanks Ive read it, but what Im trying is the oppisate of what
>you suggested?
>I trying to find any word listed in @providers in $mailhost
Still a FAQ, just a different one:
How do I efficiently match many regular expressions at once?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 23 Jul 2000 23:40:47 GMT
From: dcumro@my-deja.com
Subject: Re: MySQL and Perl problems
Message-Id: <8lfvpu$jhf$1@nnrp1.deja.com>
Hi
try $dbh = DBI->connect ("DBI:mysql:smeg");
or try replacing 139.142.174.159 with 127.0.0.1
Dennis L. Cumro
In article <3977D863.A5B006A8@jetstream.net>,
"Dragonia Radar Freedom, C.S."
<radar@jetstream.net> wrote:
> I've managed to get my MySQL server up and
running and have successfully created my
table "Smeg". I've used the following lines
> to grant full access to the database using the
MySQL command interface:
> ------------
> grant all on smeg.* to user@localhost
identified by "password";
> grant all on smeg.* to user@steve identified
by "password";
> #note: steve isn't my name, just my computer
name...
> ------------
>
> In my Win32 Perl code, I have the following
(mostly from the code examples in my books):
> ------------
> require "d:/temp/web/cgi-bin/cgi-
lib.pl"; #this will be needed later on...
>
> main:
> { #Begin main routine
> use DBI;
> use strict;
>
> my ($dsn)
= "DBI:mysql:smeg:139.142.174.159";
#connecting to localhost gives more errors.
> my ($username) = "user";
> my ($password) = "password";
> my ($dbh, $sth);
> my (@ary);
>
> $dbh = DBI->connect ($dsn, $username,
$password, { RaiseError => 1});
> } #End main routine
> ------------
>
> This gives me the following message when I run
the script:
> ------------
> DBI->connect failed: Access denied for
user: 'user@steve' (Using password: YES) at
sql.pl line 14
> ------------
>
> What I currently am looking to do is be able to
connect and find the only existing record within
the only table in the
> database. Once I can connect, I should be able
to continue forwards in my learning.
>
> I would greatly appreciate any and all help in
this matter. I've been messing around with this
bit for two days now :(
>
> Thanks.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 24 Jul 2000 04:31:12 +0300
From: Eyal Ben-David <eyalb@aks.com>
Subject: Re: NT4-IIS-MSSQL7
Message-Id: <m28zus71r3.fsf@localhost.localdomain>
"Joe_Broz@transarc.com" <jbroz@transarc.com> writes:
> clayton collie wrote:
> >
> > hello,
> > ive searched CPAN, but i cant find a DBD module for MSSQL7 (im running
> > ActiveState). Any leads ?
>
> There isn't one AFAIK. I think that DBD::ODBC may work but have never tried
> it
Hello,
It works fine with my configuration: NT 4.0, BC++ 5.4 (from BCB 4).
Eyal.
------------------------------
Date: Sun, 23 Jul 2000 18:50:26 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Perl 6 page updated
Message-Id: <brian-ya02408000R2307001850260001@news.panix.com>
Perl Mongers hosts the official information source for Perl 6 news.
http://www.perl.org/perl6/
i've added:
* Jarkko's initial plans for continued Perl 5 maintenance
* information on the interim Perl 6 list - bootstrap-subscribe@perl.org
* notes from the Perl 6 happenings at TPC
* initial, short term goals of the (still-forming) development team
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Mon, 24 Jul 2000 00:57:32 GMT
From: "J.M. Ivler" <ivler@basecamp1.netquest.net>
Subject: Re: perl v. tcl
Message-Id: <0wMe5.34293$I7.697955@news-west.usenetserver.com>
In comp.lang.tcl sjfromm@my-deja.com wrote:
> What are the pros/cons of tcl vs. perl?
1) People have already given you enough advice
2) I'll explain my choice...
I'm a VAX Macro hacker who became a VAX Fortran 4P and then Fortran 77
hacker who loved DCL. I then started using lisp and found I loved that
too. Then I was forced to learn Pascal and C and disliked both
[there were others I disliked, like rpg and colbol (which I also
taught at one point), but those are the majors). When I moved to *nix I
learned shell, awk, etc and looked for a decent scripting language. I was
offered Perl and Tcl. Of the two Perl is more C-like and Tcl is
lisp-ish. Three guesses on what I chose. :-)
Oh yes. I generally don't write TK but use the wen browser as my interface
of choice. I like the way Tcl plays on the CGI end, so much that I even
wrote a book about it. :-)
------------------------------
Date: 23 Jul 2000 21:15:53 -0500
From: claird@starbase.neosoft.com (Cameron Laird)
Subject: Re: perl v. tcl
Message-Id: <6C299F31380AAA2B.C4A695C868400B21.7DAE2A0431EF856F@lp.airnews.net>
In article <8leouj$q4t$1@nnrp1.deja.com>, <sjfromm@my-deja.com> wrote:
>I'm looking for a scripting language to automate simple tasks, such as
>asking a user for a few parameters, then running some binary files on
>some data and logging what was done, etc.; or providing nice wrappers
>for some UNIX commands.
.
.
.
>idiosyncratic for my taste; and my impression (very shallow, I'll
>admit) is that perl and tcl facilities for list manipulation are a
>little bit easier to learn than sh's.
More than one person has already emphasized to
you how close all these languages are in essen-
tially all substantive matters; their most
prominent differences have to do with style.
HOWEVER, one of the most dramatic technical
distinctions is the one at which you hint here.
In fact, "Perl and Tcl facilities for list
manipulation are a *lot* [my word choice and
emphasis] easier to learn than sh's."
>
>I'm also interested in a reference about the different scripting
>languages (sh, tcl, perl, etc) that compares their syntax and merits.
<URL:http://starbase.neosoft.com/~claird/comp.lang.misc/language_comparisons.html>
.
.
.
--
Cameron Laird <claird@NeoSoft.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
------------------------------
Date: 23 Jul 2000 21:22:35 -0500
From: claird@starbase.neosoft.com (Cameron Laird)
Subject: Re: perl v. tcl
Message-Id: <D4CE11EF7094ED0E.C5383182D47A804D.406F7BBA944AE32C@lp.airnews.net>
In article <8lere8$ok$4@slb0.atl.mindspring.net>,
Eric Bohlman <ebohlman@netcom.com> wrote:
>sjfromm@my-deja.com wrote:
>: I'm looking for a scripting language to automate simple tasks, such as
>: asking a user for a few parameters, then running some binary files on
>: some data and logging what was done, etc.; or providing nice wrappers
>: for some UNIX commands.
>:
>: What are the pros/cons of tcl vs. perl? Right now, I'm using C, which
>
>For the types of tasks you're looking at, the decision is going to be
>determined almost entirely by the amount of expertise in the two
>languages that you have access to, not by language features themselves.
>If you're going to be doing all the work yourself, go with whichever
>language gives you the best gut feel. If others are going to be doing or
.
.
.
Eric's right.
I use both Tcl and Perl. One of the few arguments I do
think worth making in comparing the two is that Tcl is
superior at "providing nice wrappers for some Unix com-
mands." This is important in my work, and I've become
quite convinced of Tcl's virtues at this kind of "glu-
ing."
A fair number of people don't agree with me. In any
case, do start with at least one of these two. The dif-
ferences between them pale in comparison with the joy
either will bring you on your passage out from the world
of C.
--
Cameron Laird <claird@NeoSoft.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
------------------------------
Date: Sun, 23 Jul 2000 09:54:48 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Question on hashes...
Message-Id: <slrn8nlu98.5if.tadmc@magna.metronet.com>
On Sun, 23 Jul 2000 05:27:53 GMT, Rusty Williamson <rwilliamson@uno.gers.com> wrote:
>> Where is it that you looked?
>>
>> Knowing where people looked, but didn't find, is useful
>> information. Because then it can be put where they
>> look for it :-)
>>
>
>Yes, that's cool. I looked under 'lists of lists', struct, define, declare
>and anything else I could think of referencing the index of 'Programming
>Perl' by Wall and 'Advanced Perl Programming' by Srintivansan.
Oh.
I'm not very concerned with 3rd level resources, which is what
books are. I am concerned primarily that folks can find things
in the _standard_ Perl docs.
>But my
>problem -- besides being away from PERL for 2 years -- was I just didn't
>know what something like this would be under.
But you _did_ know!
>So that probably doesn't help
>anyone decide where to add anything. However if you know where I should
>have looked that be nice for me.
The First Level Resource is the standard documentation that
ships with the perl distribution.
You used "local variable" in your original post, so using "local"
would have worked:
perldoc -q local
finds the FAQ I mentioned previously.
perldoc -f local
finds a reference to my() and perlsub.pod.
perldoc -f my
perldoc perlsub
The Second Level Resource is searching a newsgroup archive,
such as www.deja.com to see if your question has already
been asked/answered.
If those 2 do not work, _then_ you resort to expensive, out-dated
dead trees :-)
>I owe you bud!
^^^
You do not owe _me_!
I am just a member of the clp.misc community.
You owe the community.
Answer someone else's question sometime (later, when you're pretty
sure that you are giving a _correct_ answer :-), and you'll
be squared.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Jul 2000 20:37:58 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Read a file into a hash ?
Message-Id: <slrn8nn3v0.vcg.abigail@alexandra.foad.org>
M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote on MMDXVIII September MCMXCIII in
<URL:news:8lf06e$4cn$1@pegasus.csx.cam.ac.uk>:
-- In article <8leq0u$2e8e$1@nntp1.ba.best.com>, Joe Smith <inwap@best.com> wrote:
-- >In article <MPG.13dd297feb3984b098abda@nntp.hpl.hp.com>,
-- >Larry Rosler <lr@hpl.hp.com> wrote:
-- >>
-- >>Closing a file opened for reading is pointless, unless another process
-- >>or later in this process intends to access it.
-- >
-- >Closing a file opened for reading is good programming, otherwise you
-- >could run out of available file descriptors.
-- >
-- >I'm willing to give Larry the benefit of doubt. I believe he meant
-- >"Checking the return value from close() on a file opened for reading is
-- >pointless".
--
-- But that is a silly thing to say as well. If you don't check
-- the return from close(), you will end up ignoring I/O errors.
-- Hardly good programming practice.
What I/O error can occur when closing a file handle opened for reading?
-- Always check the return from *all* system calls.
That should include print() then.
Abigail
--
New email address: abigail@foad.org
------------------------------
Date: 23 Jul 2000 18:43:06 -0400
From: Kevin Falcone <kevinfal+clpm@seas.upenn.edu>
Subject: Re: reading binary and sending it to client browser...
Message-Id: <m3ittw5uyt.fsf@bowline.jibsheet.com>
>>>>> "SS" == Sigmund Straumland <sigmund@easy-net.no> writes:
SS> With this code the image apears as gibberish. If my assumption
SS> is right and I have to use another command to send the picture,
SS> what is it, or where can I find it in the documentation?
print should work, but why read the variable into memory?
#!/usr/local/bin/perl -w
open(FILE, "<c:/apache/serverroot/sok.gif")
or die "Can't open c:/apache/serverroot/sok.gif: $!";
binmode FILE;
print "Content-type: image/gif\n\n";
print <FILE>;
close FILE;
-kevin
------------------------------
Date: Sun, 23 Jul 2000 22:55:56 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: reading binary and sending it to client browser...
Message-Id: <x7n1j8a22r.fsf@home.sysarch.com>
>>>>> "KF" == Kevin Falcone <kevinfal+clpm@seas.upenn.edu> writes:
KF> print should work, but why read the variable into memory?
KF> binmode FILE;
good.
KF> print <FILE>;
that still reads the whole file into memory. also since you don't know
the record size that might slurp in the whole file looking for a \n.
better is a read/print loop.
print $buf while read( FILE, $buf, 8192 ) ;
should work fine.
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: 23 Jul 2000 20:40:31 EDT
From: abigail@foad.org (Abigail)
Subject: Re: secure auth trick
Message-Id: <slrn8nn43r.vcg.abigail@alexandra.foad.org>
Bart Lateur (bart.lateur@skynet.be) wrote on MMDXVIII September MCMXCIII
in <URL:news:5lklns47i9f9blgn0s1nkb71mhc8ai86ph@4ax.com>:
)) Robin Bank wrote:
))
)) >That way when someone tries to access the file through http, it tries TO RUN
)) >THE SCRIPT and causes an internal server error...
))
)) >OR, IF IT IS A VALID program, stores the output
)) >rather than the source code. This is awesome...
))
)) It's only secure for people not having access to your machine. If, for
)) example, you have web space with an ISP on a machine that is shared
)) between you and many other people, each and every one of those can read
)) your file through their FTP connection, I would think.
It wouldn't in any webserver *I* would admin. Or for that matter, any
machine with "users" that runs an FTP server.
chroot() is a useful mechanism.
Abigail
--
New email address: abigail@foad.org
------------------------------
Date: Mon, 24 Jul 2000 02:58:57 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: secure auth trick
Message-Id: <Pine.GHP.4.21.0007240247410.19271-100000@hpplus05.cern.ch>
On Fri, 21 Jul 2000, Robin Bank wrote:
> Just came up with a really cool trick to get a fairly secure password
> authentication in PERL for a site without having to go through all that
> encryption stuff.
The words "secure" and "trick" are not good bedfellows.
> I store my passwords in a plain text file. At first I wasn't so sure about
> this because to use a script, all have to have read access, right? So, my
> solution was to change the file to an unknown mime type - like .USR or
> whatever... and, HERE'S THE KICKER, give the file permissions of 777.
You could put them outside of the web tree. You could put them in a
script-aliased directory. Etc., etc.
It seems your only priority was to avoid them being read via the web
server, but you missed quite a number of other issues.
> That way when someone tries to access the file through http, it tries TO RUN
> THE SCRIPT and causes an internal server error...
If you put them outside the web tree, then you have that one licked.
But why am I falling in with your agenda? You are considering nothing
more than a web server configuration issue, and the relevance to perl
programming is tenuous in the extreme.
In reality, if the files are on a shared system then you have more
than a mere _web_ server issue to worry about, but it still isn't
about perl language miscellaneous.
> If anyone knows how to crack such a sytem through http,
What was it Nelson was reputed to have said when putting the telescope
to his blind eye?
--
"Mir ist es ein Rätsel wie man mit minimalem Verstand so einen
Unfug fabrizieren kann." - Adrian Knoth
------------------------------
Date: Sun, 23 Jul 2000 23:17:12 GMT
From: "suj_h" <suj_h@yahoo.com>
Subject: string replacement
Message-Id: <Y1Le5.5282$RG6.503038@bgtnsc05-news.ops.worldnet.att.net>
I'm trying to replace every occurrence of "<" in a text file to
"<". The following script works but only for the first occurrence
of "<" in a line and leaves the rest unchanged. What's missing in the
script?
while($line=<infile>){
$line =~ s/</</;
print "$line";
}
------------------------------
Date: Sun, 23 Jul 2000 19:18:35 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: string replacement
Message-Id: <397B7D4B.B5B37BC8@attglobal.net>
suj_h wrote:
>
> I'm trying to replace every occurrence of "<" in a text file to
> "<". The following script works but only for the first occurrence
> of "<" in a line and leaves the rest unchanged. What's missing in the
> script?
>
> while($line=<infile>){
> $line =~ s/</</;
> print "$line";
> }
$line =~ s/</</g;
^
$ perldoc perlre
------------------------------
Date: 23 Jul 2000 21:30:42 EDT
From: abigail@foad.org (Abigail)
Subject: Re: string replacement
Message-Id: <slrn8nn71u.vcg.abigail@alexandra.foad.org>
suj_h (suj_h@yahoo.com) wrote on MMDXVIII September MCMXCIII in
<URL:news:Y1Le5.5282$RG6.503038@bgtnsc05-news.ops.worldnet.att.net>:
'' I'm trying to replace every occurrence of "<" in a text file to
'' "<". The following script works but only for the first occurrence
'' of "<" in a line and leaves the rest unchanged. What's missing in the
'' script?
One letter, as the manual could have told you.
'' while($line=<infile>){
'' $line =~ s/</</;
'' print "$line";
Why the quotes?
'' }
Abigail
--
New email address: abigail@foad.org
------------------------------
Date: Sun, 23 Jul 2000 22:31:17 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Why won't "use strict;" work?
Message-Id: <10658-397BB885-47@storefull-243.iap.bryant.webtv.net>
The codes below seem to work fine, but when I insert "use strict;" they
quit working. Why? Also: do I have the flocking done correctly now? I
have studied all of your previous suggestions, the FAQs, and many other
sites extensively, and still do not understand. Please help me with any
errors(including lines out of order) that you see below. I'd be really
grateful.
#!/usr/local/bin/perl -w
use Fcntl;
use diagnostics;
$LOCK_EX = "2";
$LOCK_UN = "8";
print "Content-type: text/html\n\n";
open(COUNT, "visits.dat") or die "Can't READ data file: $!";
flock(COUNT, $LOCK_EX) or die "Can't LOCK data file: $!";
$cnt = <COUNT>;
chomp $cnt;
$cnt++;
open(COUNT, ">visits.dat") or die "Can't
WRITE to data file: $!";
print(COUNT $cnt);
1 while $cnt =~ s/(.*\d)(\d\d\d)/$1,$2/;
for($cnt) {s/(1[123]|[4-90]$)/$1th/ or
s/(1$)/$1st/ or s/(2$)/$1nd/ or
s/(3$)/$1rd/;};
print("<font size='3' color='#000066'>You
are the $cnt visitor to this
page</font><BR>");
close COUNT;
flock(COUNT, $LOCK_UN);
## END SCRIPT
PS E-mails welcomed.
Regards,
Dennis
------------------------------
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 3782
**************************************