[7464] in Perl-Users-Digest
Perl-Users Digest, Issue: 1089 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 27 11:33:17 1997
Date: Sat, 27 Sep 97 08:00:30 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 27 Sep 1997 Volume: 8 Number: 1089
Today's topics:
Re: a2p (newbie question) samdie@ibm.net
Re: a2p (newbie question) <creede@worldnet.att.net>
Re: array assignment problem. <doug@3dlabs.com.remove>
Re: Bad start on Win95 <creede@worldnet.att.net>
Re: can 'print' be overridden ? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Re: CD width CPAN ? <creede@worldnet.att.net>
Re: CD width CPAN ? (Clay Irving)
Re: CGI, Losing query parameters. HELP! <rootbeer@teleport.com>
Re: Error in perl used for guestbook. (Tad McClellan)
Re: Error in perl used for guestbook. <rootbeer@teleport.com>
Re: Exec Unix command inPerl <rootbeer@teleport.com>
Flatten hash utility? Which one? (Fred Elbel)
Formdata to File & Missing Data wviecht@rs6000.cmp.ilstu.edu
Re: Formdata to File & Missing Data <creede@worldnet.att.net>
Help with regular expressions! (Ben Glazer)
Re: Help with regular expressions! (John L. Allen)
Re: how to create array of file handles? <hietanie@koah.research.nokia.com>
Re: How to get close match on keywords <rootbeer@teleport.com>
Re: Memory fails me <rootbeer@teleport.com>
Re: Perl script is not executed by Web browser <jefpin@bergen.org>
PERL with TCP/IP <miked@psiaustin.com>
Re: Reading files (newb) <SPAM_ME_NOT_oberon@erols.com>
Re: Searching a directory <jefpin@bergen.org>
Re: sysread() question (Tad McClellan)
Typeglob - Temporary Aliases (Kevin Bass)
Re: Unlist syntax <russ@mail.org.uk>
Re: WHILE LOOP LOGIC <rootbeer@teleport.com>
Re: Win95 cgi <russ@mail.org.uk>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 27 Sep 97 09:34:06 -0400
From: samdie@ibm.net
Subject: Re: a2p (newbie question)
Message-Id: <342d0f76$1$fnzqvr$mr2ice@news-s01.ny.us.ibm.net>
In <Pine.GSO.3.96.970926055730.376J-100000@usertest.teleport.com>, on 09/26/97
at 06, Tom Phoenix <rootbeer@teleport.com> said:
> On Thu, 25 Sep 1997 samdie@ibm.net wrote:
> > I wanted to convert a bunch of my AWK scripts to Perl and experiment
> > with them but I don't get any output. I tried with a number of AWK
> > scripts and in all cases, after a second or so, I'm back at the command
> > prompt; no error messages, no new files in the directory, nothing to the
> > screen.
> >
> > As a specific example, I took a script that I would usually run by
> > \awk\gawk32 -f reorg.awk < images.fmt and entered: \perl\emx\bin\a2p
> > reorg.awk
> That looks right from what I know, although I'd probably redirect the output
Don't have any output to redirect. However, thinking that I might be getting
senile, I did actually try that too (not surprisingly - zilch).
> to a file. Have you tried using a2p's debugging option?
Can't get that to work. Tried:
a2p -d0 resize.awk, a2p -d1 repairs.awk, a2p -d2 repairs.awk
a2p -D0 repairs.awk, a2p -D1 repairs.awk, a2p -D2 repairs.awk
a2p -d 0 repairs.awk, a2p -d 1 repairs.awk, a2p -d 2 repairs.awk
a2p -D 0 repairs.awk, a2p -D 1 repairs.awk, a2p -D 2 repairs.awk
all of which get me "unrecognized switch -d (or -D or -d1 etc.)"
Also tried some (more or less random) values for the -F switch (don't
understand what it's for at all).
> I've heard that a2p isn't able to deal with all of the features added in
> some awk variants, such as gawk. Could you have used some feature that a2p
> doesn't understand? (Not that it shouldn't give some diagnostic message in
> that case...)
Thought of that. Though I'd certainly like to translate some of my longer,
more complicated AWK scripts, among the ones that I fed to a2p were several
that are "dead simple" (no GAWK or NAWK stuff), e.g. (repairs.awk)
BEGIN { FS=OFS="|" }
NF== 5 { Subject[$1]=$4; next }
{
is=substr($1,6); sb=substr($9,5,6); if (is==sb) next
print $4,$1,sb,Subject[sb]
}
--
-----------------------------------------------------------
samdie@ibm.net
-----------------------------------------------------------
------------------------------
Date: 27 Sep 1997 14:44:02 GMT
From: "Creede Lambard" <creede@worldnet.att.net>
Subject: Re: a2p (newbie question)
Message-Id: <01bccb53$bc7d8cc0$8314410c@boris>
I dunno. I tried both
a2p reorg.awk
and
a2p <reorg.awk
and they both worked on my system. :\ If you didn't try redirecting stdin
you might see if that works better for you, but it looks like you've tried
a lot. :D
-- Creede
samdie@ibm.net wrote in article
<342d0f76$1$fnzqvr$mr2ice@news-s01.ny.us.ibm.net>...
> In <Pine.GSO.3.96.970926055730.376J-100000@usertest.teleport.com>, on
09/26/97
>
> at 06, Tom Phoenix <rootbeer@teleport.com> said:
>
> > On Thu, 25 Sep 1997 samdie@ibm.net wrote:
>
> > > I wanted to convert a bunch of my AWK scripts to Perl and experiment
> > > with them but I don't get any output. I tried with a number of AWK
> > > scripts and in all cases, after a second or so, I'm back at the
command
> > > prompt; no error messages, no new files in the directory, nothing to
the
> > > screen.
> > >
> > > As a specific example, I took a script that I would usually run by
> > > \awk\gawk32 -f reorg.awk < images.fmt and entered: \perl\emx\bin\a2p
> > > reorg.awk
>
> > That looks right from what I know, although I'd probably redirect the
output
> Don't have any output to redirect. However, thinking that I might be
getting
> senile, I did actually try that too (not surprisingly - zilch).
>
> > to a file. Have you tried using a2p's debugging option?
> Can't get that to work. Tried:
> a2p -d0 resize.awk, a2p -d1 repairs.awk, a2p -d2 repairs.awk
> a2p -D0 repairs.awk, a2p -D1 repairs.awk, a2p -D2 repairs.awk
> a2p -d 0 repairs.awk, a2p -d 1 repairs.awk, a2p -d 2 repairs.awk
> a2p -D 0 repairs.awk, a2p -D 1 repairs.awk, a2p -D 2 repairs.awk
> all of which get me "unrecognized switch -d (or -D or -d1 etc.)"
>
> Also tried some (more or less random) values for the -F switch (don't
> understand what it's for at all).
>
> > I've heard that a2p isn't able to deal with all of the features added
in
> > some awk variants, such as gawk. Could you have used some feature that
a2p
> > doesn't understand? (Not that it shouldn't give some diagnostic message
in
> > that case...)
> Thought of that. Though I'd certainly like to translate some of my
longer,
> more complicated AWK scripts, among the ones that I fed to a2p were
several
> that are "dead simple" (no GAWK or NAWK stuff), e.g. (repairs.awk)
>
> BEGIN { FS=OFS="|" }
>
> NF== 5 { Subject[$1]=$4; next }
> {
> is=substr($1,6); sb=substr($9,5,6); if (is==sb) next
> print $4,$1,sb,Subject[sb]
> }
>
>
> --
> -----------------------------------------------------------
> samdie@ibm.net
> -----------------------------------------------------------
>
>
------------------------------
Date: 27 Sep 1997 13:44:49 GMT
From: "Doug" <doug@3dlabs.com.remove>
Subject: Re: array assignment problem.
Message-Id: <01bcbf80$4e852900$d9d880c1@doug-laptop.3dlabs.com>
Hi,
Thanks for the regex improvement :)
My question though I think has been mis-interpreted. the following
works
@areas = ('database','news');
but the following doesn't
@areas = ('database','news','personal');
Any ideas?
Doug
------------------------------
Date: 27 Sep 1997 13:58:42 GMT
From: "Creede Lambard" <creede@worldnet.att.net>
Subject: Re: Bad start on Win95
Message-Id: <01bccb4d$7703f680$8314410c@boris>
Robert Crooks <robert.crooks@nortel.ca> wrote in article
<342C2F83.409E@nortel.ca>...
> Michael Powe wrote:
> >
[snip]
>
> I had the same thing happen to me. However, I executed
> c:\windows\Command which brought up a command prompt. It is that
> command prompt that I use to run perl.
>
> Robert Crooks
>
Yes, that will work just fine, though I find it easier to put a shortcut to
COMMAND.COM in my Start button, since I use it a lot. Another thing you can
do if you have sufficient screen resolution (well, you can do it at 640 x
480 but it's a lot easier at 1024 x 768 or better) is to open both a DOS
window on your desktop and PFE, and switch back and forth between the two.
Of course if you do this, you have to make sure your DOS shortcut is set
for "Windowed" and not "full screen."
------------------------------
Date: Sat, 27 Sep 97 10:16:47 -0400
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: can 'print' be overridden ?
Message-Id: <342d160b$1$ofn$mr2ice@speaker>
In <875317893.710@bellsouth.net>, on 09/26/97 at 06:51 PM,
anybody2@nospam.bellsouth.net (Snow White) said:
+-----
| Can 'print' be overridden?
+--->8
No. Or "not yet". You can, however, use tiehandle in Perl 5.004 to create
"filehandles" which convert "print", et al., into method calls.
--
brandon s. allbery [Team OS/2][Linux] bsa@void.apk.net
cleveland, ohio mr/2 ice's "rfc guru" :-) KF8NH
Warpstock '97: OS/2 for the rest of us! http://www.warpstock.org
Memo to MLS: End The Burn Scam --- Doug Logan MUST GO! FORZA CREW!
------------------------------
Date: 27 Sep 1997 14:10:55 GMT
From: "Creede Lambard" <creede@worldnet.att.net>
Subject: Re: CD width CPAN ?
Message-Id: <01bccb4f$2c003fc0$8314410c@boris>
I find it difficult to walk through the perl section of the bookstore
without tripping over a book that includes a CPAN CD. However, this might
not be the case in Spain . . .
I got mine with a copy of Perl5 For Dummies from IDG books, possibly
available at http://www.amazon.com. You might also try
http://www.cdrom.com, who publish all sorts of "archive" CD-ROMS (Linux
compilations, shareware games, OS/2 libraries, etc.). Keep in mind that a
CD will never have the latest version of CPAN, but if you can look at the
CD and see that a module is there you can always go to the net's version of
CPAN to pick up the latest version.
HTH,
-- Creede
Juan <juan@tres.com> wrote in article
<342c5cc0.16659959@noticias.ibernet.es>...
> Please, where can I purchase a CD width the CPAN?
>
> Thanks.
> Juan Palacio
> juan@tres.com
>
>
------------------------------
Date: 27 Sep 1997 10:26:34 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: CD width CPAN ?
Message-Id: <60j52q$rfe@panix.com>
In <342c5cc0.16659959@noticias.ibernet.es> juan@tres.com (Juan) writes:
>Please, where can I purchase a CD width the CPAN?
O'Reilly's Perl Resource Kit will have CPAN on a CD-ROM. See:
http://perl.oreilly.com/
--
Clay Irving <clay@panix.com> http://www.panix.com/~clay/
------------------------------
Date: Sat, 27 Sep 1997 07:41:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: CGI, Losing query parameters. HELP!
Message-Id: <Pine.GSO.3.96.970927073635.5897L-100000@usertest.teleport.com>
On Thu, 25 Sep 1997, George Torres wrote:
> I have a problem with losing query parameters when performing a button
> action.
If you're not getting the parameters from the form, one possible reason is
that the form is incorrect. If that's the problem, check with your HTML
docs, FAQs, and associated newsgroups, since those sources will be able to
give you a better and more complete answer than we can here.
Another possible reason is that there's a bug in the browser which is
sending the form, or in the server which is processing it. This isn't
likely, but if you think it's the problem, check with the associated docs,
FAQs, and newsgroups for the browser and server you're using.
Of course, the final reason that you might not be getting the parameters
is because of a problem in your Perl code. If you're using CGI.pm (or
something similar) you can check your code from the command line with the
Perl debugger. If you can't find the answer to your Perl question in the
docs and FAQs, go ahead and ask it here. It would be good to post a small
sample of the code which isn't doing what you want it to do.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sat, 27 Sep 1997 08:09:34 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Error in perl used for guestbook.
Message-Id: <ei0j06.3n.ln@localhost>
Thomas Larsson (thomas.larsson@vpress.se) wrote:
: Hello
: Does anyone know what the following error means?
: "Can't call method "_" without a package or object reference at
: gbook.pl at line 65"
I cannot duplicate your problem. Sorry.
: This is the part is the program surrounding line 65, starting with
: line 63.
: for ($i=0;$i<=SIZE;$i++) {
^^^^
What is SIZE?
A filehandle?
A subroutine?
A scalar missing the dollar sign?
I don't think that is going to work.
-w complains about it. You *are* using the -w switch, aren't you?
: $_=$LINES[$i];
: if (/<!--begin-->/) { <------- HERE's the line
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 27 Sep 1997 07:51:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Thomas Larsson <thomas.larsson@vpress.se>
Subject: Re: Error in perl used for guestbook.
Message-Id: <Pine.GSO.3.96.970927074435.5897M-100000@usertest.teleport.com>
On Fri, 26 Sep 1997, Thomas Larsson wrote:
> Does anyone know what the following error means?
>
> "Can't call method "_" without a package or object reference at
> gbook.pl at line 65"
>
> This is the part is the program surrounding line 65, starting with
> line 63.
>
> for ($i=0;$i<=SIZE;$i++) {
> $_=$LINES[$i];
> if (/<!--begin-->/) { <------- HERE's the line
> if ($entry_order eq '1') {
> print GUEST "<!--begin-->\n";
> }
That error shouldn't be happening there, as far as I can tell. What
version of Perl are you using? It may be that you've found a bug in Perl's
parser, although I can't replicate this with 5.004_03. It seems more
likely that you've got a syntax error earlier in your code which has
confused the parser. Could you have, for example, quoted something using
bang ('!') characters as quotes? If you accidentally left off the closing
bang, that might cause this kind of error.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sat, 27 Sep 1997 07:35:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ian OH <ianoh@welleslian.com>
Subject: Re: Exec Unix command inPerl
Message-Id: <Pine.GSO.3.96.970927073035.5897K-100000@usertest.teleport.com>
On Sat, 27 Sep 1997, Ian OH wrote:
> 1. How to execute a unix command like:
>
> $mv file1.txt file2.txt
>
> in perl?
Check out the system function in the perlfunc(1) manpage and qx// in the
perlop(1) manpage. (But you can probably do what you want faster with
rename, also documented in perlfunc.)
> 2. Transfer a posted "form" data to an other server -->a user fill out
> some data to a perl program that will transfer the data again to an
> other server.
I think you want the LWP module, possibly in connection with the CGI
module or one of its relatives. You'll find the modules on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sat, 27 Sep 1997 13:27:41 GMT
From: frelbel@csnN0SPAM.net (Fred Elbel)
Subject: Flatten hash utility? Which one?
Message-Id: <342d0560.44106047@news-2.csn.net>
I need to flatten a moderately complex hash in order to ship it via a
socket connection to another perl application, and then restore it on
the other end. Ease of use, reliability, and speed are all important.
Advaced Perl Programming on page 156 mentions the FreezeThaw module.
It has been suggested that RPC from CPAN can handle this. Any
comments and recommendations?
Thanks,
Fred
-- Fred Elbel frelbel@N0SPAMcsn.net
-- To e-mail: delete N0SPAM in my return address
------------------------------
Date: Sat, 27 Sep 1997 07:55:26 GMT
From: wviecht@rs6000.cmp.ilstu.edu
Subject: Formdata to File & Missing Data
Message-Id: <342cb9ba.3330560@news.ilstu.edu>
I am conducting some psychological research over the internet. I wrote
this script to take some formdata and save it to a text file. Now in
some cases, people don't want to fill out all the fields or answer all
the questions. Let's say I have three radio button like questions.
Person 1 picks answers 3, 5, and 2. With the commands:
print DATA "$in{question1}";
print DATA " $in{question2}";
print DATA " $in{question3}\n";
I will get 3 5 2 in the output file.
Let's say, Person 2 picks 2, no answer, 6.
Then I will get 2 6 in the data file ...
But in order to match the variables up when I import the data into
some database, I want it to read 2 6 or 2 9 6 (where 9 will indicate
that the data is missing). I hope I am making myself clear ...
So how do I check for missing data and then write a value such as 9 or
empty space into the spot where the answer ought to be???
Any suggestions or comments?
Wolfgang
------------------------------
Date: 27 Sep 1997 14:22:16 GMT
From: "Creede Lambard" <creede@worldnet.att.net>
Subject: Re: Formdata to File & Missing Data
Message-Id: <01bccb50$c237f2c0$8314410c@boris>
Well, you should be able to do something like this:
print DATA (($in{question1} eq "") ? "9" : $in{question1});
print DATA " ",(($in{question2} eq "") ? "9" : $in{question2});
print DATA " ",(($in{question3} eq "") ? "9" : $in{question3}),"\n";
-- Creede
wviecht@rs6000.cmp.ilstu.edu wrote in article
<342cb9ba.3330560@news.ilstu.edu>...
> I am conducting some psychological research over the internet. I wrote
> this script to take some formdata and save it to a text file. Now in
> some cases, people don't want to fill out all the fields or answer all
> the questions. Let's say I have three radio button like questions.
> Person 1 picks answers 3, 5, and 2. With the commands:
>
> print DATA "$in{question1}";
> print DATA " $in{question2}";
> print DATA " $in{question3}\n";
>
> I will get 3 5 2 in the output file.
>
> Let's say, Person 2 picks 2, no answer, 6.
>
> Then I will get 2 6 in the data file ...
>
> But in order to match the variables up when I import the data into
> some database, I want it to read 2 6 or 2 9 6 (where 9 will indicate
> that the data is missing). I hope I am making myself clear ...
>
> So how do I check for missing data and then write a value such as 9 or
> empty space into the spot where the answer ought to be???
>
> Any suggestions or comments?
>
> Wolfgang
>
>
>
------------------------------
Date: Sat, 27 Sep 1997 09:01:34 GMT
From: ben.glazer@mail.utexas.edu (Ben Glazer)
Subject: Help with regular expressions!
Message-Id: <342cca51.23150193@news.cc.utexas.edu>
Hello, all!
i'm trying to write a short perl script to convert HTML tags to
lowercase except inside of quote marks, e.g.
<IMG SRC="/images/lwall.jpg" ALt="Larry!">
should be translated to
<img src="/images/lwall.jpg" alt="Larry!">
see? easy, right?
okay, well this is what i have:
while (<>) {
s/(.*?<)(.*?)(".*?")(.*>)/$1\L$2\E$3\L$4>/g;
}
and this is very nice when you have exactly one pair of quote marks.
otherwise, it bites. is there any way to have the regexp skip over a
variable number of quoted strings?
thanks,
Ben
------------------------------
Date: 27 Sep 1997 10:43:43 -0400
From: allen@gateway.grumman.com (John L. Allen)
Subject: Re: Help with regular expressions!
Message-Id: <60j62v$m2r@gateway.grumman.com>
In article <342cca51.23150193@news.cc.utexas.edu>,
Ben Glazer <ben.glazer@mail.utexas.edu> wrote:
>Hello, all!
>
>i'm trying to write a short perl script to convert HTML tags to
>lowercase except inside of quote marks, e.g.
>
> <IMG SRC="/images/lwall.jpg" ALt="Larry!">
>
>should be translated to
>
> <img src="/images/lwall.jpg" alt="Larry!">
>
>see? easy, right?
>
>okay, well this is what i have:
>
>while (<>) {
> s/(.*?<)(.*?)(".*?")(.*>)/$1\L$2\E$3\L$4>/g;
>}
I think you have to first find the tags, then alter them :
while (<>) {
s{ (<.*?>) }
{ ($tag = $1) =~ s/([^"]*)("[^"]*")([^"]*)/\L$1\E$2\L$3/g; $tag }egx
}
so, each tag is found by the (<.*?>) and then a global substitution is
performed on it.
Of course, nested "'s and <'s are still a problem.
John.
--
_/JohnL\_allen@gateway.grumman.com <Sun>: 9.5 billion pounds per sec to energy
~\Allen/~Fax: 516-575-7428 <Universe>: 1e22 stars = 22 solar masses per sec
------------------------------
Date: 27 Sep 1997 16:56:00 +0300
From: Jarkko Hietaniemi <hietanie@koah.research.nokia.com>
Subject: Re: how to create array of file handles?
Message-Id: <dpiuvmzwr3.fsf@koah.research.nokia.com>
alex@kawo2.rwth-aachen.de (Trudno zhit' v derevne bez nagana.) writes:
> PS: I've seen that IO:Socket can be used for server programs,
> but i am not allowed to install it at my web-server.
Do "man perlvar" and see what @INC does.
--
Jarkko Hietaniemi
------------------------------
Date: Sat, 27 Sep 1997 07:11:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Joel Shellman <tou@tou.com>
Subject: Re: How to get close match on keywords
Message-Id: <Pine.GSO.3.96.970927070554.5897H-100000@usertest.teleport.com>
On Fri, 26 Sep 1997, Joel Shellman wrote:
> I need something that will find words that are close but not exactly the
> same.
How about String::Approx, which you can find on CPAN?
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
> Because I wouldn't be surprised if this is answered in the FAQ, can
> someone also point out where to get the FAQ?
Try the 'perldoc' command, and 'perldoc perlfaq', which should work if you
have the most recent version of Perl properly installed on most systems.
Or use this URL.
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq.html
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sat, 27 Sep 1997 07:29:22 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Rufus <rste@greencathedral.com>
Subject: Re: Memory fails me
Message-Id: <Pine.GSO.3.96.970927071705.5897J-100000@usertest.teleport.com>
On Fri, 26 Sep 1997, Rufus wrote:
> Subject: Memory fails me
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> How do I pick out character n of a string of length N?
Use the substr function, documented in the perlfunc(1) manpage.
> I can clearly do this using substr, but I am sure that once I could
> clearly do it the right way.
<freud>For how long haff you had this delusion that some other way is the
"right" way?</freud> :-) I can think of several other ways, but (based
upon what you've said so far) I don't see why anything else would be any
more right.
> substr works, but will be slow, and I am sure is not the way I did it
> before. Please someone, remind me...
Actually, substr will almost certainly be faster than any of these other
ways. (But if you'll need to get at every character in the string, one at
a time, you may want to use a variation on the first method.)
$char = eval { my(@chars) = split //, $string; $chars[$n] };
($char) = ($string =~ /.{$n}(.)/s);
$char = chr( (unpack "C*", $string)[$n] );
There's more than one way to do it, but the simple and obvious may well be
the best. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sat, 27 Sep 1997 09:30:18 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
To: Larry Nguyen <Larry_P_Nguyen@qmail2.sp.trw.com>
Subject: Re: Perl script is not executed by Web browser
Message-Id: <Pine.SGI.3.95.970927092858.13058B-100000@vangogh.bergen.org>
>"HTTP/1.0 403 Access Forbdden (Read Access denied. This virtual
>directory does not allow objects to be read."
>It appears to me that the browser did not attempt to execute the Perl
>cmd which then run the Perl script. It tries to READ the script instead.
It has to read the script to execute it... the directory has to be chmoded
AT LEAST 444, that is, everyone has read and execute access.
> - I installed the Perl script (howdy.pl) to a valid directory which is
>set up by IIS (c:\inetpub\wwwroot\cgi-bin). This directory is set up
>with the correct permission to EXECUTE.
Make sure the directory has been chmoded to allow READ access as well.
----------------
| Before you think UNIX is family-oriented, note that all children must die.
| - Cross-Platform Perl
----------------
Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
** I can be found on #perl on irc.ais.net as jpinyan **
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>$ P+++$>++++ L E--->---- W++$
N++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
------------------------------
Date: 27 Sep 97 13:43:50 GMT
From: "Michael Duffy" <miked@psiaustin.com>
Subject: PERL with TCP/IP
Message-Id: <01bccb29$182c8600$144eaacf@miked>
I am trying to write a PERL script that will send an automatic "Thank you
for visiting" e-mail message when someone comes to our web site.
Do you have any ideas on how to do this directly with TCP/IP without using
our mail.exe (which is outside of our firewall) or without using UNIX
sendmail (we have MS IIS 3.0).
This simple concept has turned into a major hassle.
Your help would be appreciated.
Mike
------------------------------
Date: Sat, 27 Sep 1997 09:05:10 -0400
From: Kenneth Taborek <SPAM_ME_NOT_oberon@erols.com>
Subject: Re: Reading files (newb)
Message-Id: <342D0486.18CFBB44@nospam.erols.com>
Jason Gloudon wrote:
>
> Marc Genberg (mgenberg@marjar.com) wrote:
>
> : Tom MacMillan wrote:
>
> : why not try something like this:
>
> : my $counter=0;
> : my @data;
>
> : open (DATA, "./data.file");
> : while(<DATA>) {
> : chomp;
>
> : $data[$counter] = $_;
> : $counter++;
> These two are better as one
>
> push @data, $_;
>
> Jason Gloudon
How about:
open(DATA, "data.file") || die
"File users not found in local directory, exited with error $!\n";
@data = <DATA>;
--Ken Taborek oberon@nospam.erols.com
------------------------------
Date: Sat, 27 Sep 1997 09:24:01 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
To: Eric Phillips <ephillips@starhosting.com>
Subject: Re: Searching a directory
Message-Id: <Pine.SGI.3.95.970927092258.13058A-100000@vangogh.bergen.org>
>Could someone please tell me how to search using Perl? I am fairly new
>at this, but I do know some of the basics of Perl. Please tell me by
>E-mailing me at e.phillips@mindspring.com. Thanks!
use this:
opendir(DIR, "/your/dir/tobe/opened");
@contents = <DIR>;
close (DIR); # or is it closedir(DIR); ???
that will give you the contents of a directory.
----------------
| "I don't contemplate it, I just sit and think about it."
| - Sonia Balsky
----------------
Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
** I can be found on #perl on irc.ais.net as jpinyan **
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>$ P+++$>++++ L E--->---- W++$
N++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
------------------------------
Date: Sat, 27 Sep 1997 08:14:14 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: sysread() question
Message-Id: <6r0j06.3n.ln@localhost>
Trudno zhit' v derevne bez nagana. (alex@kawo2.rwth-aachen.de) wrote:
: can someone please explain me, what i am doing wrong?
: I am trying to sysread a byte sequence from a TCP-socket.
: The first byte contains the number of bytes to follow:
: sub read_seq
: {
: my $SOCKET = shift; # socket handle
: my $seq;
: # first read 1 byte:
: my $bytes_read = sysread $SOCKET, $seq, 1; # line 43
: But when i am trying to use this subroutine like:
: my $client_address_packed = accept(CLIENT, SERVER) or die "accept: $!";
: select CLIENT;
: $| = 1;
: ....
: $seq = read_seq(CLIENT);
: i am receiving warning:
: Use of uninitialized value at ./pref.pl line 43
: Does it mean, my $SOCKET=shift; didnt work? How am i then
: supposed to use file/socket handles in Perl subroutines?
Perl FAQ, part 5:
"How can I make a filehandle local to a subroutine?
How do I pass filehandles between subroutines?
How do I make an array of filehandles?"
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 27 Sep 1997 14:01:16 GMT
From: akil1@mindspring.com (Kevin Bass)
Subject: Typeglob - Temporary Aliases
Message-Id: <60j3n6$e94@camel3.mindspring.com>
On page 43 of Advanced Perl Programming (O'Reilly & associates, Inc.)
the answer to the problem below is $a = 20 and $b = 10. In solving
this problem, I got the result of $a = 20 and $b = 20. Please explain
why $b = 10.
$b = 10;
{
local *b;
*b = *a;
$b = 20;
}
print $a;
print $b;
Kevin Bass
------------------------------
Date: Sat, 27 Sep 1997 13:40:51 +0100
From: Russell Odom <russ@mail.org.uk>
Subject: Re: Unlist syntax
Message-Id: <342CFED3.FCEB98C3@mail.org.uk>
wazza wrote:
>
> Thanks to those who promptly answered my query on how to delete files.
>
> I tried out the lines:
> $file = $path."temp.txt";
> unlink $file;
>
> but nothing seems to be happening. Could someone assist me with the
> correct syntax please.
Your syntax looks correct to me. My guess is that there's no '/' on the
end of $path. Oh, and check the return value from unlink()...
$path .= '/temp.txt';
unlink $file or die ('Can't unlink $file');
Russ
---------------------------------------------------------------------
--[ R u s s e l l O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[ University of York, UK ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[ FAQ maintainer, news:comp.os.ms-windows.win95.moderated ]--
---------------------------------------------------------------------
------------------------------
Date: Sat, 27 Sep 1997 07:15:57 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Yash Khemani <yash@teczar.com>
Subject: Re: WHILE LOOP LOGIC
Message-Id: <Pine.GSO.3.96.970927071252.5897I-100000@usertest.teleport.com>
On Fri, 26 Sep 1997, Yash Khemani wrote:
> open (inf,$filename);
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check of the return value after opening a file.
Also, it's generally best to make the name of a filehandle all caps.
> while (<inf>) {
> local (@ary = split /\s+/,$_;
You probably wanted to use my() instead of local there. Although either
should work for what you're doing, my() vars are faster and almost always
preferred. (And, of course, you left out a closing paren. :-)
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sat, 27 Sep 1997 13:20:09 +0100
From: Russell Odom <russ@mail.org.uk>
Subject: Re: Win95 cgi
Message-Id: <342CF9F9.A064804B@mail.org.uk>
Ian Dickson wrote:
>
> I am trying to get HTML forms to communicate with perl
> scripts (using aWin95 server --WebSite). I gather from the
> FAQ that I will probably need to convert my scripts using
> pl2bat, I'd be really grateful if someone could tell me
> where I can find pl2bat -- it didn't come with my Win32
> version of perl. Or, even better, mail me the binary code.
Get Gurusamy Sarathy's Win32 port from
http://www.perl.com/CPAN/ports/win95/Gurusamy_Sarathy/
This includes pl2bat and other stuff not included in the
Activeware/Activestate port.
HTH,
Russ
---------------------------------------------------------------------
--[ R u s s e l l O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[ University of York, UK ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[ FAQ maintainer, news:comp.os.ms-windows.win95.moderated ]--
---------------------------------------------------------------------
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
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 1089
**************************************