[18681] in Perl-Users-Digest
Perl-Users Digest, Issue: 849 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 7 18:05:55 2001
Date: Mon, 7 May 2001 15:05:14 -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: <989273114-v10-i849@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 7 May 2001 Volume: 10 Number: 849
Today's topics:
Re: Access 97 *.mdb & Perl (Andrew J. Perrin)
Re: Access 97 *.mdb & Perl <bart.lateur@skynet.be>
Re: Capturing matches from several regexpes <godzilla@stomp.stomp.tokyo>
Re: Capturing matches from several regexpes (Rudolf Polzer)
Re: Capturing matches from several regexpes (Rudolf Polzer)
Cwd & -T <diab.lito@usa.net>
Re: Cwd & -T <djberge@uswest.com>
Re: Cwd & -T <elijah@workspot.net>
Re: Cwd & -T <djm@spamfree.mcoe.k12.ca.us>
Re: General Personal Development Strategy (John R Ramsden)
Re: global variables (Abigail)
Help: Need better sleep(1) <djm@spamfree.mcoe.k12.ca.us>
Re: Help: Need better sleep(1) <tony_curtis32@yahoo.com>
Re: Help: Need better sleep(1) <djm@spamfree.mcoe.k12.ca.us>
How do I use client text file for cgi script? <resslers@ohsu.edu>
Re: How do I use client text file for cgi script? <godzilla@stomp.stomp.tokyo>
Re: How to determine file type of a filehandle? <ren@tivoli.com>
Re: Local Time ryan@dcntet.net
Newbie LWP Question <jean.zoch@utoronto.ca>
Problem: Formmail acting up with Senmail <nanoburn@newsfeeds.com>
Question: some odd-looking behavior viscido@u.washington.edu
Re: Question: some odd-looking behavior <ren@tivoli.com>
Re: Question: some odd-looking behavior <djm@spamfree.mcoe.k12.ca.us>
R: Cwd & -T <diab.lito@usa.net>
R: Help slim down Perl code <diab.lito@usa.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 07 May 2001 16:14:29 -0500
From: andrew_perrin@unc.edu (Andrew J. Perrin)
Subject: Re: Access 97 *.mdb & Perl
Message-Id: <878zk8vp3e.fsf@nujoma.perrins>
jtjohnston <jtjohnston@courrier.usherb.ca> writes:
>
> I know I've seen it somewhere where I can
> open (MADBFILE, "./thisfile.mdb");
Well, yes, you can open the file, but you won't get much out of
it. AFAIK there is no way to directly and usefully access the
information in an Access file without some form of Microsoft Jet, the
database engine that underlies Access. You can use Access, or you can
use Jet via the Access ODBC driver, but you can't just open the file.
>
> I don't want to install servers or other stuff. And I'll show you why. I'm
> using perl on this type of a server:
> http://www.indigostar.com/microweb.htm
> (As crazy as it sounds, it works very well. It's a educational project I'm
> working on.)
Unfortunately, if you want the db to be in Access you're going to have
to run Windows in order to serve the Access db via ODBC. If you're
flexible on db's, use mSQL (because it's small) or the package whose
name escapes me but which implements an SQL database using text files
in perl.
Slightly OT: You need to learn some of the basics of databases,
specifically what SQL is and how DBI and ODBC work, to do this
project. SQL != SQL Server, for example.
--
----------------------------------------------------------------------
Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology
(Soon: Asst Professor of Sociology, U of North Carolina, Chapel Hill)
andrew_perrin@unc.edu - http://www.unc.edu/~aperrin
------------------------------
Date: Mon, 07 May 2001 21:20:34 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Access 97 *.mdb & Perl
Message-Id: <dd3eftsip6r295gu1fdipe0q0dnn2npp4k@4ax.com>
jtjohnston wrote:
>Can I use win32::obdc without http://www.activestate.com/PPMpackages/5.6/ ?
>
>I don't want to use a SQL server. I have the necessary *.pm & *.dll
>successfully installed, which I got from here:
>http://www.geocities.com/Area51/Cavern/4503/perl_odbc.htm .
Er... hello?
The link I gave you is nothing but a directory of precompiled modules.
Now the URL you gave, doesn't use DBI and DBD::ODBC, but the older
competitor, Win32::ODBC. Which is fine by me (although I have my doubts
on how they distribute their binary files. Couldn't they just create a
ZIP file?). The DBI book devotes a whole chapter on comparing
Win32::ODBC and DBI+DBD::ODBC.
But it won't buy you anything. As you can see from the URL you quoted,
you still need to create a DSN, you still need ODBC and the Access
driver ("Jet") installed.
>I know I've seen it somewhere where I can
> open (MADBFILE, "./thisfile.mdb");
>
>I don't want to install servers or other stuff.
>And I'll show you why. I'm
>using perl on this type of a server:
> http://www.indigostar.com/microweb.htm
>(As crazy as it sounds, it works very well. It's a educational project I'm
>working on.)
So you want to create a CD-ROM? Well, then this is a dead end. Think
about alternatives, that don't use ODBC.
Do you even need an SQL database? A tied hash, using SDBM or any other
similar engine (see the docs for AnyDBM_File for a list), might work
just as well.
>All I need is a few lines of code to get started. Open the *.mdb, open the
>table, display the data.
Won't work.
--
Bart.
------------------------------
Date: Mon, 07 May 2001 12:05:49 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Capturing matches from several regexpes
Message-Id: <3AF6F20D.3E9BEC92@stomp.stomp.tokyo>
Rudolf Polzer wrote:
(snipped in entirety)
Why do you parrot my code? Polly want a cracker?
If you are to emulate my superior style, at least
write parrot code which works right. You are not
a very well trained parrot. Thank Goodness for
cage bottom newspaper.
* laughs *
Godzilla!
--
@ø=(a .. z);@Ø=qw(6 14 3 25 8 11 11 0 17 14 2 10 18);
$§="\n";$ß="\b";undef$©;print$§x($Ø[4]/2);
for($¡=0;$¡<=$Ø[2];$¡++){foreach$¶(@Ø){
$ø[$¶]=~tr/A-Z/a-z/;if(($¡==1)||($¡==$Ø[2]))
{$ø[$¶]=~tr/a-z/A-Z/;}print$ø[$¶];if($¶==0)
{print" ";}if($¶==$Ø[12]){print" !";}&D;}
print$ßx($Ø[4]*2);}print$§x($Ø[10]*2);
sub D{select$©,$©,$©,.25;}exit;
------------------------------
Date: Mon, 7 May 2001 23:46:52 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Capturing matches from several regexpes
Message-Id: <slrn9fe5uc.q1u.eins@www42.t-offline.de>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Rudolf Polzer wrote:
>
> (snipped in entirety)
>
>
> Why do you parrot my code? Polly want a cracker?
I did not parrot it, I improved it to a one-liner.
> If you are to emulate my superior style, at least
> write parrot code which works right. You are not
It does. At least on my machine.
> * laughs *
o.oOOOo. Oo .oOOOo. `o O
o o o O .O o o O
o O O O O o o O O o O
O O oOooOO. oOooOoOo o oOo O O
oooOooo o `O o O o o o oooOooo
O O O o O o O O O O O
O `o o .O o O `o .o o o O `o
`OooOO' O. O `OoooO' O O
> @ø=(a .. z);@Ø=qw(6 14 3 25 8 11 11 0 17 14 2 10 18);
g o d z i l l a r o c k s # I do know the alphabet
--
To view the lower part of this signature, apply ROT13 to the whole message.
Gb ivrj gur hccre cneg bs guvf fvtangher, nccyl EBG13 gb gur jubyr zrffntr.
------------------------------
Date: Mon, 7 May 2001 23:48:57 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Capturing matches from several regexpes
Message-Id: <slrn9fe629.q1u.eins@www42.t-offline.de>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> If you are to emulate my superior style, at least
^^^^^^^^^^^^^^
So you think it is good style to use variables named $§, $¢ etc.?
--
#!/usr/bin/perl -- Random sig generator. Editor command in slrn => ~/siggs
$F=shift;open H,"+<$F";$_=join"",<H>;$s=index$_,"\n\n-- \n";$s<0||truncate
H,$s;close H;system"$ENV{EDITOR} $F</dev/tty>/dev/tty";$s=$n=0;for#sichtig
(<~/siggs/*>){++$n;int rand$n or$s=$_};`(echo "\n\n-- ")|cat - $s>>$F`+nan
------------------------------
Date: Mon, 7 May 2001 20:59:03 +0200
From: "Mario Rizzuti" <diab.lito@usa.net>
Subject: Cwd & -T
Message-Id: <fgCJ6.5474$oa2.124764@news6.giganews.com>
Is there a way to avoid specification of the full path to scripts while
still working under taint mode?
#!perl -T
require "./hello.pl"; # error
require "/a/b/c/d/hello.pl"; # ok
Thanks anyone,
Mario Rizzuti
------------------------------
Date: Mon, 07 May 2001 15:17:57 -0500
From: "Mr. Sunray" <djberge@uswest.com>
Subject: Re: Cwd & -T
Message-Id: <3AF702F5.5687A84A@uswest.com>
Mario Rizzuti wrote:
> Is there a way to avoid specification of the full path to scripts while
> still working under taint mode?
>
> #!perl -T
> require "./hello.pl"; # error
> require "/a/b/c/d/hello.pl"; # ok
>
> Thanks anyone,
> Mario Rizzuti
I just had to fight this myself. Here's what I came up with...
# Assuming that the cwd is the dir you want. I think you'll at least get
the drift
use Cwd;
BEGIN{
use vars qw($lib_dir);
$lib_dir= getcwd();
if($lib_dir =~ /^(.*?)$/){ $lib_dir = $1 } # You probably want a better
regex here
}
use lib $lib_dir;
require "hello.pl";
------------------------------
Date: 7 May 2001 20:27:36 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Cwd & -T
Message-Id: <eli$0105071625@qz.little-neck.ny.us>
In comp.lang.perl.misc, Mario Rizzuti <diab.lito@usa.net> wrote:
> Is there a way to avoid specification of the full path to scripts while
> still working under taint mode?
>
> #!perl -T
> require "./hello.pl"; # error
> require "/a/b/c/d/hello.pl"; # ok
What perl are you using? I didn't get an error doing that with
perl 5.6.0.
Elijah
------
was going to try an explict chdir() if perl balked
------------------------------
Date: Mon, 07 May 2001 20:28:58 GMT
From: "Dave" <djm@spamfree.mcoe.k12.ca.us>
Subject: Re: Cwd & -T
Message-Id: <eADJ6.8999$po.36406@typhoon.sonic.net>
The only problem with that solution is that the users CURRENT working
directory is reported. If you happen to not be in that directory, and run
the program from someplace else, you get the wrong result from cwd.
for example:
program resides in /usr/local/bin, the require file is right there next to
it.
i'm in /root and I type the programs name into bash: runtest
the results of cwd are "/root"
and the require will fail to find the require file in /usr/local/bin/
"Mr. Sunray" <djberge@uswest.com> wrote in message
news:3AF702F5.5687A84A@uswest.com...
> Mario Rizzuti wrote:
>
> > Is there a way to avoid specification of the full path to scripts while
> > still working under taint mode?
> >
> > #!perl -T
> > require "./hello.pl"; # error
> > require "/a/b/c/d/hello.pl"; # ok
> >
> > Thanks anyone,
> > Mario Rizzuti
>
> I just had to fight this myself. Here's what I came up with...
>
> # Assuming that the cwd is the dir you want. I think you'll at least get
> the drift
> use Cwd;
>
> BEGIN{
> use vars qw($lib_dir);
> $lib_dir= getcwd();
> if($lib_dir =~ /^(.*?)$/){ $lib_dir = $1 } # You probably want a better
> regex here
> }
>
> use lib $lib_dir;
> require "hello.pl";
>
------------------------------
Date: Mon, 07 May 2001 20:58:16 GMT
From: jr@redmink.demon.co.uk (John R Ramsden)
Subject: Re: General Personal Development Strategy
Message-Id: <3af70c50.26612648@news.demon.co.uk>
lvirden@cas.org wrote:
>
> Treating someone poorly, regardless of their inappropriate behavior,
> seldom converts them to one's point of view, creates barriors, and
> in all likelihood burns bridges which, one day, one may regret having
> burned (imagine if you will finding yourself across the hiring desk
> from someone that you might have treated that way...)
I'd just tell the moron there was no point in continuing the interview
and they should seek a job elsewhere.
;-)
Cheers
---------------------------------------------------------------------------
John R Ramsden (jr@redmink.demon.co.uk)
---------------------------------------------------------------------------
The new is in the old concealed, the old is in the new revealed.
St Augustine.
---------------------------------------------------------------------------
------------------------------
Date: Mon, 7 May 2001 19:15:01 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: global variables
Message-Id: <slrn9fdt1l.t91.abigail@tsathoggua.rlyeh.net>
MJ (nobody@nobody.com) wrote on MMDCCCVI September MCMXCIII in
<URL:news:3AF6DF89.5D508185@nobody.com>:
"" How do I set a variable within a package so that subsequent
"" calls to routines in that same package will see that value?
"" I'd also like to have access to that initially-set variable
"" from the calling program.
$PACKAGE::variable = 'value';
Abigail
------------------------------
Date: Mon, 07 May 2001 18:17:52 GMT
From: "Dave" <djm@spamfree.mcoe.k12.ca.us>
Subject: Help: Need better sleep(1)
Message-Id: <kFBJ6.8984$po.36190@typhoon.sonic.net>
I need to create a sleep routine that I can control on
the -less-then-one-second- intervals.
For example:
I need to sleep my program for 0.10 seconds
I don't want a routine which sucks up CPU time like this does:
for ($x=0; $x < 1000000; ++$x) {}
That routine sucks, I want the program to really SLEEP and not do anything,
like sleep(1) does.....
(my program cannot halt on input either)
I've been over all my books, from Programming Perl to Advanced Perl, and
nothing.... I work for a school administration, your help will get you bonus
points in heaven for helping kids! :)
------------------------------
Date: 07 May 2001 13:24:16 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Help: Need better sleep(1)
Message-Id: <87heyx3tm7.fsf@limey.hpcc.uh.edu>
>> On Mon, 07 May 2001 18:17:52 GMT,
>> "Dave" <djm@spamfree.mcoe.k12.ca.us> said:
> I need to sleep my program for 0.10 seconds
perldoc -f select, the select(2) variant. Discusses
fractional sleeps at the end.
A more abstract approach can be found at
http://search.cpan.org/ ==> "time"
Time::HiRes ==>
http://search.cpan.org/doc/DEWEG/Time-HiRes-01.20/HiRes.pm
which provides "usleep".
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: Mon, 07 May 2001 18:39:17 GMT
From: "Dave" <djm@spamfree.mcoe.k12.ca.us>
Subject: Re: Help: Need better sleep(1)
Message-Id: <pZBJ6.8986$po.36276@typhoon.sonic.net>
Turns out that select(undef, undef, undef, 0.25) was perfect!
"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87heyx3tm7.fsf@limey.hpcc.uh.edu...
> >> On Mon, 07 May 2001 18:17:52 GMT,
> >> "Dave" <djm@spamfree.mcoe.k12.ca.us> said:
>
> > I need to sleep my program for 0.10 seconds
>
> perldoc -f select, the select(2) variant. Discusses
> fractional sleeps at the end.
>
> A more abstract approach can be found at
>
> http://search.cpan.org/ ==> "time"
>
> Time::HiRes ==>
>
> http://search.cpan.org/doc/DEWEG/Time-HiRes-01.20/HiRes.pm
>
> which provides "usleep".
>
> hth
> t
> --
> Just reach into these holes. I use a carrot.
------------------------------
Date: Mon, 7 May 2001 11:43:05 -0700
From: "Sean Ressler" <resslers@ohsu.edu>
Subject: How do I use client text file for cgi script?
Message-Id: <11CJ6.540$7O2.10344@typhoon.aracnet.com>
I recently wrote a Perl script that transforms a text file to an HTML
document. I would like to allow my users to call the script via web browser
(cgi) and supply the text file from their local machine.
The script runs from the command line by issuing the command: "<scriptname>
<path/text filename>" without quotes.
How do I supply / determine the <path/text filename> to the script that
resides on the server?
Thanks in Advance.
Sean.
------------------------------
Date: Mon, 07 May 2001 12:20:41 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: How do I use client text file for cgi script?
Message-Id: <3AF6F589.EA42A91D@stomp.stomp.tokyo>
Sean Ressler wrote:
> I recently wrote a Perl script that transforms a text file to an HTML
> document. I would like to allow my users to call the script via web
> browser (cgi) and supply the text file from their local machine.
> The script runs from the command line by issuing the command: "<scriptname>
> <path/text filename>" without quotes.
This is not cgi type scripting but does serve to establish a background.
> How do I supply / determine the <path/text filename> to the script that
> resides on the server?
Unless you are willing to open up a FTP server or a Telnet server
for clients to load these text files to your server, a rather logical
approach would be to provide a text area input via a form action,
being mindful about number of character limits which may or may not
be imposed by your server software or, theirs. America Onlame is
infamous for limits of this nature, as an example, as well as
FUBAR'n most html code entered or returned via a form action.
Another option would be to have your script fetch client text files
from remote servers, presumably theirs, via LWP Simple then print a
returned results page. This would seem to be most logical.
Godzilla!
------------------------------
Date: 07 May 2001 14:41:54 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: How to determine file type of a filehandle?
Message-Id: <m3snihhrp9.fsf@dhcp9-172.support.tivoli.com>
On Sun, 6 May 2001, djmarcus@ex-pressnet.com wrote:
> # I tried both versions since the very sparse documentation on the
> # 'if -r' and others does not mention whether they want a glob, a
> # file handle or a fileno integer.
Seems pretty clear to me (from perlfunc(1), or "perldoc -f -r"):
[...] This unary operator takes one argument,
either a filename or a filehandle, and tests the
associated file to see if something is true about
it. [...]
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Mon, 07 May 2001 21:19:24 GMT
From: ryan@dcntet.net
Subject: Re: Local Time
Message-Id: <wjEJ6.43650$FS3.483121@sjc-read.news.verio.net>
"Alan J. Flavell" <flavell@mail.cern.ch> wrote in
<Pine.LNX.4.30.0105071759230.30987-100000@lxplus003.cern.ch>:
>On Mon, 7 May 2001 ryan@dcntet.net wrote:
>
>[comprehensive quote snipped]
>
>> That did the trick. Thanks all!
>
>Congratulations, you just succeeded in unleashing the entire power of
>the world-wide Perl community on reading the documentation to you.
>However, for some reason they didn't seem to answer your real problem,
>which appears to be how to use the comprehensive documentation that
>came as standard with your Perl installation.
>
Thank you Alen for the advice, since a point in the right direction as far
as documentation is what I asked for. ( I do appreciate the help that
others provided though). Besides I was really just curious as to which
module to use. I am new to perl and learning as much as I can from the
documentation, and books. Do you really feel that you snide comments where
warranted? jeez...
Ryan
The advice on perldoc is appreciated though.
------------------------------
Date: Mon, 7 May 2001 18:41:57 GMT
From: "Jean" <jean.zoch@utoronto.ca>
Subject: Newbie LWP Question
Message-Id: <GCzAM0.37E@campus-news-reading.utoronto.ca>
Hello,
I've been using LWP::Simple to get the HTML code from a website. To do this
I use:
$url = http://the.url.iwant;
use LWP::Simple;
$content = get($url);
I also, however, need the actual URL of the page. Since many pages have
redirects, the URL of the content I get is often not my $url. I thought
maybe I could get the actual URL using the 'head' command, but this does not
return it.
Any suggestions? Perhaps I need to use a different Module?
Thanks,
Jean
------------------------------
Date: Mon, 7 May 2001 12:56:58 -0500
From: "Nanoburn" <nanoburn@newsfeeds.com>
Subject: Problem: Formmail acting up with Senmail
Message-Id: <3af6e644_2@news3>
I've recently upgraded to Redhat 7.0 and am using Sendmail 8.11.0. I've
always used FormMail.pl from Matt's Script Archive even before my upgrade,
and there were never any problem. I'm now wondering if there is some
compatibility issues with the newer version of Sendmail because every time a
user tries to send data from a form on an html page they get redirected the
way they should, but there isn't an email sent out. I've checked my script
and it has the right addresses for perl and sendmail. When I check my
maillog in Sendmail it shows that FormMail is trying to send something, but
all the fields are either blank or equal to zero. Does anyone have any clue
at all as to what is happening?
Bobby G. Brown, Jr.
bobby@superiorsites.net
sysadmin@superiorsites.net
------------------------------
Date: 07 May 2001 12:38:50 -0700
From: viscido@u.washington.edu
Subject: Question: some odd-looking behavior
Message-Id: <m33dahrlth.fsf@fiddler.u.washington.edu>
I will preface this by saying I'm quite a perl newbie, so please have
patience if this is a dumb question. I've tried to fix this problem
every way I can think of, and it's not just not working, it's giving
me some darn odd output.
History:
A few friends and I, who play on (and run) MUSHes that use the C-based
PennMUSH server, have decided to try a little experiment we call
"PerlMUSH". What we want to do, in a nutshell, is build a MUSH server
in Perl (instead of the standard C code such things are written
in). We haven't gotten very far at all yet in our design thinking
(such as database structure). Right now we're just trying to see if we
can get the server loop to work.
The problem: We co-opted a nonforking server out of the Perl Cookbook
recipe 17.13 (thanks to one of the other members of the design
team). The only thing it's supposed to do right now is loop
continuously, and listen on a port (at the moment we're using 5555)
for telnet connections. When one happens, it prints a welcome
message. All of that works just fine.
I decided to twiddle with the code in a subroutine we named handle(),
which is supposed to handle all the input from the user. My desire at
this point was just to see if it could "hear" the user's typings, and
just echo back what you typed. Fairly simple, it seemed. Here's the
subroutine:
# handle($socket) deals with all pending requests for $client
sub handle {
# requests are in $ready{client}
# send output to $outbuffer{$client}
my $client = shift;
my $request;
foreach $request (@{$ready{$client}}) {
# $request is the text of the request.
chomp $request;
print $client "You typed $request.\n";
}
delete $ready{$client};
}
If you do this without the chomp, and type hello, you see:
You typed hello
.
So clearly, the newline needs to be "chomped" off. I tried it with
chomp (as I show above), and I get this if I type "hello":
.ou typed hello
So it gets ridd of the newline, but for some bizzare reason, it places
the period at the front of the string and chops off the first
character of the string. I get similar (but worse) behavior using the
format the other guy originally wanted, which is this:
$outbuffer{$client} .= "You typed $request.\n";
Using that, typing hello into the program, you get this out:
. o typed hello
So not only is the Y chopped off, but the u is removed and replaced
with a space character.
Any ideas on why the period's being moved within the string and the
first character(s) of "You typed..." is being removed? I'm utterly
baffled. I realise I haven't put all of our code in here for you to
peruse, but I thought perhaps someone had seen behavior like this
before in another context and might be able to offer some quick
insight.
Thanks for any help,
Steve
--
Steven Viscido [viscido@u.washington.edu]
Department of Zoology, Box 351800 Kincaid Hall
University of Washington
Seattle, WA 98195 Tel: 206-221-6893
------------------------------
Date: 07 May 2001 15:06:40 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Question: some odd-looking behavior
Message-Id: <m3oft4j54f.fsf@dhcp9-172.support.tivoli.com>
On 07 May 2001, viscido@u.washington.edu wrote:
> If you do this without the chomp, and type hello, you see:
> You typed hello
> .
>
> So clearly, the newline needs to be "chomped" off. I tried it with
> chomp (as I show above), and I get this if I type "hello":
>
> .ou typed hello
You're getting rid of the newline ("\n"), but there is still a
carriage return ("\r").
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Mon, 07 May 2001 20:41:41 GMT
From: "Dave" <djm@spamfree.mcoe.k12.ca.us>
Subject: Re: Question: some odd-looking behavior
Message-Id: <9MDJ6.9002$po.36516@typhoon.sonic.net>
Hows about, instead of chomp, he use this:
split /\r?\n?$/
Does that even work? the ? should mean 0 or 1 matches.
"Ren Maddox" <ren@tivoli.com> wrote in message
news:m3oft4j54f.fsf@dhcp9-172.support.tivoli.com...
> On 07 May 2001, viscido@u.washington.edu wrote:
>
> > If you do this without the chomp, and type hello, you see:
> > You typed hello
> > .
> >
> > So clearly, the newline needs to be "chomped" off. I tried it with
> > chomp (as I show above), and I get this if I type "hello":
> >
> > .ou typed hello
>
> You're getting rid of the newline ("\n"), but there is still a
> carriage return ("\r").
>
> --
> Ren Maddox
> ren@tivoli.com
------------------------------
Date: Mon, 7 May 2001 22:50:48 +0200
From: "Mario Rizzuti" <diab.lito@usa.net>
Subject: R: Cwd & -T
Message-Id: <oVDJ6.5828$oa2.131346@news6.giganews.com>
Eli the Bearded <elijah@workspot.net> wrote in message
eli$0105071625@qz.little-neck.ny.us...
> In comp.lang.perl.misc, Mario Rizzuti <diab.lito@usa.net> wrote:
> > Is there a way to avoid specification of the full path to scripts while
> > still working under taint mode?
> >
> > #!perl -T
> > require "./hello.pl"; # error
> > require "/a/b/c/d/hello.pl"; # ok
>
--
> What perl are you using? I didn't get an error doing that with
> perl 5.6.0.
For some reason I miss, I guess it is server dependant since it works fine
on my Apache/win98 server while gives me error on IIS4/NT for example.
--
Mario Rizzuti
------------------------------
Date: Mon, 7 May 2001 21:48:02 +0200
From: "Mario Rizzuti" <diab.lito@usa.net>
Subject: R: Help slim down Perl code
Message-Id: <6fDJ6.5576$oa2.128261@news6.giganews.com>
Falc2199 <falc2199@aol.comNOJUNK> wrote in message
20010505191621.15352.00002168@ng-xc1.aol.com...
> I have here a lot of reduntant code. I need a way to slim it down. It
bascially
> does the same thing over and over, open and a file and read the contents
into
> an array....
>
> $lChoiceFile = 'lChoice.txt';
>
> open (LCHOICE,"<$lChoiceFile");
> @lCarray=<LCHOICE>;
> close (lCHOICE);
>
> $oChoiceFile = 'oChoice.txt';
>
>
> open (OCHOICE,"<$oChoiceFile");
> @oCarray=<OCHOICE>;
> close (OCHOICE);
>
> $bChoiceFile = 'bChoice.txt';
>
> open (BCHOICE,"<$bChoiceFile");
> @bCarray=<BCHOICE>;
> close (BCHOICE);
>
> It works fine but as you can see I am repeating it often. I think
arrays/for
> loops or an openFile function might be a good way to cut it down but
niether
> seem to work.
>
> You see I need each of those arrays @lCarry and @tCarry later on in the
code.
> If I use arrays/ for loops then I need mulit-dimensional arrays and if I
use a
> function then I think I have to pass these arrays by reference so the
function
> can modify them. I an not sure Perl can do either of this.
I would do it in this way but if you have a lot of files to read, maybe it
would be more slim to have array and file names in 2 arrays or an hash and
use references.
[not tested]
my @lCarray=&read_it($lChoiceFile);
my @oCarray=&read_it($oChoiceFile);
my @bCarray=&read_it($bChoiceFile);
sub read_it {
my $filename=shift;
open (FH, $file_name) || die "$filename: $!";
my @lines=<FH>;
close (FH) || die "$filename: $!";
return @lines;
}
--
Mario Rizzuti
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 849
**************************************