[13903] in Perl-Users-Digest
No subject found in mail header
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 10 17:44:59 1999
Date: Tue, 9 Nov 1999 18:10:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942199817-v9-i1333@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 9 Nov 1999 Volume: 9 Number: 1333
Today's topics:
Re: perl as first language? <uri@sysarch.com>
Re: perl as first language? (Kragen Sitaker)
Re: perl as first language? (Martien Verbruggen)
Re: perl as first language? (Martien Verbruggen)
Re: Perl EXE? <joneill@pgicompanies.com>
Re: Perl EXE? <cassell@mail.cor.epa.gov>
Re: Perl EXE? <cassell@mail.cor.epa.gov>
Re: Perl Extensions. Arrgh. (Ilya Zakharevich)
Re: Perl Extensions. Arrgh. (Arved Sandstrom)
Re: Piping script to Perl <cassell@mail.cor.epa.gov>
Portable Perl Code <sglicker@ticom-geo.com>
Re: Portable Perl Code (Kragen Sitaker)
Problem: MySQL, variable scope, references salvadorej@my-deja.com
Re: regular expression help <lr@hpl.hp.com>
Re: Rounding numbers to specific decimal places <cassell@mail.cor.epa.gov>
Re: Rounding numbers to specific decimal places <aqumsieh@matrox.com>
Re: Sharp PERLers needed - San Diego company. (Kragen Sitaker)
Re: Sharp PERLers needed - San Diego company. <uri@sysarch.com>
Re: Thanx for help :-) (kfratzke)
Variables in Strings and Substituting a Path Name sneswhiz@my-deja.com
Re: YA Find/Replace newbie question <cassell@mail.cor.epa.gov>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 09 Nov 1999 18:53:32 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perl as first language?
Message-Id: <x7so2fz0g3.fsf@home.sysarch.com>
>>>>> "JL" == Jean-Louis Leroy <jll@skynet.be> writes:
JL> Let this sink in. He did not know about open(), yet he had done
JL> significant work in Perl.
JL> Thinking about it, I suppose he doesn't know about $_, regexes, $1,
JL> local (but he knows about my all right), etc.
can you post or illustrate some of the actual stuff he did without ever
opening a file? was he writing modules or subs that were called with
data from code he didn't write?
JL> AND (I say again) YET HE HAS CODED COMPLICATED, SIGNIFICANT PARTS OF
JL> OUR APP. IN PERL!
AND I SAY AGAIN, TELL US WHAT HIS CODE DID!
(who says i don't know where the caps key is!)
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: Tue, 09 Nov 1999 23:58:42 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: perl as first language?
Message-Id: <Sy2W3.61948$23.2398988@typ11.nn.bcandid.com>
In article <x7so2fz0g3.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "JL" == Jean-Louis Leroy <jll@skynet.be> writes:
> JL> Let this sink in. He did not know about open(), yet he had done
> JL> significant work in Perl.
>
>can you post or illustrate some of the actual stuff he did without ever
>opening a file? was he writing modules or subs that were called with
>data from code he didn't write?
If they're storing all their data in an RDBMS via an object-relational
persistence library, which is what it sounds like, they probably don't
need to open files much.
> JL> AND (I say again) YET HE HAS CODED COMPLICATED, SIGNIFICANT PARTS OF
> JL> OUR APP. IN PERL!
>
>AND I SAY AGAIN, TELL US WHAT HIS CODE DID!
>
>(who says i don't know where the caps key is!)
I laughed out loud when I read this.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 01:48:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl as first language?
Message-Id: <_94W3.160$Y86.3863@nsw.nnrp.telstra.net>
On 9 Nov 1999 14:13:20 GMT,
Simon Cozens <simon@othersideofthe.earth.li> wrote:
> Martien Verbruggen (comp.lang.perl.misc):
> As such, I don't think it's fair to lump C and Perl in the same
> category; the learning curves, the style, the objectives and the
> usability are very different between the two languages. If you don't
> believe me, it might be that you're writing Perl like you would C...?
Heh, judge for yourself. You can probably find one or two code
snippets that I wrote on this group. :)
Just to clarify, I did not lump C and Perl into the same category. I
mentioned that C and Perl are both good choices for sysadmin tasks.
Each will have a different application domain, but each also has
particular strengths that are very applicable to the sysadmin domain
in general. As for shells: Note that in my first post in response to
this thread I mentioned shells. I sort of assume that anyone calling
themselves sysadmin already has that sort of skill.
Unless all you need to know is how to press the reset button after you
see a blue screen. :)
Martien
--
Martien Verbruggen |
Interactive Media Division | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd. | no excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: Wed, 10 Nov 1999 01:56:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl as first language?
Message-Id: <uh4W3.164$Y86.3863@nsw.nnrp.telstra.net>
On 9 Nov 1999 19:04:29 GMT,
Damian Conway <damian@cs.monash.edu.au> wrote:
> abigail@delanet.com (Abigail) writes:
>
> >I disagree with Perl, for the same reason I don't recommend C. It's way
> >too messy and there's too much rope. That's great for someone who knows
> >what they are doing, but not good for someone who doesn't. First learn
> >to program, then you know how to exploit the mess and ropes of Perl and C.
>
> Amen, sibling!
But, Damian, your own book (OO Perl) shows some pretty good examples
of how decent code can be written in Perl. It also explains a few of
the dangers in the same, but that just comes back to learning things
from a good source, instead of just diving in.
Don't misunderstand me; I've already agreed that for educational
puproses and general programming other languages than the ropey ones
are more applicable. But I maintain that for sysadmin tasks it will
probably be a waste of time to learn a heavily structured language
first; because after that you will want to apply it to your day to day
administration task, and you'll find out that you can't do bugger all.
Or if you can do it at all, it looks and feels totally alien to the
language at hand.
Martien
--
Martien Verbruggen |
Interactive Media Division | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd. | no excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: Tue, 09 Nov 1999 23:51:10 GMT
From: "joneill" <joneill@pgicompanies.com>
Subject: Re: Perl EXE?
Message-Id: <Or2W3.6790$L5.75910@c01read02-admin.service.talkway.com>
On Tue, 09 Nov 1999 22:35:52 GMT barrytrot@yahoo.com wrote:
> I have made several perl scripts that I would like to be able to
> distribute in "executable form".
>
> In other words, I want to have one install program which will create
> all of the things that you need to run my scripts.
>
> I want this to be platform independent if possible.
>
> Basicly, I want to allow people to run my cgi-perl scripts from their
> own machine without having to connect to the internet and my computer.
>
> Any help with this would be greatly appreciated.
>
> Thanks.
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
The Perl compiler that I recommend is perl2exe. You can get a working
demo at www.demobuilder.com. I think there is also a version of
perl2exe in the Perl Resource Kit. I develop on Win32 platform, but I
think the Unix version is at both of the locations I recommended.
Jay O'Neill
PGI Companies
jo'neill@pgicompanies.com
--
Free audio & video emails, greeting cards and forums
Talkway - http://www.talkway.com - Talk more ways (sm)
------------------------------
Date: Tue, 09 Nov 1999 16:58:56 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl EXE?
Message-Id: <3828C350.912F44D6@mail.cor.epa.gov>
barrytrot@yahoo.com wrote:
>
> I have made several perl scripts that I would like to be able to
> distribute in "executable form".
>
> In other words, I want to have one install program which will create
> all of the things that you need to run my scripts.
>
> I want this to be platform independent if possible.
>
> Basicly, I want to allow people to run my cgi-perl scripts from their
> own machine without having to connect to the internet and my computer.
You cannot have all those things at once. If you want this
to be platform-independent, you can't compile it. Perl
maintains its platform independence by remaining a text file
until interpreted. If you want one install program, you'll
have to do a lot of work to make even that be platform-
independent. How are you going to write one install program
which will work on win32 and linux and MacOS, unless you write
the installer in Perl and make everyone have Perl first?
And your executables will be *huge* too. Less portable.
Less transferable. Your best bet is to write an installer
which puts Perl onto the system along with any needed
modules, then makes any needed changes to run your program.
There is a FAQ covering this topic. You'll get something
out of reading it.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 09 Nov 1999 17:02:39 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl EXE?
Message-Id: <3828C42F.5DEA4563@mail.cor.epa.gov>
joneill wrote:
>
> On Tue, 09 Nov 1999 22:35:52 GMT barrytrot@yahoo.com wrote:
[snip]
> > I want this to be platform independent if possible.
[snip]
> The Perl compiler that I recommend is perl2exe. You can get a working
> demo at www.demobuilder.com. I think there is also a version of
> perl2exe in the Perl Resource Kit. I develop on Win32 platform, but I
> think the Unix version is at both of the locations I recommended.
But how does that make his program portable? He'll have different
non-portable versions to disperse. And they won't run on lots
of platforms where Perl runs. And perl2exe won't do a good
job in certain cases, so it also depends on which modules he
wants to use. That's why I usually refer people to the FAQ
instead.
But thanks anyway. You gave an answer that wasn't wrong,
and you used Usenet guidelines for your response. We
appreciate that.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 9 Nov 1999 23:11:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl Extensions. Arrgh.
Message-Id: <80a9mc$6mj$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Dan Sugalski
<dan@tuatha.sidhe.org>],
who wrote in article <7j1W3.2655$c06.23147@news.rdc1.ct.home.com>:
> >> Nope. void in XS isn't the same as void in C. It means either "Go figure
> >> out if I'm returning an SV". In this case it's OK. Better to be explicit
> >> with a return type of SV *, but not an error.
>
> > I do not think you are right. Given CODE/PPCODE without output,
> > return value specificator is most probably ignored.
>
> > How would you think RETVAL is going to be declared in your example?
>
> If you'll notice, I added in an OUTPUT: RETVAL to the example.
I noticed. But my remark still stands: what do you think is the
declaration of RETVAL? It is C, not Perl, variables have types...
> The use of void to mean "well, go guess" is mildly depricated at this
> point
I "mildly depricated" it *several years* ago. Though probably we can
continue supporting it for some more time.
Ilya
------------------------------
Date: Tue, 09 Nov 1999 21:19:16 -0400
From: Arved_37@chebucto.ns.ca (Arved Sandstrom)
Subject: Re: Perl Extensions. Arrgh.
Message-Id: <Arved_37-0911992119160001@dyip-19.chebucto.ns.ca>
In article <80a9mc$6mj$1@charm.magnus.acs.ohio-state.edu>,
ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:
> [A complimentary Cc of this posting was sent to Dan Sugalski
> <dan@tuatha.sidhe.org>],
> who wrote in article <7j1W3.2655$c06.23147@news.rdc1.ct.home.com>:
> > The use of void to mean "well, go guess" is mildly depricated at this
> > point
>
> I "mildly depricated" it *several years* ago. Though probably we can
> continue supporting it for some more time.
>
And to sum up, I think *I* will continue doing what I have been doing, in
order to maintain my sanity and also be able to understand my code 6
months down the road: void for nothing being returned and a specific
return type if I _am_ returning something. :-)
Arved Sandstrom
P.S. Although it's an interesting little quirk that I'll likely not be
able to forget... :-)
------------------------------
Date: Tue, 09 Nov 1999 17:05:24 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Piping script to Perl
Message-Id: <3828C4D4.71253884@mail.cor.epa.gov>
Wes Morrison wrote:
>
> I am attempting to duplicate the behavior of the Perl interpreter when it is
> invoked with no arguments, where the script may be typed in, e.g.
[snip]
> If I instead use the -e argument to pass my "print" statement when Perl is
> invoked, then I can get the script's output on stdout, so stdout
Yes. Use the -e flag. Read the perlrun pages for why.
Or, better yet, re-think your process. Is there a good reason
for opening Perl like this, instead of embedding it in your
app, or embedding a C program to do your work inside Perl, or
running a Perl program externally and capturing the output?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 09 Nov 1999 18:12:22 -0600
From: Steven Glicker <sglicker@ticom-geo.com>
Subject: Portable Perl Code
Message-Id: <3828B866.54447E45@ticom-geo.com>
Hi,
I would greatly appreciate knowing how one typically writes portable
code in Perl in cases where a function (say alarm) exists in Linux but
not in Windows. In C this is typically handled at compile-time with
#ifdef's. Is there a convention for handling this (at run-time) in Perl?
Regards,
Steven
------------------------------
Date: Wed, 10 Nov 1999 00:21:18 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Portable Perl Code
Message-Id: <2U2W3.61993$23.2402589@typ11.nn.bcandid.com>
In article <3828B866.54447E45@ticom-geo.com>,
Steven Glicker <sglicker@ticom-geo.com> wrote:
>I would greatly appreciate knowing how one typically writes portable
>code in Perl in cases where a function (say alarm) exists in Linux but
>not in Windows. In C this is typically handled at compile-time with
>#ifdef's. Is there a convention for handling this (at run-time) in Perl?
eval { alarm(0) }; $bloody_broken_stupid_system = 1 if $@;
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 01:14:25 GMT
From: salvadorej@my-deja.com
Subject: Problem: MySQL, variable scope, references
Message-Id: <80agte$rt7$1@nnrp1.deja.com>
NOTE: the description of this problem takes a bit of wading through,
but I think at its heart it's a problem with my understanding of
variable scope in perl and references. PLEASE don't give up! I've been
banging around with this for two weeks, and can't seem to get anywhere.
OK, I'm working on creating a database of performances I can
search by venue and date. Perl and MySQL are my tools of choice.
I have a subroutine, makeVenueDateQuery, that I want to give
a date and a venue, and have it give me back a list of references
to hashes (naturally, each hash corresponds to a row in a table in
the database).
The problem is, when I pass back the list of references to hashes,
I seem to lose everything.
Here's the routine:
################# Begin Routine #####################
sub makeVenueDateQuery
{
my($date,$venue) = @_;
my $queryStr;
my %queryhash;
my @queryhashes;
my $qh;
############## create the query string,
############## using $date and $venue arguments
$queryStr = "SELECT * FROM calendar WHERE
(Event_Date = \"$date\") and
(Venue = \"$venue\")";
############## make the query, check for errors
$qh = $gDBH->query($queryStr);
if(!defined $qh)
{ die "SQL Error: $Mysql::db_errstr"; }
else
{ print "\n<!--Result: $qh\n-->"; }
############# transfer hashes that correspond to row matches
############# from the SELECT statement into @queryhashes
my $i=0;
while(%queryhash = $qh->FetchHash())
{
$queryhashes[$i]=\%queryhash;
$i++;
}
############# return the whole mess
return @queryhashes;
}
################## End Routine ######################
Now, here's the script I call it from:
#!/usr/local/bin/perl
use Mysql;
($date, $venue) = @ARGV;
####### Open MySQL Database, check for errors
if (!($gDBH = Mysql->Connect("myhost","myuser","mydb","mypasswd")))
{ die "SQL Error: $Mysql::db_errstr";}
####### Call Subroutine (get list of references to hashes that
####### correspond to date and venue)
@hashes = &makeVenueDateQuery($date,$venue);
####### print out all keys and values for each hash
####### referenced in @hashes
foreach $hashRef (@hashes)
{
my %hash = %$hashRef;
print "\n==$hashRef==============";
foreach my $key (keys %hash)
{ print "\n$key: $hash{$key}"; }
}
print "\n==========================\n\n";
exit;
That's it.
Some printf debugging reveals that I can access my data just fine
from within the while loop in the subroutine (makeVenueDateQuery).
However, the foreach loop that's supposed to spit all of the key-value
pairs in each hash referenced in the list, doesn't give me back
anything.
Help.......
================================================================
"The best laid plans of mice and men are about equal"
iowa_s8ong@hot8mail.com
Remove Eight's to reach me by email.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 9 Nov 1999 15:37:37 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: regular expression help
Message-Id: <MPG.1292501c41d1659798a1c8@nntp.hpl.hp.com>
In article <3828A0D7.B4A88543@umr.edu> on Tue, 09 Nov 1999 16:31:51 -
0600, Matt Schuette <schuette@umr.edu> says...
> Ivan Berg wrote:
...
> > How would you grab all text after 6 periods in a string.
> >
> > For example, in the string
> >
> > "blah.23.0993.cs.monkey.s.This.is.what,I.want"
> >
> > I could get "This.is.what,I.want"
>
> my $string = "blah.23.0993.cs.monkey.s.This.is.what.I.want";
> $string =~ /([^.]*\.){6}(.*)/;
> my $end = $2;
> print $end;
>
> This returned "This.is.what.I.want". Tried one or two things to "break"
> it and it seemed to be fine. The -w option and "use strict;" didn't
> complain about anything.
A good try. But it would "break" if the regex failed to match. Before
using the results of a match, you should ensure that the match
succeeded.
Also, 'all text' might include newlines, so the regex should deal with
that via the /s modifier.
Also (a minor point) capturing a result you don't need is wasteful.
my $string = 'blah.23.0993.cs.monkey.s.This.is.what,I.want';
if ($string =~ /(?:[^.]*\.){6}(.*)/s) {
print $1;
} else {
print 'no match';
}
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 Nov 1999 16:50:00 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Rounding numbers to specific decimal places
Message-Id: <3828C138.D7B9EDCC@mail.cor.epa.gov>
kfratzke wrote:
>
> Howdy...
Hi...
> Pretty stupid question...I need a hint on how to round numbers to a
> specific number of decimal places.
It's in the FAQ. If you have Perl, you have the FAQ too.
It comes with the install. If you don't have Perl, grab a
copy. The plerdoc comes with Perl, and it will help you
search the FAQ for keywords. Try this. Type at a command
prompt this line:
perldoc -q round
and you'll get the answer to your question. Nifty, huh?
> I can't find anything specific on this topic...thought I was on track
> when I read about the truncate function, but that only works on file :-(
Hmmm. What were you looking through? The Perl answer to
this question is pretty non-obvious to a non-programmer, so
I was wondering what reference you were accessing...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 9 Nov 1999 18:51:14 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Rounding numbers to specific decimal places
Message-Id: <x3yhfivz0jy.fsf@tigre.matrox.com>
kfratzke <kfratzke@luminet.net> writes:
> Pretty stupid question...I need a hint on how to round numbers to a
> specific number of decimal places.
It's not stupid. It's in the FAQs though. Please check the FAQs before
posting. From perlfaq4:
Does Perl have a round() function?
What about ceil() and floor()? Trig functions?
> I can't find anything specific on this topic...thought I was on track
> when I read about the truncate function, but that only works on file :-(
Type 'perldoc perldoc' to get an idea of how to peruse the faqs and docs.
HTH,
--Ala
------------------------------
Date: Tue, 09 Nov 1999 23:43:34 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Sharp PERLers needed - San Diego company.
Message-Id: <Gk2W3.61909$23.2396363@typ11.nn.bcandid.com>
In article <80a6pb$k51$1@nnrp1.deja.com>, <michaelreed647@my-deja.com> wrote:
>Planet Earth Communications
>
>Title: Hot Webmaster Needed for an Exploding Company.
Dear Michael,
We understand your need for rapid response. We have located the
offices of the company "Planet Earth Communications"; the HE charges
are set. We will detonate them just as soon as we can arrange
payment. We understand payment potential is unlimited; we would like
$2,000,000. We require cash.
Hot Webmaster Demolitions, Inc.
(Just kidding, of course.)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 09 Nov 1999 19:03:46 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Sharp PERLers needed - San Diego company.
Message-Id: <x7ogd3yzz1.fsf@home.sysarch.com>
>>>>> "KS" == Kragen Sitaker <kragen@dnaco.net> writes:
KS> In article <80a6pb$k51$1@nnrp1.deja.com>, <michaelreed647@my-deja.com> wrote:
>> Planet Earth Communications
>>
>> Title: Hot Webmaster Needed for an Exploding Company.
KS> Dear Michael,
KS> We understand your need for rapid response. We have located the
KS> offices of the company "Planet Earth Communications"; the HE charges
KS> are set. We will detonate them just as soon as we can arrange
KS> payment. We understand payment potential is unlimited; we would like
KS> $2,000,000. We require cash.
KS> Hot Webmaster Demolitions, Inc.
<cue mission impossible theme and light that fuse!>
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: Tue, 09 Nov 1999 19:13:46 -0600
From: kfratzke@luminet.net (kfratzke)
Subject: Re: Thanx for help :-)
Message-Id: <kfratzke-0911991913460001@kfratzke.luminet.net>
Eric & Dave,
Thanks for the pointers...I feel pretty "Duh!" right now....I got lost in
the online perl reference section on mathmatics modules and was banging my
head against the wall...99% percent of the perl stuff I do is print
statements, so I really appreciate your taking the time to answer a Q
that's obviously covered in the FAQ...proof the world is still made up of
good folk :-)
I hoist a virtual beer to you both...
Kirk
In article <3828C138.D7B9EDCC@mail.cor.epa.gov>, David Cassell
<cassell@mail.cor.epa.gov> wrote:
> kfratzke wrote:
> >
> > Howdy...
>
> Hi...
>
> > Pretty stupid question...I need a hint on how to round numbers to a
> > specific number of decimal places.
>
> It's in the FAQ. If you have Perl, you have the FAQ too.
> It comes with the install. If you don't have Perl, grab a
> copy. The plerdoc comes with Perl, and it will help you
> search the FAQ for keywords. Try this. Type at a command
> prompt this line:
>
> perldoc -q round
>
> and you'll get the answer to your question. Nifty, huh?
>
> > I can't find anything specific on this topic...thought I was on track
> > when I read about the truncate function, but that only works on file :-(
>
> Hmmm. What were you looking through? The Perl answer to
> this question is pretty non-obvious to a non-programmer, so
> I was wondering what reference you were accessing...
>
> David
------------------------------
Date: Wed, 10 Nov 1999 01:15:03 GMT
From: sneswhiz@my-deja.com
Subject: Variables in Strings and Substituting a Path Name
Message-Id: <80aguk$rtl$1@nnrp1.deja.com>
Can anyone help me with the following program?
I've indicated what the program does, and what I
want it to do.
$a = "f:\\web page stuff";
$b = "f:\\web page stuff\\a\\b.html";
$c = "../";
$b =~ s/$a\\//;
print "$b\n";
# should print a\b.html (plus newline)
# instead prints f:\web page stuff\a\b.html
# (plus newline)
$b =~ s/f:\\web page stuff\\//;
print "$b\n";
# should print (and does so) a\b.html
#(plus newline)
print "$cabc.html\n";
# should print ../abc.html (plus newline)
# instead prints .html (plus newline) since
# $cabc is undefined
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 09 Nov 1999 16:46:18 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: YA Find/Replace newbie question
Message-Id: <3828C05A.FF509AD9@mail.cor.epa.gov>
visigothe wrote:
>
> Hello all;
>
> First things first; I have read quite a lot of the archives and I can't
> quite seem to find the answer to my problem. I also tried news.answers
> for the FAQ, but to no avail.
Hmmm. Well, if you have Perl on your machine or your network,
you have Perl's FAQ. It [and far more documentation and
tutorial material] comes with the install. If that's not an
option, go to www.perl.com and follow the links to the FAQ.
Then you can have your own personal copy.
> I am attempting to write a script that opens an existing html file,
> searches for a specific string "<!--Begin Content Section-->" [also
> referred to internally as "$nukeme"] and replaces that string with a
> template filled with captured form data. Then the file is promptly
> rewritten, ready to be served.
>
> Capturing the form data [and cleaning it] is not a problem. I have set
> them up as variables:
>
> $newsbr [$newsbr is actually the cleaned version of $news]
> $author
> and
> $headline
[snip]
> OK great. now what? Do I make the above one big variable and replace
> $nukeme with $newdata?
That is one option. You could do that with the substitution
operator s/// [read the perlre and perlop pages for more details].
> Really silly Q; but how would I go about putting that huge textblock
> into a variable? just put quotes around it and escape all the funky
> chars?
A here-doc is a much better idea. If you have experience
with shell programming, you know about that already. If not,
read the perldata page which comes with Perl to learn how to
do it.
> Is there a better way to do all of this?
You may find the HTML::Template module to be a help here. All
modules are available at CPAN [www.cpan.org], but win32 Perl
has a bunch of pre-prepared modules at www.activestate.com ,
right where Win32 Perl came from.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
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 1333
**************************************