[19058] in Perl-Users-Digest
Perl-Users Digest, Issue: 1253 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 6 03:05:36 2001
Date: Fri, 6 Jul 2001 00:05:10 -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: <994403109-v10-i1253@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 6 Jul 2001 Volume: 10 Number: 1253
Today's topics:
Re: calling a PERL script from Matlab (Steve Miller)
Re: DBI/MySQL: finding ID of an added record <mbudash@sonic.net>
Re: FAQ 9.26: How can I do RPC in Perl? (Chris Fedde)
FAQ: What is Perl? <faq@denver.pm.org>
Floating point accuracy? Is this a bug? <abrice2@home.com>
Re: Floating point accuracy? Is this a bug? <bwalton@rochester.rr.com>
Re: Floating point accuracy? Is this a bug? ctcgag@hotmail.com
Re: Floating point accuracy? Is this a bug? <gtoomey@usa.net>
Re: Floating point accuracy? Is this a bug? <william-news-102374@scissor.com>
Re: how do you move a created file (Smiley)
Re: how do you move a created file <shop@wehug.com>
Re: how do you move a created file (Smiley)
Re: How to delete consecutive blank lines <godzilla@stomp.stomp.tokyo>
Re: How to delete consecutive blank lines <james.mctiernan@rcn.com>
Re: How to delete consecutive blank lines <james.mctiernan@rcn.com>
Re: Newbie: Anyone heard of Mail::Sender? <Athera@yahoo.com>
Re: OT: The Evils of Posting to comp.lang.perl (Tim Hammerquist)
Re: putting arrays in arrays!?!? <mr.thanquol@gmx.de>
Q: Global variables (^CooL^)
Trouble with LWP::UserAgent setting UserAgent (Nick S.)
Re: Trouble with LWP::UserAgent setting UserAgent <godzilla@stomp.stomp.tokyo>
Re: Wants to use Ftp functions <tony_curtis32@yahoo.com>
Re: web fetching <uri@sysarch.com>
Re: Will using DB_File work for this?? <bwalton@rochester.rr.com>
Re: Will using DB_File work for this?? <miscellaneousemail@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Jul 2001 21:00:18 -0700
From: steveaux@my-deja.com (Steve Miller)
Subject: Re: calling a PERL script from Matlab
Message-Id: <12db7b5d.0107052000.18d89b4@posting.google.com>
Hi.
First, thanks for the helpful post. Some more info would be
appreciated as you will see below.
> split exists for Windows too. Get the Cygwin utilities from
> http://sources.redhat.com/cygwin/. Coming from a UNIX
> environment, being used to powerful tools, I would be helplessly
> lost on a PC without them.
Believe me, I know and love the Cygwin utilities! However, there are
two problems with that approach.
1. Can you shell out to use them? (e.g. ">> cygwin split -b4800000
hugefile prefix) If you know off the top of your head or know of any
pitfalls, you could save me some time!
2. I haven't had a chance to upgrade yet, but in my version of Cygwin
(1.0, I think), split has a bug. My files came out too small and, if I
recall, not even of uniform size. Does anyone know if that's been
fixed?
> > Are there other things I need to download?
>
> Yes. You need to get a complete version of Perl. Get it at
>
> http://www.ActiveState.com/
>
Probably, this is what I'll do, but I am curious about the other two
points. Since I can check them on my own in a day or so, no biggie,
but all the same....
Thanks again!
Steve
------------------------------
Date: Fri, 06 Jul 2001 01:17:37 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: DBI/MySQL: finding ID of an added record
Message-Id: <mbudash-90207E.18173705072001@news.sonic.net>
In article <20010705191745.759$A3@newsreader.com>, ctcgag@hotmail.com
wrote:
> "Stuart Moore" <stumo@bigfoot.com> wrote:
> > Just starting to use MySQL through the DBI interface (just starting
> > MySQL
> > for that matter)
> >
> > I have several tables who's primary key is an unsigned autoincrement
> > integer. When I add a record to the table, I want to know what value
> > the
> > id field has been given. What's the best way of doing this?
> >
> > Apologies if you consider this off topic - I'm undecided as to whether
> > this is related to Perl or a general MySQL issue.
> >
> > TIA
> >
> > Stuart
>
> Try running the query "select last_insert_id()"
you can also use:
$lastid = $sth->{insertid};
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Fri, 06 Jul 2001 04:42:12 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: FAQ 9.26: How can I do RPC in Perl?
Message-Id: <Ekb17.7$T3.177484288@news.frii.net>
In article <9hv7md$11q$1@sloth.swcp.com>, Tramm Hudson <hudson@swcp.com> wrote:
>In article <5PD07.349$T3.194419200@news.frii.net>,
>PerlFAQ Server <faq@denver.pm.org> wrote:
>> How can I do RPC in Perl?
>
>And in article <xxy07.344$T3.193812480@news.frii.net>,
>PerlFAQ Server <faq@denver.pm.org> wrote:
>> How can I do RPC in Perl?
>
>So which is it? Question 9.25 or 9.26?
>
Administrative error in the posting software. Thanks for pointing that
out.
--
This space intentionally left blank
------------------------------
Date: Fri, 06 Jul 2001 06:17:00 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: What is Perl?
Message-Id: <wJc17.8$T3.171054592@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
What is Perl?
Perl is a high-level programming language with an eclectic heritage
written by Larry Wall and a cast of thousands. It derives from the
ubiquitous C programming language and to a lesser extent from sed, awk,
the Unix shell, and at least a dozen other tools and languages. Perl's
process, file, and text manipulation facilities make it particularly
well-suited for tasks involving quick prototyping, system utilities,
software tools, system management tasks, database access, graphical
programming, networking, and world wide web programming. These strengths
make it especially popular with system administrators and CGI script
authors, but mathematicians, geneticists, journalists, and even managers
also use Perl. Maybe you should, too.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
01.01
--
This space intentionally left blank
------------------------------
Date: Fri, 06 Jul 2001 01:28:54 GMT
From: Aaron Brice <abrice2@home.com>
Subject: Floating point accuracy? Is this a bug?
Message-Id: <3B45154D.4EEE4278@home.com>
Running the following code:
$value = "0.300100";
$value = $value * 10**5; # multiply by 100000
$value = int($value);
I get $value = 30009. Is this a bug? I would expect more accuracy than
this.
Running the following code:
$value = (.30010*10**5);
printf ("%.0f, %f, %d\n", $value, $value, $value);
Gives you:
30010, 30010.00, 30009
Note that this only happens for a small percentage of values..
------------------------------
Date: Fri, 06 Jul 2001 03:23:33 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Floating point accuracy? Is this a bug?
Message-Id: <3B452D4A.E802D539@rochester.rr.com>
Aaron Brice wrote:
>
> Running the following code:
>
> $value = "0.300100";
> $value = $value * 10**5; # multiply by 100000
> $value = int($value);
>
> I get $value = 30009. Is this a bug? I would expect more accuracy than
> this.
>
> Running the following code:
>
> $value = (.30010*10**5);
> printf ("%.0f, %f, %d\n", $value, $value, $value);
>
> Gives you:
>
> 30010, 30010.00, 30009
>
> Note that this only happens for a small percentage of values..
Nope, not a bug -- just typical floating point rounding error. The
number 0.300100 cannot be represented exactly in binary, just like 2/3
cannot be represented accurately in base 10. In the case of 0.300100,
the binary representation happens to be just a bit less than 0.300100,
so if that is multiplied by 1e5 and truncated, the result is 30009.
That same thing will happen on any computer that uses binary arithmetic
(although one could write a package to perform exact decimal arithmetic
on any computer [maybe already is one?]). If you want to get a rounded
integer value rather than a truncated value, try:
$value=int($value+0.5);
(for positive values only). Or maybe $value=sprintf('%.0f',$value);
--
Bob Walton
------------------------------
Date: 06 Jul 2001 03:37:48 GMT
From: ctcgag@hotmail.com
Subject: Re: Floating point accuracy? Is this a bug?
Message-Id: <20010705233747.720$HC@newsreader.com>
Aaron Brice <abrice2@home.com> wrote:
> Running the following code:
>
> $value = "0.300100";
> $value = $value * 10**5; # multiply by 100000
> $value = int($value);
>
> I get $value = 30009. Is this a bug?
No, it's a feature.
> I would expect more accuracy than
> this.
Than what? You got the advertised 16 digits. It's not Perl's fault that
the squish in that digit propagates up to bite you when you take the int of
30009.999999999996362021.
>
> Running the following code:
>
> $value = (.30010*10**5);
> printf ("%.0f, %f, %d\n", $value, $value, $value);
>
> Gives you:
>
> 30010, 30010.00, 30009
>
> Note that this only happens for a small percentage of values..
Yep. Naively turn floats into ints at your own peril.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service
------------------------------
Date: Fri, 6 Jul 2001 15:35:38 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Floating point accuracy? Is this a bug?
Message-Id: <CWb17.22709$e5.62551@newsfeeds.bigpond.com>
"Aaron Brice" <abrice2@home.com> wrote in message
news:3B45154D.4EEE4278@home.com...
> Running the following code:
>
> $value = "0.300100";
> $value = $value * 10**5; # multiply by 100000
> $value = int($value);
>
> I get $value = 30009. Is this a bug? I would expect more accuracy than
> this.
Depending on how Perl is optimised, 10**5 is computed using logarithms.
10**5 = exp (log(10)*5)
The exp and log functions are approximated using Taylor or Macluarin series.
This is the main source of the floating point discrepancy.
gtoomey
------------------------------
Date: Thu, 5 Jul 2001 23:09:54 -0700
From: William Pietri <william-news-102374@scissor.com>
Subject: Re: Floating point accuracy? Is this a bug?
Message-Id: <tkalhjbh6o4if2@corp.supernews.com>
Gregory Toomey wrote:
> "Aaron Brice" <abrice2@home.com> wrote in message
> news:3B45154D.4EEE4278@home.com...
>> Running the following code:
>>
>> $value = "0.300100";
>> $value = $value * 10**5; # multiply by 100000
>> $value = int($value);
>>
>> I get $value = 30009. Is this a bug? I would expect more accuracy than
>> this.
>
> Depending on how Perl is optimised, 10**5 is computed using logarithms.
> 10**5 = exp (log(10)*5)
> The exp and log functions are approximated using Taylor or Macluarin
> series.
>
> This is the main source of the floating point discrepancy.
Are you sure about that? Using perl 5.6.0, this code
$crazy = "0.300100";
$sane = "30010";
$divisor = 0;
for ($i = 0; $i < 100000; $i++) {$divisor++;}
$log = $sane - $crazy * 10 ** 5;
$const = $sane - $crazy * 100000;
$addup = $sane - $crazy * $divisor;
print "does $log == $const? ",($log==$const ? "yup" : "nope"),"!\n";
print "does $log == $addup? ",($log==$addup ? "yup" : "nope"),"!\n";
produces this output:
does 3.63797880709171e-12 == 3.63797880709171e-12? yup!
does 3.63797880709171e-12 == 3.63797880709171e-12? yup!
So it looks like the source of the discrepancy is unrelated to the exponent
or to any parse-time recognition of 100000 as 10**5.
William
------------------------------
Date: Fri, 06 Jul 2001 05:08:40 GMT
From: gurm@intrasof.com (Smiley)
Subject: Re: how do you move a created file
Message-Id: <3b4545a7.218647588@news1.on.sympatico.ca>
Hey Mike,
I'm actually working on modifying the EveryAuctions script myself for
a client right now, I thought I recognized some of that code :)
From my experience the cgi-bin directory doesn't like html files.
You've got to set it so that it creates the file in another directory.
It sounds like you've got a problem with your $config{'megalist'}
variable. Go up to where it's set and make sure that you've got the
proper information in there. It should likely be a full path to the
directory you want created.
If you need more help with EveryAuction, I've been living and
breathing it for a few months now so don't hesitate to ask. Let me
know if I've helped.
>Hello all,
>Need some help,
>
>I'm getting 403 errors and must resolve.
>
> I'm using a cgi/perl script that creates a file called
>mega.htm and puts that file in my cgi-bin area. When I
>try to look at that file by typing the url in my browser,
>it gives me a 403 permissions error.
>
>The file is given 666 level permissions by the script,
>which seems adequate but still returns a 403 error.
>
>My problem is that the file called mega.htm must be accessed
>and read by a spider from an outside website.
>
>There is a peculiar thing , I do not see the directory named
>megalist but I do see the file mega.htm in my cgi-bin
>area.
>
>I can physically download and then upload this file to my
>public html area and then can look at it with my browser.
>
>So what is the best way to fix this, create another few lines
>of perl code that can move this file to my public html area ?
>
------------------------------
Date: Fri, 06 Jul 2001 02:49:46 GMT
From: Crystal Ball <shop@wehug.com>
Subject: Re: how do you move a created file
Message-Id: <3B45281E.9AFD5681@wehug.com>
Hi Smiley,
Thanks for the reply.
I've tried many various path possibilities, but when ever I
try to use anything like http://www.wehug.com/
which is where I want it to mkdir and put the mega.htm file
it wont do it. I don't get any error messages, the program just
sails along and does nothing regarding the creation of the Dir
or the mega file. I have no problem with the script creating
the mega.htm file as long as I set the path anywhere inside
the cgi-bin area. Here is the script in it's current state.
http://www.wehug.com/auction.txt
I have used everyauction on and off for the last 4 years or
so, this is the first time I've used ver 1.5
Do you have your auction going yet?
Later
Mike
ps here is the current script result
http://www.wehug.com/cgi-bin/testauction/auction.pl
this is only a testing auction separate from my current live auction.
here is my current live auction,
http://www.wehug.com/cgi-bin/newauction/auction.pl?category=All
please don't mess around with this
one as these are my real customers and a real current auction.
Smiley wrote:
>
> Hey Mike,
>
> I'm actually working on modifying the EveryAuctions script myself for
> a client right now, I thought I recognized some of that code :)
>
> From my experience the cgi-bin directory doesn't like html files.
> You've got to set it so that it creates the file in another directory.
> It sounds like you've got a problem with your $config{'megalist'}
> variable. Go up to where it's set and make sure that you've got the
> proper information in there. It should likely be a full path to the
> directory you want created.
>
> If you need more help with EveryAuction, I've been living and
> breathing it for a few months now so don't hesitate to ask. Let me
> know if I've helped.
>
> >Hello all,
> >Need some help,
> >
> >I'm getting 403 errors and must resolve.
> >
> > I'm using a cgi/perl script that creates a file called
> >mega.htm and puts that file in my cgi-bin area. When I
> >try to look at that file by typing the url in my browser,
> >it gives me a 403 permissions error.
> >
> >The file is given 666 level permissions by the script,
> >which seems adequate but still returns a 403 error.
> >
> >My problem is that the file called mega.htm must be accessed
> >and read by a spider from an outside website.
> >
> >There is a peculiar thing , I do not see the directory named
> >megalist but I do see the file mega.htm in my cgi-bin
> >area.
> >
> >I can physically download and then upload this file to my
> >public html area and then can look at it with my browser.
> >
> >So what is the best way to fix this, create another few lines
> >of perl code that can move this file to my public html area ?
> >
------------------------------
Date: Fri, 06 Jul 2001 05:59:52 GMT
From: gurm@intrasof.com (Smiley)
Subject: Re: how do you move a created file
Message-Id: <3b455299.221961263@news1.on.sympatico.ca>
Mike,
Right away I see your problem. You're trying to set the value to your
HTTP directory. You need to set it to your Server directory. Instead
of http://www.wehug.com, it will probably be something like
/home/users/wehug/public_html/ - that is the directory path on the
server, and not the URL.
My script's working - I'm setting up a demo site soon. I'll tell you
when it's up. (The site I'm working on is for the medical community
though so it probably won't be of much interest to you outside of the
auction script.)
On Fri, 06 Jul 2001 02:49:46 GMT, Crystal Ball <shop@wehug.com> wrote:
>Hi Smiley,
>Thanks for the reply.
>I've tried many various path possibilities, but when ever I
>try to use anything like http://www.wehug.com/
>which is where I want it to mkdir and put the mega.htm file
>it wont do it. I don't get any error messages, the program just
>sails along and does nothing regarding the creation of the Dir
>or the mega file. I have no problem with the script creating
>the mega.htm file as long as I set the path anywhere inside
>the cgi-bin area. Here is the script in it's current state.
>http://www.wehug.com/auction.txt
------------------------------
Date: Thu, 05 Jul 2001 19:39:19 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: How to delete consecutive blank lines
Message-Id: <3B4524D7.95480212@stomp.stomp.tokyo>
Jim McTiernan wrote:
> I have a text file with multiple blank lines before and after paragraphs.
> How can I get rid of them?
Oh look, it's "get rid" once again!
You have failed to provide any clear and concise parameters.
There is no indication if you want to clear these blank lines
during a print or, if you want to rewrite this text file.
Not providing clear and concise parameters is highly illogical.
A consequence of your laziness in writing your article is
I will make presumptions or, if you like, respond in a
fashion which tickles my fancy.
I have chosen to provide a rewrite script. If you don't
like this, if this is not what you want, tough luck, Bozo.
My expectation is you will accept these consequences of
your inappropriate actions without complaint nor whimper.
> How also to delete paragraphs that contain certain words, or would it be
> easier to save the paragraphs that contain only certain words.
Which is easier? Pouring a split of champagne into a twelve ounce
champagne glass or pouring half of a split of champagne into a
six ounce champagne glass?
Hey! What will you do if a paragraph contains both words you
don't want and words you do want? Decisions! Decisions!
Personally, my preference is chilled strawberries with my
chilled American brut champagne, full spilt please. Very
easy decision, that.
Caution is to be exercised when rewriting a file. Error
checking for various functions should be included. Before
a rewrite, a backup copy should be made. Logical, yes?
Below my signature, you will discover a method I like,
being a unique rogue programmer. I have never read any
geeks here using this method, which delights me and,
reminds of what unimaginative twits they are.
This method uses a sub-routine so $/ can be localized.
if (index ($_, "FUBAR") == -1)
{ push (@Array, $_); }
Those two lines are where you can either ignore certain
paragraphs, or include certain paragraphs. Oh my, as a
boy I am certain you are stressed by having to make a
major decision. My "FUBAR" can be a variable, or you
can incorporate looping to march through variables.
Chances are good, this would be a logical point in
a program to remove lines which consist of a \n
character only, you think? I have not performed
this operation in my script simply because I do
not feel like doing this. Did I hear a whimper?
Remainder of my test script, is a piece of cake, which
I avoid as I have ample seating cushion. Strawberries
and champagne sit better with me.
* champagne tongue wets her finger and whets her tongue *
Ever delicately run a wet finger around a rim of a fine
leaded crystal champagne glass? It will sing a tune almost
as delightful as my well whetted tongue, although it will
not sing as many sharp notes.
Godzilla!
--
TEST SCRIPT:
____________
#!perl
print "Content-type: text/plain\n\n";
&Rewrite;
sub Rewrite
{
local ($/) = "";
open (REWRITE, "+<test.txt");
while (<REWRITE>)
{
$_ =~ s/\n$//;
if (index ($_, "FUBAR") == -1)
{ push (@Array, $_); }
}
seek (REWRITE, 0, 0);
truncate (REWRITE, tell (REWRITE));
for (@Array)
{ print REWRITE $_; }
close (REWRITE);
}
print "All Done Boss.";
exit;
________________
test.txt Before:
________________
Gypsy Crossing
- Kira
Didn't we put up a magnificent fight,
Waging a war of love against ol' Death.
Never daunted by his haunting fright,
We wielded weapons well till last breath.
For your grave, some tears leave my mark,
A glittering tombstone ever so sadly wet.
Your epitaph, my raging love's watermark
Forever reminding me Love's weapons to whet.
REMOVE THIS PARAGRAPH. THIS IS FUBAR HERE.
You are free, forever roam my sweet Gypsy,
And should you cross my dear mother's path,
Please my warrior of love, tell her to see
Ol' Death will never be free from my wraith.
So long ago before you and me took to love,
Maternal love, ol' Death snatched from me.
Although I am told, her breasts my trove
He set to cold long 'fore I could truly see.
Wiping at unwanted tombstone, I find strength,
My heart hears you well and something I know.
Along your many paths, a crossing at length,
Mother listens well of tale without any woe.
REMOVE THIS PARAGRAPH. THIS IS FUBAR HERE.
Stroking your length as I did during fight,
She feels my love's very last tender touch.
Her loving hands will cradle you during night
And bring her memories of her baby's own touch.
Whisper her my long tale of lasting love Gyspy,
There on your crossing for a moment long last.
Give her a purr to fly with Time's windward lee,
To set sail to join her young one distant past.
Someday on smooth sea, we three will sail away,
So far away in love and comfort day and night.
For now my tears fall on this mild joyful day,
To whet words of a kitten for Mother's delight.
_______________
test.txt After:
_______________
Gypsy Crossing
- Kira
Didn't we put up a magnificent fight,
Waging a war of love against ol' Death.
Never daunted by his haunting fright,
We wielded weapons well till last breath.
For your grave, some tears leave my mark,
A glittering tombstone ever so sadly wet.
Your epitaph, my raging love's watermark
Forever reminding me Love's weapons to whet.
You are free, forever roam my sweet Gypsy,
And should you cross my dear mother's path,
Please my warrior of love, tell her to see
Ol' Death will never be free from my wraith.
So long ago before you and me took to love,
Maternal love, ol' Death snatched from me.
Although I am told, her breasts my trove
He set to cold long 'fore I could truly see.
Wiping at unwanted tombstone, I find strength,
My heart hears you well and something I know.
Along your many paths, a crossing at length,
Mother listens well of tale without any woe.
Stroking your length as I did during fight,
She feels my love's very last tender touch.
Her loving hands will cradle you during night
And bring her memories of her baby's own touch.
Whisper her my long tale of lasting love Gyspy,
There on your crossing for a moment long last.
Give her a purr to fly with Time's windward lee,
To set sail to join her young one distant past.
Someday on smooth sea, we three will sail away,
So far away in love and comfort day and night.
For now my tears fall on this mild joyful day,
To whet words of a kitten for Mother's delight.
------------------------------
Date: Thu, 5 Jul 2001 21:39:41 -0700
From: "Jim McTiernan" <james.mctiernan@rcn.com>
Subject: Re: How to delete consecutive blank lines
Message-Id: <9i3fii$aks$1@bob.news.rcn.net>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
news:3B4524D7.95480212@stomp.stomp.tokyo...
> Jim McTiernan wrote:
>
> > I have a text file with multiple blank lines before and after
paragraphs.
> > How can I get rid of them?
>
> Oh look, it's "get rid" once again!
>
> You have failed to provide any clear and concise parameters.
> There is no indication if you want to clear these blank lines
> during a print or, if you want to rewrite this text file.
> Not providing clear and concise parameters is highly illogical.
>
> A consequence of your laziness in writing your article is
> I will make presumptions or, if you like, respond in a
> fashion which tickles my fancy.
>
> I have chosen to provide a rewrite script. If you don't
> like this, if this is not what you want, tough luck, Bozo.
> My expectation is you will accept these consequences of
> your inappropriate actions without complaint nor whimper.
>
>
> > How also to delete paragraphs that contain certain words, or would it be
> > easier to save the paragraphs that contain only certain words.
>
> Which is easier? Pouring a split of champagne into a twelve ounce
> champagne glass or pouring half of a split of champagne into a
> six ounce champagne glass?
>
> Hey! What will you do if a paragraph contains both words you
> don't want and words you do want? Decisions! Decisions!
>
> Personally, my preference is chilled strawberries with my
> chilled American brut champagne, full spilt please. Very
^^^
Oh Bozo, I wasn't the twit who spilt their champagne!
------------------------------
Date: Thu, 5 Jul 2001 21:42:32 -0700
From: "Jim McTiernan" <james.mctiernan@rcn.com>
Subject: Re: How to delete consecutive blank lines
Message-Id: <9i3fnt$bik$1@bob.news.rcn.net>
Craig Berry <cberry@cinenet.net> wrote in message
news:tka1o4gs3bl6e@corp.supernews.com...
> Jim McTiernan (james.mctiernan@rcn.com) wrote:
> : I have a text file with multiple blank lines before and after
paragraphs.
> : How can I get rid of them?
>
> If the file is of manageable size, use one of the standard idioms to read
> the entire file into a scalar, then translate away multiple adjacent
> newlines using 'tr/\n//s'.
>
> : How also to delete paragraphs that contain certain words, or would it be
> : easier to save the paragraphs that contain only certain words.
>
> Depends on the application. In either case, reading the file by
> paragraphs (perldoc -q paragraphs) will make your life easier.
>
> --
> | Craig Berry - http://www.cinenet.net/~cberry/
> --*-- "Magick is the art and science of causing change in conformity
> | with Will." - Aleister Crowley
Thanks for the help
Jim
------------------------------
Date: Fri, 06 Jul 2001 01:22:53 GMT
From: Athera <Athera@yahoo.com>
Subject: Re: Newbie: Anyone heard of Mail::Sender?
Message-Id: <mk4akt81o9rg18pp736t3a0539dbi7kboa@4ax.com>
It sounds like what you want is Net::SMTP
You just need an SMTP server somewhere (like your ISP provides -- same
one you enter in your email client).
perldoc Net::SMTP has a couple basic examples.
It doesn't require sendmail (I'm running it from Windows).
On Mon, 22 Jan 2001 00:36:43 +0000, sound <sound@sound-web.co.uk>
wrote:
>Hi,
>
>I am a complete Newbie to perl and have had trouble getting a script
>that will handle a form to email submission. Every script I have seen
>seems to use Sendmail, but my ISP says it doesn't support that and
>provides me with an example that uses Mail::sender instead. However,
>there is no form parsing in this example and I was wondering how to go
>about converting another script to use this Mail::sender thingie.
>
>(Or even better, has anyone seen a script that uses such a
>modification)
>
>Any help would be appreciated, even if I am barking up the wrong tree.
>
>Thanks
>
>Dave
------------------------------
Date: Fri, 06 Jul 2001 04:41:54 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: OT: The Evils of Posting to comp.lang.perl
Message-Id: <slrn9kah2e.39i.tim@vegeta.ath.cx>
Tad McClellan <tadmc@augustmail.com> wrote:
> Tim Hammerquist <tim@vegeta.ath.cx> wrote:
>
> >And so I repose my question to the groups at large: due to the intended
> >replacement of clp with clp.*, am I making matters worse by continuing
> >to post there?
>
> In as much as answering questions there encourages folks to post
> there instead of the replacement where their odds are better,
> I would say yes, it does make matters worse.
That's what I suspected. Thank you.
> >Especially since not as many people knowledgable at Perl
> >can help out there?
>
> Folks should be encouraged to post to comp.lang.perl.misc instead
> of comp.lang.misc especially since not as many people knowledgable
> at Perl can help out in comp.lang.misc.
I have encouraged them several times to post to clpm and most loudly
refuse, citing clpm's reputation for short temper, etc.
But if it will help the intentions of the Perl NGs, I'll snub them.
Thanks again. =)
--
-Tim Hammerquist <timmy@cpan.org>
God made the Idiot for practice, and then He made the School Board.
-- Mark Twain
------------------------------
Date: Fri, 6 Jul 2001 08:59:15 +0200
From: "felix" <mr.thanquol@gmx.de>
Subject: Re: putting arrays in arrays!?!?
Message-Id: <9i3ni6$ftk$1@crusher.de.colt.net>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9k94bj.gu0.tadmc@tadmc26.august.net...
> felix <mr.thanquol@gmx.de> wrote:
>
> > I'm hopelessly lost
>
>
> No you're not.
>
>
> >I want to put the content of an array in an array like this and
addititonaly
> ^^^^^^^^
> >scalar values
>
> >@small_array = (1 , 2 , 3);
>
>
> That is putting the contents of a list into an array. Perl FAQ, part 4:
>
> "What is the difference between a list and an array?"
>
>
> >$some_value = '4' ;
> >$some_more_value = '5';
> >
> >
> >@BIG_ARRAY = (@small_array , $some_value , $some_more_value)
> >
> >and afterwards the output
>
>
> Err, your code above does not make any output...
>
>
> >should look like this
> >1
> >2
> >3
> >4
> >5
> >
> >
> >... can somebody give me a hand with this??
>
>
> You do not need a hand with it. It works as you have it.
>
> Did you try it?
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
ARGH!!! .... I found the mistake ... in another part of the script
BUT THX A LOT TO ALL!!!
felix
------------------------------
Date: 5 Jul 2001 23:36:16 -0700
From: cool133@hotmail.com (^CooL^)
Subject: Q: Global variables
Message-Id: <211c8e3f.0107052236.4c362f0d@posting.google.com>
Hi.
Please consider the following code snippet in mod_perl:
In start.pl
===========
use strict;
use CGI qw(:standard);
use lib qw(..);
use common::conf qw(%config);
use vars qw(%config);
# Enable service
common::conf::readFromDB();
$config{SERVICE_STATUS} = "Enabled";
common::conf::writeToDB();
In conf.pm:
===========
package common::conf;
use strict;
use DBI;
# Export Global Variables
BEGIN {
use Exporter ();
@conf::ISA = qw(Exporter);
@conf::EXPORT = qw();
@conf::EXPORT_OK = qw(%config);
}
use vars qw(%config);
sub readFromDB {
...
}
sub writeToDB {
...
}
readFromDB() is a function that reads a set of configuration values
from a database and stores them in a hash called %config, while
writeToDB() updates the database with the values in the %config hash.
For some reason, $config{SERVICE_STATUS} does not get updated in
common::conf package when I change its value in start.pl, so when I
call writeToDB() it re-writes the old value as it was read from
readFromDB()!
On the other hand, it seems to work fine if I replace:
$config{SERVICE_STATUS} = "Enabled";
with
$common::conf::config{SERVICE_STATUS} = "Enabled";
Isn't it supposed to work without the fully qualified name? Isn't that
what Export.pm is supposed to be for?
Regards,
Clyde.
------------------------------
Date: 5 Jul 2001 21:54:12 -0700
From: nickysantoro@yahoo.com (Nick S.)
Subject: Trouble with LWP::UserAgent setting UserAgent
Message-Id: <3f8ea7b5.0107052054.18e84413@posting.google.com>
Hi,
I'm trying to get my script to present itself as a certain class of
Mozilla browser to access a site that varies according to browser
version. Anyway, I found in LWP you can use this:
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("$0/0.1 " . $ua->agent);
# $ua->agent("Mozilla/8.0") # pretend we are very capable
browser
and I assume uncommenting the last line would present a v8 browser
type as the ENV{'HTTP_USER_AGENT'}, right? Anyway, nothing is working
and everything just shows up lwp-trivial/1.32. When I just print out
$ua in the above script I get LWP::UserAgent=HASH(0x1057a4). Anybody
know what's going on?
Thanks for any info...
------------------------------
Date: Fri, 06 Jul 2001 00:01:28 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Trouble with LWP::UserAgent setting UserAgent
Message-Id: <3B456248.76C8645B@stomp.stomp.tokyo>
Nick, using a fake email account at yahoo and posting
anonymously through google, a classic troll method,
actually posting from "famine.OCF.Berkeley.EDU" using
an eight bit Mozilla browser although not shown, wrote:
(snippage)
> I'm trying to get my script to present itself as a certain class of
> Mozilla browser....
> ...Anyway, nothing is working and everything just shows
> up lwp-trivial/1.32. When I just print out $ua in the
> above script I get LWP::UserAgent=HASH(0x1057a4).
> Anybody know what's going on?
Yes, and more than you think.
You need to update your LWP module.
Special syntax is needed for a print when using
LWP user agent.
My printed results are derived from an html page
which employs simple Server Side Include "echo"
of selected environmental variables.
I have added a few extras to assist you. Look over
my print method to avoid a hash reference print.
Godzilla!
--
TEST SCRIPT:
____________
#!perl
print "Content-type: text/html\n\n";
require LWP::UserAgent;
$user_agent = new LWP::UserAgent;
$user_agent -> agent ("Etch-A-Sketch 2000");
$request = new HTTP::Request ('GET', 'http://localhost/~callgirl/echo.htm');
$request -> header ('Accept' => 'text/html');
$request -> referer ('http://alturus.5.gamma.sector');
$response = $user_agent -> request ($request);
print $response -> headers_as_string,
$response -> content;
exit;
PRINTED RESULTS HTML FORMAT:
____________________________
(headers have been cleaned up)
Connection: close
Date: Fri, 06 Jul 2001 06:33:29 GMT
Server: Apache/1.3.14 (Win32) mod_perl/1.24_02-dev
Content-Type: text/html
Client-Date: Fri, 06 Jul 2001 06:33:29 GMT
Client-Peer: 127.0.0.1:80
Title: Environmental Variables
Environmental Variables
Variable:
Your IP ADDRESS
Value: 127.0.0.1
Variable:
Your HOSTNAME
Value: localhost
Variable:
Your PORT being used
Value: 1586
Variable:
Your BROWSER / SYSTEM type
Value: Etch-A-Sketch 2000
Variable:
Your REFERRING site
Value: http://alturus.5.gamma.sector
------------------------------
Date: 05 Jul 2001 20:54:11 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Wants to use Ftp functions
Message-Id: <87vgl6bz5o.fsf@limey.hpcc.uh.edu>
>> On Fri, 6 Jul 2001 01:46:28 +0200,
>> "CentaureZ" <julien.carosi@club-internet.fr> said:
> Hello, i'm quite new to perl and i'd like to write a
> program that could use ftp functions, so i put
> use Net::FTP
> at the beggining of my source, but it doesn't work when
> i try to launch it i get
> centaurez@gateway:~/perl$ ./essai Can't locate
> Net/FTP/Common.pm in @INC (@INC contains:
perl -MCPAN -e 'install qw(Net::FTP ...other modules...)'
should do the trick. Also
perl -MCPAN -eshell
is the interactive way to look at what's out there and
install.
hth
t
--
Beep beep! Out of my way, I'm a motorist!
------------------------------
Date: Fri, 06 Jul 2001 03:06:02 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: web fetching
Message-Id: <x77kxm69k1.fsf@home.sysarch.com>
>>>>> "BN" == BUCK NAKED1 <dennis100@webtv.net> writes:
BN> Thanks for that excellent explanation. I mistated. I have Socket.pm and
BN> IO::Socket installed; but not IO::Socket::INET.
IO::Socket now contains IO::Socket::INET.
just do a use IO::Socket, and later a IO::Socket::INET->new(....)
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Fri, 06 Jul 2001 03:30:29 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Will using DB_File work for this??
Message-Id: <3B452EE8.DDA92913@rochester.rr.com>
"Carlos C. Gonzalez" wrote:
...
> I would appreciate help from anyone who might have some thoughts about
> using DB_File.
>
> Will it allow me to work with records that contain MORE than a single
> value associated with my key?
>
> For example my records would look like this.
>
> KEY VALUE_1 VALUE_2 VALUE_n
> <email_address>,<first_name>,<date_subscribed>,etc.
> <email_address>,<first_name>,<date_subscribed>,etc.
> etc..
>
> Can I use DB_File to work with such records and can it save such
> records to a comman delimited, text file?
>
> Short of going to a full relational database are there other Perl
> database modules that anyone would recommend??
...
> Carlos
...
You can store any value which is a string in a DB_File tied hash. So
your comma-separated list of fields would do fine as a value. When you
look the value up, you will need to split it to retrieve the individual
fields. You could also check out the MLDBM module, which will permit
you to store references to stuff using DB_File (it "cheats" by
stringifying the reference, typically with Data::Dumper).
--
Bob Walton
------------------------------
Date: Fri, 06 Jul 2001 05:06:23 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: Will using DB_File work for this??
Message-Id: <MPG.15aef44e40deffea989681@news.edmonton.telusplanet.net>
In article <3B452EE8.DDA92913@rochester.rr.com>, bwalton@rochester.rr.com
says...
> You can store any value which is a string in a DB_File tied hash. So
> your comma-separated list of fields would do fine as a value...<snip>
Thanks for your input Bob. I don't know why I didn't think of that but
it makes total sense.
Someone else had suggested creating wrapper functions to put together the
various values and store them under seperate ID's. Creating a block of
such ID's for each write and retrieving the same block of ID's for each
read but I think your idea is easier to implement and cleaner.
I can now go ahead with using DB_File knowing that I can store a great
number of extra values in a string tied to the one key.
Thanks again Bob.
--
Carlos
www.internetsuccess.ca
------------------------------
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 1253
***************************************