[15640] in Perl-Users-Digest
Perl-Users Digest, Issue: 3053 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 15 18:06:27 2000
Date: Mon, 15 May 2000 15:05:18 -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: <958428318-v9-i3053@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 15 May 2000 Volume: 9 Number: 3053
Today's topics:
Re: "make test" question (perl-5.6) <rootbeer@redcat.com>
Re: 'use integer' causes strange output.. <rootbeer@redcat.com>
Re: [General] From which script size Perl performance d (Abigail)
Re: [General] From which script size Perl performance d <aqumsieh@hyperchip.com>
Re: [Hash] Is the key always double-quoted? (Abigail)
Re: [Hash] Is the key always double-quoted? (Randal L. Schwartz)
Re: [RegExp] Specific or General, which is faster? (Abigail)
Re: [RegExp] Specific or General, which is faster? <charles.henry@engineer2k.com>
Re: About MAcPerl Webserver <rootbeer@redcat.com>
Re: alphabeticalize a perl array (Craig Berry)
Change list another way ? <hans-jan@stack.nl>
Re: Change list another way ? (Tad McClellan)
Re: Complexed perl problem. <rootbeer@redcat.com>
Re: Diamond operator litchoon@my-deja.com
Re: Diamond operator <sariq@texas.net>
Re: Diamond operator <jeff@vpservices.com>
Do YOU use taint-checking? <webqueen@my-deja.com>
Re: Do YOU use taint-checking? (Jerome O'Neil)
Re: Do YOU use taint-checking? (brian d foy)
Emacs modules for Perl programming (Jari Aalto+mail.perl)
File exists shoaibq@my-deja.com
Re: How do I convert? <bert@scanlaser.nl>
Re: How do I convert? <sariq@texas.net>
Re: How do I get a user's home directory with NIS+? (Andrews)
Re: How to simulate a post request ? <uri@sysarch.com>
Re: HTML corruption from perl script <tony_curtis32@yahoo.com>
Initializing variables jamalone@earthlink.net
Re: Looking to purchase an FTP script ... <andrew.mcguire@walgreens.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 15 May 2000 12:50:15 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: "make test" question (perl-5.6)
Message-Id: <Pine.GSO.4.10.10005151246500.25459-100000@user2.teleport.com>
On Fri, 12 May 2000 garrem@my-deja.com wrote:
> I've managed to get perl 5.6 to build on my AIX 4.3 box. When i do
> a "make test", there are three failures listed:
>
> lib/attrs............FAILED at test 0
> lib/io_linenum.......FAILED at test 0
> lib/io_xs............FAILED at test 0
>
> Yet when i execute each of the three tests on its own, each seems to
> succeed;
Mysterious. It _probably_ means a failure in the test harness code, but it
could be something else. You should probably use perlbug to report this,
although nothing may come of it.
If you're not sure about whether 5.6.0 is safe to install despite these
results, I'd say no - it's got a number of known bugs which will soon be
fixed in 5.6.1. But you wouldn't have compiled it if you weren't willing
to be bitten by a bug or two, would you? :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 12:45:38 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: 'use integer' causes strange output..
Message-Id: <Pine.GSO.4.10.10005151227160.25459-100000@user2.teleport.com>
On Sat, 13 May 2000, Bernie Cosell wrote:
> Now I'm confused. The doc says "left-hand operand". In:
> -betty => ...
> what's the "left hand operand" to that '=>'? I'd have guessed it is the
> expression "-betty"...
I think of it as 'betty', but let's see...
> Is it just "betty"? If so, then how is the expression parsed --- that
> is, if you were to fully parenthesize that expression so we could see
> what the operand of the negation is, what would it be?
Sounds like a job for B::Deparse.
$ perl -MO=Deparse -we '@ARGV = (- betty=>42);'
-e syntax OK
@ARGV = ('-betty', 42);
Well, actually, I could have determined that from the precedence chart.
Unary negation is high precedence, but comma (and the big arrow) are low
precedence.
> What happens if you do
> 1 . betty => "some value"
Now _that_ is a job for the precedence chart. :-)
> So it seems that the parsing/magicification of '=>' is a *little* more
> complicated than just 'left operand'.
I don't think so, but it's worth noting that the quoting of the preceding
bareword happens before the precedence chart comes into play. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 15 May 2000 20:02:05 GMT
From: abigail@foad.org (Abigail)
Subject: Re: [General] From which script size Perl performance decreases dramatically?
Message-Id: <slrn8i0ltt.dco.abigail@ucan.foad.org>
On Mon,
15 May 2000 12:54:41 +0100, Charles Henry <charles.henry@engineer2k.com> wrote:
++ I have a 65kb Perl script (reasonably organized) and I was wondering such a
++ size would decrease Perl performance a lot. I believe Perl will take a lot
++ of time parsing my code ...
And how much did Perl take when you timed it?
++ Also do "use strict" and "perl -w" slow down my code? I'm asking that
++ because obviously Perl will take the time to check ambiguous consctructs and
++ correct variable declarations, which may decrease performance ...
Well, it's trivial to remove the 'use strict' and '-w'. Time it, and see
whether you can notice the difference....
Abigail
------------------------------
Date: Mon, 15 May 2000 20:39:54 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: [General] From which script size Perl performance decreases dramatically?
Message-Id: <7a66sfli0l.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
"Charles Henry" <charles.henry@engineer2k.com> writes:
> I have a 65kb Perl script (reasonably organized) and I was wondering such a
> size would decrease Perl performance a lot. I believe Perl will take a lot
> of time parsing my code ...
The size of the script is not the real problem. While it is true that
the longer your code, the more commands you need to execute, the more
time it takes Perl to execute all of it, you have to take into account
looping constructs that add a lot to your code.
I can write a one-line script that never finishes:
1 while 1;
> Also do "use strict" and "perl -w" slow down my code? I'm asking that
> because obviously Perl will take the time to check ambiguous consctructs and
> correct variable declarations, which may decrease performance ...
No, those will not slow down your code in any dramatic fashion.
When you run a Perl script, the code is first compiled to byte-code
(executing any compile-time commands in the way), and then the Perl
interpreter starts executing the byte-code. So, once your script
actually starts to run, you know that Perl has already finished parsing
the whole thing.
If you notice that your code takes a long time, I suggest using a little
technique I learnt some time ago. Try placing print() statements in
strategic locations in your code, such that you print the amount of time
your code has been running so far.
Examining the time stamps generated, you will be able to easily
figure out where your program is spending most of its time, and then
concentrate on trying to optimize that code.
PS. Of course, you have to add some token to your printed statements to
be able to distinguish among them, or else you won't be able to figure
out which statement printed which line.
HTH,
--Ala
------------------------------
Date: 15 May 2000 18:42:03 GMT
From: abigail@foad.org (Abigail)
Subject: Re: [Hash] Is the key always double-quoted?
Message-Id: <slrn8i0h7r.dco.abigail@ucan.foad.org>
On 15 May 2000 07:03:24 -0700, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
++
++ %foo = (last => "Flintstone", first => "Fred");
++
++ The downside of using these "automatically quoted" contexts is that
++ you'll get warnings for both if you enable -w, because the word "last"
++ is also a function call.
Only for outdated Perls. That warning was dropped in 5.005.
Abigail
------------------------------
Date: 15 May 2000 14:58:21 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: [Hash] Is the key always double-quoted?
Message-Id: <m166sfmq6a.fsf@halfdome.holdit.com>
>>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:
>> The downside of using these "automatically quoted" contexts is that
>> you'll get warnings for both if you enable -w, because the word "last"
>> is also a function call.
Larry> No warnings since version 5.005.
See, I got burned once, and I never do it again. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 15 May 2000 20:00:16 GMT
From: abigail@foad.org (Abigail)
Subject: Re: [RegExp] Specific or General, which is faster?
Message-Id: <slrn8i0lqg.dco.abigail@ucan.foad.org>
On Mon,
15 May 2000 12:48:11 +0100, Charles Henry <charles.henry@engineer2k.com> wrote:
++ I have a list of strings which 2 first character belong to the [a-z] class.
++ I want to match those two character.
++
++ I was wondering what would be faster for Perl :
++
++ A general :
++ foreach (@strings) {
++ /^(.{2})/
++ }
++
++ or a specific :
++ foreach (@strings) {
++ /^([a-z]+)/
++ }
Since neither of them does something, except for a few side effects
(which get overwritten anyway), does it matter which one is faster?
Once you have some working code, and you want to find out which is
faster, Benchmark is your friend. But unless your Perl and programming
is so good nothing else leads to more obvious gains, you probably
shouldn't bother.
Oh, and once your are going to Benchmark, make sure you benchmark all
possible ways of archieving your results. You missed the most obvious
solution: substr.
Abigail
------------------------------
Date: Mon, 15 May 2000 22:36:06 +0200
From: "Charles Henry" <charles.henry@engineer2k.com>
Subject: Re: [RegExp] Specific or General, which is faster?
Message-Id: <8fpnd5$1tjf$1@news5.isdnet.net>
> You missed the most obvious solution: substr.
"substr" ??
------------------------------
Date: Mon, 15 May 2000 13:40:45 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: About MAcPerl Webserver
Message-Id: <Pine.GSO.4.10.10005151339560.25459-100000@user2.teleport.com>
On Sat, 13 May 2000, Salvo Jr wrote:
> I use the webserver MacPerl 1.0b3.5
I don't think that's a webserver. But if it is, perhaps you should be
asking in a newsgroup about webservers. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 18:09:52 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: alphabeticalize a perl array
Message-Id: <si0fbgigrj0113@corp.supernews.com>
Andrew (awd@seol.net.au) wrote:
: hi I need to make an array (over 100 entries) in alphabetical order.
: Would anyone have an idea on how to do this.
: it's perl 5.
See the documentation on the sort function. Note that by default, the
sort is done in string-comparison (cmp) order, which may match your sense
of 'alphabetical order' closely enough to be useable as-is. If not,
you'll need to define your sort order functionally. For example, you can
easily craft a case-insensitive sort.
Just out of curiosity, how did you miss finding the sort function in the
documentation?
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "The road of Excess leads to the Palace
of Wisdom" - William Blake
------------------------------
Date: 15 May 2000 20:33:10 GMT
From: Hans <hans-jan@stack.nl>
Subject: Change list another way ?
Message-Id: <8fpmu6$rnt$1@news.tue.nl>
Hi,
I want to put some vars in a list :
$msg_in->attach(
Type =>$tpe_file,
Encoding =>$enc_file,
Path =>$nam_file);
this won't work but
${$msg_in->{"Type"}} = $tpe_file;
${$msg_in->{"Encoding"}} = $enc_file;
${$msg_in->{"Path"}} = $nam_file;
should work. How is it done in the first list ?
H.
------------------------------
Date: Mon, 15 May 2000 16:12:06 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Change list another way ?
Message-Id: <slrn8i0mgm.10f.tadmc@magna.metronet.com>
On 15 May 2000 20:33:10 GMT, Hans <hans-jan@stack.nl> wrote:
>Hi,
>
>I want to put some vars in a list :
>
>$msg_in->attach(
> Type =>$tpe_file,
> Encoding =>$enc_file,
> Path =>$nam_file);
That is not a list.
>this won't work but
>
>${$msg_in->{"Type"}} = $tpe_file;
>${$msg_in->{"Encoding"}} = $enc_file;
>${$msg_in->{"Path"}} = $nam_file;
That is not a list either.
>should work. How is it done in the first list ?
I dunno. What list is it that you are referring to?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 15 May 2000 13:37:23 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Complexed perl problem.
Message-Id: <Pine.GSO.4.10.10005151257210.25459-100000@user2.teleport.com>
I don't have the time to read and ponder your whole problem, but here's
some help. (If you can express your problem more simply, someone here may
be able to help more than this.)
On Sat, 13 May 2000, Jimmy Lantz wrote:
> open(FILE, "$icedata");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Also, those quote marks are merely misleading.
> while(<FILE>) {
> $file = $_;
Shouldn't that variable be called $line? I mean, it'll work either way,
but let's not confuse the maintenance programmer.
> if ($file =~ /$faktor1/) {
> $file =~ s/$faktor1/ /;
Maybe you could do just the s///.
> elsif ($file !~ /$faktor1/ ){
Looks like a job for a plain-old else clause.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 19:00:10 GMT
From: litchoon@my-deja.com
Subject: Re: Diamond operator
Message-Id: <8fphff$r2v$1@nnrp1.deja.com>
Thanks for your reply. But I don't know how to get this module from
CPAN. This module is not in the standard Perl release right ? Could u
point me to where this module resides in & how I can use this module to
read backwards ? Appreciate your help.
In article <391C633F.42B65A5A@texas.net>,
Tom Briles <sariq@texas.net> wrote:
> litchoon@my-deja.com wrote:
> >
> > I am trying to move the file handle backwards for a few lines after
> > matching some string in a log file. Is there a way to do this ? I
would
> > appreciate if someone could respond.
>
> use File::ReadBackwards; # From CPAN
>
> Then, you don't have to roll back "a few lines".
>
> - Tom
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 15 May 2000 14:23:08 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Diamond operator
Message-Id: <39204E9C.5F36836A@texas.net>
[ Jeopardectomy performed. In the future, please post your reply
*after* the quoted text. ]
litchoon@my-deja.com wrote:
>
> In article <391C633F.42B65A5A@texas.net>,
> Tom Briles <sariq@texas.net> wrote:
> > litchoon@my-deja.com wrote:
> > >
> > > I am trying to move the file handle backwards for a few lines after
> > > matching some string in a log file. Is there a way to do this ? I
> would
> > > appreciate if someone could respond.
> >
> > use File::ReadBackwards; # From CPAN
> >
> > Then, you don't have to roll back "a few lines".
> >
>
> Thanks for your reply. But I don't know how to get this module from
> CPAN. This module is not in the standard Perl release right ?
Right.
> Could u
> point me to where this module resides in & how I can use this module to
> read backwards ?
perldoc -q CPAN
The documentation for the module is included in its distribution as well
as at CPAN. Try the CPAN search at:
http://search.cpan.org/
- Tom
------------------------------
Date: Mon, 15 May 2000 12:24:17 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Diamond operator
Message-Id: <39204EE1.10D988D9@vpservices.com>
litchoon@my-deja.com wrote:
>
> Thanks for your reply. But I don't know how to get this module from
> CPAN. This module is not in the standard Perl release right ? Could u
> point me to where this module resides in & how I can use this module to
> read backwards ? Appreciate your help.
www.cpan.org and/or the closes CPAN mirror to you have complete
documentation on how to download and install files from CPAN as well as
a search engine to find files on the repository and/or to read the
documentation of the files.
This URL gives you complete documentation and downloads for that module:
http://search.cpan.org/search?dist=File-ReadBackwards
If you are on a windoze computer, you should instead read the
activestate documentation on installing modules found on
www.activestate.com.
--
Jeff
------------------------------
Date: Mon, 15 May 2000 20:15:48 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: Do YOU use taint-checking?
Message-Id: <8fplt3$l9$1@nnrp1.deja.com>
I avoid system() and `` calls and try to stick to things that are safe,
yet -T seems to complain about almost everything.
I read the recommended security primer/tutorial (Lincoln Stein). It was
very-well written and easily understood, but I still wonder is it worth
the effort to dig through mega-lines of Perl to fix a plethora of
possible security issues which in my mind (particularly given the
cgi-wrapper on our servers) are extremely remote. In my (limited)
test-cases, I'd say I have a -T issue in every module (and there are
hundreds of them).
Yet, I do want to be a responsible www-programmer and do the right
things for my clients. So if a lot of you are using it and believe it's
worth the pain, then I'll mostly likely buckle down and update the code,
since people on this group seem to have excellent intuition about this
sorrt of thing.
So, again, are YOU a taint-checker?
HUG,
WQ
--
Time is nature's way of preventing everything from happening at once.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 15 May 2000 20:47:33 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Do YOU use taint-checking?
Message-Id: <FnZT4.567$Cq4.19544@news.uswest.net>
In article <8fplt3$l9$1@nnrp1.deja.com>,
webqueen, queen of the web <webqueen@my-deja.com> writes:
> So, again, are YOU a taint-checker?
Yes. While some modules taint complaints are pretty annoying, I develop
with taint warnings on, although I don't distribute that way. I am aware
of what makes my code squawk, though, and that's the important thing.
I use taint checking to point out potential problems, then evaluate the
problem on it's own merits.
Runing clean wit tainting on is certainly desireable, just not
always possible.
------------------------------
Date: Mon, 15 May 2000 16:46:06 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Do YOU use taint-checking?
Message-Id: <brian-1505001646060001@1cust82.tnt1.durham.nc.da.uu.net>
In article <8fplt3$l9$1@nnrp1.deja.com>, webqueen, queen of the web <webqueen@my-deja.com> wrote:
>So, again, are YOU a taint-checker?
of course.
--
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ
<URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: 15 May 2000 19:06:41 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_958417140@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://home.eu.org/~jari/ema-keys.html
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs
XEmacs/Emacs, is available to various platforms:
o Unix:
If you don't have one, bust your sysadm.
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
Emacs resources at http://home.eu.org/~jari/emacs-elisp.html
o W9x/NT:
http://www.gnu.org/software/emacs/windows/ntemacs.html
Emacs Perl Modules
Cperl -- Perl programming mode
.ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
.<olson@mcs.anl.gov> Bob Olson (started 1991)
.<ilya@math.ohio-state.edu> Ilya Zakharevich
Major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
starndard in newest Emacs.
TinyPerl -- Perl related utilities
.http://home.eu.org/~jari/tiny-tools-beta.zip
.http://home.eu.org/~jari/emacs-tiny-tools.html
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Load source code into Emacs, like Devel::DProf.pm
o Grep through all Perl manpages (.pod)
o Follow POD manpage references to next pod page with TinyUrl
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o TinyUrl is used to jump to URLs (other pod pages, man pages etc)
mentioned in POD pages. (It's a general URL minor mode)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in the tgz mentioned above]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example in the tgz (ema-tigr.ini) that shows
how to set up datatbases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to run the find for you, You can adjust
recursive grep options, ignored case, add user grep options.
You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
Check also ftp://ftp.ihs.com/pub/kevinr/
TinyCompile -- Browsing grep results in Emacs *compile* buffer
TinyCompile is minor mode for *compile* buffer from where
you can collapse unwanted lines, shorten the file URLs
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Mon, 15 May 2000 20:58:21 GMT
From: shoaibq@my-deja.com
Subject: File exists
Message-Id: <8fpod4$3dr$1@nnrp1.deja.com>
I have a file in a directory and what i am trying to do is check for
it's existence. I know the -e operator works but the thing is that the
filename that i will search for will change from time to time. Only the
first two letters of the filename will remain the same. i tried:
$fname = "aa" . "\*\.\*";
if (-e "$fname") {
printf(STDOUT "File exists");
}
else {
printf(STDOUT "Not found");
}
Any suggestions?
Thx. in advance
Shoaib
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 15 May 2000 21:59:38 +0200
From: Bert IJff <bert@scanlaser.nl>
Subject: Re: How do I convert?
Message-Id: <3920572A.C7B2BE0C@scanlaser.nl>
With perl5 on a Unix box the given script gives the error message
Missing $ on loop variable at -e line 1.
However, on my machine
perl -le 'while(<>){foreach(map(ord(),split("", $_))){ print ;}}' <
file
gives the expected output.
I'm still wondering what is wrong with the script given by Calle. (or
my version of perl5?)
Regards,
Bert
Calle Dybedahl wrote:
>
> >>>>> "Anthony" == Anthony John Doyle <strad@mondenet.com> writes:
>
> > I am wanting to read 8 bit characters in from a file
> > and I want to convert each of those bytes to its decimal
> > equivalent for example from 0 to 255.
>
> perl -le 'print for map {ord} split "",<>;' < file
> --
> Calle Dybedahl, Vasav. 82, S-177 52 Jaerfaella,SWEDEN | calle@lysator.liu.se
> "Surely the 98% of DNA we share with monkeys must be enough to stop
> people from sinking this low. " -- Frossie, A.S.R
------------------------------
Date: Mon, 15 May 2000 15:17:42 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How do I convert?
Message-Id: <39205B66.772955C2@texas.net>
[ Please place your response *after* the quoted text. ]
Bert IJff wrote:
>
> Calle Dybedahl wrote:
> >
> > >>>>> "Anthony" == Anthony John Doyle <strad@mondenet.com> writes:
> >
> > > I am wanting to read 8 bit characters in from a file
> > > and I want to convert each of those bytes to its decimal
> > > equivalent for example from 0 to 255.
> >
> > perl -le 'print for map {ord} split "",<>;' < file
>
> With perl5 on a Unix box the given script gives the error message
>
> Missing $ on loop variable at -e line 1.
>
'EXPR foreach EXPR' was introduced in 5.005. The error you saw is
coming from an older version.
- Tom
------------------------------
Date: 15 May 2000 11:53:45 -0700
From: gerg@ncal.verio.com (Andrews)
Subject: Re: How do I get a user's home directory with NIS+?
Message-Id: <8fph3p$mac$1@ncal.verio.com>
Scott Houck <shouck@bellatlantic.net> writes:
>I have a Perl program where I'd like to store options the user wants
>to save in a .dot file in their home directory. This is on Solaris
>2.6 with NIS+, so I can't use getpwent.
>
Of course you can use getpwent().
-Greg
--
::::::::::::::::::: Greg Andrews gerg@wco.com :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
------------------------------
Date: Mon, 15 May 2000 20:12:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How to simulate a post request ?
Message-Id: <x7bt27shc4.fsf@home.sysarch.com>
>>>>> "AN" == A Nonomous <gcf@my-deja.com> writes:
AN> This is the code I use:
AN> Step 1, Build the posted items.
AN> $str = "AppVersion=1.1";
AN> $str .= "&AcceptUPSLicenseAgreement=YES";
AN> $str .= "&ResponseType=application/x-ups-rss";
<snip>
AN> $str .= "&ResidentialInd=0";
AN> $str .= "&PackagingType=00";
there are many better ways to do that. here are a couple
$str = 'AppVersion=1.1' .
'&AcceptUPSLicenseAgreement=YES' .
....
$str = join( '&',
'AppVersion=1.1',
'AcceptUPSLicenseAgreement=YES',
....
AN> sub get_page {
AN> local ($n,@values);
AN> ($n,@values) = @_;
AN> local (@result);
AN> local ($them,$pagina,$port);
perl4. use my and not local. unless you are purlmoron who can't tell the
difference and who takes 7 exceptions to a rule as a reason to never use
the rule.
AN> ($them,$pagina,$port)=@_;
hmm, you already assigned @_ to $n and @values. so those 3 new vars
overlap with them. what are you trying to pass into this sub?
AN> $them = 'localhost' unless $them;
AN> $pagina = '/' unless $pagina;
AN> $port = 23 unless $port;
why default since you are assigning them with overlapping params (see
above).
AN> $AF_INET = 2; #<<<< I think you change one of these
WRONG!!!!! that is not the same value on all systems. use Socket to get
the correct values.
AN> $sockaddr = 'S n a4 x8';
AN> ($name,$aliases,$proto) = getprotobyname('tcp');
AN> ($name,$aliases,$port) = getservbyname($port,'tcp') unless $port =~
AN> /^\d+$/;;
AN> ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($hostname);
AN> ($name,$aliases,$type,$len,$thataddr) = gethostbyname($them);
yechh. use IO::Socket at least if not LWP.
AN> if (socket(S, $AF_INET, $SOCK_STREAM, $proto))
AN> {
AN> #print STDERR "socket ok\n";
AN> }
AN> else {
AN> die $!;
AN> }
AN> if (bind(S, $this)) {
AN> #print STDERR "bind ok\n";
AN> }
AN> else {
AN> die $!;
AN> }
you don't bind local sockets if you are connecting to a remote socket.
AN> if (connect(S,$that)) {
AN> #print STDERR "connect ok\n";
why the all empty if clauses? not very clear code. just do
connect || die.
# print STDERR "connected\n" ;
AN> }
AN> else {
AN> die $!;
put some info in the die message other than the error string.
much too much work for something this basic. use modules.
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: Mon, 15 May 2000 21:58:39 GMT
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: HTML corruption from perl script
Message-Id: <87ln1blblb.fsf@shleppie.uh.edu>
>> On Mon, 15 May 2000 09:31:29 GMT,
>> gelliot8@my-deja.com said:
> We are having a problem with a perl script we have
> written: When multiple users access my Java web
^^^^^^^^ ^^^^^^
Locking problem alert! Locking problem alert!
> application, the HTML returned to browsers occasionally
> becomes corrupted. A user receives HTML chunks of his
> expected page intermingled with HTML belonging to
> another user. How can this happen?
I suspect locking and I/O buffering weirdnesses. Probably
somewhere in the hidden-from-the-web bits.
hth
t
------------------------------
Date: Mon, 15 May 2000 20:54:30 GMT
From: jamalone@earthlink.net
Subject: Initializing variables
Message-Id: <39205d2c.6457445@news.earthlink.net>
I have a problem that I hope someone can help with.
I have written a very simple script that reads variables from a web
page and prints them out to the browser.
The problem is that when I fill in the field on the web page and click
submit, it varies as to what output is displayed. Sometimes it uses
values that I entered on a previous submit instead of what I just
submited.
My question is this. Is there anyway that I can initialize a
variable. I mean other than $var = ''; ???
I have tried everything that I can think of and it still wants to use
data that it is caching somewhere.
I thought that if had the following code it would clear the variables
value
$var = "test";
$var ='';
print $var;
but this still will print old data sometimes.
Thanks for your help.
Jason Malone
------------------------------
Date: Mon, 15 May 2000 13:29:55 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Looking to purchase an FTP script ...
Message-Id: <39204223.3CBF1AA5@walgreens.com>
c_neak@my-deja.com wrote:
>
> In article <391FF981.C55C1EAB@rchland.ibm.com>,
> "Paul R. Andersen" <andersen+@rchland.ibm.com> wrote:
> > jhalbrook@my-deja.com wrote:
> > >
> > > I need a script that will let me specify the IP address,
> > > userid, and password so I can FTP files from one server
> > > to another.
> > >
> > > Preferably a script that will not require installing any
> > > Perl modules.
> > >
>
> Why don't you use a korne (or Bourne) shell script which calls an
> EXPECT script ?
> You must have an Unix machine , of course + the Expect module .
> You can take a look on "comp.unix.shell" for that and you can search
> "Expect" .
Because he wants to use Perl... But even if he did want to
use sh, he would not need expect. Something like this works
fine, without expect:
#!/usr/bin/sh
# $Id: ftp.sh,v 1.1 2000/04/25 21:45:11 anm Exp anm $
ftp -in <<EOF
open sunsite.unc.edu
user ftp username@domain.com
cd /pub/solaris/freeware/SOURCES
lcd /tmp
bin
hash
mget $*
quit
EOF
But better still the OP can check out Net::FTP, although
that does not meet the criteria of not installing modules.
Regards,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
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 3053
**************************************