[24676] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6838 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 5 18:06:19 2004

Date: Thu, 5 Aug 2004 15:05:10 -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           Thu, 5 Aug 2004     Volume: 10 Number: 6838

Today's topics:
    Re: @platforms = (sort keys %prj_platforms) || (DEFAULT <usenet@morrow.me.uk>
        [OT] Perl Developers Needed for Open-Source ATC! (Aquila Deus)
    Re: Breakpoint on a builtin? <nospam-abuse@ilyaz.org>
    Re: CGI help <jgibson@mail.arc.nasa.gov>
    Re: delimited data into nested array <usenet@morrow.me.uk>
    Re: delimited data into nested array <tassilo.von.parseval@rwth-aachen.de>
    Re: How can I get a nicer HTML output from POD parsers? <noreply@gunnar.cc>
    Re: How do I detect if I have incoming data in <STDIN>  <richard@zync.co.uk>
    Re: How do I detect if I have incoming data in <STDIN>  <noreply@gunnar.cc>
    Re: if ( $a eq 1 || $b eq 2...) <nobull@mail.com>
    Re: join on space instead of comma <andrewpalmer@email.com>
    Re: Lookuping IP address using four nameservers at the  <dwall@fastmail.fm>
    Re: Lookuping IP address using four nameservers at the  <regner@dievision.de>
        mkdir() fails to apply correct permissions (Randall Perry)
    Re: mkdir() fails to apply correct permissions (Randal L. Schwartz)
        Modify Excel <todd@no.spam>
    Re: name of perl jobs newsgroup? <sbryce@scottbryce.com>
        OpenOffice::OODoc 1.2 <jean.marie.gouarne@genicorp.fr>
        partially matching a regexp <Thomas.Koenig@online.de>
    Re: partially matching a regexp <nobull@mail.com>
    Re: recursive functions [Silly Joke] <jgibson@mail.arc.nasa.gov>
    Re: search/replace values from an array - Part 2. <jgibson@mail.arc.nasa.gov>
    Re: SOAP - undefined handler subroutine <spam@couts.org>
    Re: splitting paragraph into sentences <jgibson@mail.arc.nasa.gov>
        Use of freed value in iteration (Stuart Kendrick)
        WriteExcel internal hyperlink (Sean)
    Re: WriteExcel internal hyperlink <mritty@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 4 Aug 2004 19:56:58 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: @platforms = (sort keys %prj_platforms) || (DEFAULT);
Message-Id: <q4o7u1-b06.ln1@mauzo.dyndns.org>


Quoth Alexander.Farber@t-online.de (A. Farber):
> Hi,
> 
> I must confess, that I don't fully understand the 
> difference between an array and a list and suspect 
> that the cause for my problem lies somewhere there...
> 
> Could someone please explain, why does the code below warns 
> "Useless use of sort in scalar context at ./test_case.pl"?
> 
> #!/usr/bin/perl -w
> use constant DEFAULT => qw(ARMI ARM4 THUMB WINS WINSCW);
> @platforms = (sort keys %prj_platforms) || (DEFAULT);

|| evaluates its left arg (and, in older perls, its right arg as well)
in scalar context: it has to, it needs to get a boolean out of it.

You need to do

my @platforms = sort keys %prj_platforms;
@platforms or @platforms = DEFAULT;

or something instead.

Ben

-- 
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
  ben@morrow.me.uk                                                 (Kate Rusby)


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

Date: 5 Aug 2004 07:53:03 -0700
From: aquila_deus@yahoo.co.uk (Aquila Deus)
Subject: [OT] Perl Developers Needed for Open-Source ATC!
Message-Id: <c5cfac8f.0408050653.2cc054f2@posting.google.com>

Hi all!

The project MrATC (Air Traffic Control) needs more Perl developers.
We've done some discussion and begin to code and write doc, but there
are only 2 developers now (and one is a perl noob - me).

WE NEED YOUR HELP TO BUILD THE WORLD'S NEXT GENERATION OF AIR TRAFFIC
CONTROL SYSTEM IN PERL!

If you're interested, please visit
http://sourceforge.net/projects/mratc/

-- 
me = d2004xx = d2003xx = d2002xx


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

Date: Thu, 5 Aug 2004 19:59:00 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Breakpoint on a builtin?
Message-Id: <ceu3i4$21qq$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de>], who wrote in article <cespo4$5un$1@mamenchi.zrz.TU-Berlin.DE>:
> Keith NoSpam Arner  <spam.keith.me.arner.not@marconi.com> wrote in comp.lang.perl.misc:
>     # double braces indicate an un-indented block
>     {{
>     package CORE::GLOBAL;
>     use subs 'unlink';
>     sub unlink { CORE::unlink( @_) }
>     }}

Not enough.  One needs to special-case the 0-arguments case.  [See
Fatal for how to auto-implement this.]

Hope this helps,
Ilya


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

Date: Thu, 05 Aug 2004 09:51:34 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: CGI help
Message-Id: <050820040951348683%jgibson@mail.arc.nasa.gov>

In article <38f8b5b0.0408041937.276a3a62@posting.google.com>, Steve
<steve@foutty.org> wrote:

> I need to display a neighbor state from my Cisco routers on our
> internal website. What would be the easiest way to do this..

Write a CGI program (Perl recommended) that fetches the state from the
router, format it as an HTML document, and write it to standard output
from the CGI program. If you decide to use Perl, check out the CGI
module (try entering 'perldoc CGI' at a command line), or get ahold of
a copy of 'CGI Programming with Perl (2nd ed)', by Guelich, et. al.


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

Date: Wed, 4 Aug 2004 19:54:42 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: delimited data into nested array
Message-Id: <i0o7u1-b06.ln1@mauzo.dyndns.org>


Quoth yaweh32@yahoo.com (Yup):
> Hello,
> I'm just starting to learn Perl. Up until now I'd been struggling to
> learn how to import a tab-delimited data table (from a text file) into
> Perl as a two dimensional nested array. I wanted to be able to
> manipulate that data by accessing it using x-y coordinates, and then
> output it again.
> 
> I may have been looking in the wrong place, but I had a hard time
> finding help on Google groups and other places online. However, I've
> managed to figure it out, and thought I'd post my code.
> 
> For two reasons, I suppose - to help other novices, and perhaps get
> some comments from more advanced users. On the latter part, I'm
> interested in knowing what I could do to make my code run faster and
> make it more Perl-ish.
> 
> Thanks for your help ahead of time.
> 
> #!/usr/local/bin/perl -w

use strict;
use warnings;

warnings is a more modern replacement for -w: see perldoc warnings.
strict helps catch common coding errors.

> #define filename and open it
> $file = 'a1.txt';
> open(INFO, $file) || die "Can't open file $file\n" ;

open my $INFO, '<', $file or die "Can't open $file: $!";

The lexical FH ('my $INFO' vs simply 'INFO') means it will close when it
goes out of scope. The '<' protects against nasty filenames. Using 'or'
instead of '||' removes the need for brackets.

> # read file into temporary array called "lines"

my @lines;

as you are now using strictures.

> while(<INFO>)
> {
>     #chop off the carrage return
>     chop $_;

Use chomp instead of chop to remove newlines: you might be using "\r\n"
instead of just "\n".

>     push @lines, $_;
> }
> 
> # Close the file
> close(INFO);

This whole section can be compressed into

my @lines = do {
    open my $INFO, '<', $file or die "...";
    chomp <$INFO>;
};

<$INFO> in list context will return all the lines if the file.

> #reset index for generating arrays named "line_{$i}" 
> $i = 0;

my $i;

There is no need to initialize to 0.

> #read each array entry into new array, split with tab
> foreach (@lines)
> {

More usual style would be

for (@lines) {

>     push @{'line_'.${i}}, split("\t", $lines[$i]);

Ohmygoodnessme. These are 'symrefs', and are a *very* bad idea. They are
such a bad idea that 'use strict' will prevent you from using them. What
you want here is an array; and there's no need to keep count of your
array indices as $lines[$i] is already put in $_ by the 'for':

my @A;

# A better name than @A is probably appropriate...

for (@lines) {
    push @A, [ split "\t" ];
}

or, more Perlishly, you could use map:

my @A = map { [ split /\t/ ] }, @lines;

The [...] construct is an array ref constructor: see perldoc perlreftut.

>     $i++
> }
> 
> #generate an array to hold the other arrays
> for ($i=0; $i<scalar(@lines); $i++)

Don't use C-style loops. It's not good Perl style.

There's no need for that explicit 'scalar': $i < @lines will work
perfectly well.

> {
>     push @A, *{'line_'.${i}};

I'm slightly amazed this even works... I would have expected you to
needed to say *{...}{ARRAY}... anyway, it's YUCK. You shouldn't be
messing with globs (the '*' things) unless you *really* know what you're
doing.

You've already done this, now, anyway (one advantage of doing things
right in the first place :)...

> }
> 
> #rename the top corner to be START
> $A[0][0] = "START";
> 
> #open file to send data to
> open(OUTFILE, ">a1_edited.txt");

Output can fail too:

open my $OUTFILE, '>', 'a1_edited.txt' 
    or die "can't create a1_edited.txt: $!"

> for ($i=0; $i<scalar(@lines);$i++)
> {
> 
>     for ($j=0;$j<scalar(@line_0);$j++)
>     {
> 	print OUTFILE "$A[$i][$j]";

Don't quote things when you don't need to.

> 	if ($j<(scalar(@line_0)-1)) { print OUTFILE "\t";}
>     }
> 
>     print OUTFILE "\n";
> }

for (@A) {
    print $OUTFILE join( "\t" => @$_ ), "\n";
}

or even

print $OUTFILE join( "\n", map { join "\t" => @$_ } @A ), "\n";

or, using Perl's special output variables (this is how I'd do it):

{
    open my $OUTFILE, '>', '...' or die "...";
    local ($,, $\) = ("\t", "\n");
    print $OUTFILE @$_ for @A;
}

The 'local's keep the changes to $, and $/ to within the braces.

> close(OUTFILE);

Again, I would use a scope (set of braces) to close the file unless I
wanted to check for an error on close, which might be a good idea...

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

Date: Thu, 5 Aug 2004 21:41:59 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: delimited data into nested array
Message-Id: <2nfgs9Fd3d7U1@uni-berlin.de>

Also sprach Ben Morrow:

> Quoth yaweh32@yahoo.com (Yup):

>> while(<INFO>)
>> {
>>     #chop off the carrage return
>>     chop $_;
> 
> Use chomp instead of chop to remove newlines: you might be using "\r\n"
> instead of just "\n".
> 
>>     push @lines, $_;
>> }
>> 
>> # Close the file
>> close(INFO);
> 
> This whole section can be compressed into
> 
> my @lines = do {
>     open my $INFO, '<', $file or die "...";
>     chomp <$INFO>;
> };

This wont work. chomp() cannot work on lists, it needs a proper variable
as argument.

><$INFO> in list context will return all the lines if the file.

And even if chomp() could be used like that, it'd still do the wrong
thing. The 'do' block would return the return value of chomp() and not
the chomped lines.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Thu, 05 Aug 2004 14:59:37 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How can I get a nicer HTML output from POD parsers???
Message-Id: <2nepkpF346pU1@uni-berlin.de>

[ Didn't reply to the defunct group comp.lang.perl. ]

dede wrote:
> from using the tools pod2html and pod2htmltree I understand that I might add
> a stylesheet-file (*.css) to modify the appearance of the generated tags of
> the html-resultfiles. 
> 
> Now, what I would like to understand is how to use e.g.
> 
> - these fancy grey tables for code fragments (usually parsed with <pre>-tag) !

Have you studied "perldoc perlpod"?

> - colored boxes around the head1, head2 tags (like activestate) !

Can be done with style sheets.

> - special: embedd pictures (ie. GIF or JPG-links) !

Not sure.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Thu, 05 Aug 2004 17:17:49 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: How do I detect if I have incoming data in <STDIN> when I pipe   something to my perl script ?
Message-Id: <cetmjd$ttj$1@news.freedom2surf.net>

In article <cet96a$6it$1@newstree.wise.edt.ericsson.se>, "Andreas Berg"
<andreas.berg@ericsson.com> wrote:
<SNIP>
> The script will have command line parameters for other things and when I
> do not pipe something to the script, I dont want it to try to read these
>   command line parameters as if they where a file.

This will never happen, for exactly the reason you don't want it to
happen - they are two entirely different things. CLI parameters appear in
@ARGV, stdin appears on <STDIN>.


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

Date: Thu, 05 Aug 2004 15:20:59 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How do I detect if I have incoming data in <STDIN> when I pipe something   to my perl script ?
Message-Id: <2neqsuF3vviU1@uni-berlin.de>

Andreas Berg wrote:
> I'm writing a script that is supposed to fetch information from
> <STDIN> that is piped to the script, something like this:
> > cat file.txt | myscript.pl
> 
> With this, I will get what I want into <STDIN> and I can read it.
> But, this is the only case I want to read it. I do not want my
> script to try to read from a file in case I do have any command
> line paramters and I do not want the script to wait for keyboard
> input. If something is piped to the script, I want that data, if
> nothing is piped to the script, I dont want it to do anything with
> <STDIN>, how do I accomplish this ?

     unless (eof STDIN) {
         my $data = do { local $/; <STDIN> };
         # process data
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Thu, 05 Aug 2004 17:45:37 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: if ( $a eq 1 || $b eq 2...)
Message-Id: <ceto04$lec$1@sun3.bham.ac.uk>

>   if (
>            $req =~ /\.html$/ ||
>            $req =~ /\.pl$/ ||
>            $req =~ /\.shtml$/ ||
>            $req =~ /\.txt$/ ||
>            $req =~ /\.cgi$/ ||
>            $req =~ /\.cgi\?/ ||
>            $req =~ /\/\?/ ||
>            $req =~ /\/$/
> ) {
>       $countPage++;
> }

In addition to other ways you've been shown you can combine all the 
simple suffix ones

   $req =~ /\.(\w+)$/ && $suffix{$1}

But this is probably not worth it for only five suffixes.



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

Date: Thu, 5 Aug 2004 10:14:51 -0500
From: "Andrew Palmer" <andrewpalmer@email.com>
Subject: Re: join on space instead of comma
Message-Id: <67sQc.2288$zc1.152@fe40.usenetserver.com>

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:cer6vn$8is$1@mamenchi.zrz.TU-Berlin.DE...
> If you have to extract fields of fixed length at fixed positions,
> the unpack() function is the right tool.  It can extract multiple
> substrings in one step.
>
> "pack" and "unpack" and their formats are a sub-language of its own.
> No-one memorizes all of it, but a few idioms are worth memorizing.
> One is, to extract a substring of length $length at position $pos,
> the unpack template is "@${pos}a$length".  Putting it all together,
> your solution becomes

You don't need both a starting position and a string length for each field
(unpack() will pick up at the next field where it leaves off with the last).
If you need to strip trailing spaces, use capital "A" (which is meant for
extracting space-padded fields), rather than lowercase "a" (which is for
nul-terminated fields).


>
>     chomp( my @lines = <DATA>);
>     for ( @lines ) {
>         my @fields = unpack( '@7a7 @39a10 @63a*', $_);

For the data posted, the above happens to work the same, although this is my
preferred way:
my @fields = unpack( '@7 A32 A24 A*', $_);

>         print join( ', ', @fields), "\n";
>     }

(The "@7" is for the 7 spaces at the beginning of each line. Are they there
in the actual data, or was the example just indented?)





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

Date: Thu, 05 Aug 2004 13:46:58 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Lookuping IP address using four nameservers at the same time.
Message-Id: <Xns953C6383ADF3Ddkwwashere@216.168.3.30>

Gregory Toomey <nospam@bigpond.com> wrote in message
<news:2nefvmFvjjlsU2@uni-berlin.de>: 

> Tom Regner wrote:
> 
>> Facco Eloelo wrote:
>> 
> 
>>> Is there a tool (or just a perl script) which can set four
>>> nameservers(or more) *at the same time* to query?
>>> 
> ....
>> foreach (@dnss) {
>>     my $res = qx/nslookup -type=A $host $_/;
>>     (print $res and exit(0)) if $res;
>> }
>> 
> 
> The OP wants the results in parallel. This does it sequentially.

OK, this has little to do with Perl, but can someone explain to me why 
this makes a difference? Yes, I'm ignorant; that's why I asked. :-)



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

Date: Thu, 05 Aug 2004 15:58:47 +0200
From: Tom Regner <regner@dievision.de>
Subject: Re: Lookuping IP address using four nameservers at the same time.
Message-Id: <41123d0b$0$5987$4d3ebbfe@news1.pop-hannover.net>

David K. Wall wrote:
> Gregory Toomey <nospam@bigpond.com> wrote in message
> <news:2nefvmFvjjlsU2@uni-berlin.de>:
> 
>> Tom Regner wrote:
>> 
>>> Facco Eloelo wrote:
>>> 
>> 
>>>> Is there a tool (or just a perl script) which can set four
>>>> nameservers(or more) *at the same time* to query?
>>>> 
>> ....
>>> foreach (@dnss) {
>>>     my $res = qx/nslookup -type=A $host $_/;
>>>     (print $res and exit(0)) if $res;
>>> }
>>> 
>> 
>> The OP wants the results in parallel. This does it sequentially.
> 
> OK, this has little to do with Perl, but can someone explain to me why
> this makes a difference? Yes, I'm ignorant; that's why I asked. :-)

I guess because most of the time is spent waiting, that means 
sequentiell:

time = sum(each process);

parallel:
time = max(time(processes));

so despite the overhead in organizing parallel execution, you might save a
lot of time.

kind regards
Tom
-- 
Dievision GmbH | Kriegerstrasse 44 | 30161 Hannover
Telefon: (0511) 288791-0 | Telefax: (0511) 288791-99
http://www.dievision.de


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

Date: 5 Aug 2004 12:43:40 -0700
From: rgp@systame.com (Randall Perry)
Subject: mkdir() fails to apply correct permissions
Message-Id: <fac8f6c0.0408051143.67e07f5f@posting.google.com>

I've got a perl script, run by root, with the following command:
  mkdir("cgi-bin", 0770) || die "Couldn't create cgi-bin dir.\n";

The directory is created ok, but the perms are 0750 . Is this a perl
bug? I'm using 5.8.4.


Randy


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

Date: 05 Aug 2004 13:22:42 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: mkdir() fails to apply correct permissions
Message-Id: <86oelp49nx.fsf@blue.stonehenge.com>

>>>>> "Randall" == Randall Perry <rgp@systame.com> writes:

Randall> I've got a perl script, run by root, with the following command:
Randall>   mkdir("cgi-bin", 0770) || die "Couldn't create cgi-bin dir.\n";

Randall> The directory is created ok, but the perms are 0750 . Is this a perl
Randall> bug? I'm using 5.8.4.

The third parameter is not an absolute permission, but rather is
affected by the umask, as documented.  I suspect your current umask
includes the 020 bit.

print "Just another Perl hacker,"; # the original

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 05 Aug 2004 09:25:09 -0500
From: "Todd B." <todd@no.spam>
Subject: Modify Excel
Message-Id: <cetg06$9lp$1@home.itg.ti.com>

I have read the numerous questions about methods to modify an existing 
spreadsheet with Perl.  I would like to know what people have used as a 
solution on Unix (!=Win32::OLE).  I mean cases where ParseExcel and 
WriteExcel are unable to preserve the charts, macros, etc.  Did you have 
to resort to another language like Java or C++?

Thanks,

Todd B.


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

Date: Thu, 05 Aug 2004 10:47:10 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: name of perl jobs newsgroup?
Message-Id: <10h4p4bdl9fbm02@corp.supernews.com>

John W. Krahn wrote:

> perl.jobs

There is also alt.cgi.perl.freelance, but it is used more like a help 
desk than a jobs board. I don't think people are finding much work there.



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

Date: Thu, 5 Aug 2004 12:54:16 GMT
From: Jean-Marie Gouarné <jean.marie.gouarne@genicorp.fr>
Subject: OpenOffice::OODoc 1.2
Message-Id: <I1z845.JtI@zorch.sf-bay.org>

The new OpenOffice::OODoc distribution, V 1.203, is available from CPAN
today.

This pure Perl module allows direct read/write access to OpenOffice.org
files, without using the OpenOffice.org API. It provides an object
representation of the OOo documents, with a lot of methods to get,
create, update or delete any content or presentation element.

The most recent new features are:

- While the previous releases allowed only read/write operations in
previously existing documents, the present one can create new OOo
documents from scratch; the user has just to provide an additional
"create" option giving the document class in the main object
constructor. For ex, to create a new spreadsheet (i.e. OpenOffice Calc)
document that will be stored in a "doc.sxc" file, the constructor is:

	my $doc = ooDocument
			(
			file => "doc.sxc",
			create => "spreadsheet"
			);

The new documents are generated from a set of XML templates; if needed,
each application can select user-provided templates instead of the
default ones

- The createImageElement() method has been improved to allow easy image
import in drawing and presentation documents as well as in text or
spreadsheet documents. Ex:

	$doc->createImageElement
		(
		"Mountain",
		description	=> "The Kilimanjaro",
		page		=> 3,
		position	=> "4.2cm, 5cm"
		size		=> "3cm, 4cm",
		style		=> "MyGraphics"
		);

- The OOo date fields (stored in ISO-8601 format) can be easily
translated to/from Perl localtime() dates, due to new conversion functions;

- Symbolic color names (like "blue" or "yellow") and not only raw
hexadecimal RGB codes, are allowed for text and background colors. So,
to color in dark blue with a yellow background every paragraph or item
matching "OpenOffice" (or any other string or regex), the code is more
readable:

	# define the colored style
	$doc->createTextStyle
		(
		"Outstanding",
		properties	=>
		    {
		    'fo:color' => rgb2oo("dark blue"),
		    'fo:background-color' => rgb2oo("yellow")
		    }
		);
	# give the colored style to the selected elements
	$doc->setStyle($_, "Outstanding")
		for $doc->selectElementsByContent("OpenOffice");

- Bug fixes and functional improvements in the localization; the local
character sets seems to be properly supported; the user's local
character (iso-8859-1 by default) can be selected either at the
installation level or separately in each application.

The previous text-focused methods (search/replace/create/remove) are
unchanged.

Please see http://search.cpan.org/dist/OpenOffice-OODoc for details

Thanks for comments
JMG http://jean.marie.gouarne.online.fr




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

Date: Thu, 5 Aug 2004 20:15:19 +0200 (CEST)
From: Thomas Koenig <Thomas.Koenig@online.de>
Subject: partially matching a regexp
Message-Id: <cettfn$4o9$1@meiner.onlinehome.de>

Assume I have a regexp, /^(hello)|(goodbye)$/ for example.

I want to see wether a particular string matches part of that
particular regexp, so "", "h", "he", "hel", "hell", "hello", "g",
"go", "goo" "good", "goodb", "goodby" and "goodbye" would be ok,
and anything else wouldn't.

I could hand-craft this example easily enough, but it grows
tedious and error-prone for more general regular expressions,
and automation would be much preferred.

Ideas?


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

Date: Thu, 05 Aug 2004 19:33:37 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: partially matching a regexp
Message-Id: <cetuaf$on8$1@sun3.bham.ac.uk>



Thomas Koenig wrote:
> Assume I have a regexp, /^(hello)|(goodbye)$/ for example.
> 
> I want to see wether a particular string matches part of that
> particular regexp, so "", "h", "he", "hel", "hell", "hello", "g",
> "go", "goo" "good", "goodb", "goodby" and "goodbye" would be ok,
> and anything else wouldn't.
> 
> I could hand-craft this example easily enough, but it grows
> tedious and error-prone for more general regular expressions,
> and automation would be much preferred.
> 
> Ideas?

Take a look at the source of File::Stream.  A very similar problem is 
solved in File::Stream::find and the solution to that problem could 
probably be easily be adapted (simplified!) to solve your problem.



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

Date: Thu, 05 Aug 2004 10:12:43 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: recursive functions [Silly Joke]
Message-Id: <050820041012434845%jgibson@mail.arc.nasa.gov>

In article <411220b0$0$5987$4d3ebbfe@news1.pop-hannover.net>, Tom
Regner <regner@dievision.de> wrote:

> steve_f wrote:
> > I could never really wrap my mind around the concept
> > of recursive functions. 
> That's because: 
> To Know Recursion, You Must First Know Recursion...

Dictionary entry:

recursion. n. [L. recursio] See recursion.


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

Date: Thu, 05 Aug 2004 12:54:30 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: search/replace values from an array - Part 2.
Message-Id: <050820041254303730%jgibson@mail.arc.nasa.gov>

In article <mr-540942.13322402082004@individual.net>, Sandman
<mr@sandman.net> wrote:

> In article <2n6l7qFt2pvlU1@uni-berlin.de>,
>  Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> 
> > > foreach (keys %array){
> > >     if ($string=~m/$_/i){
> > >         # It matched!
> > >         
> > >         $array{$_}=~s/#(\d+)#/$$1/;
> > >         # replace #1# with $1, #2# with $2
> > >         # from the match above
> > 

> > 
> > You need to store what was captured from the first match somewhere, 
> > i.e. in a hash:
> > 
> >          my %captures = (
> >              1 => $1,
> >          );
> >          $array{$_} =~ s/#(\d+)#/$captures{$1}/;

You can save multiple captures in an array:

   my @captures  = ( $string =~ m/$_/i );

and use them with indexing (remembering to decrement by one):

   my $replace = $array{$_};
   $replace =~ s/#(\d+)#/$captures[$1-1]/g;


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

Date: Thu, 05 Aug 2004 14:18:09 GMT
From: Aaron Couts <spam@couts.org>
Subject: Re: SOAP - undefined handler subroutine
Message-Id: <slrnch4gd1.lag.spam@waimea.local>

In article <ceq7m4$fhf$2@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel wrote:
> This defines a sub "handler" in package ServerDemo.  You need one
> in SOAP::ServerDemo.
> 
> Anno

It turns out this wasn't my only problem, but it put me on the right track.
Thanks for the response.
-Aaron

-- 
To contact me via email, substitute 
'aaronc' for 'spam' in my address.
http://www.towerdata.com


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

Date: Thu, 05 Aug 2004 12:57:14 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: splitting paragraph into sentences
Message-Id: <050820041257143589%jgibson@mail.arc.nasa.gov>

In article <mr-45EE5E.14481002082004@individual.net>, Sandman
<mr@sandman.net> wrote:

> 
> Thanks again Gunnar, I didn't even know you could do a look-behind. I ddidn't 
> find it documented anywhere I looked.

Do 'perldoc perlre' and search for 'look-behind'.


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

Date: 5 Aug 2004 06:43:24 -0700
From: skendric@fhcrc.org (Stuart Kendrick)
Subject: Use of freed value in iteration
Message-Id: <62dbf7f1.0408050543.70e21ec9@posting.google.com>

hi folks,

i don't understand why Perl bombs with 'Use of freed value in
iteration' in my code below... i don't see where i'm modifying the
contents of %esx in my loop.  can anyone see what i'm missing?

guru> cat test
#!/opt/local/bin/perl

use strict;
use warnings;
use SNMP;

my $obj = "sysDescr";
my $read = "public";
my ($sess, $val, $vb);

my %esx = (     "10.10.22.8" => "b2-esx",
                "10.10.16.8" => "a1-esx",
                "10.10.18.8" => "a2-esx",
                "10.10.20.8" => "a3-esx",
           );

for my $addr (keys %esx) {
  print "Processing $addr\n";
  $sess = new SNMP::Session (     Community     =>  $read,
                                  DestHost      =>  $addr,
                             );
  $vb = new SNMP::Varbind([$obj]);
  $val = $sess->bulkwalk('0', '10000', $vb);
  print "Finished $addr\n";
}

guru> ./test
Processing 10.10.18.8
Finished 10.10.18.8
Processing 10.10.22.8
Finished 10.10.22.8
Use of freed value in iteration at ./test line 24.
guru> 

Notes:

-line 24 is the 'print "Finished $addr\n";' line.

-naturally, im my real code, i'm not performing snmpbulkwalks on
sysDescr ... but this snippet replicates the problem and produces much
simpler output.

-perl 5.8.5, net-snmp 5.0.9


--sk

stuart kendrick
fhcrc


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

Date: 5 Aug 2004 07:31:09 -0700
From: deng0007@mc.duke.edu (Sean)
Subject: WriteExcel internal hyperlink
Message-Id: <3298858c.0408050631.6a836435@posting.google.com>

I got a question about creating hyperlinks to internal worksheet
references using Spreadsheet::WriteExcel;.

$worksheet->write_url('A6',  'internal:Sheet2!A1'); # works with
constant.

My question is whether or not the cell reference is variable
interpolated as follows:
$whichcell = A1;
$worksheet->write_url('A6',  'internal:Sheet2!$whichcell');

I tried but it cound not create the hyperlink. Anybody know if there
is a way to assign cell to the hyperlink at the run time using a
variable instead of a constant string?

thanks

Sean


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

Date: Thu, 5 Aug 2004 10:36:55 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: WriteExcel internal hyperlink
Message-Id: <20040805103556.I4433@barbara.cs.rpi.edu>

On Thu, 5 Aug 2004, Sean wrote:

> I got a question about creating hyperlinks to internal worksheet
> references using Spreadsheet::WriteExcel;.
>
> $worksheet->write_url('A6',  'internal:Sheet2!A1'); # works with
> constant.
>
> My question is whether or not the cell reference is variable
> interpolated as follows:
> $whichcell = A1;
> $worksheet->write_url('A6',  'internal:Sheet2!$whichcell');
>
> I tried but it cound not create the hyperlink. Anybody know if there
> is a way to assign cell to the hyperlink at the run time using a
> variable instead of a constant string?

I know nothing about this module, but by any chance did you try to
actually interpolate the variable?  As in, use a double quoted string
rather than single quotes?  That's a Perl standard. . . .


Paul Lalli


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

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


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