[24640] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6804 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 3 12:52:49 2004

Date: Tue, 3 Aug 2004 09:50:45 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 3 Aug 2004     Volume: 10 Number: 6804

Today's topics:
        clearing of all variables (justme)
    Re: clearing of all variables <spamtrap@dot-app.org>
    Re: clearing of all variables <jurgenex@hotmail.com>
    Re: clearing of all variables <usenet@morrow.me.uk>
        Com+ <jochen.friedmann3@de.bosch.com>
    Re: Com+ <jns@gellyfish.com>
        convert mail to mozilla format (Alythh)
    Re: convert mail to mozilla format chris-usenet@roaima.co.uk
        Counting occurances of string A in string B, and adding <mr@sandman.net>
    Re: Counting occurances of string A in string B, and ad (Anno Siegel)
    Re: Counting occurances of string A in string B, and ad <mr@sandman.net>
    Re: Counting occurances of string A in string B, and ad (J. Romano)
    Re: Counting occurances of string A in string B, and ad <uri@stemsystems.com>
        CPAN install from a local directory (Matt C)
    Re: CPAN install from a local directory (Anno Siegel)
    Re: CPAN install from a local directory <nobull@mail.com>
    Re: Creating Excel spreadsheet - Advanced question (John McNamara)
    Re: Creating Excel spreadsheet - Advanced question <lance_powers@yahoo.com>
    Re: Creating Excel spreadsheet - Advanced question <lv@aol.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 25 Jul 2004 20:59:26 -0700
From: eight02645999@yahoo.com (justme)
Subject: clearing of all variables
Message-Id: <c0837966.0407251959.46adda6f@posting.google.com>

hi

i have a while loop inside a sub

sub 1 {
  while(1)
  {
     # declaring of variables, arrays, hashes
     
     last if somecondition
  }


}#end sub

Firstly, when the loop encounters last command, will perl take care of
clearing
all the variables, arrays, hashes that was declared in the while loop?
will the subroutine clear that for me? or do i have to include "undef"
just before the sub returns? If I need to include undef , how do i
clear everything at once ??

thanks for any help


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

Date: Mon, 26 Jul 2004 00:23:41 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: clearing of all variables
Message-Id: <TbedndPHjNrTGpnc4p2dnA@adelphia.com>

justme wrote:

> i have a while loop inside a sub
> 
> sub 1 {
>   while(1)
>   {
>      # declaring of variables, arrays, hashes
>      
>      last if somecondition
>   }
> 
> 
> }#end sub
> 
> Firstly, when the loop encounters last command, will perl take care
> of clearing all the variables, arrays, hashes that was declared in
> the while loop?

Assuming that those variables are local in scope - i.e., they were 
declared with "my" - yes, they'll be cleaned up automagically.

See also:

perldoc -f my
"Private Variables via my()" in perldoc perlsub

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Mon, 26 Jul 2004 04:47:35 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: clearing of all variables
Message-Id: <H10Nc.8848$Nu4.6431@nwrddc01.gnilink.net>

justme wrote:
> hi
>
> i have a while loop inside a sub
>
> sub 1 {
>   while(1)
>   {
>      # declaring of variables, arrays, hashes
>
>      last if somecondition
>   }
>
>
> }#end sub
>
> Firstly, when the loop encounters last command, will perl take care of
> clearing
> all the variables, arrays, hashes that was declared in the while loop?

That depends upon _how_ you declared the variables (as global or as local)
and what you mean by "clearing".

Assuming you declared the variables as local, then after the block has
closed those variables are not accessible any more (unless you are keeping
some references somewhere).
Because perl does its own garbage collection, the memory that was allocated
to those inaccessible variables will be reused for new variables. So yes,
perl cleans up after variables go out of scope.
However (unless something in the implementation has changed recently) the
interpreter will not return this memory to the OS. So no, perl does not
clean up.

jue





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

Date: Tue, 27 Jul 2004 18:46:59 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: clearing of all variables
Message-Id: <j1hit1-o46.ln1@mauzo.dyndns.org>


Quoth eight02645999@yahoo.com (justme):
> hi
> 
> i have a while loop inside a sub
> 
> sub 1 {

1 isn't a valid name for a sub. Please post real code.

>   while(1)
>   {

Preferred style is

while (1) {

(not that it *really* matters...).

>      # declaring of variables, arrays, hashes
>      
>      last if somecondition

 ...;

Please post real code.

>   }
> 
> 
> }#end sub
> 
> Firstly, when the loop encounters last command, will perl take care of
> clearing
> all the variables, arrays, hashes that was declared in the while loop?

Lexical variables ('my' variables) are destroyed at the exit of their
innermost enclosing lexical scope (set of braces or file). So my
variables declared inside the loop will be destroyed when the loop is
exitted, however that occurs (falling off the end, 'last', 'die', etc.).

Globals (package variables, undeclared variables if you're not using
'strict' (you should be), 'our' variables) are never destroyed.

[Dynamicly-scoped values (what you get when you apply 'local' to a
variable) have their old value restored at the exit of their innermost
enclosing lexical scope, but you don't even want to *think* about them
until you understand scope rather better than you do now.]

> will the subroutine clear that for me?

Variables declared at sub scope will be destroyed when the sub exits.

Ben

-- 
   Although few may originate a policy, we are all able to judge it.
                                             - Pericles of Athens, c.430 B.C.
  ben@morrow.me.uk


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

Date: Fri, 30 Jul 2004 12:51:41 +0200
From: "Jochen Friedmann" <jochen.friedmann3@de.bosch.com>
Subject: Com+
Message-Id: <ced97t$ssi$1@ns1.fe.internet.bosch.com>

Hello,

how can I use a COM+ Objekt from another Computer in my PerlScript ?

my code:
----------
use Win32::OLE;

$o = Win32::OLE->new(["10.27.203.203", "CJSrv.CopyJobServer"]);
print Win32::OLE->LastError(), "\n";
print int(Win32::OLE->LastError());
-----------
The error message is: "Access denied" ! Do I need a username and a PW ?

Jochen




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

Date: Fri, 30 Jul 2004 14:07:23 GMT
From: Jonathan Stowe <jns@gellyfish.com>
Subject: Re: Com+
Message-Id: <vCsOc.234$5_.155@newsr2.u-net.net>

Jochen Friedmann <jochen.friedmann3@de.bosch.com> wrote:
> Hello,
> 
> how can I use a COM+ Objekt from another Computer in my PerlScript ?
> 
> my code:
> ----------
> use Win32::OLE;
> 
> $o = Win32::OLE->new(["10.27.203.203", "CJSrv.CopyJobServer"]);
> print Win32::OLE->LastError(), "\n";
> print int(Win32::OLE->LastError());
> -----------
> The error message is: "Access denied" ! Do I need a username and a PW ?

Not necessarily but you will need to configure the remote machine to
allow remote activations.  You will probably want to ask in a windows
newsgroup about this.

/J\




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

Date: 27 Jul 2004 05:33:34 -0700
From: alythh@netscape.net (Alythh)
Subject: convert mail to mozilla format
Message-Id: <6a25ba72.0407270433.2666f7a7@posting.google.com>

when switching from Kmail to Mozilla, I ended up (don't exactly
remember how) with  all the mails from each folder bundled in a single
mailmessage in Moz.
I know the little Perl needed to parse this big messages and split
them to single chunks, but then what? How can I save them as single
emails recognizable by Moz?

I saw that for a given Moz folder e.g. "Work" Mozilla keeps the files:
Work
Work.msf
(and a directory Work.sbd if the folder contains subfolders)

the typical "Work" file too seems a big chunk, while Work.msf has the
header // <!-- <mdb:mork:z v="1.4"/> --> on it.

Any idea on how to proceed?

Thanks!

Alessandro Magni


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

Date: Tue, 27 Jul 2004 15:28:19 +0100
From: chris-usenet@roaima.co.uk
Subject: Re: convert mail to mozilla format
Message-Id: <3d5it1-as.ln1@moldev.cmagroup.co.uk>

Alythh <alythh@netscape.net> wrote:
> when switching from Kmail to Mozilla, I ended up (don't exactly
> remember how) with  all the mails from each folder bundled in a single
> mailmessage in Moz.

That suggests the "From " header (no, not "From:") is missing from each
of the mail messages. Check this by looking at the first line of the
file - it should start with a line like this example:
	From someone@somewhere Sun Dec  7 00:00:00 2004

In perl, that should match something like this RE:
	/^From \S+ \w{3} \w{3} [ \d]\d \d\d:\d\d:\d\d \d{4}$/

> I know the little Perl needed to parse this big messages and split
> them to single chunks, but then what? How can I save them as single
> emails recognizable by Moz?

I would have expected it to "just work". I use thunderbird here (an
offshoot from moz) and it keeps my messages in one file per folder.

> I saw that for a given Moz folder e.g. "Work" Mozilla keeps the files:
> Work
> Work.msf
> (and a directory Work.sbd if the folder contains subfolders)

In this example, "Work" is the file containing all the messages for the
folder "Work". "Work.msf" is a set of lookup keys to "Work" and can be
safely deleted (moz will rebuild it automatically). "Work.sbd" is the
directory used to hold subfolders of "Work", if required.

Chris


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

Date: Tue, 03 Aug 2004 12:53:39 +0200
From: Sandman <mr@sandman.net>
Subject: Counting occurances of string A in string B, and adding it to string B
Message-Id: <mr-CF69F0.12533903082004@individual.net>

Let's say I have a string that goes like this:

    "A horse is a horse is a horse, on a horseman"

and I want to count how many "horse" there is in the string. Well, that's easy, 
by using:

    $_ = "A horse is a horse is a horse, on a horseman";
    my $nr;
    $nr++ for /horse/ig;
    print $nr;
    __END__
    Out: 4

Now, I would like add a number to each word that contains the string horse, and 
this is where I am lost.

Basically, what I want to output is this:

    "A horse (1) is a horse (2) is a horse (3), on a horseman (4)"


Note that it should be "horseman (4)" not "horse (4)man".


Anyone got a juicy regexp for this? :)

-- 
Sandman[.net]


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

Date: 3 Aug 2004 11:06:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Counting occurances of string A in string B, and adding it to string B
Message-Id: <cenrj5$ro6$2@mamenchi.zrz.TU-Berlin.DE>

Sandman  <mr@sandman.net> wrote in comp.lang.perl.misc:
> Let's say I have a string that goes like this:
> 
>     "A horse is a horse is a horse, on a horseman"
> 
> and I want to count how many "horse" there is in the string. Well, that's easy, 
> by using:
> 
>     $_ = "A horse is a horse is a horse, on a horseman";
>     my $nr;
>     $nr++ for /horse/ig;
>     print $nr;
>     __END__
>     Out: 4
> 
> Now, I would like add a number to each word that contains the string horse, and 
> this is where I am lost.
> 
> Basically, what I want to output is this:
> 
>     "A horse (1) is a horse (2) is a horse (3), on a horseman (4)"
> 
> 
> Note that it should be "horseman (4)" not "horse (4)man".

    my $n = 0;
    s/(\w*horse\w*)/do { $n ++; "$1 ($n)"}/eg;

Anno


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

Date: Tue, 03 Aug 2004 13:19:23 +0200
From: Sandman <mr@sandman.net>
Subject: Re: Counting occurances of string A in string B, and adding it to string B
Message-Id: <mr-2A5CD6.13192303082004@individual.net>

In article <cenrj5$ro6$2@mamenchi.zrz.TU-Berlin.DE>,
 anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> Sandman  <mr@sandman.net> wrote in comp.lang.perl.misc:
> > Let's say I have a string that goes like this:
> > 
> >     "A horse is a horse is a horse, on a horseman"
> > 
> > and I want to count how many "horse" there is in the string. Well, that's 
> > easy, 
> > by using:
> > 
> >     $_ = "A horse is a horse is a horse, on a horseman";
> >     my $nr;
> >     $nr++ for /horse/ig;
> >     print $nr;
> >     __END__
> >     Out: 4
> > 
> > Now, I would like add a number to each word that contains the string horse, 
> > and 
> > this is where I am lost.
> > 
> > Basically, what I want to output is this:
> > 
> >     "A horse (1) is a horse (2) is a horse (3), on a horseman (4)"
> > 
> > 
> > Note that it should be "horseman (4)" not "horse (4)man".
> 
>     my $n = 0;
>     s/(\w*horse\w*)/do { $n ++; "$1 ($n)"}/eg;

Thanks!

-- 
Sandman[.net]


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

Date: 3 Aug 2004 08:01:43 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: Counting occurances of string A in string B, and adding it to string B
Message-Id: <b893f5d4.0408030701.6b375e80@posting.google.com>

Sandman <mr@sandman.net> wrote in message news:<mr-CF69F0.12533903082004@individual.net>...
>
> Let's say I have a string that goes like this:
> 
>     "A horse is a horse is a horse, on a horseman"
> 
> Now, I would like add a number to each word that contains
> the string horse, and  this is where I am lost.
> Basically, what I want to output is this:
> 
>     "A horse (1) is a horse (2) is a horse (3), on a horseman (4)"
>
> Note that it should be "horseman (4)" not "horse (4)man". 
> Anyone got a juicy regexp for this? :)

   Yes!  You can use the /e and /g switches with s// to make a nice
elegant substitution:

      $_ = "A horse is a horse is a horse, on a horseman";
      $n = 0;
      s/\b(horse\w*)/"$1 (" . ++$n .")"/ge;

The s///ge line will find all words that begin with "horse" and
replace them with "[horse-word] (n)" (where n is a number that keeps
increasing).

   The /e switch is there so that the substitution expression is
evaluated before being substituted in the string.  The /g switch
exists so that the substitution happens more than just once.

   -- Jean-Luc


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

Date: Tue, 03 Aug 2004 15:07:54 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Counting occurances of string A in string B, and adding it to string B
Message-Id: <x7hdrkb6q2.fsf@mail.sysarch.com>

>>>>> "JR" == J Romano <jl_post@hotmail.com> writes:

  JR> Sandman <mr@sandman.net> wrote in message news:<mr-CF69F0.12533903082004@individual.net>...
  JR>    Yes!  You can use the /e and /g switches with s// to make a nice
  JR> elegant substitution:

  JR>       $_ = "A horse is a horse is a horse, on a horseman";
  JR>       $n = 0;
  JR>       s/\b(horse\w*)/"$1 (" . ++$n .")"/ge;

since you can put as much code as you want with /e (which uses the last
value of the code block), make it easier to read:

	s/\b(horse\w*)/$n++ ; "$1 ($n)"/ge;

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 26 Jul 2004 12:21:16 -0700
From: google@digitalbubblebath.com (Matt C)
Subject: CPAN install from a local directory
Message-Id: <c06931e3.0407261121.27816934@posting.google.com>

Hi All,

is it possible to have the CPAN util install packages from a local
dir, rather than a mirror?

I need to install an application on a load of client machines that
needs quite a few perl modules to do its thing.  I'd like to download
all the perl modules as tar.gz files and then put them on an install
cd with the other parts of the app.  I will script up a basic
installer that will, amoungst other things, install the perl mods onto
the target machine.

Can I get CPAN to do this for me?  Can I call it, tell it to install
and point it at the dir full of tar and gzipped perl mods?

Is there a better way to do this?

cheers in advance

matt


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

Date: 27 Jul 2004 10:43:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: CPAN install from a local directory
Message-Id: <ce5bju$dt9$1@mamenchi.zrz.TU-Berlin.DE>

Matt C <google@digitalbubblebath.com> wrote in comp.lang.perl.misc:
> Hi All,
> 
> is it possible to have the CPAN util install packages from a local
> dir, rather than a mirror?
> 
> I need to install an application on a load of client machines that
> needs quite a few perl modules to do its thing.  I'd like to download
> all the perl modules as tar.gz files and then put them on an install
> cd with the other parts of the app.  I will script up a basic
> installer that will, amoungst other things, install the perl mods onto
> the target machine.

You can use a local mirror.  Place a "file" URL that points to the
mirror in the urllist of your CPAN configuration.

Also consider building a bundle of the modules you want to install.

> Can I get CPAN to do this for me?  Can I call it, tell it to install
> and point it at the dir full of tar and gzipped perl mods?

Yes, as described in the CPAN doc.

Anno


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

Date: 28 Jul 2004 18:00:44 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: CPAN install from a local directory
Message-Id: <u9ekmwyslf.fsf@wcl-l.bham.ac.uk>

google@digitalbubblebath.com (Matt C) writes:

> is it possible to have the CPAN util install packages from a local
> dir, rather than a mirror?

You can put local directories to the list of repositories that CPAN.pm is
to use.  For details RTFM.
 
> I need to install an application on a load of client machines that
> needs quite a few perl modules to do its thing.  I'd like to download
> all the perl modules as tar.gz files and then put them on an install
> cd with the other parts of the app.  I will script up a basic
> installer that will, amoungst other things, install the perl mods onto
> the target machine.
> 
> Can I get CPAN to do this for me?  Can I call it, tell it to install
> and point it at the dir full of tar and gzipped perl mods?

You can create a "bundle" module that is nothing but a list of
dependancies and install that.

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


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

Date: 23 Jul 2004 16:32:13 -0700
From: jmcnamara@cpan.org (John McNamara)
Subject: Re: Creating Excel spreadsheet - Advanced question
Message-Id: <8cceb2da.0407231532.67a82069@posting.google.com>

Lance Powers wrote:

> Our next idea was to use the excellent Spreadsheet::WriteExcel to create 
> the entire spreadsheet (all worksheets) from scratch, but this module 
> does not have the ability to create graphs at this time.  Unfortunately, 
> I'm required to include the graphs.


I am the author of Spreadsheet::WriteExcel. I am currently trying to
implement charts in the module via external template files. The work
is at a very early stage and it may take 1-2 months before I have
functioning code. If you are interested you can subscribe to the
Freshmeat page for updates:

    http://freshmeat.net/projects/writeexcel/

John.
--


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

Date: Mon, 26 Jul 2004 11:46:46 -0700
From: Lance Powers <lance_powers@yahoo.com>
Subject: Re: Creating Excel spreadsheet - Advanced question
Message-Id: <41055197$1_3@corp.newsgroups.com>

Hi,

Thanks to all of you for your suggestions.  They have been helpful and 
appreciated.

ChrisO.  Your comments are understandable (and not taken as a personal 
attack).  We believe in using the best tool for the job and we have not 
completely ruled out using a Windows box if that is the best tool 
(although we'd rather avoid it for reasons explained below).

However, I don't think things are quite so black and white.  Although 
Excel is a Microsoft product, there are a few ways of writing Excel 
spreadsheets from Linux (like John's excellent Spreadsheet::WriteExcel 
module).  We're simply exploring all the possibilities, some of which 
may be unknown to us at this time and may be inexpensive and efficient.

Unfortunately, running a windows box does have costs above and beyond 
just the software and hardware FOR US.  It would add extra collocation 
costs (since we'd have to add a separate box to our rack just for this 
service - all of our other servers are Linux) as well as the admin costs 
of maintaining the Windows box.  Since all of us here are currently 
Linux Admins, it would require additional labor above and beyond our 
current(on an ongoing basis) to keep the box patched and running 
properly.  These costs would be ongoing, as opposed to a possible 
one-time cost for another solution.

Your suggestion is valid (and especially so for a mixed OS network), 
we're just hoping that we may find a cheaper or better solution for our 
situation.

> I am the author of Spreadsheet::WriteExcel. I am currently trying to
> implement charts in the module via external template files.

Thanks for the note John.  It's appreciated....and thanks for the module 
it's excellent!

-Lance


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 100,000 Newsgroups - 19 Different Servers! =-----


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

Date: Mon, 26 Jul 2004 15:03:29 -0500
From: l v <lv@aol.com>
Subject: Re: Creating Excel spreadsheet - Advanced question
Message-Id: <41056390$1_5@corp.newsgroups.com>

Lance Powers wrote:
> Hi,
> 
> Thanks to all of you for your suggestions.  They have been helpful and 
> appreciated.
> 
<sniped>

> Unfortunately, running a windows box does have costs above and beyond 
> just the software and hardware FOR US.  It would add extra collocation 
> costs (since we'd have to add a separate box to our rack just for this 
> service - all of our other servers are Linux) as well as the admin costs 
> of maintaining the Windows box.  Since all of us here are currently 
> Linux Admins, it would require additional labor above and beyond our 
> current(on an ongoing basis) to keep the box patched and running 
> properly.  These costs would be ongoing, as opposed to a possible 
> one-time cost for another solution.

Have you looked at VMware?  They offer workstation and server products 
which allow Linux servers to run virtual machines including Windows... 
No additional rack space.  I have not used the server versions but I 
have used the trial workstations hosted on Win XP with virtual Linux 
workstation.  I know the workstation can host on Linux, perhaps the 
server versions do as well.  It might be worth looking into.

> 
> -Lance
> 

Len


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 100,000 Newsgroups - 19 Different Servers! =-----


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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