[22372] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4593 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 20 14:06:02 2003

Date: Thu, 20 Feb 2003 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 20 Feb 2003     Volume: 10 Number: 4593

Today's topics:
        & befoer subroutine call (mans)
    Re: & befoer subroutine call <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Also religious: brackets <shondell@cis.ohio-state.edu>
    Re: Also religious: brackets (Stefan Adams)
    Re: Also religious: brackets (Kevin Cline)
        array of hash trouble (Morpheus)
    Re: array of hash trouble pauli@johannes-pauli.de
    Re: array of hash trouble <mpapec@yahoo.com>
    Re: array of hash trouble <nobull@mail.com>
    Re: array of hash trouble <glex_nospam@qwest.net>
    Re: Check for occurrence of element in Array <barryk2@SPAM-KILLER.mts.net>
        Chucking up text on word boundaries? (Robert Nicholson)
    Re: Chucking up text on word boundaries? (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=)
    Re: Chucking up text on word boundaries? <REMOVEsdnCAPS@comcast.net>
    Re: Date module (Kevin)
        fork leaks memory  in windows (glen)
    Re: How do I get the current date? <barryk2@SPAM-KILLER.mts.net>
        Installing perl on XP using Cygwin <s-p-o-e-d-n-i-e-k-@-g-m-x-.-n-e-t>
    Re: Memory problem with persistent DBI connection <doctor.jeep-fdee88a84189fe720f268444cdf58c21-20030221@email.expiry.luchs.at>
    Re: Newbie Q re form to mail script FormProcessorPro <notworking@all.com>
    Re: Newbie Q re form to mail script FormProcessorPro (Helgi Briem)
    Re: opendir question <barryk2@SPAM-KILLER.mts.net>
        Parsing Unix mbox in MS Environment (Dave)
    Re: Passing Hard Referance down more than one Sub <perl-dvd@darklaser.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Feb 2003 06:12:57 -0800
From: mans.breimer@ubs.com (mans)
Subject: & befoer subroutine call
Message-Id: <a4f94baa.0302200612.3963aaae@posting.google.com>

Hello,

Just wondering if there is a difference in calling my subroutine
like this: 
    my $retVal= mysubroutine($param); 

compared to:
    my $retVal= &mysubroutine($param);

At least I find the notation without the ampersand easier to read...

Cheers
/Måns Breimer


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

Date: Thu, 20 Feb 2003 14:14:36 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: & befoer subroutine call
Message-Id: <Xns93289A5F75BE9elhber1lidotechnet@62.89.127.66>

mans wrote:

> Hello,
> 
> Just wondering if there is a difference in calling my subroutine
> like this: 
>     my $retVal= mysubroutine($param); 
> 
> compared to:
>     my $retVal= &mysubroutine($param);


There is a difference.


  perldoc perlsub


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: 20 Feb 2003 12:20:54 -0500
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: Also religious: brackets
Message-Id: <xcw8ywaooll.fsf@psi.cis.ohio-state.edu>

Malte Ubl <ubl@schaffhausen.de> writes:

> Ryan Shondell wrote:
> > "Peter Cooper" <newsfeed2@boog.co.uk> writes:
> >
> 
> >>>One-liners goes like this;
> >>>
> >>>  do if ( statement );
> >>
> >>If I have a 'debug' or verbose switch in a program I tend to
> >>implement it like so:
> >>
> >>$debug && print $variable;
> > Wow, that's almost a carbon-copy example of what perlstyle says _not_
> 
> > to do, because it hides the main point of the statement.
> 
> No it doesn't, because here you got the very import C<$debug> as the
> first word on the line. I prefer the written C<and> though.

The part from perlstyle that I am refering to is:

 ... On the other hand

             print "Starting analysis\n" if $verbose;

         is better than

             $verbose && print "Starting analysis\n";

         because the main point isn't whether the user typed -v
         or not.


Granted, none of this (thread?) really matters, it was just an
interesting observation.

-- 
Ryan Shondell <shondell@cis.ohio-state.edu>


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

Date: 20 Feb 2003 09:33:52 -0800
From: stefan@borgia.com (Stefan Adams)
Subject: Re: Also religious: brackets
Message-Id: <dcc927de.0302200933.431de3d4@posting.google.com>

stefan@borgia.com (Stefan Adams) wrote in message news:<dcc927de.0302192056.520fe431@posting.google.com>...
> Sandman <mr@sandman.net> wrote in message news:<mr-DD6C65.23345619022003@news.fu-berlin.de>...
> > How do you use brackets in your code in loops or if statements? Here are some 
> > versions I can come up with:
> 
> Here's how I do it:
> 
> if ( statement ) {
>     do ...
> } else {
>  do ...
> }

Ok...  Something's screwy here.  When viewing this from google groups
it had the 'do' on the same line as the 'else', but now when I reply
to that message it has the do on the correct line but indented
improperly.  Clearly not my style.  Let me try this again (The
preceeding dots are an attempt to make sure things show rightly):

 .   if ( statement ) {
 .       do ...
 .   } elsif ( other statement ) {
 .       do ...
 .   } else {
 .       do ...
 .   }

Also, with one liners I do such:

 .   do if statement;

Naturally only my way is the right way :) but there is one style that
just really bugs me, and that's indenting the braces and then
indenting the 'do' or not:

Really bugs me:
 .   if(statement)        if(statement)
 .       {                     {
 .       do ...                    do ...
 .       }                     }

I also personally don't like not having the extra space before and
after the perentheses.

Yuck:                        Pretty:
 .   if(statement){           .   if ( statement ) {
        or                             or
 .   elsif(statement){        .   elsif ( statement ) {

Stefan


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

Date: 20 Feb 2003 09:54:45 -0800
From: kcline17@hotmail.com (Kevin Cline)
Subject: Re: Also religious: brackets
Message-Id: <ba162549.0302200954.2bae920a@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E541C12.91543E0B@earthlink.net>...
> Sandman wrote:
> > 
> > How do you use brackets in your code in loops or if statements? Here
> > are some versions I can come up with:
>  [snip]
> > Any other variations you prefer? I am a #1 guy myself, but use #2 if
> > the do's are one-liners.
> 
> If the two branches are single expressions, then I sometimes prefer to
> use ?: instead of if(){}else{}.
> 
> Also, while I normally use something like your #1, I put the spaces a
> bit differently:
> 
>    if( statement ) {
>       ... do ...
>    } else {
>    ... do ...
>    }

> 
> [Note the lack of a space between the 'if' and the '(', the space after
> the '(', the space before the ')', and the space between the ')' and
> the '{'.]

We noticed.  I think this style is poor because it is contrary
to the standard practice when typesetting text or mathematics.
When typesetting, an opening parenthesis never followed by a space,
nor is a closing parenthesis preceded by a space.  We have centuries
of practice doing this.  Writing code differently just slows the
reader.


> 
> Sometimes, 'statement' is really lengthy... I'll sometimes write code
> as:
> 
>    if( statement1 &&
>       statement2 &&
>       statement3
>    ) ...

Breaking statements before operators makes it easier to see the
structure of the code as one scans along the left margin.  
Breaking lines before operators is standard practice
in mathematical typesetting, and I see no reason
why code should be treated differently.


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

Date: 20 Feb 2003 06:33:54 -0800
From: daddyefsacks@yahoo.com (Morpheus)
Subject: array of hash trouble
Message-Id: <cd7c20b3.0302200633.2235c049@posting.google.com>

Hello all,

I have a data structure built like this:

push @all_data, { DAY       => $day,
		  TIME      => $time,
		  CHAN_NUM  => $chan_num, 
                  CHANNEL   => $chan_name
                  DATA      => [ @data ]
                };

First of all the reason I am using an array of hash is because I need
to sory the data in CHAN_NUM, DAY, TIME order after all the data from
a file has been read in.  I do that by:

@all_data = sort {
        $a->{CHAN_NUM} <=> $b->{CHAN_NUM}
                        ||
        $sort_day_hash{$a->{DAY}} <=> 
                $sort_day_hash{$b->{DAY}}
                        ||
        $sort_time_hash{$a->{TIME}} <=> 
                $sort_time_hash{$b->{TIME}}
} @all_data;

That all works fine, my problem is after the data is sorted I need to
be able to easily find all the data for a particular channel (CHANNEL
from the hash) from anywhere in the array of hash and I'm not sure how
to do this without iterating through the entire array of hash
everytime.  Optimally I think I would want to have a hash of array or
something like that where the hash key is CHANNEL and the array holds
all the data.  So anyway I was wondering if there is anyway to easily
convert this array of hash to a hash of array without having to
iterate through the thing with a for loop.  And also in general if
anyone sees a better approach to my problem.  This is my first actual
perl program so any advice is welcome and my first actual post here so
sorry if I did anything wrong :)


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

Date: Thu, 20 Feb 2003 19:09:52 +0100
From: pauli@johannes-pauli.de
Subject: Re: array of hash trouble
Message-Id: <3E5519F0.91595A53@johannes-pauli.de>

Morpheus wrote:
> 
> Hello all,
> 
> I have a data structure built like this:
> 
> push @all_data, { DAY       => $day,
>                   TIME      => $time,
>                   CHAN_NUM  => $chan_num,
>                   CHANNEL   => $chan_name
>                   DATA      => [ @data ]
>                 };
> 
> First of all the reason I am using an array of hash is because I need
> to sory the data in CHAN_NUM, DAY, TIME order after all the data from
> a file has been read in.  I do that by:
> 
> @all_data = sort {
>         $a->{CHAN_NUM} <=> $b->{CHAN_NUM}
>                         ||
>         $sort_day_hash{$a->{DAY}} <=>
>                 $sort_day_hash{$b->{DAY}}
>                         ||
>         $sort_time_hash{$a->{TIME}} <=>
>                 $sort_time_hash{$b->{TIME}}
> } @all_data;
> 
> That all works fine, my problem is after the data is sorted I need to
> be able to easily find all the data for a particular channel (CHANNEL
> from the hash) from anywhere in the array of hash 
maybe I did not anything well or is:

my @matching_data = grep {$ARG->{CHANNEL} eq "WhatEver"} @all_data;

just what you want?
> and I'm not sure how
> to do this without iterating through the entire array of hash
> everytime.  Optimally I think I would want to have a hash of array or
> something like that where the hash key is CHANNEL and the array holds
> all the data.  So anyway I was wondering if there is anyway to easily
> convert this array of hash to a hash of array without having to
> iterate through the thing with a for loop.  And also in general if
> anyone sees a better approach to my problem.  This is my first actual
> perl program so any advice is welcome and my first actual post here so
> sorry if I did anything wrong :)
Absolutly not :-)
Best wishes,
Johannes

-- 

PI4: Wir forschen gern!
                                  \\|//
                                  (. .)
------------------------------oOOo-(_)-oOOo--------------------- 

Johannes Pauli
      Physikalisches Institut IV
      Erwin-Rommel-Str. 1
91058 Erlangen
      Germany

 -o)   | Tel.  : ++49-(0)9131-852-7153
  /\\  | Web   : http://www.johannes-pauli.de
 _\_v  | email : pauli@johannes-pauli.de


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

Date: Thu, 20 Feb 2003 18:05:05 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: array of hash trouble
Message-Id: <cl2a5vcjlb4jbkj4rpicc7j5od7cupa278@4ax.com>

X-Ftn-To: Morpheus 

daddyefsacks@yahoo.com (Morpheus) wrote:
>I have a data structure built like this:
>
>push @all_data, { DAY       => $day,
>		  TIME      => $time,
>		  CHAN_NUM  => $chan_num, 
>                  CHANNEL   => $chan_name
>                  DATA      => [ @data ]
>                };

Maybe,
$all_data{$chan_name} = { 
    DAY       => $day,
		  TIME      => $time,
		  CHAN_NUM  => $chan_num, 
    DATA      => [ @data ]
};

or:
$all_data{$chan_name} = [ $day, $time, $chan_num, @data ];

In both cases downside is that you can't have duplicate channel names while
using array you can.

>First of all the reason I am using an array of hash is because I need
>to sory the data in CHAN_NUM, DAY, TIME order after all the data from
>a file has been read in.  I do that by:
>
>@all_data = sort {
>        $a->{CHAN_NUM} <=> $b->{CHAN_NUM}
>                        ||
>        $sort_day_hash{$a->{DAY}} <=> 
>                $sort_day_hash{$b->{DAY}}
>                        ||
>        $sort_time_hash{$a->{TIME}} <=> 
>                $sort_time_hash{$b->{TIME}}
>} @all_data;

I didn't any testing but hope this works,

@index = sort {
 $all_data{$a}{CHAN_NUM} <=> $all_data{$b}{CHAN_NUM} 
 ||
 $sort_day_hash{$all_data{$a}{DAY}} <=> $sort_day_hash{$all_data{$a}{DAY}}
 ||
 $sort_time_hash{$all_data{$a}{TIME}} 
 <=>
 $sort_time_hash{$all_data{$a}{TIME}}
} keys %all_data;

@index now contains sorted /hash keys/


-- 
Matija


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

Date: 20 Feb 2003 17:34:58 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: array of hash trouble
Message-Id: <u9vfzeetz1.fsf@wcl-l.bham.ac.uk>

daddyefsacks@yahoo.com (Morpheus) writes:

> I have a data structure built like this:
> 
> push @all_data, { DAY       => $day,
> 		  TIME      => $time,
> 		  CHAN_NUM  => $chan_num, 
>                   CHANNEL   => $chan_name
>                   DATA      => [ @data ]
>                 };
 
>  Optimally I think I would want to have a hash of array or
> something like that where the hash key is CHANNEL and the array holds
> all the data.

my %data_by_channel;
push @{$data_by_channel{$_->{CHANNEL}}}, $_ for @all_data;

> So anyway I was wondering if there is anyway to easily
> convert this array of hash to a hash of array without having to
> iterate through the thing with a for loop. 

Not that I know of.

> And also in general if anyone sees a better approach to my problem.

No, generating an index for a set of records in this way is common
idiom and I don't think, in general, there's a better approach.
 
>  This is my first actual perl program so any advice is welcome and
> my first actual post here so sorry if I did anything wrong :)

No, I'd say your post scores a 9/10.  Good clear description of what
you've done and what you want to know.  No obvious manaual section you
should have read.  Not, AFAIK, a FAQ.  Reasonable subject line.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 20 Feb 2003 12:58:29 -0600
From: Jeff D Gleixner <glex_nospam@qwest.net>
Subject: Re: array of hash trouble
Message-Id: <gx95a.191$C37.41643@news.uswest.net>

Morpheus wrote:
> Hello all,
> 
> I have a data structure built like this:
> 
> push @all_data, { DAY       => $day,
> 		  TIME      => $time,
> 		  CHAN_NUM  => $chan_num, 
>                   CHANNEL   => $chan_name
>                   DATA      => [ @data ]
>                 };
> 
> First of all the reason I am using an array of hash is because I need
> to sory the data in CHAN_NUM, DAY, TIME order after all the data from
> a file has been read in.  I do that by:
> 
> @all_data = sort {
>         $a->{CHAN_NUM} <=> $b->{CHAN_NUM}
>                         ||
>         $sort_day_hash{$a->{DAY}} <=> 
>                 $sort_day_hash{$b->{DAY}}
>                         ||
>         $sort_time_hash{$a->{TIME}} <=> 
>                 $sort_time_hash{$b->{TIME}}
> } @all_data;

Depending on the amount of data you have, it might be faster/easier
to create an INDEX field in your hash..
	INDEX => $chan_num . $day . $time,
everything but $chan_num would need to be correctly 0 padded, so
things like $time would be 000001 instead of 1 to make INDEX
101000001 instead of 111, where $chan_num=$day=$time=1.

That way you could just quickly sort on INDEX.

>   Optimally I think I would want to have a hash of array or
> something like that where the hash key is CHANNEL and the array holds
> all the data.  So anyway I was wondering if there is anyway to easily
> convert this array of hash to a hash of array without having to
> iterate through the thing with a for loop.  And also in general if
> anyone sees a better approach to my problem.  This is my first actual
> perl program so any advice is welcome and my first actual post here so
> sorry if I did anything wrong :)

If you only need to find all the values for one CHANNEL, then iterate or
grep through @all_data.  If you need to find multiple CHANNELs, then
create some sort of hash, to avoid going through the entire array
more than once.

You could create the CHANNEL hash of lists in the same loop as
you're creating @all_data..

push (@{$CHANNEL{$chan_name}},  { DAY => ...blah..});

Of course, you could use $all_data[$#all_data] or iterate through
@all_data after it's sorted and setting the value apropriately.

Or after you sort your array, go through it and create a CHANNEL_INDX_LOOKUP

my %CHANNEL_INDX_LOOKUP;
foreach my $i  (0 .. $#all_data)
{
	push (@{$CHANNEL_INDX_LOOKUP{$all_data[$i]->{CHANNEL}}}, $i);
}

Then %CHANNEL_INDX_LOOKUP would contain all the indexes in @all_data
for each CHANNEL and in your sorted order.  It makes things more complex
and would only be useful if you have a large number of entries in @all_data.
This way you don't have separete copies of the data and you do have
a quick way to find the data in the array.

Since it seems that there can be multiple values for each CHANNEL, you'll
need to iterate through something.





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

Date: Thu, 20 Feb 2003 08:16:27 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Check for occurrence of element in Array
Message-Id: <MPG.18be9f34f5e01dd7989705@news.mts.net>



In article <87smukdnqh.fsf@web.de>, upro (upro@gmx.net) says...
> Hello,
> 
> I'm quite sure this is an easy issue, but please help...:
> 
> I want to check for occurrences of a pattern in an array.
> 
> E. g. my array contains the valuaes "de", "en", and "fr". I have
> anther list with iso codes, and I want to check for their presence.
> Well, I guess what I want to do is a kind of pattern matching on an
> array...
> 
> I have heard that it is better tpo do this with a hash but I don't
> know how to do that.
> 
> Any help (woith array or hash) is greatly appreciated...
> 
> 
> Yours,
> 
> Michael
> 
> 

@array = ( "de", "en", "fr" );
$value = <STDIN>;  # read a value from user
chomp $value;
if ( 0 < grep /${value}/,@array ) {
	print "Found it.\n";
}
else {
	print "No match.\n";
}



%hash = ( "de" => 0 , "en" => 0 , "fr" => 0 );
$value = <STDIN>;  # read a value from user
chomp $value;
if ( exists $hash{$value} ) {
	print "Found it.\n";
}
else {
	print "No match.\n";
}
 
-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: 20 Feb 2003 06:31:05 -0800
From: robert@elastica.com (Robert Nicholson)
Subject: Chucking up text on word boundaries?
Message-Id: <24a182bd.0302200631.7a81702c@posting.google.com>

Are there any examples of taking a large string and cutting it up into
smaller pieces where each "chunk" is split on a word boundary?

I want to SMS the body of email that arrives to my email account but
ideally instead of using substr with a fixed chuck size of characters
I'd like to break the chuck on a word boundary. If I can easily
identify where the word boundary lies I can still use my substr
solution.

presumably this involves tokenizing by word and making sure "n" words
fit into the chunk size allowable.


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

Date: 20 Feb 2003 15:46:59 +0100
From: mru@users.sourceforge.net (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=)
Subject: Re: Chucking up text on word boundaries?
Message-Id: <yw1x65rfc8m4.fsf@lakritspipa.e.kth.se>

robert@elastica.com (Robert Nicholson) writes:

> Are there any examples of taking a large string and cutting it up into
> smaller pieces where each "chunk" is split on a word boundary?
> 
> I want to SMS the body of email that arrives to my email account but
> ideally instead of using substr with a fixed chuck size of characters
> I'd like to break the chuck on a word boundary. If I can easily
> identify where the word boundary lies I can still use my substr
> solution.

/(.{1,160})\b/

Repeat to get more chunks.

-- 
Måns Rullgård
mru@users.sf.net


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

Date: Thu, 20 Feb 2003 12:24:53 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Chucking up text on word boundaries?
Message-Id: <Xns932888705A19Esdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

robert@elastica.com (Robert Nicholson) wrote in 
news:24a182bd.0302200631.7a81702c@posting.google.com:

> Are there any examples of taking a large string and cutting it up into
> smaller pieces where each "chunk" is split on a word boundary?

Suggest you look into the Text::Wrap module.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;


-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPlUdZ2PeouIeTNHoEQL6ZACfbyvxKRsPh18NGmQKKfp8xExf9K4AoKsH
zA5wRnqSAjlvHybBTfzmHGfp
=TMDB
-----END PGP SIGNATURE-----


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

Date: 20 Feb 2003 08:24:55 -0800
From: kevin_mudd@adp.com (Kevin)
Subject: Re: Date module
Message-Id: <bf26a3a6.0302200824.4cf147a7@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb54obc.3jt.tadmc@magna.augustmail.com>...
> Kevin <kevin_mudd@adp.com> wrote:
> 
> > Is there an existing Date module where I can get the number of days in
> > the current month?
> 
> 
>    Date::Calc::Days_in_Month()
> 
> 
> Did you overlook it when you checked CPAN before posting?

I must have.  

Thanks gentlemen....this is exactly what I needed.  

Kevin


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

Date: 20 Feb 2003 06:21:51 -0800
From: glen2005@yahoo.com (glen)
Subject: fork leaks memory  in windows
Message-Id: <97e5cb64.0302200621.6c3eb031@posting.google.com>

Why the most basic implementation of fork is leaking memory in every loop?
It leaks 10~20K on every iteration both on AS 5.6.1 and 5.8.0.

Am I missing something or fork() is just useless in Windows?

-Thanks

while(1)
{
	my $pid=fork();
	die "Fork failed!" if (! defined $pid);
	if ($pid) 
	{   # parent
 		print STDOUT "PARENT\n";
		waitpid($pid,0);
	} 
	else 
	{   #child
 		print STDOUT "START Child $$\n";
 		exit 0;
	}

  	select(undef,undef,undef,0.5); #sleep a little
}


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

Date: Thu, 20 Feb 2003 08:20:38 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: How do I get the current date?
Message-Id: <MPG.18bea03245f8de3e989706@news.mts.net>


In article <3E53E86F.2090803@hotmail.com>, Justin A. Graham 
(justinagraham@hotmail.com) says...
> I want to write a script that zip up files, and names the archive 
> file-month-day-year.zip
> 
> How do I get the current date in a perl script?
> 
> Thanks
> Justin
> 
> 


$now = time;
( $sec , $min , $hour , $mday , $mon , $year , $wday , $yday , $isdst ) =
              localtime($now);
  @months = ( "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , 
"Aug" ,
              "Sep" , "Oct" , "Nov" , "Dec" );

$archive = $filename . "-" . $months[$mon] . "-" . $mday . "-" .
	$year+1900;

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Thu, 20 Feb 2003 18:28:24 +0200
From: "Henry Holland" <s-p-o-e-d-n-i-e-k-@-g-m-x-.-n-e-t>
Subject: Installing perl on XP using Cygwin
Message-Id: <b32vpd$n9k$1@ctb-nnrp2.saix.net>

Hi,

I'm having trouble compiling perl on cygwin. This is my configuration:

------------------
#!/bin/sh

# This script is designed to provide a handy summary of the configuration
# information being used to build perl. This is especially useful if you
# are requesting help from comp.lang.perl.misc on usenet or via mail.

# Note that the text lines /^Summary of/ .. /^\s*$/ are copied into
Config.pm.
cat <<'!NO!SUBS!'
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=cygwin, osvers=1.3.20(0.7332), archname=cygwin-multi
    uname='cygwin_nt-5.1 spoedniek 1.3.20(0.7332) 2003-02-08 12:10 i686
unknown unknown cygwin '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=define
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='gcc', ccflags
='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -I/usr/local/include',
    optimize='-O2',



 cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.2 20020927 (prerelease)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=4
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld2', ldflags =' -s -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib
    libs=-lgdbm -lcrypt -lcygipc
    perllibs=-lcrypt -lcygipc
    libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl5_6_1
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s'
    cccdlflags=' ', lddlflags='--enable-extra-pe-debug'

!NO!SUBS!
--------------------------------

Part of the errors/warnings I get:

------------------------
rm -f opmini.c
Live child 0x0a056330 (opmini.o) PID 808
Got a SIGCHLD; 1 unreaped children.
Reaping winning child 0x0a056330 PID 808
Removing child 0x0a056330 PID 808  from chain.
    Successfully remade target file `opmini.o'.
   Finished prerequisites of target file `miniperl'.
  Must remake target `miniperl'.
PATH=/usr/src/perl-5.6.1-2:.:/usr/local/bin:/usr/bin:/bin:/usr/local:/etc:/u
sr/lib:/lib:/usr/sbin gcc -L/usr/src/perl-5.6.1-2  -s -L/usr/local/lib -o
miniperl miniperlmain.o opmini.o -lperl5_6_1s -lcrypt -lcygipc
Putting child 0x0a067398 (miniperl) PID 3560 on the chain.
Live child 0x0a067398 (miniperl) PID 3560

<---snip endless auto-import warnings on __ctype__'-->
/usr/src/perl-5.6.1-2/libperl5_6_1s.a(regexec.o)(.text+0x87fb):regexec.c:
variable '__ctype_' can't be auto-imported. Please read the documentation
for ld's --enable-auto-import for details.
/usr/src/perl-5.6.1-2/libperl5_6_1s.a(regexec.o)(.text+0x8811):regexec.c:
variable '__ctype_' can't be auto-imported. Please read the documentation
for ld's --enable-auto-import for details.
/usr/src/perl-5.6.1-2/libperl5_6_1s.a(regexec.o)(.text+0x882a):regexec.c:
variable '__ctype_' can't be auto-imported. Please read the documentation
for ld's --enable-auto-import for details.
/usr/src/perl-5.6.1-2/libperl5_6_1s.a(regexec.o)(.text+0x8843):regexec.c:
variable '__ctype_' can't be auto-imported. Please read the documentation
for ld's --enable-auto-import for details.
/usr/src/perl-5.6.1-2/libperl5_6_1s.a(regexec.o)(.text+0x8858):regexec.c:
variable '__ctype_' can't be auto-imported. Please read the documentation
for ld's --enable-auto-import for details.
/usr/src/perl-5.6.1-2/libperl5_6_1s.a(regexec.o)(.text+0x8875):regexec.c:
variable '__ctype_' can't be auto-imported. Please read the documentation
for ld's --enable-auto-import for details.
/usr/src/perl-5.6.1-2/libperl5_6_1s.a(regexec.o)(.text+0x88a6):regexec.c:
variable '__ctype_' can't be auto-imported. Please read the documentation
for ld's --enable-auto-import for details.
/usr/src/perl-5.6.1-2/libperl5_6_1s.a(regexec.o)(.text+0x8a3b):regexec.c:
variable '__ctype_' can't be auto-imported. Please read the documentation
for ld's --enable-auto-import for details.
Info: resolving __ctype_ by linking to __imp___ctype_ (auto-import)
Info: resolving _h_errno by linking to __imp__h_errno (auto-import)
collect2: ld returned 1 exit status
Got a SIGCHLD; 1 unreaped children.
Reaping losing child 0x0a067398 PID 3560
make: *** [miniperl] Error 1
Removing child 0x0a067398 PID 3560  from chain.
--------------------

At first I got an error:
make: *** No rule to make target '<built-in>', needed by 'miniperlmain.o'.
Stop.

I found in my GNUMakefile under dependencies a number of lines containing
<built-in> and so deleted them. Then when I do the make I get the __ctype__
warnings.

Can someone help me here? I've been trying for days and am running out of
ideas. Please let me know what more information I can provide.

Thanks in advance,
Henry




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

Date: Thu, 20 Feb 2003 14:23:08 +0100
From: "DJ" <doctor.jeep-fdee88a84189fe720f268444cdf58c21-20030221@email.expiry.luchs.at>
Subject: Re: Memory problem with persistent DBI connection
Message-Id: <pan.2003.02.20.13.23.02.946147@pentex.at>

On Tue, 18 Feb 2003 15:59:39 +0000, Benjamin Goldberg emitted the following data:

> DJ wrote:
>> 
>> The problem is that the daemon process accumulates memory over time. I
>> ran the daemon for three days and the process got as big as 50 MB.
>> [...]
> 
> The only time you need finish() is if you have a SELECT statement, and
> you read *part*, but not all of the data, and you don't want the rest of
> the data.  It has no effect if you've read all of the data from a
> statement handle.

Ok. I wasn't sure about this and decided to call finish() anyway.

>> Does anyone have any idea how to trace this problem or how to make
>> sure that the process doesn't grow?
> 
> Add 'use strict' to your program, then declare all of your variables
> with the smallest possible scope.

The program already uses 'use strict'. I will check the variables and see
if I find anything.

> Don't use nested anonymous subroutines.

The code consists of a simple loop.

> If possible, use sql statements with placeholders, instead of
> interpolating data -- this way, you can prepare them ahead of time, and
> avoid having to re-prepare them.  This will speed up your program for
> sure, and *may* avoid a memory leak.

Ok, I'll try to do this and see if the problem persists.

Thanks,
dj.

-- 
Get real! Make a pact with a demon!



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

Date: Thu, 20 Feb 2003 15:36:28 -0000
From: Trilby <notworking@all.com>
Subject: Re: Newbie Q re form to mail script FormProcessorPro
Message-Id: <MPG.18bf06599d9435859896e6@news.iol.ie>

While busily concocting a devastating reply anno4000@lublin.zrz.tu-
berlin.de retorted
> You asked what you *think* is a simple question.  What you did ask
> is for somebody to debug your script.  Since you didn't give any
> information, the request to study the package was implicit.

Bullshit.  A simple question.
> 
> > > Best guess, and it's a real WAG, is there's some CRLF mistranslation
> > > going on when the template is uploaded onto the server.
> > > 
> > > 
> > And that was so difficult, was it ?
> 
> Haughty remarks about things you don't understand won't make you
> any friends.
> 
You're the sarcastic twit.  Get a life.

Trilby


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

Date: Thu, 20 Feb 2003 16:14:21 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Newbie Q re form to mail script FormProcessorPro
Message-Id: <3e54fec8.1139085979@news.cis.dfn.de>

On Thu, 20 Feb 2003 15:36:28 -0000, Trilby
<notworking@all.com> wrote:

>While busily concocting a devastating reply anno4000@lublin.zrz.tu-
>berlin.de retorted
>> You asked what you *think* is a simple question.  What you did ask
>> is for somebody to debug your script.  Since you didn't give any
>> information, the request to study the package was implicit.
>
>Bullshit.  A simple question.
>> 
>> > > Best guess, and it's a real WAG, is there's some CRLF mistranslation
>> > > going on when the template is uploaded onto the server.
>> > > 
>> > > 
>> > And that was so difficult, was it ?
>> 
>> Haughty remarks about things you don't understand won't make you
>> any friends.
>> 
>You're the sarcastic twit.  Get a life.

*plonk*

Leave us, moron.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Thu, 20 Feb 2003 08:08:15 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: opendir question
Message-Id: <MPG.18be9d46d751a75e989704@news.mts.net>



In article <SfO4a.4603241$6N5.614076@post-03.news.easynews.com>, 
Dartnagnan (cb@sebaw.com) says...
> This may be a silly question but how do you close a directory handle so you
> can open a different one.
> 
> opendir(DH,$dir) || die "Couldn't open the current directory:$!";
> while ($_ = readdir(DH)){
> next if $_ eq "." or $_ eq "..";
> my @test =  $_,;
> my $test = $_;
> copy ("$file", "$dir\\$test");
> 
> Once I do this want to do it again on a different directory.
> 
> Any thoughts or should I setup a sub routine to get the variables... but
> then I would still need to close it before I get another one.
> 
> CB
> 
> 
> 

closedir DH;

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: 20 Feb 2003 10:37:17 -0800
From: bluvampire@yahoo.com (Dave)
Subject: Parsing Unix mbox in MS Environment
Message-Id: <c3c6af16.0302201037.132cf5dc@posting.google.com>

I need to be able to post unix (and netscape - which is in the same
format for certain versions) mailbox folders
/var/spool/mail/<username> in perl, but I need it to run on a
Microsoft environment.  Every Perl Module I have found for this
requires Unix - such as Mail::Folder (which is exactly what I need). 
Anyone able to point me to a module that will do this in the MS
environment.  The code to deal with individual mails, attachments,
etc. in MIME is already done, so it would be great if I could extract
MIME entities outof it.  I am currently looking at Mail::MboxParser
but not sure if that is going to do the trick.

Thanks in advance


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

Date: Thu, 20 Feb 2003 15:48:40 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: Passing Hard Referance down more than one Sub
Message-Id: <sN65a.49$F6.11314@news-west.eli.net>

"Tom" <thomasb95@mac.com> wrote in message
news:MMR2a.402$3l2.36628520@newssvr15.news.prodigy.com...
> Sorry for such a basic question  but I have been trying to send a
referance
> to an array thru more than one subroutine and I am failing.
> I use say i.e. $referance = \@array1 then call the first subroutine
but when
> the first subrountne calls the next and then say I do a
> print "----> @$referance[0]\n\r";   I get   ---->    and no values
from
> inside the array. I Have also tried TypeGlob but it did not work ether
but I
> also don't think it was intened to do that anyway
> So I guess my question is how do you pass and array down multi.
subroutines
> or global it.
> Note here I do preload the array with values.

Here is an example:

my @array = ('stuff', 'more stuff');
my $retval = first_sub(\@array);

sub first_sub {
    my $arrayref = shift;
    my $retval = second_sub($arrayref);
    return($retval);
}

sub second_sub {
    my $arrayref = shift;
    my $first_array_element = ${$arrayref}[0];
    return($first_array_element);
}


Regards,
David




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

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


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