[16492] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3904 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 3 18:10:41 2000

Date: Thu, 3 Aug 2000 15:10:28 -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: <965340628-v9-i3904@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 3 Aug 2000     Volume: 9 Number: 3904

Today's topics:
        combining hashes <ab@cd.com>
    Re: combining hashes <tina@streetmail.com>
    Re: combining hashes (Greg Bacon)
    Re: combining hashes <lr@hpl.hp.com>
    Re: combining hashes <mjcarman@home.com>
    Re: combining hashes <stephen.kloder@gtri.gatech.edu>
    Re: combining hashes <uri@sysarch.com>
    Re: combining hashes <ab@cd.com>
    Re: combining hashes <uri@sysarch.com>
    Re: combining hashes <aqumsieh@hyperchip.com>
    Re: combining hashes <uri@sysarch.com>
    Re: combining hashes <aqumsieh@hyperchip.com>
    Re: combining hashes (Greg Bacon)
    Re: combining hashes (Abigail)
    Re: combining hashes (Abigail)
    Re: combining hashes (Tim)
    Re: combining hashes (Tim)
    Re: connecting to oracle <gellyfish@gellyfish.com>
    Re: date manipulation <lr@hpl.hp.com>
    Re: date manipulation <jeff@yoak.com>
    Re: Excessive memory use under OSF1 (was: numeric stora <cawlfiel@uiuc.edu>
    Re: File IO <robert99@maine.rr.nodamnspam.com>
    Re: File IO <flavell@mail.cern.ch>
    Re: File IO <juex@deja.com>
    Re: FormMail.pl problems (Red Jackson)
        How do I parse "file0001" into 2 parts? (P&C)
    Re: How do I run CGIs on my desktop? <zentara@gypsyfarm.com>
    Re: How do I run CGIs on my desktop? <bean@agentkhaki.com>
        How to GREP ascii files only (n\)
    Re: How to GREP ascii files only (Greg Bacon)
    Re: How to GREP ascii files only (Brandon Metcalf)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 03 Aug 2000 18:17:10 GMT
From: "Blair Heuer" <ab@cd.com>
Subject: combining hashes
Message-Id: <GGii5.6510$0W4.212498@newsread2.prod.itd.earthlink.net>

Is there a simple way to combine two hashes?
Take this simple code for instance:

        my %hash = ( one => 'value_one' );
        my %add = ( two => 'value_two' );

How would I go about putting all the values of %add into %hash without
losing the values of %hash?
Here are some ways I had tried:
        %hash = %add;    Just replaces %hash with %add;
        %hash .= %add;   Is an illegal operation.
The way I have found to do this is:
        foreach (keys(%add)) { $hash{$_} = $add{$_}; }
I just want to check if that is the best way to do it, since I would think
there would be some built-in way to do this like arrays have push.

Thanks for any feedback,
Blair





------------------------------

Date: 3 Aug 2000 18:27:23 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: combining hashes
Message-Id: <8mcdi7$5sfa9$1@ID-24002.news.cis.dfn.de>

hi,
Blair Heuer <ab@cd.com> wrote:
> Is there a simple way to combine two hashes?
> Take this simple code for instance:

>         my %hash = ( one => 'value_one' );
>         my %add = ( two => 'value_two' );

> How would I go about putting all the values of %add into %hash without
> losing the values of %hash?

%hash = (%hash,%add);


tina



-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.


------------------------------

Date: Thu, 03 Aug 2000 18:34:34 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: combining hashes
Message-Id: <sojepqghdbm87@corp.supernews.com>

In article <GGii5.6510$0W4.212498@newsread2.prod.itd.earthlink.net>,
    Blair Heuer <ab@cd.com> wrote:

: Is there a simple way to combine two hashes?
: Take this simple code for instance:
: 
:         my %hash = ( one => 'value_one' );
:         my %add = ( two => 'value_two' );
: 
: How would I go about putting all the values of %add into %hash without
: losing the values of %hash?

Some people made noises about wanting to use C<push HASH, LIST>, e.g.,
C<push %hash, %add>, to do what you want, but it didn't happen.  You
could use

     $hash{$_} = $add{$_} for keys %add;

which is similar to what you wrote but with less clutter.  Note that
this will clobber values in %hash whose keys exist in %add.

Greg
-- 
Words are the most powerful drug used by mankind. 
    -- Rudyard Kipling


------------------------------

Date: Thu, 3 Aug 2000 11:49:12 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: combining hashes
Message-Id: <MPG.13f35e819e186ee598ac33@nntp.hpl.hp.com>

In article <8mcdi7$5sfa9$1@ID-24002.news.cis.dfn.de> on 3 Aug 2000 
18:27:23 GMT, Tina Mueller <tina@streetmail.com> says...
> Blair Heuer <ab@cd.com> wrote:
> > Is there a simple way to combine two hashes?
> > Take this simple code for instance:
> 
> >         my %hash = ( one => 'value_one' );
> >         my %add = ( two => 'value_two' );
> 
> > How would I go about putting all the values of %add into %hash without
> > losing the values of %hash?
> 
> %hash = (%hash,%add);

Too much copying.  Use the wonderful 'hash slice':

  @hash{keys %add} = values %add;

A note to the original poster:  Values in the first hash that have the 
same keys as values in the second hash will be overwritten, no matter 
what method is used.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Thu, 03 Aug 2000 13:39:52 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: combining hashes
Message-Id: <3989BC78.17CF4F1A@home.com>

Blair Heuer wrote:
> 
> Is there a simple way to combine two hashes?
>
> [...] I  would think there would be some built-in way to do this 
> like arrays have push.

No need for builtins:

%hash = (%hash, %add);

Note, however, that if any of the keys in %add match a key from %hash,
they will overwrite them. If that's an issue for you, you'll need to add
them inside a loop so that you can test for prior existance.

-mjc


------------------------------

Date: Thu, 03 Aug 2000 15:55:56 -0400
From: Stephen Kloder <stephen.kloder@gtri.gatech.edu>
Subject: Re: combining hashes
Message-Id: <3989CE4C.E9F31FF4@gtri.gatech.edu>

Larry Rosler wrote:

> > > How would I go about putting all the values of %add into %hash without
> > > losing the values of %hash?
> >
> > %hash = (%hash,%add);
>
> Too much copying.  Use the wonderful 'hash slice':
>
>   @hash{keys %add} = values %add;
>
> A note to the original poster:  Values in the first hash that have the
> same keys as values in the second hash will be overwritten, no matter
> what method is used.
>

Not if you use:
$hash{$_} = $hash{$_} || $add{$_} foreach(keys %add);




------------------------------

Date: Thu, 03 Aug 2000 20:00:34 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: combining hashes
Message-Id: <x7itti2jz1.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> In article <8mcdi7$5sfa9$1@ID-24002.news.cis.dfn.de> on 3 Aug 2000 
  LR> 18:27:23 GMT, Tina Mueller <tina@streetmail.com> says...
  >> Blair Heuer <ab@cd.com> wrote:
  >> > Is there a simple way to combine two hashes?
  >> > Take this simple code for instance:
  >> 
  >> >         my %hash = ( one => 'value_one' );
  >> >         my %add = ( two => 'value_two' );
  >> 
  >> > How would I go about putting all the values of %add into %hash without
  >> > losing the values of %hash?
  >> 
  >> %hash = (%hash,%add);

  LR> Too much copying.  Use the wonderful 'hash slice':

  LR>   @hash{keys %add} = values %add;

  LR> A note to the original poster:  Values in the first hash that have the 
  LR> same keys as values in the second hash will be overwritten, no matter 
  LR> what method is used.

not necessarily true.

a minor variant on the previously quoted method:

	%hash = ( %add, %hash ) ;	# %hash has priority
	%hash = ( %hash, %add ) ;	# %add has priority

and for an ugly exercise in slicing:

	@hash{ grep !exists $hash{$_}, keys %add } =
				@add{ grep !exists $hash{$_}, keys %add } ;


too bad you can't do the grep on keys and just get the values. hmm, a
perl6 idea?

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: Thu, 03 Aug 2000 20:10:02 GMT
From: "Blair Heuer" <ab@cd.com>
Subject: Re: combining hashes
Message-Id: <ukki5.6783$0W4.218469@newsread2.prod.itd.earthlink.net>

> %hash = (%hash,%add);

This method is perfect for what I need. The second hash to be added to the
first comes from a subroutine, so using this I could easily do it without
having to store the results of the subroutine in a temporary hash. The other
methods are great too, but not in my context. I'll keep them in mind for
when I need to do it another way.

I don't worry about keys of %add overwriting %hash. I knew that that would
happen, but was refering more to losing everything in %hash. My values
should not overlap and if they do it would be intentional. Thanks for
pointing that out to make sure I was doing it right.

-Blair




------------------------------

Date: Thu, 03 Aug 2000 20:15:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: combining hashes
Message-Id: <x7em462jal.fsf@home.sysarch.com>

>>>>> "SK" == Stephen Kloder <stephen.kloder@gtri.gatech.edu> writes:

  SK> Larry Rosler wrote:
  >> A note to the original poster:  Values in the first hash that have the
  >> same keys as values in the second hash will be overwritten, no matter
  >> what method is used.

  SK> Not if you use:
  SK> $hash{$_} = $hash{$_} || $add{$_} foreach(keys %add);

and what if a value in %hash is undefined or 0 or ''? you just overwrote
it.

either make your code an exists ?: test or read my earlier post.

$hash{$_} = exists $hash{$_} ? $hash{$_} : $add{$_} foreach(keys %add);

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: Thu, 03 Aug 2000 20:15:24 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: combining hashes
Message-Id: <7a1z06f6ea.fsf@merlin.hyperchip.com>


Uri Guttman <uri@sysarch.com> writes:

> and for an ugly exercise in slicing:
> 
> 	@hash{ grep !exists $hash{$_}, keys %add } =
> 				@add{ grep !exists $hash{$_}, keys %add } ;

Isn't that easier written as:

	@add{keys %hash} = values %hash;

?

Ok .. it is not exactly identical as %add and %hash will be
different. But the original question didn't favour one over the other.

--Ala


------------------------------

Date: Thu, 03 Aug 2000 20:25:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: combining hashes
Message-Id: <x7bsza2iu7.fsf@home.sysarch.com>

>>>>> "AQ" == Ala Qumsieh <aqumsieh@hyperchip.com> writes:

  AQ> Uri Guttman <uri@sysarch.com> writes:

  >> and for an ugly exercise in slicing:
  >> 
  >> @hash{ grep !exists $hash{$_}, keys %add } =
  >> @add{ grep !exists $hash{$_}, keys %add } ;

  AQ> Isn't that easier written as:

  AQ> 	@add{keys %hash} = values %hash;

  AQ> Ok .. it is not exactly identical as %add and %hash will be
  AQ> different. But the original question didn't favour one over the other.


huh? mine modifies only %hash and yours mungs %add. slightly
different. the main point is mine is the use of exists so you don't
overwrite false values. if you don't care about overwriting with the
slice idom, it is fine. if you really care then the list idiom
(mentioned in this thread) is fine except for the hit on adding to a
large hash. it has to be listed and rehashed each time. so then the
slice idea will win on speed.

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: Thu, 03 Aug 2000 21:04:32 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: combining hashes
Message-Id: <7asnsmdpjy.fsf@merlin.hyperchip.com>


Uri Guttman <uri@sysarch.com> writes:

> >>>>> "SK" == Stephen Kloder <stephen.kloder@gtri.gatech.edu> writes:
> 
>   SK> Larry Rosler wrote:
>   >> A note to the original poster:  Values in the first hash that have the
>   >> same keys as values in the second hash will be overwritten, no matter
>   >> what method is used.
> 
>   SK> Not if you use:
>   SK> $hash{$_} = $hash{$_} || $add{$_} foreach(keys %add);
> 
> and what if a value in %hash is undefined or 0 or ''? you just overwrote
> it.
> 
> either make your code an exists ?: test or read my earlier post.
> 
> $hash{$_} = exists $hash{$_} ? $hash{$_} : $add{$_} foreach(keys %add);

Although I agree that we don't really need a ?? operator, it would come
quite handy in situations like this. Any plans for it in Perl6?

--Ala


------------------------------

Date: Thu, 03 Aug 2000 20:58:13 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: combining hashes
Message-Id: <sojn75gbdbm175@corp.supernews.com>

In article <3989CE4C.E9F31FF4@gtri.gatech.edu>,
    Stephen Kloder  <stephen.kloder@gtri.gatech.edu> wrote:

: Larry Rosler wrote:
: 
: > Too much copying.  Use the wonderful 'hash slice':
: >
: >   @hash{keys %add} = values %add;
: >
: > A note to the original poster:  Values in the first hash that have the
: > same keys as values in the second hash will be overwritten, no matter
: > what method is used.
: 
: Not if you use:
: $hash{$_} = $hash{$_} || $add{$_} foreach(keys %add);

What if some values are false but defined?

Greg
-- 
If you believe in yourself and have dedication and pride and never quit,
you'll be a winner. The price of victory is high but so are the rewards.
    -- Paul "Bear" Bryant


------------------------------

Date: 03 Aug 2000 21:33:23 GMT
From: abigail@foad.org (Abigail)
Subject: Re: combining hashes
Message-Id: <slrn8ojp8j.io6.abigail@alexandra.foad.org>

Ala Qumsieh (aqumsieh@hyperchip.com) wrote on MMDXXIX September MCMXCIII
in <URL:news:7asnsmdpjy.fsf@merlin.hyperchip.com>:
== 
== Uri Guttman <uri@sysarch.com> writes:
== 
== > >>>>> "SK" == Stephen Kloder <stephen.kloder@gtri.gatech.edu> writes:
== > 
== >   SK> Larry Rosler wrote:
== >   >> A note to the original poster:  Values in the first hash that have the
== >   >> same keys as values in the second hash will be overwritten, no matter
== >   >> what method is used.
== > 
== >   SK> Not if you use:
== >   SK> $hash{$_} = $hash{$_} || $add{$_} foreach(keys %add);
== > 
== > and what if a value in %hash is undefined or 0 or ''? you just overwrote
== > it.
== > 
== > either make your code an exists ?: test or read my earlier post.
== > 
== > $hash{$_} = exists $hash{$_} ? $hash{$_} : $add{$_} foreach(keys %add);
== 
== Although I agree that we don't really need a ?? operator, it would come
== quite handy in situations like this. Any plans for it in Perl6?


Actually, that wouldn't work either as undef is a perfectly valid hash
value.

But if you don't want your data overriden, just use: %hash = (%add => %hash);
unless %hash is really large.


Abigail
-- 
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT


------------------------------

Date: 03 Aug 2000 21:45:52 GMT
From: abigail@foad.org (Abigail)
Subject: Re: combining hashes
Message-Id: <slrn8ojpvg.io6.abigail@alexandra.foad.org>

Uri Guttman (uri@sysarch.com) wrote on MMDXXIX September MCMXCIII in
<URL:news:x7bsza2iu7.fsf@home.sysarch.com>:
\\ >>>>> "AQ" == Ala Qumsieh <aqumsieh@hyperchip.com> writes:
\\ 
\\   AQ> Uri Guttman <uri@sysarch.com> writes:
\\ 
\\   >> and for an ugly exercise in slicing:
\\   >> 
\\   >> @hash{ grep !exists $hash{$_}, keys %add } =
\\   >> @add{ grep !exists $hash{$_}, keys %add } ;
\\ 
\\   AQ> Isn't that easier written as:
\\ 
\\   AQ> 	@add{keys %hash} = values %hash;
\\ 
\\   AQ> Ok .. it is not exactly identical as %add and %hash will be
\\   AQ> different. But the original question didn't favour one over the other.
\\ 
\\ 
\\ huh? mine modifies only %hash and yours mungs %add. slightly
\\ different. the main point is mine is the use of exists so you don't
\\ overwrite false values. if you don't care about overwriting with the
\\ slice idom, it is fine. if you really care then the list idiom
\\ (mentioned in this thread) is fine except for the hit on adding to a
\\ large hash. it has to be listed and rehashed each time. so then the
\\ slice idea will win on speed.


But for large hashes, you don't want to repeat the grep, or even use
keys.

    while (my ($k => $v) = each %add) {exists $hash {$k} or $hash {$k} = $v}

And it's shorter than the ugly slice as well.



Abigail
-- 
perl -wle 'eval {die ["Just another Perl Hacker"]}; print ${${@}}[$#{@{${@}}}]'


------------------------------

Date: Thu, 03 Aug 2000 21:48:29 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: combining hashes
Message-Id: <8F85A70D1indigodimcom@166.93.207.145>

ab@cd.com (Blair Heuer) wrote in 
<GGii5.6510$0W4.212498@newsread2.prod.itd.earthlink.net>:

>Is there a simple way to combine two hashes?
>Take this simple code for instance:
>
>        my %hash = ( one => 'value_one' );
>        my %add = ( two => 'value_two' );
>
>How would I go about putting all the values of %add into %hash without
>losing the values of %hash?
>Here are some ways I had tried:

Simplest is:

    %hash = (%hash, %add);

However, this expands %hash unnecessarily.

A hash slice is probably more efficient:

    @hash{keys %add} = values %add;

Also, don't forget that keys appearing in both
%hash and %add will be overwritten.

-T


------------------------------

Date: Thu, 03 Aug 2000 21:52:53 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: combining hashes
Message-Id: <8F85A7A9Aindigodimcom@166.93.207.145>

[ a million other correct responses deleted ]

Damn...last time I answer a gimme with a slow news
server...:)

-T


------------------------------

Date: 3 Aug 2000 21:21:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: connecting to oracle
Message-Id: <8mck97$9gd$1@orpheus.gellyfish.com>

On Wed, 2 Aug 2000 17:29:11 +0200 Gabriel Euzet wrote:
> Hi,
> 
> This question may have been answered but I haven't it ...
> 
> We've 2 PC's
> * Redhat + Perl 5
> * Redhat + Oracle 8
> 
> And ... I don't know what I need to connect from the
> first to the second with Perl ???
> 
> I don't know :
> * if I must compile Perl again,
> * if a module exists
> * what are the perl functiojns to use
> 

You will probably need to use the module DBD::Oracle in association with
DBI - the README file for DBD::Oracle will tell you what you need to
build it and its manpage will tell you how to use it.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


------------------------------

Date: Thu, 3 Aug 2000 11:13:09 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: date manipulation
Message-Id: <MPG.13f3560d4e681f4a98ac31@nntp.hpl.hp.com>

In article <u9zomu2tao.fsf@wcl-l.bham.ac.uk> on 03 Aug 2000 17:39:11 
+0100, nobull@mail.com <nobull@mail.com> says...
> jponder9@my-deja.com writes:
> 
> > It occured to me that this type of problem must occur quite often,
> > often enough for there to be a formula or generic code to solve it.
> 
> In fact there's a generic formula that stands a good chance of solving
> _any_ problem that "must occur quite often" in Perl.
> 
> It goes like this:
> 
> Look to see if there's an question in the FAQ. (perldoc perlfaq) 
> 
> Look to see if there's a builtin function.  (perldoc perlfunc)
> 
> Look for a module on CPAN.  (http://www.cpan.org/)
> 
> I think you need to look into the Date::* modules on CPAN.

Following your sequence of steps, I would find this in perlfaq4: "How do 
I find yesterday's date?".  It isn't hard to relate that to the original 
question: "I was wondering if there is a tried and tested way of 
calculating dates (day/month/year) in the future from a given date."

No modules are needed to solve this problem.  Your second step will do 
it.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Thu, 03 Aug 2000 12:26:21 -0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: date manipulation
Message-Id: <8mca1u0781@news2.newsguy.com>

In article <8mc0r5$r9e$1@nnrp1.deja.com>, jponder9@my-deja.com wrote:

>    As a bit of a newbie to perl programming, 

Welcome to the community.

> I was wondering if there is a tried and tested way of calculating dates
> (day/month/year) in the future from a given date. e.g. given todays date
> what will the date be
> 364 days from now. Seems simple on the face of it but then what about
> leap years? and what if current month is a 31 day month? It occured to
> me that this type of problem must occur quite often, often enough for
> there to be a formula or generic code to solve it. Does anyone know of
> such??
> 

Another poster pointed out Date::Calc which is probably what you need, but
there is a heavier duty (read slower and larger :-) Date::Manip.  If you
find that you want to do heavier work with recurrances and the like, it
may be helpful to you.  Good luck.

Cheers, Jeff



------------------------------

Date: Thu, 03 Aug 2000 16:02:06 -0500
From: Topher Cawlfield <cawlfiel@uiuc.edu>
Subject: Re: Excessive memory use under OSF1 (was: numeric storage efficiency)
Message-Id: <3989DDCE.8C379666@uiuc.edu>

Ilmari Karonen wrote:
 ...
> Well, let me quote from "perldoc perldebug":
> 
>   Debugging Perl memory usage
>          Perl is very frivolous with memory.  There is a saying
>          that to estimate memory usage of Perl, assume a reasonable
>          algorithm of allocation, and multiply your estimates by
>          10.  This is not absolutely true, but may give you a good
>          grasp of what happens.
> 
 ...

Ahh, okay.  Yep, that was the explanation I was looking for.  Close enough,
anyway.  If nothing else, I have learned more respect for perldoc by
reading this newsgroup.

I usually don't even worry about memory considerations, but in this
particular case I was sensitive to it because, first, the program was
crashing with "Out of Memory" (even though the computer had 1 GB of
physical RAM and much more swap).  Second, I was also writing a bunch of
Fortran code that takes these same values and byte-packs them 4 to an
integer.  What Perl used 160 MB of RAM to store, my Fortran code required
 .5 MB.  Actually, the Perl scripts were used to manipulate these data and
write them out as hexadecimal values in an ascii file for the Fortran to
read.  I use Fortran when I absolutely have to, and Perl (and rarely Tcl)
whenever I have the choice.  As nasty as Fortran is, it is complimentary to
Perl in that it's strengths and weaknesses are all the opposite of Perl's. 
Of course I would never use Fortran at all if I weren't working on a big
collaborative experiment with millions of lines of legacy code.

Thanks again for your help (insight)!

 - Topher


------------------------------

Date: Thu, 3 Aug 2000 14:21:04 -0400
From: "Robert Lee" <robert99@maine.rr.nodamnspam.com>
Subject: Re: File IO
Message-Id: <RKii5.28893$9E6.174258@newsr1.maine.rr.com>

There is no faq built into news groups. You assume that I have the docs
installed...I don't, in fact I'm not even using a unix server. Before
posting the question I did a search at google and didn't find anything
usefull. If you don't what to answer questions then please stop coming here.
The entire point to programming topics in newsgroups is to provide help not
critisism. If you want to critisize create you own site at geocities. You'll
have to learn HTML first and judging by your attitude towards learning, may
take years.

I found out about the eq thing already via the searches. The post below
yours helped with the break function and >> prefix.

-Robert




------------------------------

Date: Thu, 3 Aug 2000 20:40:25 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: File IO
Message-Id: <Pine.GHP.4.21.0008032034290.23768-100000@hpplus03.cern.ch>

On Thu, 3 Aug 2000, Robert Lee wrote:

> You assume that I have the docs installed... I don't,

Then _that_ problem would be your first priority to solve.

> in fact I'm not even using a unix server. 

So what?  I have the Perl docs installed in the Win PC that I use for
accessing the unix server.  As well as on the unix server, natch.

What would be the point of discussion file IO with someone who doesn't
have files?  If you have files, then install Perl.  It comes with
ample documentation.

> If you don't what to answer questions then please stop coming here.

No, Sir.  If you don't want to make use of the available doc
resources, YOU stop coming here.

> The entire point to programming topics in newsgroups is to provide help 

NO, it isn't.  That's a side-effect of the discussions.

My disk quota is sure getting used up with killfile entries these days.

-- 

      A patent application requires an implementation, 
      which is impossible due to the lack of sufficently 
      dense material to make one that would work.
       - Glenn Randers-Pehrson discussing specification for a clue-stick



------------------------------

Date: Thu, 3 Aug 2000 12:20:02 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: File IO
Message-Id: <3989c5a1@news.microsoft.com>

"Robert Lee" <robert99@maine.rr.nodamnspam.com> wrote in message
news:RKii5.28893$9E6.174258@newsr1.maine.rr.com...
> There is no faq built into news groups. You assume that I have the docs
> installed...I don't, [...]

Then your Perl installation is broken and you may want to fix that first

jue




------------------------------

Date: Thu, 03 Aug 2000 18:31:37 GMT
From: redone~nospam~@siteconnect.com (Red Jackson)
Subject: Re: FormMail.pl problems
Message-Id: <3989ba4d.686155399@news.siteconnect.com>

Hi!
Thanks for the tip! This is my first tangle with FormMail.
Any suggestions for alternatives?

Thanks again!

Red

On Thu, 03 Aug 2000 02:14:12 GMT, tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
wrote:

>I was shocked! How could Red Jackson <redone~nospam~@siteconnect.com>
>say such a terrible thing:
>>Hi!
>>I'm running Formmail.pl  (Ver 1.6) on Apache 1.3.9 with mod_perl built
>
>No offense but all of Matt Wrights scripts are well known to horribly
>buggy and full of sucurity issues. You'd do better to write your own.



------------------------------

Date: Thu, 03 Aug 2000 21:47:26 GMT
From: mailloop@localhost.com (P&C)
Subject: How do I parse "file0001" into 2 parts?
Message-Id: <3989e7f7.416042307@news.comstar.net>

I have a series of file names:

file0001, file0002, file0003 etc. and I need to parse off just the
numeric part.

I've read the documentation and spent the afternoon trying to make
this work but no luck.  What's the trick to this?

Thanks,

Phil
p c   a t   n t a d m i n   d o t   c o m


------------------------------

Date: Thu, 03 Aug 2000 17:26:00 -0400
From: zentara <zentara@gypsyfarm.com>
Subject: Re: How do I run CGIs on my desktop?
Message-Id: <g8ojoskmv994mg7j81ibk3iiuvbrah0rdh@4ax.com>

On Thu, 3 Aug 2000 00:00:24 +0100, "jbr" <jbr@ntlworld.com> wrote:

>I'm just a humble html scripter and I started writing CGI scripts, but to
>try them out I upload them to my remote web server.   This takes a lot of
>time because I keep having to alter them and upload them to see if it
>worked.   So I got a copy of ActivePerl and installed it on my desktop.
>But I can't make my locally stored copies of my webpages call my locally
>stored CGI scripts.   I'd very much value any good advice on how to do
>this - it must be simple, if you know how.
>

You need to setup a http server to run on your "localhost", ie your
desktop computer.

I see you use windows. If you used linux, you could set up the Apache
web server, and run it on your desktop. 

I believe there is a version of Apache for win32,  go to
www.apache.org and look for it.  Alternatively look for 
a windows http server,  I'm sure Microsoft puts one out for
non-commercial personal use.


------------------------------

Date: 03 Aug 2000 21:29:35 GMT
From: bean <bean@agentkhaki.com>
Subject: Re: How do I run CGIs on my desktop?
Message-Id: <MPG.13f3ac02fecf23d5989683@news.concentric.net>

> I believe there is a version of Apache for win32,  go to
> www.apache.org and look for it.  Alternatively look for 
> a windows http server,  I'm sure Microsoft puts one out for
> non-commercial personal use.

I had problems with the win32 version of apache, but I'm not genius so 
I'm sure it was my fault and not theirs. If you're just looking to test 
scripts, Omnihttpd is a lot easier to setup (read "no setup") and will 
do exactly what you're looking to do.

I believe their site is http://www.omnicron.ab.ca

bean


------------------------------

Date: Thu, 3 Aug 2000 14:54:51 -0400
From: "steve fu\(n\)" <steve_fu@nai.com>
Subject: How to GREP ascii files only
Message-Id: <8mcf4v$7q0$1@zeitung.ngc.com>

Hi

I like to do a Unix-like grep on all the ASCII files in a directory tree.
The quetsion is how to test for ASCII files and avoid binery files. Thanks!

Steve




------------------------------

Date: Thu, 03 Aug 2000 19:07:19 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: How to GREP ascii files only
Message-Id: <sojgn7qgdbm123@corp.supernews.com>

In article <8mcf4v$7q0$1@zeitung.ngc.com>,
    steve fu\(n\) <steve_fu@nai.com> wrote:

: I like to do a Unix-like grep on all the ASCII files in a directory tree.
: The quetsion is how to test for ASCII files and avoid binery files. Thanks!

Look up the documentation for the -T file test operator in the perlfunc
manpage.  PPT's tcgrep <URL:http://doriath.perl.com/ppt/src/grep/tcgrep>
does what you want to do and much more.

Greg
-- 
There's a lovely paper which compares Unix to Zork in both cognitive and user
motivational terms.  Maybe you like Unix because it's an adventure game?
Still, I just don't think Unix will succeed as a theme park (some small
fraction of :-)  -- Bruce Cohen


------------------------------

Date: 3 Aug 2000 19:30:13 GMT
From: bmetcalf@nortelnetworks.com (Brandon Metcalf)
Subject: Re: How to GREP ascii files only
Message-Id: <8mch85$fdi$1@bcrkh13.ca.nortel.com>

steve_fu@nai.com writes:

 > I like to do a Unix-like grep on all the ASCII files in a directory tree.
 > The quetsion is how to test for ASCII files and avoid binery files. Thanks!

print "it's a text file\n" if -T $filename;

Brandon


------------------------------

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 3904
**************************************


home help back first fref pref prev next nref lref last post