[12705] in Perl-Users-Digest
Perl-Users Digest, Issue: 114 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 11 23:07:12 1999
Date: Sun, 11 Jul 1999 20:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 11 Jul 1999 Volume: 9 Number: 114
Today's topics:
Re: [1] 988?? (Martien Verbruggen)
Re: ActiveState's PerlScript <john@dlugosz.com>
Re: checking Perl offline (Michael Rubenstein)
Re: checking Perl offline <tchrist@mox.perl.com>
Re: date format (Saku Ytti)
Re: Help -- Weird Increments (MacPerl) <tmornini@netcom9.netcom.com>
Help : running a script through the browser <berube@odyssee.net>
Re: Help : running a script through the browser (Martien Verbruggen)
How do you get rid of a remainder in a number <perl@dfwplaza.com>
Re: How do you get rid of a remainder in a number (Abigail)
Re: How do you get rid of a remainder in a number <perl@dfwplaza.com>
Re: How do you get rid of a remainder in a number <perl@dfwplaza.com>
Re: How do you get rid of a remainder in a number (Ronald J Kimball)
Re: How secure is my Perl code on the web? <ptimmins@itd.sterling.com>
Re: Imrpoving performance (Tad McClellan)
Need Perl solution to search, replace, split files (Sim <mp@dna.de>
Re: Need Perl solution to search, replace, split files (Abigail)
Re: newbies and usenet [was: DB tutorials] <Webdesigner@NewWebSite.com>
Re: newbies and usenet [was: DB tutorials] (Ronald J Kimball)
Re: Quest: pingecho for Linux. (Anno Siegel)
Searching <pgrech@uoguelph.ca>
Re: Searching <bwalton@rochester.rr.com>
Re: Searching <gt7202e@prism.gatech.edu>
simple Perl question: <cadet@bu.edu>
Re: simple Perl question: <gt7202e@prism.gatech.edu>
Re: simple Perl question: (Ronald J Kimball)
Re: Thoughts on my new game <bie@connect.ab.ca>
Re: trying to read a variable? (elephant)
Re: trying to read a variable? (Ronald J Kimball)
Re: trying to read a variable? (Tad McClellan)
Re: Use a Perl Module w/o Installing It? nkaiser@my-deja.com
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Jul 1999 02:42:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: [1] 988??
Message-Id: <KCci3.96$4J4.6264@nsw.nnrp.telstra.net>
In article <3785E807.6B252458@gmx.net>,
"Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net> writes:
>> @@ ./email.pl?from=joe@aol.co&subject=test&text=this is a test
> No; after starting the program './ema[etc.].com' in the background, he
> gives the environment variable 'subject' the value 'test' (in the
> background), and then starts the program 'is' with the two parameters
> 'a' and 'test', setting the environment variable 'text' to the value
> 'this' for the duration of the execution of program 'is'.
Actually, it depends on the shell in use.
MArtien
--
Martien Verbruggen | My friend has a baby. I'm writing down
Interactive Media Division | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: Sun, 11 Jul 1999 21:57:00 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: Re: ActiveState's PerlScript
Message-Id: <D76C298A4CA543F5.11D84F744D0B120D.35D282E677026E1D@lp.airnews.net>
Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
news:7m9pi2$3ce$1@gellyfish.btinternet.com...
> The object model that Perl uses when running as an ActiveX scripting
engine
> is the same as VBScript. You will need to examine the documentation
> supplied by Microsoft at <http://msdn.microsoft.com>. I believe that
there
> is an answer in the Win32 Specific FAQ supplied with Activeperl that
> addresses how to convert between the two - once you have realised the way
> that Perl implements this model is as if it were a default Module that
> doesnt require 'use' the whole thing should be simple to someone familiar
> with Perl and access to the VBScript documentation. The documentation
> for the module Win32::OLE might also prove useful in this respect too.
Yes, I've adapted the syntax but use documentation from JavaScript and
VBScript sources. However, interaction between Perl and other languages
isn't clear -- For example, functions defined in PerlScript are in the
main:: package and that makes it difficult to call from other languages.
> I think you will find that $document is already defined as the object
> 'document' is in VBScript. Anyhow you probably dont want to do that - you
> might find that :
>
> my $newdoc = $window->document
>
> will do what you want allowing you to acess the documents methods and
> properties via the variable $newdoc.
I would assume that this is what the existing $main::document is, but it
doesn't work.
> You might find that File::Find doesnt work because of the security
settings
> on your browser - this comes to the major point that needs to be addressed
> here that a lot of the problems you will find are to do with the browser
> or the Scripting Host implementation rather than with Perl. Perlscript is
> hobbled by the necessity to run within the limitations of the Scripting
> Host.
>
> I think that you might need to look at the FileSystem object if you need
> to access the local filesystem - although I'm far from being an expert in
> this stuff. The FileSystem object is documented in the Microsoft
documentation
> as mentioned above.
I wrote my own using Perl primitives (readdir) and it works fine. Something
about the implementation of that module doesn't work, but it's not the lack
of ability to access the local drive.
IAC, crashing the Perl engine proper is, by definition, a bug.
--John
------------------------------
Date: Sun, 11 Jul 1999 23:23:15 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: checking Perl offline
Message-Id: <378c2605.12248582@nntp.ix.netcom.com>
On 11 Jul 1999 15:22:40 -0700, Tom Christiansen
<tchrist@mox.perl.com> wrote:
>In comp.lang.perl.misc,
> miker3@ix.netcom.com (Michael Rubenstein) writes:
>:<usual Christeansen foaming at the mouth elided>
> ^^^^^^^^^^^^
>
>That's a curious elision, but I suppose that today being Sunday and all
>that it's the day for such things. :-)
>
>Hm... you know, I can't imagine whom you might be referring to up there.
>Perhaps you might consult the OED.
I don't intend to continue this discussion, but since you seem to
have difficulty following even correct usage, let alone my error
here, let me assure you that I was refering to your foaming at
the mouth.
I apologize for mispelling your name.
--
Michael M Rubenstein
------------------------------
Date: 11 Jul 1999 18:34:53 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: checking Perl offline
Message-Id: <3789382d@cs.colorado.edu>
In comp.lang.perl.misc, miker3@ix.netcom.com (Michael Rubenstein) writes:
:>Hm... you know, I can't imagine whom you might be referring to up there.
:
:I don't intend to continue this discussion, but since you seem to
:have difficulty following even correct usage, let alone my error
:here, let me assure you that I was refering to your foaming at
:the mouth.
:
:I apologize for mispelling your name.
Apology for my mangled name accepted.
However, if you should someday encounter the owners of the words
"misspelling" and of "referring", I hope that they are as willing
to accept your apology. :-)
--tom, whose -w flag seems to be stuck on :-)
--
"When I originally designed Perl 5's OO, I thought about a lot of this
stuff, and chose the explicit object model of Python as being the least
confusing. So far I haven't seen a good reason to change my mind on that."
(Larry Wall, February 1997, on perl5-porters)
------------------------------
Date: 11 Jul 1999 23:41:14 GMT
From: saku.eisikanautaa@ytti.net (Saku Ytti)
Subject: Re: date format
Message-Id: <slrn7oiat2.rn1.saku.eisikanautaa@ytti.net>
On Sun, 11 Jul 1999 15:52:46 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
>> perl -e '($d,$d,$d,$d,$m,$y)=localtime();print$y+1900,$m+1,$d,"\n";'
>> hth.
>
>Well, it might be hard to distinguish January 11 from November 1,
>though:
>
>1999111
>
>Use printf to zero-pad month and day to two characters.
Never do something right at the first time, it's boring. Much more
fun to write tons of lines and then search for a bug. :)
--
--ytti - ::3585:0512:1378
------------------------------
Date: 12 Jul 1999 00:15:13 GMT
From: Tom Mornini <tmornini@netcom9.netcom.com>
Subject: Re: Help -- Weird Increments (MacPerl)
Message-Id: <7mbc2h$2hk@dfw-ixnews5.ix.netcom.com>
Larry Rosler <lr@hpl.hp.com> wrote:
: [Posted and a courtesy copy sent.]
: In article <7m8sj2$g2h@dfw-ixnews21.ix.netcom.com> on 11 Jul 1999
: 01:38:42 GMT, Tom Mornini <tmornini@netcom9.netcom.com> says...
:> johnny99 <john@your.abc.net.au> wrote:
:> : Can someone
:> : instead tell me in a little more detail how to do the
:> : equivalent of this:
:>
:> : data.txt consists of a number
:> : I get the number from data.txt
:> : I do stuff to it in Perl and get a new number
:> : I replace the entire contents of data.txt with the new
:> : number
:>
:> open (IN,'file.txt') || die "Cannot open file for input";
: Where is the $! in the error message?
I didn't feel it was necessary in such a short snippet of code. It's
not as though I've broken a law here...
:> $number=<>;
: Having gone to the trouble of opening IN, it might be nice to read from
: it instead of from God-knows-what!
Oh my gosh! This is a terrible error. :-(
:> close IN;
:>
:> $number=chomp($number)+1; # Add 1 to $number
: This would be great if one wanted $number always to have the same value:
: 2. Hint: `perldoc -f chomp` and read the last sentence.
Ouch.
:> open (OUT,'>file.txt') || die "Cannot open file for output";
: Where is the $! in the error message?
See above.
:> print OUT $number;
: It might be nice to throw a newline on, so the output would be a valid
: text file.
As long as it works, though... (which it doesn't!)
:> close OUT;
:>
:> : I'm a little bemused that this task is so hard -- that I
:> : have to do all this "rewind the file to the right place"
:> : stuff. As soon as I've read the file, it's history. I want
:> : to trash it and write a new one, or do the equivalent of a
:> : "save as". Was the writer of this script being extra careful
:> : for some reason to do with UNIX, or am I missing something
:> : obivous because it's late?
:>
:> That's not so hard, is it?
:>
:> The person who wrote the script either:
:>
:> 1) Had more requirements than you do
:> 2) Did not have a clue
: You could use some clues yourself.
Yes, obviously you're right. I apologize for soiling myself in public.
: Clue 1. Write and test whatever you offer, even if it is as trivial as
: you seem to think.
Yes, you're absolutely right, of course.
Let me offer some insight as to why this happened, though it doesn't
materially effect my mistakes.
1) I did test, just did an incredibly poor job of testing, as the results
beat out. When I first ran the program, it errored on the first line
since the file file.txt didn't exist. So I created it with the value
of '1'.
2) I ran it, and it didn't work, and I thought it might be because of a
stray carriage return, so I added the chomp.
3) I ran it again, and it seemed to work, since the value was 2, so I
posted it.
4) What is now obvious is that I didn't even notice the fact that the
program was waiting for STDIN, and I was supplying it! I had a terrible
modem connection that was giving me constant disconnects, and literally
multi-second response times, and I was constantly pressing return to
try and force a response. This is how I missed the STDIN problem.
So, the lesson learned for me is 1) Don't post from a crappy connection, and
2) make absolutely certain that you get it right or Larry will pull your
pants down in public.
: Clue 2. Refer questions like this to the FAQ, in this case perlfaq5:
: "How do I change one line in a file/delete a line in a
: file/insert a line in the middle of a file/append to the
: beginning of a file?" Many people with much more experience than you or
: I have put a lot of effort into getting the answers right.
That doesn't mean that it is the only source of correct answers, though.
What's you're point, in the end? I read you loud and clear on the "don't
bother posting unless you get it right" and agree wholeheartedly. Your
tone here is rather caustic, however, and I would think that you might
actually try to encourage a free discussion on these lists.
I value your participation much more than you might realize, and that of
everyone else that puts their time into this group. The fact that you're
a huge contributor here, however, doesn't make you some sort of moderator
of form on how to respond to posts.
Thanks for taking the time to point out my mistakes though. I do know
how to take constructive criticism positively.
-- Tom Mornini
-- InfoMania
------------------------------
Date: Sun, 11 Jul 1999 19:52:10 -0400
From: "Benjamin Bérubé" <berube@odyssee.net>
Subject: Help : running a script through the browser
Message-Id: <7mb9uj$9uo$1@news.quebectel.com>
hi,
I installed Perl for Win (under Win98) from the book CGI/Perl Cookbook. I'm
trying to run a script using the web browser, but it's runing it using the
msdos shell (for the output). I want to be able to see the output through
the browser. Know what to modify so that it works ?
thanks ! please reply me directly.
ben
------------------------------
Date: Mon, 12 Jul 1999 02:21:44 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help : running a script through the browser
Message-Id: <Yici3.85$4J4.6264@nsw.nnrp.telstra.net>
In article <7mb9uj$9uo$1@news.quebectel.com>,
"Benjamin Bérubé" <berube@odyssee.net> writes:
> I installed Perl for Win (under Win98) from the book CGI/Perl Cookbook. I'm
> trying to run a script using the web browser, but it's runing it using the
> msdos shell (for the output). I want to be able to see the output through
> the browser. Know what to modify so that it works ?
You need to install a server. At least, I am assuming here that you
are trying to run CGI programs, right?
This question comes up a lot on this group. Look through some news
archives (e.g. at www.deja.com) to find some more complete answers.
Also, if you need more information, go to one of the
comp.infosystems.www.* groups, and ask there how to run CGI scripts on
your local machine.
> thanks ! please reply me directly.
Post here, read here.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | Can't say that it is, 'cause it ain't.
NSW, Australia |
------------------------------
Date: Sun, 11 Jul 1999 23:46:02 GMT
From: "Warren McCoy" <perl@dfwplaza.com>
Subject: How do you get rid of a remainder in a number
Message-Id: <01becbf7$d54bd530$69e20718@c55639-c>
I am creating a formula for going through an array,
and I want to use the whole number from the result
of a division statement.
i.e. 14 divided by 5 = 2.7999999999999998224
I just want the 2!
I have tried the remainder function (%) but that does
not work like the book states; (I am on a UNIX server)
Does anyone have a clue on how I can truncate my resutls
into a whole number without to much trouble?
(I tried sprintf and it gave me nothing of value)
Peace
Warren McCoy
------------------------------
Date: 11 Jul 1999 19:03:45 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How do you get rid of a remainder in a number
Message-Id: <slrn7oic69.h7.abigail@alexandra.delanet.com>
Warren McCoy (perl@dfwplaza.com) wrote on MMCXL September MCMXCIII in
<URL:news:01becbf7$d54bd530$69e20718@c55639-c>:
// I am creating a formula for going through an array,
// and I want to use the whole number from the result
// of a division statement.
//
// i.e. 14 divided by 5 = 2.7999999999999998224
// I just want the 2!
//
// I have tried the remainder function (%) but that does
// not work like the book states; (I am on a UNIX server)
Really? What does the book say? Which book is it? What did you try?
What did you expect? Why do you think you need the remainder function
to get the whole number from the result of a division? What do you mean
by UNIX server? Why do you think the OS is relevant - is math using
different rules on a VMS box?
// Does anyone have a clue on how I can truncate my resutls
// into a whole number without to much trouble?
RTFM. RTFFAQ.
// (I tried sprintf and it gave me nothing of value)
Are you sure?
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 12 Jul 1999 00:05:16 GMT
From: "Warren McCoy" <perl@dfwplaza.com>
Subject: Re: How do you get rid of a remainder in a number
Message-Id: <01becbfa$854840c0$69e20718@c55639-c>
Well I have been digging and found a way to round
the number, but I don't need that, I need truncation.
I tried $war1 = sprintf("%.0f", $num3);
it made 2.799999... 3
but I need the 2.
Any suggestions
Peace
Warren McCoy <perl@dfwplaza.com> wrote in article
<01becbf7$d54bd530$69e20718@c55639-c>...
> I am creating a formula for going through an array,
> and I want to use the whole number from the result
> of a division statement.
>
> i.e. 14 divided by 5 = 2.7999999999999998224
> I just want the 2!
>
> I have tried the remainder function (%) but that does
> not work like the book states; (I am on a UNIX server)
>
> Does anyone have a clue on how I can truncate my resutls
> into a whole number without to much trouble?
>
> (I tried sprintf and it gave me nothing of value)
>
> Peace
>
> Warren McCoy
>
>
------------------------------
Date: Mon, 12 Jul 1999 00:10:33 GMT
From: "Warren McCoy" <perl@dfwplaza.com>
Subject: Re: How do you get rid of a remainder in a number
Message-Id: <01becbfb$42293820$69e20718@c55639-c>
Damn I love getting help from smart asses.
Check you attitude at the door, no-one needs
a smart ass. just don't answer it next time.
The OS might matter (NT vs. Unix) Win32.
Anyhow, I tired $war1 = sprintf("%.0d", $num3);
and it worked.
So thanks for nothing!
Abigail <abigail@delanet.com> wrote in article
<slrn7oic69.h7.abigail@alexandra.delanet.com>...
> Warren McCoy (perl@dfwplaza.com) wrote on MMCXL September MCMXCIII in
> <URL:news:01becbf7$d54bd530$69e20718@c55639-c>:
> // I am creating a formula for going through an array,
> // and I want to use the whole number from the result
> // of a division statement.
> //
> // i.e. 14 divided by 5 = 2.7999999999999998224
> // I just want the 2!
> //
> // I have tried the remainder function (%) but that does
> // not work like the book states; (I am on a UNIX server)
>
> Really? What does the book say? Which book is it? What did you try?
> What did you expect? Why do you think you need the remainder function
> to get the whole number from the result of a division? What do you mean
> by UNIX server? Why do you think the OS is relevant - is math using
> different rules on a VMS box?
>
> // Does anyone have a clue on how I can truncate my resutls
> // into a whole number without to much trouble?
>
> RTFM. RTFFAQ.
>
> // (I tried sprintf and it gave me nothing of value)
>
> Are you sure?
>
>
>
> Abigail
> --
> perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
>
>
> -----------== Posted via Newsfeeds.Com, Uncensored Usenet News
==----------
> http://www.newsfeeds.com The Largest Usenet Servers in the
World!
> ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers
==-----
>
------------------------------
Date: Sun, 11 Jul 1999 22:29:32 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How do you get rid of a remainder in a number
Message-Id: <1dustk3.18liwbw1llsid8N@p53.block1.tc4.state.ma.tiac.com>
Warren McCoy <perl@dfwplaza.com> wrote:
> I am creating a formula for going through an array,
> and I want to use the whole number from the result
> of a division statement.
>
> i.e. 14 divided by 5 = 2.7999999999999998224
> I just want the 2!
>
> I have tried the remainder function (%) but that does
> not work like the book states; (I am on a UNIX server)
The remainder here is 4, not 2. I think you must be misunderstanding
what the book says.
What you want is the integer portion of the quotient. That is
ridiculously easy: int(14/5).
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 11 Jul 1999 23:10:44 GMT
From: Patrick Timmins <ptimmins@itd.sterling.com>
Subject: Re: How secure is my Perl code on the web?
Message-Id: <7mb89f$7km$1@nnrp1.deja.com>
In article <7mabcb$a3a$1@news.fsu.edu>,
"Brian Wagener" <wagener@cs.fsu.edu:NOSPAM> wrote:
> Oh I forgot that some people were actually born with all the
> knowledge. But for me I am still a student at FSU, and I am just
> trying to learn. Thanks for nothing.
De nada!
You've had four people tell you in short order that no one needs to see
your code, if you don't want them to. It's too bad you feel you can't
take it from there, and go discover for yourself how this works.
But it has nothing to do with Perl.
All hail El Cabeza Del Oro!
http://www.panix.com/~dha/elcabeza.html
$monger{Omaha}[0]
Patrick Timmins
ptimmins@itd.sterling.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Sun, 11 Jul 1999 16:10:20 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Imrpoving performance
Message-Id: <cntam7.e4b.ln@magna.metronet.com>
MAX (max@panix.com) wrote:
: How can I find out what's using all the
: resources?
Perl FAQ, part 3:
"How do I profile my Perl programs?"
You are expected to check the Perl FAQs before posting
to the Perl newsgroup.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 11 Jul 1999 16:49:04 +0200
From: "Martin Post" <mp@dna.de>
Subject: Need Perl solution to search, replace, split files (Simple HTML Preprocessor)
Message-Id: <7maasq$i8g$1@black.news.nacamar.net>
What I'm looking for is surely very trivial in Perl and
has probably been done a dozen times before. So before I
re-invent the wheel (or pay someone to do it), maybe
someone here can tell me about a Perl-based solution to
do this:
1) Read a plain input text file ("input.txt")
2) Replace characters and strings, even over multiple lines,
using an external translation table (another text file
"translation.txt" with strings and regular expressions
like
- "ä" > "ä"
- "HEADER{([^}+])}" > "<HTML>\n<TITLE>\n\1\n</TITLE>"
(to turn
"HEADER{Hello World}" into
"<HTML>
<TITLE>
Hello World
</TITLE>" etc.)
3) Split the resulting file wherever a certain marker/string
appears and store the following piece of text in a
new file.
So when the parser encounters eg
"{SPLIT file1.htm} This is file 1. {SPLIT file2.htm}
This the beginning of file 2."
in the input file, it should produce two output files:
"file1.htm", containing "This is file 1." and
"file2.htm", containing "This the beginning of file 2."
I'd like to define those "splitpoint markers" in the translation table
as well.
So the rethoric question is: Can this be done in Perl? Has it been
done in a freely available script? If not, would someone from this
group be interested in developing such a script (or a compact
standalone app for DOS or W9X) for an adequate fee?
(I know I could probably use one of the "big" HTML preprocessors, but
that would be overkill for the application I have in mind).
Martin Post
------------------------------
Date: 11 Jul 1999 21:59:58 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Need Perl solution to search, replace, split files (Simple HTML Preprocessor)
Message-Id: <slrn7oimgj.h7.abigail@alexandra.delanet.com>
Martin Post (mp@dna.de) wrote on MMCXL September MCMXCIII in
<URL:news:7maasq$i8g$1@black.news.nacamar.net>:
@@
@@ What I'm looking for is surely very trivial in Perl and
@@ has probably been done a dozen times before. So before I
@@ re-invent the wheel (or pay someone to do it), maybe
@@ someone here can tell me about a Perl-based solution to
@@ do this:
@@
@@ 1) Read a plain input text file ("input.txt")
Manual.
@@ 2) Replace characters and strings, even over multiple lines,
@@ using an external translation table (another text file
@@ "translation.txt" with strings and regular expressions
FAQ.
@@ 3) Split the resulting file wherever a certain marker/string
@@ appears and store the following piece of text in a
@@ new file.
@@ So when the parser encounters eg
@@ "{SPLIT file1.htm} This is file 1. {SPLIT file2.htm}
@@ This the beginning of file 2."
open/close.
Abigail
--
perl -e 'for (s??4a75737420616e6f74686572205065726c204861636b65720as?;??;??)
{s?(..)s\??qq \?print chr 0x$1 and q ss\??excess}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 12 Jul 1999 00:46:44 GMT
From: Floyd Morrissette <Webdesigner@NewWebSite.com>
Subject: Re: newbies and usenet [was: DB tutorials]
Message-Id: <7mbdti$99p$1@nnrp1.deja.com>
In article <MPG.11ebbcd62a955e3989af8@news-server>,
e-lephant@b-igpond.com (elephant) wrote:
> [ item posted to comp.lang.perl.misc and CCed to Floyd Morrissette ]
>
> Floyd Morrissette writes ..
> >...But I always thought it would best to ask
> >perhaps hundreds of people to get different ideas.
>
> the attitude that you express here Floyd is one of the most annoying
to
> regular visitors to the newsgroups ..
<snip>
I just know that I can answer a question about as fast as telling
someone where to go. So I'd rather help someone rather than leave them
hanging. I have 4 perl books and none of them for instance cover the
crypt command. Where did I find the answer about crypt? The newsgroup. I
did not ask the question but somebody else did and I am glad because I
did not even know about the command. But that is another story.
If everybody could learn something, anything, by just reading about it
then there would be no need of schools. I guess we need to start another
newsgroup called comp.lang.perl.beginners How do I go about doing that?
Never mind. I forgot you don't want to answer questions.
--
Get your web site from http://www.NewWebSite.com
Consultation is always free.
Help with cgi scripts.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Sun, 11 Jul 1999 22:29:31 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: newbies and usenet [was: DB tutorials]
Message-Id: <1dust1s.rd3ku2rvxq8wN@p53.block1.tc4.state.ma.tiac.com>
Floyd Morrissette <Webdesigner@NewWebSite.com> wrote:
> I just know that I can answer a question about as fast as telling
> someone where to go.
The drawback with this approach is that the person answering the
question directly may give an inaccurate or even incorrect answer,
whereas the documentation contains answers which have already been
verified by countless Perl programmers. That's why we prefer to point
people to those answers when they ask the corresponding questions.
> So I'd rather help someone rather than leave them
> hanging. I have 4 perl books and none of them for instance cover the
> crypt command. Where did I find the answer about crypt? The newsgroup. I
> did not ask the question but somebody else did and I am glad because I
> did not even know about the command. But that is another story.
Obviously none of those books are Programming Perl, which discusses
crypt() on page 153. Nor the standard documentation, which discusses
crypt in perlfunc. I would say that these four books are not
comprehensive enough to be your sole resource on Perl.
> If everybody could learn something, anything, by just reading about it
> then there would be no need of schools. I guess we need to start another
> newsgroup called comp.lang.perl.beginners How do I go about doing that?
> Never mind. I forgot you don't want to answer questions.
Not that question, anyway. It's been discussed to death numerous times
already, with various suggestions for the name of the new group. I
refer you to the DejaNews archives if you're interested in reading the
past discussions.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 12 Jul 1999 02:20:51 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Quest: pingecho for Linux.
Message-Id: <7mbje3$avi$1@lublin.zrz.tu-berlin.de>
Rusty Williamson <rwilliamson@uno.gers.com> wrote in comp.lang.perl.misc:
>Hi,
>
>I need a way to determine if a Linux box is responding on the network. It
>was suggested that another version of pingecho existed that would work (you
>needed to be root but that's okay). Does anyone know of another version of
>ping or a way to accomplish my goal?
Net::Ping v2.02
Anno
------------------------------
Date: Sun, 11 Jul 1999 21:34:09 -0400
From: Paul <pgrech@uoguelph.ca>
Subject: Searching
Message-Id: <37894611.AB880052@uoguelph.ca>
I have opened a file and now want to compare a string located in a
variable $string with each string in the file I opened.
Today is my first day with Perl and have seen a few examples but am not
sure whch is best.
Can someone give me an example of how to search a file for a particlular
string.
Thanks
Paul
------------------------------
Date: Sun, 11 Jul 1999 22:38:21 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Searching
Message-Id: <3789551D.98DCF088@rochester.rr.com>
Paul wrote:
> I have opened a file and now want to compare a string located in a
> variable $string with each string in the file I opened.
> Today is my first day with Perl and have seen a few examples but am not
> sure whch is best.
>
> Can someone give me an example of how to search a file for a particlular
> string.
...
Paul, assuming you are using an operating system, try:
grep string filename
instead of a Perl program. If you are using Windoz, then try (in Perl,
assuming that you want to match exactly what is in $string, not giving
regular expression metacharacters their usual meanings):
perl -ne "$string='whatever';print $_ if(/\Q$string\E/)" filename.ext
------------------------------
Date: Sun, 11 Jul 1999 22:35:48 -0400
From: andy barfoot <gt7202e@prism.gatech.edu>
Subject: Re: Searching
Message-Id: <37895484.87DC5F4E@prism.gatech.edu>
Paul wrote:
> I have opened a file and now want to compare a string located in a
> variable $string with each string in the file I opened.
> Today is my first day with Perl and have seen a few examples but am not
> sure whch is best.
>
> Can someone give me an example of how to search a file for a particlular
> string.
Nah. Get "Learning Perl", from O'Reilly.
--
andy barfoot
------------------------------
Date: 11 Jul 1999 21:05:21 -0400
From: David Bakhash <cadet@bu.edu>
Subject: simple Perl question:
Message-Id: <cxjyagm1xv2.fsf@acs5.bu.edu>
I want to write a function that does _EXACTLY_ what print does, except that it
prints a newline at the end. The function (let's call it 'println') would do
this:
println "hello world";
==>
print "hello world", "\n";
and it would also work when print is given a handle, where the newline would
print to the handle as well.
I asked several people to write this function, and even the really good ones
couldn't. Why is this so hard?
In Lisp, it's trivial:
(defun perl-println (&rest args)
(apply #'perl-print (append args (list "\n"))))
I suspect that this is doable in Perl, and I'm excited to see how. I'd prefer
a way that doens't have a if/then cases, like the one above, in Common Lisp.
thanks,
dave
------------------------------
Date: Sun, 11 Jul 1999 22:20:49 -0400
From: andy barfoot <gt7202e@prism.gatech.edu>
Subject: Re: simple Perl question:
Message-Id: <37895101.2C931DF@prism.gatech.edu>
David Bakhash wrote:
> I want to write a function that does _EXACTLY_ what print does, except that it
> prints a newline at the end..
> and it would also work when print is given a handle, where the newline would
> print to the handle as well.
> ...
> I suspect that this is doable in Perl, and I'm excited to see how. I'd prefer
> a way that doens't have a if/then cases, like the one above, in Common Lisp.
#!/usr/local/bin/perl -w
use strict;
use FileHandle;
sub println {
local $\="\n";
ref $_[0] eq 'FileHandle'?
do {my $ref = shift; print {$ref} @_}: do {print @_}
}
my $fh = new FileHandle;
open $fh,'>a.out' or die;
println $fh, "hello world.";
println "hello world.";
Why don't you like if/then statements? :)
Anyway, this is silly. The real answer is: just use 'local $\="\n";'
and 'print'.
--
andy barfoot
------------------------------
Date: Sun, 11 Jul 1999 22:29:33 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: simple Perl question:
Message-Id: <1dustw2.hts6slqm2hrfN@p53.block1.tc4.state.ma.tiac.com>
David Bakhash <cadet@bu.edu> wrote:
> I want to write a function that does _EXACTLY_ what print does, except that it
> prints a newline at the end.
Is there any reason you can't use $\?
$\ = "\n";
print "Ta da!";
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 11 Jul 1999 16:02:21 -0600
From: Tim <bie@connect.ab.ca>
Subject: Re: Thoughts on my new game
Message-Id: <3789146D.7723@connect.ab.ca>
Hey,
The only reason I get the user to register is so they can come back &
continue playing at a later date if they like. Also the registration
process is very short.
I agree with the pop-up windows, I hate them, but my javascript is
almost always turned off
It's just a game
Tim
Tony Greenwood wrote:
>
> Hey! Tim <bie@connect.ab.ca>
> >Hello,
> >
> >
> >I just finished making this game, Can you tell me what you think of it.
> >It's done in perl, it's my first perl game, but I think it's pretty
> >good.
> >
> >Go to: http://tbe.virtualave.net/chatters/dealin/
>
> Pop-up window advertisements are off putting.
>
> I have to register to play, that's not fun.
>
> It glorifies drug dealing :(
>
> Three perfectly good reasons never to play your game even if I wanted
> to put up with all the advertisments and having to register, Take it
> from a real game maker.. change your direction .
>
> Sorry but you did ask :)
>
> --
> Tony Greenwood
> PORTFOLIO www.webscripts.org
--
-------------------------------------------------------
| TBE: http://tbe.virtualave.net |
| * 3:2 Ratio + 100 Free credits! * |
| Tim's Chat Doors: http://www.connect.ab.ca/~mundy/ |
-------------------------------------------------------
------------------------------
Date: Mon, 12 Jul 1999 07:41:41 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: trying to read a variable?
Message-Id: <MPG.11f3baa039a257eb989b2a@news-server>
ted fiedler writes ..
>open (RNA, "< tmp/workfile");
>open (DNA, "> tmp/workfile2");
>while (<RNA>) {
> if (/015\s+(\w+\s\w*\s*\w+)/) {
> s/^015\s+//;
> select DNA;
> print $1;
> }
>}
>if i have multiple lines in file 'workfile' that llok like this
>
>015 JOHN Q PUBLIC
>015 SALLY ROSENGARDEN
>015 JOHN Q PUBLIC
>015 MAVIS BEACON
>etc...
>
>i cant get just the names into a variable -- $1???
ignoring the other weirdisms in your code .. your regex is failing on
SALLY and MAVIS because * is greedy .. so for 'MAVIS BEACON' the \w+
matches 'MAVIS' the \s matches the space then the \w* matches 'BEACON'
and the \s* matches a zero length after 'BEACON' .. but then your regex
fails because there's no trailing \w+ after 'BEACON'
use /015\s+(\w+\s\w+\s*\w*)/ to match all four
and just quietly (because it's difficult to resist) the line
s/^015\s+//;
is a waste of time (unless there's code that you've not included here)
because $1 already matches the string less that stuff at the front
also - then lines
select DNA;
print $1;
are more readably/commonly/elegantly written as
print DNA $1;
--
jason - remove all hyphens for email reply -
------------------------------
Date: Sun, 11 Jul 1999 22:29:34 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: trying to read a variable?
Message-Id: <1dusu9e.hfy9ue1hdxs9fN@p53.block1.tc4.state.ma.tiac.com>
elephant <e-lephant@b-igpond.com> wrote:
> > if (/015\s+(\w+\s\w*\s*\w+)/) {
> >015 MAVIS BEACON
> ignoring the other weirdisms in your code .. your regex is failing on
> SALLY and MAVIS because * is greedy .. so for 'MAVIS BEACON' the \w+
> matches 'MAVIS' the \s matches the space then the \w* matches 'BEACON'
> and the \s* matches a zero length after 'BEACON' .. but then your regex
> fails because there's no trailing \w+ after 'BEACON'
I have one word for you: backtracking.
DB<1> x "015 MAVIS BEACON" =~ /015\s+(\w+\s\w*\s*\w+)/
0 'MAVIS BEACON'
DB<2>
There is no trailing \w+ after 'BEACON', so the regex engine backtracks,
matches the null string with \w* and \s*, and then matches \w+ against
'BEACON'. The overall match is successful.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 11 Jul 1999 16:22:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: trying to read a variable?
Message-Id: <aduam7.e4b.ln@magna.metronet.com>
ted fiedler (tfiedler@ptd.net) wrote:
: open (RNA, "< tmp/workfile");
: open (DNA, "> tmp/workfile2");
You should always, yes *always* check the return value from
open() calls:
open(RNA, '< tmp/workfile') || die "could not open 'tmp/workfile' $!";
Asking for variable interpolation and/or backslash escapes
when you don't use them is going to throw readers of your
code off the track. (using double quotes is _asking for those)
You should use single quotes instead.
Maintenance labor costs are nearly always the lion's share
of the cost of software.
: while (<RNA>) {
: if (/015\s+(\w+\s\w*\s*\w+)/) {
^^
^^
Don't you want an ^ anchor there too?
: s/^015\s+//;
^^^^^^^^^^^
This pattern match (without parens) is Very Likely to
be succussful, given the m// in the conditional :-)
And I'm wondering why you are doing the substitution anyway.
You already have what you want in $1.
If you want the substitution made, then the s/// should be
in the conditional, not a m//
if (/^015\s+(\w+\s\w*\s*\w+)/$1/)
: select DNA;
: print $1;
That is a strange way of doing things.
I have never used select() in 5 years of full-time Perl programming.
print DNA $1; # replace two lines with one
: i cant get just the names into a variable -- $1???
Ah, but you _are_ getting the names into the $1 variable,
however you are resetting $1 before you print it.
The dollar-digit variables are *reset* on each successful
pattern match.
You must use (or copy) them before you get to a successful
pattern match, which your program above does not do.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 12 Jul 1999 00:16:10 GMT
From: nkaiser@my-deja.com
Subject: Re: Use a Perl Module w/o Installing It?
Message-Id: <7mbc44$8ou$1@nnrp1.deja.com>
Perhaps I should clarify.....in some cases, I may not even have telnet
access to a server. Only FTP access. Does a module (in this
case "Storable") always have to be compiled on the server first?
In article <49p9m7.37a.ln@magna.metronet.com>,
tadmc@metronet.com (Tad McClellan) wrote:
> nkaiser@my-deja.com wrote:
>
> : I have a Perl program which will be installed on many Unix
machines. It
> : uses the "Storable" Perl module. However, many of these machines
will
> : not have this module installed...and I will not have root access.
Is
> : it possible to somehow bundle this module and reference it that way?
>
> Perl FAQ, part 8:
>
> "How do I keep my own module/library directory?"
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 114
*************************************