[16134] in Perl-Users-Digest
Perl-Users Digest, Issue: 3546 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 14:57:19 2000
Date: Mon, 10 Jul 2000 11:57:06 -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: <963255426-v9-i3546@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 10 Jul 2000 Volume: 9 Number: 3546
Today's topics:
Re: <newbie>How to determine current location (pwd) in <colinrei@oz.net>
Re: <newbie>How to determine current location (pwd) in (Bernard El-Hagin)
Re: <newbie>How to determine current location (pwd) in <colinrei@oz.net>
Re: <newbie>How to determine current location (pwd) in (Bernard El-Hagin)
Re: <newbie>How to determine current location (pwd) in (Tad McClellan)
Re: <newbie>How to determine current location (pwd) in (Tad McClellan)
Re: <newbie>How to determine current location (pwd) in <colinrei@oz.net>
Re: <newbie>How to determine current location (pwd) in (Jon Bell)
[ References ] I'm trying to replace \%hash by its cont <TheEx0rcist@fanclub.org>
Re: [ References ] I'm trying to replace \%hash by its (Marcel Grunauer)
Re: [ References ] I'm trying to replace \%hash by its <uri@sysarch.com>
Re: [ References ] I'm trying to replace \%hash by its (Keith Calvert Ivey)
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
Re: [Perl] How to find the Perl FAQ <uri@sysarch.com>
Re: [Perl] How to find the Perl FAQ (Eric Bohlman)
[Q] Reading a file containing control characters <vwcorrado@my-deja.com>
Re: [Q] Reading a file containing control characters <care227@attglobal.net>
Re: [Q] Reading a file containing control characters <care227@attglobal.net>
[Q] Seperate string with newline in stream ? (Markus Fischer)
Re: [Q] Seperate string with newline in stream ? (John Harden Borwick)
Re: [Q] Seperate string with newline in stream ? (Markus Fischer)
A 5.6 installation question... <webqueen@my-deja.com>
Re: A 5.6 installation question... <tony_curtis32@yahoo.com>
Re: a large amount of unique numbers in an efficient wa <aahz@writeme.com>
A minor problem using Net::XWhois. Looking for ideas on <robert@chalmers.com.au>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Jul 2000 06:25:00 GMT
From: "Colin Reinhardt" <colinrei@oz.net>
Subject: Re: <newbie>How to determine current location (pwd) in CGIscript?</newbie>
Message-Id: <8jukbs$g4g$0@216.39.148.120>
That rocks. Perl simply rocks!
btw, how do I make a system call (to 'pwd')?
Colin
Nico Zigouras <zigouras@mail.med.upenn.edu> wrote in message
news:Pine.OSF.4.21.0007050120400.28425-100000@mail.med.upenn.edu...
> Do you mean the absolute current path or the relative path for your web
> server? I think you mean the latter, in which case
> get_current_path() would look like:
>
> sub get_current_path {
> return $ENV{'SCRIPT_URL'};
> }
>
> This will return the relative path from your web server root including the
> name of the script itself. If you want the query string, append
> $ENV{'QUERY_STRING'} on to it.
>
> for the former use $ENV{'SCRIPT_FILENAME'} for the full path. Or use a
> system call to 'pwd'. $ENV{'SCRIPT_FILENAME'} will include the
> script name though.
>
>
> On 5 Jul 2000, Colin Reinhardt wrote:
>
> > Date: 5 Jul 2000 04:55:34 GMT
> > From: Colin Reinhardt <colinrei@oz.net>
> > Newsgroups: comp.lang.perl.misc
> > Subject: <newbie>How to determine current location (pwd) in CGI
> > script?</newbie>
> >
> > I need to dynamically set a path for a Location: redirect in my Perl
script.
> >
> > I'd like to do something like this...
> >
> > print "Location: ", get_current_path(), "/index2.html\n\n";
> >
> > Any tips on how to implement get_current_path( ) easily?
> >
> > Like I said, I'm a total Perl newbie with a deadline (a very scary
> > thing...your worst nightmare?)
> >
> > Thanks!
> >
> > Colin
> >
> >
> >
>
------------------------------
Date: Wed, 05 Jul 2000 06:42:50 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: <newbie>How to determine current location (pwd) in CGIscript?</newbie>
Message-Id: <slrn8m5lut.gk1.bernard.el-hagin@gdndev25.lido-tech>
On 5 Jul 2000 06:25:00 GMT, Colin Reinhardt <colinrei@oz.net> wrote:
>That rocks. Perl simply rocks!
>btw, how do I make a system call (to 'pwd')?
>
>Colin
perldoc -f system
BTW, you need to stop jeopardy quoting or you'll get murdered here.
Bernard
--
perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'
------------------------------
Date: Wed, 5 Jul 2000 07:02:52 -0700
From: "colinr" <colinrei@oz.net>
Subject: Re: <newbie>How to determine current location (pwd) in CGIscript?</newbie>
Message-Id: <sm6fujkggas62@corp.supernews.com>
Thanks.
btw, why is it called "jeopardy quoting"?
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn8m5lut.gk1.bernard.el-hagin@gdndev25.lido-tech...
> On 5 Jul 2000 06:25:00 GMT, Colin Reinhardt <colinrei@oz.net> wrote:
> >That rocks. Perl simply rocks!
> >btw, how do I make a system call (to 'pwd')?
> >
> >Colin
>
> perldoc -f system
>
> BTW, you need to stop jeopardy quoting or you'll get murdered here.
>
> Bernard
> --
> perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
> ${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'
------------------------------
Date: Wed, 05 Jul 2000 14:12:53 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: <newbie>How to determine current location (pwd) in CGIscript?</newbie>
Message-Id: <slrn8m6gan.iha.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 5 Jul 2000 07:02:52 -0700, colinr <colinrei@oz.net> wrote:
>Thanks.
You're welcome.
>btw, why is it called "jeopardy quoting"?
If you give an answer first and later quote the question you're doing
the Alex Trebeck thang which is only welcome on the game show "Jeopardy".
On newsgroups it's very annoying.
Bernard
--
perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'
------------------------------
Date: Wed, 5 Jul 2000 09:11:45 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: <newbie>How to determine current location (pwd) in CGIscript?</newbie>
Message-Id: <slrn8m6d0h.ghk.tadmc@magna.metronet.com>
On Wed, 05 Jul 2000 06:42:50 GMT, Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>BTW, you need to stop jeopardy quoting or you'll get murdered here.
^^^^^^^^
Ignored, actually (you're probably making a pun on killfile,
but Jeopardists aren't going to get that).
If you quote in reverse-time order (Jeopardy style), you'll
get ignored here.
Getting ignored is not good, as the Ignorer may have been an Answerer.
:-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 5 Jul 2000 09:27:15 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: <newbie>How to determine current location (pwd) in CGIscript?</newbie>
Message-Id: <slrn8m6dtj.gs1.tadmc@magna.metronet.com>
On Wed, 5 Jul 2000 07:02:52 -0700, colinr <colinrei@oz.net> wrote:
>btw, why is it called "jeopardy quoting"?
Because the Answer comes _before_ the Question, as in the popular
U.S. game show "Jeopardy".
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 5 Jul 2000 09:04:51 -0700
From: "colinr" <colinrei@oz.net>
Subject: Re: <newbie>How to determine current location (pwd) in CGIscript?</newbie>
Message-Id: <sm6n3ab8gas66@corp.supernews.com>
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn8m6gan.iha.bernard.el-hagin@gdndev25.lido-tech...
> On Wed, 5 Jul 2000 07:02:52 -0700, colinr <colinrei@oz.net> wrote:
> >Thanks.
>
> You're welcome.
>
> >btw, why is it called "jeopardy quoting"?
>
> If you give an answer first and later quote the question you're doing
> the Alex Trebeck thang which is only welcome on the game show "Jeopardy".
> On newsgroups it's very annoying.
>
> Bernard
> --
> perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
> ${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'
I think it's the fault of the lame newsreader app I'm using... (M$ OutofLuck
Express)
Sorry. And thanks for the etiquette tip...
Colin
------------------------------
Date: Thu, 6 Jul 2000 04:32:09 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: <newbie>How to determine current location (pwd) in CGIscript?</newbie>
Message-Id: <Fx9DxL.DCL@presby.edu>
In article <sm6n3ab8gas66@corp.supernews.com>, colinr <colinrei@oz.net> wrote:
>
>Sorry. And thanks for the etiquette tip...
Can you stand another one? :-) Most people appreciate it if you delete
(or "trim" or "snip") the quoted material so it doesn't contain material
which is irrelevant to your response. *Especially* it's a good idea to
delete other people's "signatures" and other stuff like that; news-posting
software usually puts in an "attribution line" at the top to indicate who
wrote the quoted material, and that's all you need by way of
identification.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
[ Questions about newsgroups? Visit http://www.geocities.com/nnqweb/ ]
[ or ask in news:news.newusers.questions ]
------------------------------
Date: Thu, 6 Jul 2000 16:20:47 +0200
From: "TheEx0rcist" <TheEx0rcist@fanclub.org>
Subject: [ References ] I'm trying to replace \%hash by its contents
Message-Id: <8k7m60$1jm$1@news3.isdnet.net>
Here is some sample code that works perfectly :
my %hash = (
a => 'b',
c => 'c',
);
SomeSub(
'data1',
'data2',
\%hash,
);
But as soon as I replace %hash by its data, it suddenly stops working :
SomeSub(
'data1',
'data2',
\(
a => 'b',
c => 'c',
),
);
------------
I sure have the impression i'm making a gross mistake on the above code. But
I don't know which one it is ...
So I counting on you to enlighten me :-)
Thanks in advance for your help !!
------------------------------
Date: Sat, 08 Jul 2000 16:53:57 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: [ References ] I'm trying to replace \%hash by its contents
Message-Id: <slrn8menfu.40a.marcel@gandalf.local>
On Thu, 6 Jul 2000 16:20:47 +0200, TheEx0rcist <TheEx0rcist@fanclub.org> wrote:
>But as soon as I replace %hash by its data, it suddenly stops working :
>
>SomeSub(
> 'data1',
> 'data2',
> \(
> a => 'b',
> c => 'c',
> ),
>);
You need the anonymous hash composer, {} .
Thus:
SomeSub(
'data1',
'data2',
{
a => 'b',
c => 'd',
},
);
Likewise, for array references, you'd use the anonymous array composer, [] .
perldoc perldsc
perldoc perllol
--
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();
------------------------------
Date: Sat, 08 Jul 2000 17:06:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: [ References ] I'm trying to replace \%hash by its contents
Message-Id: <x7hfa0o8la.fsf@home.sysarch.com>
>>>>> "T" == TheEx0rcist <TheEx0rcist@fanclub.org> writes:
T> Here is some sample code that works perfectly :
T> my %hash = (
T> a => 'b',
T> c => 'c',
T> );
T> SomeSub(
T> 'data1',
T> 'data2',
T> \%hash,
T> );
T> But as soon as I replace %hash by its data, it suddenly stops working :
T> SomeSub(
T> 'data1',
T> 'data2',
T> \(
T> a => 'b',
T> c => 'c',
T> ),
T> );
that is not the same as the above example. you are doing a special case
of taking the reference of a list which returns a list of refs to each
element of the list. what you want is an anonymous hash which is done
with {}.
SomeSub(
'data1',
'data2',
{
a => 'b',
c => 'c',
},
);
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: Sat, 08 Jul 2000 17:06:35 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: [ References ] I'm trying to replace \%hash by its contents
Message-Id: <39685ea3.14477811@nntp.idsonline.com>
"TheEx0rcist" <TheEx0rcist@fanclub.org> wrote:
>SomeSub(
> 'data1',
> 'data2',
> \(
> a => 'b',
> c => 'c',
> ),
>);
\( a => 'b', c => 'c', )
is equivalent to
\( 'a', 'b', 'c', 'c' )
which is equivalent to
(\'a', \'b', \'c', \'c')
because \ distributes over a list.
What you want is a reference to an anonymous hash:
{ a => 'b', c => 'c', }
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Sat, 08 Jul 2000 10:22:39 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage963051841.19734@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://www.cpan.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
For an alternative way to get answers, check out the Perlfaq website.
http://www.perlfaq.com/
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://www.cpan.org/
http://www.perl.com/CPAN/
http://www.cpan.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 08 Jul 2000 15:47:29 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: [Perl] How to find the Perl FAQ
Message-Id: <x7og48oc8f.fsf@home.sysarch.com>
i figured to restart the group mini faq thread here. other groups have been
deleted.
first off, randal says we should use this and not create a new fa
autopost. here are some of the points we have been discussing.
subject:
this subject is poor in general. and it doesn't address the group at all
which we agree needs to be done.
how about: [Perl] Mini-FAQ - README
group info:
we have had some good ideas on describing this group. we should also
briefly describe the whole comp.lang.perl.* hierarchy. info here should
also include some netiquette stuff like good subjects, proper quoting
(no jeopardy), do your homework first, no asking for programs, no jobs, etc.
>>>>> "TP" == Tom Phoenix <rootbeer&pfaq*finding*@redcat.com> writes:
TP> Archive-name: perl-faq/finding-perl-faq
TP> Posting-Frequency: weekly
definitely needs more frequent posting. we get group newbies
everyday. at least every 2 days or even once a day. if it stops one
extra newbie post a day, it is break even in terms of volume.
TP> Last-modified: 29 Apr 2000
TP> [ That "Last-modified:" date above refers to this document, not to the
TP> Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
TP> of 1998; of course, ongoing updates are made as needed. ]
why the verbiage? just say 'this posting last modified'. and why the
header format and not plain text?
TP> For most people, this URL should be all you need in order to find Perl's
TP> Frequently Asked Questions (and answers).
TP> http://www.cpan.org/doc/FAQs/
TP> Please look over (but never overlook!) the FAQ and related docs before
TP> posting anything to the comp.lang.perl.* family of newsgroups.
TP> For an alternative way to get answers, check out the Perlfaq website.
TP> http://www.perlfaq.com/
that stuff is good but i feel can use a little editing
TP> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
TP> Beginning with Perl version 5.004, the Perl distribution itself includes
TP> the Perl FAQ. If everything is pro-Perl-y installed on your
^^^^^^^^^^
no puns in this doc. :-)
TP> system, the
TP> FAQ will be stored alongside the rest of Perl's documentation, and one
TP> of these commands (or your local equivalents) should let you read the FAQ.
TP> perldoc perlfaq
TP> man perlfaq
tell them how to run perldoc in winblows. it is obvious many can't even
do that.
TP> If you have a web connection, the first and foremost source for all things
TP> Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
TP> CPAN also includes the Perl source code, pre-compiled binaries for many
TP> platforms, and a large collection of freely usable modules, among its
TP> 560_986_526 bytes (give or take a little) of super-cool (give or take
TP> a little) Perl resources.
TP> http://www.cpan.org/
TP> http://www.perl.com/CPAN/
TP> http://www.cpan.org/doc/FAQs/FAQ/html/
TP> http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
TP> You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
TP> you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
TP> selected FTP sites is especially good for you, a full list of CPAN sites
TP> is in the SITES file within CPAN.)
TP> California ftp://ftp.cdrom.com/pub/perl/CPAN/
TP> Texas ftp://ftp.metronet.com/pub/perl/
TP> South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
TP> Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
TP> Australia ftp://cpan.topend.com.au/pub/CPAN/
TP> Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
TP> Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
TP> Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
do we need all this cpan info here? why not shorten it and just mention
www.cpan.org and maybe its search page?
TP> If you have no connection to the Internet at all (so sad!) you may wish
TP> to purchase one of the commercial Perl distributions on CD-Rom or other
TP> media. Your local bookstore should be able to help you to find one.
how can they read the newsgroup without net access? this should be cut.
TP> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
TP> Comments and suggestions on the contents of this document
TP> are always welcome. Please send them to the author at
TP> <pfaq&finding*comments*@redcat.com>. Of course, comments on
TP> the docs and FAQs mentioned here should go to their respective
TP> maintainers.
maybe a more general email address? that looks wierd even though it is legit.
TP> Have fun with Perl!
TP> --
TP> Tom Phoenix Perl Training and Hacking Esperanto
TP> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
i don't think a .sig file is appropriate for a public autopost like
this.
--
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: 8 Jul 2000 18:09:00 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: [Perl] How to find the Perl FAQ
Message-Id: <8k7qns$3d5$1@nntp9.atl.mindspring.net>
Uri Guttman (uri@sysarch.com) wrote:
: TP> If you have no connection to the Internet at all (so sad!) you may wish
: TP> to purchase one of the commercial Perl distributions on CD-Rom or other
: TP> media. Your local bookstore should be able to help you to find one.
:
: how can they read the newsgroup without net access? this should be cut.
It's possible to have access to Usenet without access to the WWW and FTP
and, more likely, to want to install Perl on a machine (not the one on
which the user is reading news) that has access to neither. I'd suggest
changing that to:
"If you need to install Perl on a machine with no Internet connection,
you may..."
------------------------------
Date: Thu, 06 Jul 2000 14:47:07 GMT
From: VW Corrado <vwcorrado@my-deja.com>
Subject: [Q] Reading a file containing control characters
Message-Id: <8k2658$1mp$1@nnrp1.deja.com>
Hello from a newbie,
I am trying to read in data from a : deliminted file. The file is 100k
records but I only want some of them (whatever the user searches on).
As you can see, I clean up $searchterms a little and then use grep to
get only the records I want. I think the problem is that the file
contains plus (+), question mark (?), and other symbols. How do I
escape these symbols in the open call so that $_ contains the full
string (including ++)? Or if I'm doing this all wrong, please tell me a
better way.
Here is my code snippet:
======================================
# Search for the searchterms
$_ = $searchterms;
s/[^0-9A-Za-z ]//g;
$searchterms = $_;
open (FILE, "grep -i \"$searchterms\" lm1.dat |") || die;
Data File:
======================================
5723:Roseville Falline - 9":413:505:446::
5724:Weller Or Roseville Petestal By Frank Ferrell:413:505:446::++
5725: 1935 Roseville Morning Glory Vase..729-9:413:504:446::
searchterm
======================================
weller
Here is the error I get:
======================================
Tk::Error: /5724:Weller Or Roseville Petestal By Frank
Ferrell:413:505:446::++/:
nested *?+ in regexp at listmasteri.pl line 138, <FILE> chunk 2.
main::perform_search at listmasteri.pl line 138
--
Thanx!
Richard
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 06 Jul 2000 13:06:45 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: [Q] Reading a file containing control characters
Message-Id: <3964BCA5.32CD4385@attglobal.net>
VW Corrado wrote:
>
> As you can see, I clean up $searchterms a little and then use grep to
> get only the records I want. I think the problem is that the file
> contains plus (+), question mark (?), and other symbols. How do I
> escape these symbols in the open call so that $_ contains the full
> string (including ++)? Or if I'm doing this all wrong, please tell me a
> better way.
> ======================================
> # Search for the searchterms
> $_ = $searchterms;
> s/[^0-9A-Za-z ]//g;
> $searchterms = $_;
> open (FILE, "grep -i \"$searchterms\" lm1.dat |") || die;
Yuck!
#!/usr/bin/perl -w
use strict;
$searchterms =~ s/\W+//g;
open FILE, "/home/simonis/lml.dat" or die "Can't open file: $!\n";
while(<FILE>)
{
if (/$searchterms/oi){
print;
}
}
> Data File:
> ======================================
> 5723:Roseville Falline - 9":413:505:446::
> 5724:Weller Or Roseville Petestal By Frank Ferrell:413:505:446::++
> 5725: 1935 Roseville Morning Glory Vase..729-9:413:504:446::
The above Perl will get you just line 2. I'm only printing it,
but you can just as easily substitute in some other code to build
an array.
------------------------------
Date: Thu, 06 Jul 2000 13:11:53 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: [Q] Reading a file containing control characters
Message-Id: <3964BDD9.66B33EAA@attglobal.net>
Drew Simonis wrote:
>
>
> #!/usr/bin/perl -w
> use strict;
>
> $searchterms =~ s/\W+//g;
> open FILE, "/home/simonis/lml.dat" or die "Can't open file: $!\n";
>
> while(<FILE>)
> {
> if (/$searchterms/oi){
> print;
> }
>
> }
Forgot to mention that the above code assumes that you will
add in the definition of $searchterms. I assume you are getting
it from a web form and I assume you already know how to do it.
------------------------------
Date: 5 Jul 2000 17:22:24 GMT
From: mfischer-news@josefine.ben.tuwien.ac.at (Markus Fischer)
Subject: [Q] Seperate string with newline in stream ?
Message-Id: <slrn8m6rmg.h5c.mfischer-news@josefine.ben.tuwien.ac.at>
Hi,
I lately had the problem to substitute a given string
with a new line. Since I allready preprocessed the stream a few
times with bash commands (lynx, sed, tr, etc) I tried on of these
tails and failed :/
echo test1bla2test | sed "s/bla/^M/"
just gives : 2test.
The same with 'tr':
echo test1bla2test | tr bla "^M"
outputs : 2test.
[Note: ^M is actually by pressing ctrl-v and then enter in bash]
My try with perl was
echo test1bla2test | perl -e 'while(<STDIN>) { foreach(split"bla"){print "$_\n"}}'
which gives me (nearly) what I wanted;
test1
bla
2test
but including of course a trailing newline.
Please note, it works now for me! I'm just interested how I can
do it more elegant with perl (and if someone knows how it works
with the mentioned tools above: as good either!).
kind regards :-)
Markus
--
Markus Fischer, http://josefine.ben.tuwien.ac.at/~mfischer/
EMail: mfischer@josefine.ben.tuwien.ac.at
PGP Public Key: http://josefine.ben.tuwien.ac.at/~mfischer/C2272BD0.asc
PGP Fingerprint: D3B0 DD4F E12B F911 3CE1 C2B5 D674 B445 C227 2BD0
- Free Software For A Free World -
------------------------------
Date: 5 Jul 2000 18:49:59 GMT
From: jhborwic@unity.ncsu.edu (John Harden Borwick)
Subject: Re: [Q] Seperate string with newline in stream ?
Message-Id: <8k000n$h1u$1@uni00nw.unity.ncsu.edu>
In article <slrn8m6rmg.h5c.mfischer-news@josefine.ben.tuwien.ac.at>,
Markus Fischer <mfischer-news@josefine.ben.tuwien.ac.at> wrote:
[ snip ]
> echo test1bla2test | perl -e 'while(<STDIN>) { foreach(split"bla"){print "$_\n"}}'
>
>which gives me (nearly) what I wanted;
>test1
>bla
>2test
>
>but including of course a trailing newline.
This code will not print "bla" at all. Did you copy the code that you wrote?
echo "test1bla2test" | perl -pe 's/bla/\n/g'
will produce output without "bla"'s in them, while
echo "test1bla2test" | perl -pe 's/bla/\nbla\n/g'
produces output that looks like it conforms to the output you had in your post.
--
John Borwick
------------------------------
Date: 5 Jul 2000 19:13:57 GMT
From: mfischer-news@josefine.ben.tuwien.ac.at (Markus Fischer)
Subject: Re: [Q] Seperate string with newline in stream ?
Message-Id: <slrn8m727l.k5g.mfischer-news@josefine.ben.tuwien.ac.at>
In article <8k000n$h1u$1@uni00nw.unity.ncsu.edu>,
John Harden Borwick <jhborwic@unity.ncsu.edu> wrote:
>This code will not print "bla" at all. Did you copy the code that you wrote?
Thats right; I wanted to remove the 'bla' at all
>echo "test1bla2test" | perl -pe 's/bla/\n/g'
_Great_ ! That is exactly what I wanted ! I didn't knew
that \n work in perlre ... it does not with sed :/
For sed, I found another solution anyway:
echo "test1bla2test" | sed 's/bla/\
/'
thanks ! :-)
Markus
--
Markus Fischer, http://josefine.ben.tuwien.ac.at/~mfischer/
EMail: mfischer@josefine.ben.tuwien.ac.at
PGP Public Key: http://josefine.ben.tuwien.ac.at/~mfischer/C2272BD0.asc
PGP Fingerprint: D3B0 DD4F E12B F911 3CE1 C2B5 D674 B445 C227 2BD0
- Free Software For A Free World -
------------------------------
Date: Mon, 03 Jul 2000 18:31:39 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: A 5.6 installation question...
Message-Id: <8jqm6b$u1n$1@nnrp1.deja.com>
I pretty much defaulted everything on our System V Perl installs
previously. Now I'm installing 5.6, and I wonder, will the kit pick up
all of the modules I've installed (SQL, sendmail, DBI, etc etc) or will
I have to reinstall all of those?
I'm trying to just prety much default the install and in fact it ran
through to completion and passed all tests. I haven't done the
make install
yet though for fear that I'll find myself having to spend the next 4
days reloading mods from CPAN.
I read INSTALL pretty much front-to-back and didn't see a lot of related
discussion. There is a somewhat bothersome question about what former
module dirs to include- which I defaulted hoping 5.6 would be clever
enough to look in the usual places pointed out by the current resident
in /usr/local/bin/perl through @INC.
Before I pressed the launch button though I wanted some reassurance.
Thanks and happy fourth!
-WQ
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 03 Jul 2000 14:01:18 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: A 5.6 installation question...
Message-Id: <87sntr11j5.fsf@limey.hpcc.uh.edu>
>> On Mon, 03 Jul 2000 18:31:39 GMT,
>> webqueen, queen of the web <webqueen@my-deja.com> said:
> I pretty much defaulted everything on our System V Perl
> installs previously. Now I'm installing 5.6, and I
> wonder, will the kit pick up all of the modules I've
> installed (SQL, sendmail, DBI, etc etc) or will I have
> to reinstall all of those?
The 5.6 configure process asks you if you want to look for
modules from previous perl5 installations. I'm not sure
if the default does this. Take a look at the resultant
config.sh file to see what the @INC path looks like.
> Thanks and happy fourth! -WQ
I'm a Brit. Should I be sad on the 4th? ( <-- humour )
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Wed, 05 Jul 2000 14:58:55 GMT
From: Andrew Collington <aahz@writeme.com>
Subject: Re: a large amount of unique numbers in an efficient way?
Message-Id: <39634C3A.FE3748E0@writeme.com>
Andrew Collington wrote:
> What would be the most efficient way to generate a large array of random
> numbers, from, say 1000 to 9999?
Thank you so much to everyone who helped me out on this! I've been shown a
few ways now, and I'm learning more and more as I go along. I'm going to
use the Fisher Yates algorithm that Abigail showed because it uses some
techniques that I hadn't thought of before and so it teaches me :)
Thanks!!
Andy
------------------------------
Date: Sat, 8 Jul 2000 10:38:54 +1000
From: "Robert Chalmers" <robert@chalmers.com.au>
Subject: A minor problem using Net::XWhois. Looking for ideas on gracefull handling of timeout
Message-Id: <UHu95.14$jK2.2309@nsw.nnrp.telstra.net>
I'm looking for a gracefull way to continue the program, when a whois query
using NetX::Whois times out doing a lookup.
............. the sample code from Net::XWhois ..........
my $w = new Net::XWhois;
$w->lookup ( Domain => "perl.com" );
print $w->response ();
............................................................................
.
From another sample... in the package.
..........
if ( $opts{n} ) { my @emails = $whois->nameservers; $" = ", "; print
"Nameservers: @emails\n"; exit }
...............
Now, it all works fine, but on some domains, for unknown reasons, the lookup
fails due to 'timeout'. This is understandable, so I'm trying to discover if
I can build a 'trap' into my code, to gracefully handle such an event and
keep processing, or is this something in the Net::XWhois code that could be
fixed. ie: handletimeout() type of routine.?
Does anoyone have any ideas on how to handle this?
Thanks for any ideas
Robert
------------------------------
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 3546
**************************************