[19166] in Perl-Users-Digest
Perl-Users Digest, Issue: 1361 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 23 18:05:40 2001
Date: Mon, 23 Jul 2001 15:05:15 -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: <995925915-v10-i1361@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 23 Jul 2001 Volume: 10 Number: 1361
Today's topics:
Re: Appanding to hash_key_value (Nipa)
Re: Apple Quicktime Module <rachel@lspace.org>
Re: converting numeric-string to integer doesn't work f <skilchen@swissonline.ch>
Re: converting numeric-string to integer doesn't work f <pne-news-20010723@newton.digitalspace.net>
create files from a list & use join to add an extension (Casey Chambliss)
Re: create files from a list & use join to add an exten <krahnj@acm.org>
Re: Engineering vs. Hacking (was Re: How to supply modu <godzilla@stomp.stomp.tokyo>
Re: Engineering vs. Hacking (was Re: How to supply modu <newspost@coppit.org>
Re: Escaped period! Someone apprehend it! <ReplyToTheGroup@DoNotEmailMe.Com>
Re: Escaped period! Someone apprehend it! <ReplyToTheGroup@DoNotEmailMe.Com>
Re: Escaped period! Someone apprehend it! <ReplyToTheGroup@DoNotEmailMe.Com>
Re: Escaped period! Someone apprehend it! (remove the obvious)
FAQ: How do I multiply matrices? <faq@denver.pm.org>
Re: How can I determine how many charcters to represnt <jeff@vpservices.com>
How can I determine how many charcters to represnt a gi (Stan Brown)
Re: How can I determine how many charcters to represnt (Logan Shaw)
Re: How do I count the number of characters in a string <djberge@uswest.com>
Re: Including a perl file into another perl file??? <no_spam.yet_another_apprentice@hotmail.com>
Re: Including a perl file into another perl file??? (Joe Smith)
ksh script porting problem <blevin@lucent.com>
newbie: storing multiple objects in a hash <r.deenen@chello.nl>
Re: newbie: storing multiple objects in a hash <krahnj@acm.org>
Re: newbie: storing multiple objects in a hash (Joe Smith)
Open files <kirbyr@ucar.edu>
Re: PASCAL > PERL (Gary E. Ansok)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Jul 2001 14:04:36 -0700
From: npatel@webley.com (Nipa)
Subject: Re: Appanding to hash_key_value
Message-Id: <24d1a4c3.0107231304.45e71893@posting.google.com>
Michael Budash <mbudash@sonic.net> wrote in message news:<mbudash-62E887.09212023072001@news.sonic.net>...
> In article <24d1a4c3.0107230748.6c45fc02@posting.google.com>,
> npatel@webley.com (Nipa) wrote:
>
> > Here is more elaborate explainations:
> > while($line = <LOG>)
> > {
> > ($key, $value) = split(/:/, $line ,2);
> > $formdata{$key} = $value;
I know this line above shouldn't be there. !!(I must have not been
thinking !!)
> > if(exists $formdata{$key}) { $formdata{$key} .= $value; }
> > else { $formdata{$key} = $value; }
> > }
> >
> you're re-setting the value, THEN checking if it exists (which of course
> it will - you just set it!), then appending it! try this:
>
> while ($line = <LOG>) {
> ($key, $value) = split (/:/, $line, 2);
I have already tried the code below. unfortunately it doesn't work :(
It still overwirtes the original value.
> if (exists $formdata{$key}) {
> $formdata{$key} .= $value;
> }
> else {
> $formdata{$key} = $value;
> }
> }
I think there is some problem with '\n' , carrige return. The file I
am reading from has \n at the end of each line. So when i use
'chomp($line)' it overwrites the origianl value. It does a very
strange action.
here is an example of my code:
assume that all the variables are declared using 'my'.
while($line = <LOG>)
{
chomp($line);
($key, $value) = split(/:/,$line, 2);
if(exists $form{$key}) { $form{$key} .= $value; }
else { $form{$key} = $value ; }
}
Here is the STRANGE action. the 'chomp($line)' in the first line over
writes.
HOWEVER, if I do this instead, it works:
while($line = <LOG>)
{
($key, $value) = split(/:/,$line, 2);
if(exists $form{$key})
{
$form{$key} .= $value;
chomp($form{$key});
}
else { $form{$key} = $value ; }
}
If I print the hash,(if above code is used to store values) , correct
value prints. However values are printed in double spaced manner.
something like this:
key : value
key: value
key: value
.....
I know it does this because when i print i have put \n at the end of
the print statement. BUT if i don't have the \n at the end it once
prints the last key and value of the hash and ON TOP OF THAT it prints
on the commadline.
this is what i mean:
-=> key: value (# it shouldn't do that)
SO i really don't know what improtance does \n have in perl. I don't
the reason for this strange behavior either.
Please provide some insight, ( I have been working on this little
issue which apperently hasn't been a little issue, and now I brain is
stumped.)
Thanks everyone for your replies. I appreciate it.
Nipa
------------------------------
Date: Mon, 23 Jul 2001 20:00:18 +0100
From: Rachel Coleman <rachel@lspace.org>
Subject: Re: Apple Quicktime Module
Message-Id: <6rsolt8mchpai6kisjpre299midg9g6fsr@4ax.com>
On Sat, 21 Jul 2001 17:03:25 -0500, "Jason Jenkins"
<foo@northwestern.edu> wrote:
>I am just curious if there is a quicktime module, and if possible where this
>could be obtained?
2 min work at CPAN (http://search.cpan.org) finds no matches for
"quick time", "quicktime" or "QuickTime" on either 'Module' or
'Documentation'.
So I'd guess the answer is 'No'.
Best wishes,
Rachel
------------------------------
Date: Mon, 23 Jul 2001 21:03:23 +0200
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: converting numeric-string to integer doesn't work for me... help!
Message-Id: <9jhsol$ns83v$1@ID-13368.news.dfncis.de>
"Beng" <benghua@NOSPAM.cyberworks.net.sg> wrote in news:3b5bc55a@news...
>
> I am trying to write a perl script to crunch a series of BIG numbers from
> an array, and then perform arithmetic operations on them. Those BIG
> numbers are actually numeric-strings, and I need to convert these strings
> to integers first before I do the summing operation.
>
1. As others already pointed out: the output example you have provided is
highly unplausible.
2. If your numbers (and results) are guaranteed to be smaller than 2**53
then you should not have problems doing integer arithmetic on them (Perl
will store numbers between 2**32 and 2**53 as "floating-point integers"
and there is enough precision to exactly represent a difference of 1
between two such numbers).
3. Use the Math::BigInt module if you have to do integer arithmetics on
numbers bigger than 2**53.
------------------------------
Date: Mon, 23 Jul 2001 21:16:04 +0200
From: Philip Newton <pne-news-20010723@newton.digitalspace.net>
Subject: Re: converting numeric-string to integer doesn't work for me... help!
Message-Id: <u8toltsmc5bresdgbfd39vi7aln03k531r@4ax.com>
On 23 Jul 2001 09:02:11 -0700, garry_short@hotmail.com (Garry) wrote:
> the for, which I was convinced should be a foreach until I tried it
From `perldoc perlsyn`:
: The `foreach' keyword is actually a synonym for the `for'
: keyword, so you can use `foreach' for readability or `for' for
: brevity. (Or because the Bourne shell is more familiar to you
: than *csh*, so writing `for' comes more naturally.)
If you are a very sick puppy, you could even write loops like
foreach($i = 0; $i < @array; $i++) { ... }
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 23 Jul 2001 12:46:24 -0700
From: cchambli@lycos.com (Casey Chambliss)
Subject: create files from a list & use join to add an extension
Message-Id: <a15e3f18.0107231146.2a3b1949@posting.google.com>
I have a list of projects called @MasterProjectList
I have a list of URLs that are downloads for my project list
(@DownloadURL)
the problem I am running into is this:
When I use getstore like this:
getstore($DownloadURL[1], $ExcelFile);
it dosen't name the downloaded file correctly.
I want $ExcelFile to be the text that is in $MasterProjectList[1] and
end with ".xls"
I've used the chomp on the @MasterProjectList and my join still won't
work. Here is what I have:
chomp(@MasterProjectList);
$ExcelFile = join($MasterProjectList[1], ".xls");
getstore($DownloadURL[1], $ExcelFile);
The resulting file name is only ".xls" ... what do I do?
------------------------------
Date: Mon, 23 Jul 2001 20:22:38 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: create files from a list & use join to add an extension
Message-Id: <3B5C878F.B9B6985@acm.org>
Casey Chambliss wrote:
>
> I have a list of projects called @MasterProjectList
> I have a list of URLs that are downloads for my project list
> (@DownloadURL)
>
> the problem I am running into is this:
>
> When I use getstore like this:
>
> getstore($DownloadURL[1], $ExcelFile);
>
> it dosen't name the downloaded file correctly.
>
> I want $ExcelFile to be the text that is in $MasterProjectList[1] and
> end with ".xls"
getstore( $DownloadURL[1], "$ExcelFile.xls" );
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 23 Jul 2001 12:12:01 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Engineering vs. Hacking (was Re: How to supply modules with your software.)
Message-Id: <3B5C7701.5AB900F7@stomp.stomp.tokyo>
David Coppit wrote:
> Godzilla! wrote:
> > David Coppit wrote:
(snipped)
> <sigh> Not everyone is here to burn you at the stake. Let me reiterate
> that I'm trying to change your mind, not tell you how to think. And I'm
> providing an alternative view to your "just code up every module you
> need" view.
You are practicing deceit as usual. You clearly stated,
"...do not advocate this position."
Shove it.
Godzilla!
------------------------------
Date: Mon, 23 Jul 2001 14:47:45 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Engineering vs. Hacking (was Re: How to supply modules with your software.)
Message-Id: <3B5C7151.4000907@coppit.org>
Godzilla! wrote:
> David Coppit wrote:
>
>>This is a well known figure among software engineers, sorta like the
>>80/20 rule. It was first quantified by Belady and Lehman
>>("Characteristics of Large Systems", Belady & Lehman 1977) studying the
>>development of OS 360. Of course, it really depends on the application
>>and how you count, but most later studies have averaged less than 100
>>LOC/day (particularly studies of NASA software). This number goes up
>>when you do OO because of the bloat. :)
>
> Your reference is incorrect.
>
> "IBM Systems Journal 15, 3, 1976, pp 225-252"
I'm quoting the book that followed the journal article.
> You cite, as support, an abstract based upon maintenance of legacy
> binary executable operating system code, you cite this as support
> of Bohlman's wild-eyed claim a programmer writing natural language
> code, Perl for this topic, can only produce ten lines of code per
> day as an average?
Well, this is a bit of a Red Herring, but an interesting one...
If you mean to imply that language makes a difference, experiments in
developing "productive" languages Ada, Algol, COBOL, and PL/1 (horrors)
have largely failed (where success is defined as "an order of magnitude
improvement). See Fred Brooks' "No Silver Bullet". Here's a good summary
paper on research to date:
http://cwis.usc.edu/dept/ATRIUM/Papers/Software_Productivity.html
Of course, it's probably not fruitful to argue this point too much,
since there is a lot of debate on what good metrics are in the first
place. If you want to argue that Perl is X% more productive than C++,
I'd likely agree with you even though no one knows what the right way to
measure X is.
But to bring this back to the topic of using modules, I'd bet I'm more
productive by using LWP than you are without it:
perl -MLWP::Simple '-e getprint "ftp://ftp.gnu.org"'
Like I said, I don't believe you can back up your claim that it's better
to write your own solutions rather than use preexisting modules. If you
want to debate someone else's point about productivity, fine. I need to
find more productive ways to spend my time than summarizing 30 years of
research.
> This reference you cite is nearly thirty years
> old, pertains to legacy maintenance, is not supported by any controlled
> statistical survey, discusses aspects of binary executable programming
> and is written for IBM specific programming.
Like I said, that was one of the first studies. See ref above for
follow-on studies.
> You apply this to Perl, a natural programming language?
What's a "natural programming language"?
> Do you bag your mule manure and bring it with you to this newsgroup
> or produce your mule manure as you make up this idiocy?
My mule manure is backed up by the likes of Barry Boehm and Vic Basili. :)
> As you can readily surmise, I will express any opinion I deem fit
> and appropriate despite your dictates as a yet another self-proclaimed
> Perl Perl Land deity. I don't cotton much to those here like you whom
> believe you have both a right and duty to dictate and moderate what
> opinions may or may not be presented within this newsgroup.
<sigh> Not everyone is here to burn you at the stake. Let me reiterate
that I'm trying to change your mind, not tell you how to think. And I'm
providing an alternative view to your "just code up every module you
need" view.
David
------------------------------
Date: Mon, 23 Jul 2001 18:10:49 GMT
From: "Jay" <ReplyToTheGroup@DoNotEmailMe.Com>
Subject: Re: Escaped period! Someone apprehend it!
Message-Id: <JMZ67.3974$LP2.418733@bgtnsc06-news.ops.worldnet.att.net>
Steve Holland <holland@origo.ifa.au.dk> wrote in message
news:w47puar5y9j.fsf@origo.ifa.au.dk...
| "Jay" <ReplyToTheGroup@DoNotEmailMe.Com> writes:
|
| > Sorry for the pun in the subject. I had the following in a program.
|
| Don't be. Puns are the highest form of humour.
|
|
| > if(/\d+\.?\d+/) {
| > print "OK!";
| > }
|
| > Now what I wanted was it to accept numbers which can be either whole
| > numbers or decimal numbers(hence the period). This doesn't work,
| > though. It accepts numbers alright, and anything else too. If I
| > put it as /\d+\.\d+/ it works fine, but then the decimal is
| > required(not what I wanted). Shouldn't adding the ? make it so it
| > accepts one or more numbers zero or one decimal and one or more
| > numbers? Obviously not, otherwise I wouldn't be here. I appreciate
| > any help.
|
| print "OK!" if ( /\d+\.*\d+/ );
| print "OK!" if ( \/d*\.*\d*/ ); # if you want to accept .39 or 89. as
valid.
I tried that, but it seems to accept anything also. I tried
12fd32
43.....12
etc.
All return TRUE, which aren't right. I can't figure it out for nothing.
Jay,
------------------------------
Date: Mon, 23 Jul 2001 18:15:45 GMT
From: "Jay" <ReplyToTheGroup@DoNotEmailMe.Com>
Subject: Re: Escaped period! Someone apprehend it!
Message-Id: <lRZ67.3980$LP2.419459@bgtnsc06-news.ops.worldnet.att.net>
Eric Bohlman <ebohlman@omsdev.com> wrote in message
news:9jhotu$rt8$1@bob.news.rcn.net...
| Jay <ReplyToTheGroup@donotemailme.com> wrote:
| > Sorry for the pun in the subject. I had the following in a program.
|
| > if(/\d+\.?\d+/) {
| > print "OK!";
| > }
|
| > Now what I wanted was it to accept numbers which can be either whole
numbers
| > or decimal numbers(hence the period). This doesn't work, though. It
| > accepts numbers alright, and anything else too. If I put it as
/\d+\.\d+/
|
| That's because you haven't anchored the pattern at both ends, so it will
| match if there's a number anywhere in the string. Also, it won't match
| single-digit numbers as written; you need to make the part after the
| decimal point optional as well. Try /^\d+(?:\.\d+)$/.
Yep, that did it. I was looking at wrong. The more I looked at it, the
worse it got. Thanks a lot!
Jay,
------------------------------
Date: Mon, 23 Jul 2001 18:16:55 GMT
From: "Jay" <ReplyToTheGroup@DoNotEmailMe.Com>
Subject: Re: Escaped period! Someone apprehend it!
Message-Id: <rSZ67.3981$LP2.419716@bgtnsc06-news.ops.worldnet.att.net>
Jay <ReplyToTheGroup@DoNotEmailMe.Com> wrote in message
news:JMZ67.3974$LP2.418733@bgtnsc06-news.ops.worldnet.att.net...
| Steve Holland <holland@origo.ifa.au.dk> wrote in message
| news:w47puar5y9j.fsf@origo.ifa.au.dk...
| | "Jay" <ReplyToTheGroup@DoNotEmailMe.Com> writes:
| |
| | > Sorry for the pun in the subject. I had the following in a
program.
| |
| | Don't be. Puns are the highest form of humour.
| |
| |
| | > if(/\d+\.?\d+/) {
| | > print "OK!";
| | > }
| |
| | > Now what I wanted was it to accept numbers which can be either whole
| | > numbers or decimal numbers(hence the period). This doesn't work,
| | > though. It accepts numbers alright, and anything else too. If I
| | > put it as /\d+\.\d+/ it works fine, but then the decimal is
| | > required(not what I wanted). Shouldn't adding the ? make it so it
| | > accepts one or more numbers zero or one decimal and one or more
| | > numbers? Obviously not, otherwise I wouldn't be here. I appreciate
| | > any help.
| |
| | print "OK!" if ( /\d+\.*\d+/ );
| | print "OK!" if ( \/d*\.*\d*/ ); # if you want to accept .39 or 89. as
| valid.
|
| I tried that, but it seems to accept anything also. I tried
|
| 12fd32
| 43.....12
| etc.
|
| All return TRUE, which aren't right. I can't figure it out for nothing.
I spoke too soon. Eric Bohlman gave me the fix.
Jay,
------------------------------
Date: Mon, 23 Jul 2001 20:05:30 GMT
From: "--Rick" <no_trick@my-de(remove the obvious)ja.com>
Subject: Re: Escaped period! Someone apprehend it!
Message-Id: <es%67.4058$LP2.427956@bgtnsc06-news.ops.worldnet.att.net>
"Eric Bohlman" <ebohlman@omsdev.com> wrote in message
news:9jhotu$rt8$1@bob.news.rcn.net...
| Jay <ReplyToTheGroup@donotemailme.com> wrote:
| > Sorry for the pun in the subject. I had the following in a
program.
|
| > if(/\d+\.?\d+/) {
| > print "OK!";
| > }
|
| > Now what I wanted was it to accept numbers which can be either whole
numbers
| > or decimal numbers(hence the period). This doesn't work, though.
It
| > accepts numbers alright, and anything else too. If I put it as
/\d+\.\d+/
|
| That's because you haven't anchored the pattern at both ends, so it
will
| match if there's a number anywhere in the string. Also, it won't
match
| single-digit numbers as written; you need to make the part after the
| decimal point optional as well. Try /^\d+(?:\.\d+)$/.
|
Please bear with me as I'm still new to perl. This solution didn't work
at all for me. If it does work, then I would love to learn how. I
suspect that there is a question-mark missing just ahead of the tail
anchor that is needed to make the decimal portion optional. When I
tested it, only whole numbers would pass. To get decimals I think it
should look like this: /^\d+(?:\.\d+)?$/.
That was better, but I made the mistake of including a number like .04
in my test cases. I'm sure there is a pretty way, and I still haven't
gotten all the cases, but to accept the bare decimal, I came up with
this kludged expression: /^\.\d+$|^\d+(?:\.\d+)?$/
--
--Rick
------------------------------
Date: Mon, 23 Jul 2001 18:16:55 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I multiply matrices?
Message-Id: <rSZ67.56$T3.170737152@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.
+
How do I multiply matrices?
Use the Math::Matrix or Math::MatrixReal modules (available from CPAN)
or the PDL extension (also available from CPAN).
-
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.
04.06
--
This space intentionally left blank
------------------------------
Date: Mon, 23 Jul 2001 13:38:57 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: How can I determine how many charcters to represnt a given int value?
Message-Id: <3B5C8B61.42CFF2BB@vpservices.com>
Stan Brown wrote:
>
> I'm doing something (wrong perhaps) with PerlTK that requires that I tell
> the widget how much space to reserve for a given number (integer).
>
> How can I do this in perl? In C I would kust printf it into a temporary
> char array, anddo len() on it.
>
> What's a better perl way of doing it?
print length 1234567;
--
Jeff
------------------------------
Date: 23 Jul 2001 16:39:25 -0400
From: stanb@panix.com (Stan Brown)
Subject: How can I determine how many charcters to represnt a given int value?
Message-Id: <9ji21t$gh9$1@panix6.panix.com>
I'm doing something (wrong perhaps) with PerlTK that requires that I tell
the widget how much space to reserve for a given number (integer).
How can I do this in perl? In C I would kust printf it into a temporary
char array, anddo len() on it.
What's a better perl way of doing it?
------------------------------
Date: 23 Jul 2001 15:51:16 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How can I determine how many charcters to represnt a given int value?
Message-Id: <9ji2o4$q38$1@charity.cs.utexas.edu>
In article <9ji21t$gh9$1@panix6.panix.com>, Stan Brown <stanb@panix.com> wrote:
>I'm doing something (wrong perhaps) with PerlTK that requires that I tell
>the widget how much space to reserve for a given number (integer).
>
>How can I do this in perl? In C I would kust printf it into a temporary
>char array, anddo len() on it.
You mean strlen()?
Anyway, something like this:
$widget_string = sprintf ("%d", $given_number);
$widget_length = length $widget_string;
$widget->some_function_that_sets_width ($widget_length);
$widget->some_function_that_sets_contents ($widget_string);
Hope that helps.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: Mon, 23 Jul 2001 15:04:22 -0500
From: "Mr. Sunray" <djberge@uswest.com>
Subject: Re: How do I count the number of characters in a string
Message-Id: <3B5C8346.3E540B72@uswest.com>
carlos wrote:
> RTFM!
> "J.D. Fieldsend" <u9jdf@csc.liv.ac.uk> wrote in message
> news:3B5C0795.A79D7050@csc.liv.ac.uk...
> > Hi
> >
> > I want to be able to tabulate text without knowing beforehand how many
> > characters are in each string.
> >
> > Thanks
> >
> > John
Try "length($string)".
John, while I don't agree with "STFM" screams, this is such a basic problem
that I'm surprised you found clpm before you found the answer to your
question. Either that, or we've misunderstood the question.
Dan
------------------------------
Date: Mon, 23 Jul 2001 21:15:23 +0200
From: "Bob Rock" <no_spam.yet_another_apprentice@hotmail.com>
Subject: Re: Including a perl file into another perl file???
Message-Id: <9jhtfh$nrgus$1@ID-98646.news.dfncis.de>
> However, an appropriate idiom in one language may not be
> appropriate in another. If you explain what the
> underlying problem is that you're trying to solve, maybe
> someone can suggest the best (or seeing this is perl, "a
> best") solution...
>
> hth
> t
> --
Hello all and thank for the numerous answers,
what I'd like to do is like have the code necessary to generate a header or
a footer placed in one file and then include that one file in all the file
that need that header/footer. Which of the statements suggested would do?
Thx.
Regards,
Bob Rock
------------------------------
Date: Mon, 23 Jul 2001 21:47:00 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: Including a perl file into another perl file???
Message-Id: <9ji60k$2jd0$1@nntp1.ba.best.com>
In article <9jhtfh$nrgus$1@ID-98646.news.dfncis.de>,
Bob Rock <no_spam.yet_another_apprentice@hotmail.com> wrote:
>what I'd like to do is like have the code necessary to generate a header or
>a footer placed in one file and then include that one file in all the file
>that need that header/footer. Which of the statements suggested would do?
require "header+footer.pl"; # Defines $HEADER and $FOOTER;
$middle_stuff = "A bunch of text\n";
print $HEADER, $middle_stuff, $FOOTER;
or
require "header+footer.pl"; # Defines Header() and Footer();
$_ = time;
print Header($_), calculate_stuff($_), Footer($_);
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Mon, 23 Jul 2001 17:16:45 -0400
From: John Blevin <blevin@lucent.com>
Subject: ksh script porting problem
Message-Id: <3B5C943D.40191A07@lucent.com>
This is a multi-part message in MIME format.
--------------B771107B69E854BF523DD80C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I have a UNIX ksh script that I would like to port to perl.
The ksh script has a few lines like:
. env_file_1
. env_file_2
It is "dotting in" these environment configuration files which define
environment variables used in this script.
I would like to port over this script without yet having to change these
environment files. Is there a way I can port over these lines? The system(),
exec() and backtick don't work.
Thanks!
- John
--------------B771107B69E854BF523DD80C
Content-Type: text/x-vcard; charset=us-ascii;
name="blevin.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for John Blevin
Content-Disposition: attachment;
filename="blevin.vcf"
begin:vcard
n:Blevin;John
tel;pager:800-759-8888 #4127274
tel;fax:973-386-2182
tel;work:973-386-2748
x-mozilla-html:FALSE
org:AnyMedia Access System
adr:;;;Whippany 2C-228A;;;
version:2.1
email;internet:blevin@lucent.com
fn:John Blevin
end:vcard
--------------B771107B69E854BF523DD80C--
------------------------------
Date: Mon, 23 Jul 2001 21:31:33 GMT
From: "Rolf Deenen" <r.deenen@chello.nl>
Subject: newbie: storing multiple objects in a hash
Message-Id: <VI077.429460$6b.16636998@Flipper>
Hi,
'm just starting to getting to learn perl and i have a small question about
storing data in a hash.
You can store object-pairs in a hash like in this example:
%users (name, John Doe, email, jdoe@hotmail.com, telephone, 01234-567890)
In this fasion it is possible to recall variables by there "type", like name
or telephone-number...
$johndoe_telephone=%users[telephone];
But what happens when I want to put in more than one users in a hash and how
can i recall them?
Like:
user1: John Doe, jdoe@hotmail.com, 01234-567890
user2: Bert Smith, bsmith@netscape.com, 56789-012345
I'm having trouble visualising this...
Thanks in advance,
Rolf Deenen
------------------------------
Date: Mon, 23 Jul 2001 22:01:40 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: newbie: storing multiple objects in a hash
Message-Id: <3B5C9F1A.F4BC97D6@acm.org>
Rolf Deenen wrote:
>
> 'm just starting to getting to learn perl and i have a small question about
> storing data in a hash.
> You can store object-pairs in a hash like in this example:
>
> %users (name, John Doe, email, jdoe@hotmail.com, telephone, 01234-567890)
>
> In this fasion it is possible to recall variables by there "type", like name
> or telephone-number...
> $johndoe_telephone=%users[telephone];
>
> But what happens when I want to put in more than one users in a hash and how
> can i recall them?
>
> Like:
> user1: John Doe, jdoe@hotmail.com, 01234-567890
> user2: Bert Smith, bsmith@netscape.com, 56789-012345
>
> I'm having trouble visualising this...
Here's one way to do it:
my %users = (
'John Doe' => { 'email' => 'jdoe@hotmail.com',
'phone' => '01234-567890' },
'Bert Smith' => { 'email' => 'bsmith@netscape.com',
'phone' => '56789-012345' }
);
for $user ( keys %users ) {
print "User: $user E-mail: $users{$user}{'email'}\n";
}
my $newuser = 'Fred Bloggs';
$users{$newuser}{'email'} = 'fbloggs@nowhere.net';
$users{$newuser}{'phone'} = '34567-876543';
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 23 Jul 2001 22:04:38 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: newbie: storing multiple objects in a hash
Message-Id: <9ji71m$2jpm$1@nntp1.ba.best.com>
In article <VI077.429460$6b.16636998@Flipper>,
Rolf Deenen <r.deenen@chello.nl> wrote:
>
>Hi,
>
>'m just starting to getting to learn perl and i have a small question about
>storing data in a hash.
>You can store object-pairs in a hash like in this example:
>
>%users (name, John Doe, email, jdoe@hotmail.com, telephone, 01234-567890)
>
>In this fasion it is possible to recall variables by there "type", like name
>or telephone-number...
>$johndoe_telephone=%users[telephone];
>
>But what happens when I want to put in more than one users in a hash and how
>can i recall them?
>
>Like:
>user1: John Doe, jdoe@hotmail.com, 01234-567890
>user2: Bert Smith, bsmith@netscape.com, 56789-012345
>
>I'm having trouble visualising this...
Use a hash of hashes.
$key = "user001";
$name="John Doe";
$email='jdoe@hotmail.com';
$phone="01234-567890";
$users{$key} = { name => $name, email => $email, phone => $phone };
is the same as
$users{"user001"}{"name"} = "John Doe";
$users{"user001"}{"email"} = 'jdoe@hotmail.com';
$users{"user001"}{"phone"} = "01234-567890";
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Mon, 23 Jul 2001 14:42:23 -0600
From: Rob Kirby <kirbyr@ucar.edu>
Subject: Open files
Message-Id: <3B5C8C2F.70F88EA7@ucar.edu>
I would like to use the Find.pm to traverse a filesystem to create
a list of files that reside in that filesystem and record various
info about each file with the stat.pm module. Is there a module
to obtain a list of open files for a given filesystem?
--
Rob Kirby - [mailto:kirbyr@ucar.edu][http://www.ncar.ucar.edu]
--
"Simplify, simplify." Thoreau
------------------------------
Date: 23 Jul 2001 21:21:29 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: PASCAL > PERL
Message-Id: <9ji4gp$r2o@gap.cco.caltech.edu>
In article <9jd4oo$let$6@bob.news.rcn.net>,
Eric Bohlman <ebohlman@omsdev.com> wrote:
>Ciric Vukasin <cvule@eunet.yu> wrote:
>> How to convert this code into PERL ?
>
>> b:=(((pom XOR 197) XOR 247 ) XOR 231);
>
>In Perl, assignment is '=', exclusive or is '^' and scalar (simple number
>or string) variables start with '$'. So you want:
>
>$b = ((($pom^197)^247)^231);
>
>> b:=b+2*i+7;
>
>You should be able to convert this yourself now, but read up on the "+="
>operator in the perlop manpage to see a more Perlish way of doing such
>assignments.
>
>> pom:=b mod 10;
>
>In Perl, the modulus operator is '%'.
>
>> Res:=Res+Chr(Ord('0')+pom)
>
>In perl, the chr() and ord() functions are written in all lower case (case
>is significant in Perl identifiers) but otherwise work as they do in
>Pascal.
Actually, in Perl one could probably just do
$res .= $pom
for that last line, since Perl is pretty flexible about automatically
converting numbers to strings. (Assuming all the numbers are integers.)
The four lines together could be significantly simplified, even in Pascal.
$res .= $pom = (($pom ^ 213) + 2 * $i + 7) % 10;
is one way to do it in Perl (assuming $pom is needed later and $b isn't --
and assuming that the four lines go together, of course).
Gary Ansok
--
Practice random acts of intelligence and senseless acts of self-control.
------------------------------
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 1361
***************************************