[29068] in Perl-Users-Digest
Perl-Users Digest, Issue: 312 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 6 11:09:47 2007
Date: Fri, 6 Apr 2007 08:09:07 -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 Fri, 6 Apr 2007 Volume: 11 Number: 312
Today's topics:
Creating Word Documents with Perl <amerar@iwc.net>
HTML::template Module in perl <nitindutt2005@gmail.com>
Re: HTML::template Module in perl <xicheng@gmail.com>
Re: perl OOP <bik.mido@tiscalinet.it>
Re: perl OOP <bik.mido@tiscalinet.it>
Re: perl system command <rvtol+news@isolution.nl>
Re: perl system command xhoster@gmail.com
Re: profiling - analyse by time "on behalf of"? <brian.d.foy@gmail.com>
read path from a file keepyourstupidspam@yahoo.co.uk
Re: read path from a file <purlgurl@purlgurl.net>
Re: read path from a file keepyourstupidspam@yahoo.co.uk
Re: read path from a file keepyourstupidspam@yahoo.co.uk
Re: Testing against a list of values ? <hjp-usenet2@hjp.at>
Re: Testing against a list of values ? <uri@stemsystems.com>
Re: Use different modules based on variable <geoffrobinson@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Apr 2007 07:49:51 -0700
From: "amerar@iwc.net" <amerar@iwc.net>
Subject: Creating Word Documents with Perl
Message-Id: <1175870991.802942.126510@l77g2000hsb.googlegroups.com>
Hi All,
I need to create a Microsoft Word document on Perl. This will be on
a Linux Box.
The actual process is, I need the script to query a MySQL database and
get the data for the Word document, create the document, and email it.
The first and last steps are easy. I am lost on how to create the
Word document. And, as I mentioned, this is on a Linux box, not a
Windows box.....
Can anyone help???
Thanks!!
Art
------------------------------
Date: 6 Apr 2007 04:26:07 -0700
From: "andy" <nitindutt2005@gmail.com>
Subject: HTML::template Module in perl
Message-Id: <1175858767.865048.283820@y80g2000hsf.googlegroups.com>
I have a html file named test.tmpl and containing the below lines.
=====================================================================
<html>
<head>
<title>Song Listing</title>
</head>
<body>
<h1>My Songs</h1>
<tr>
<td valign="top">
<table width="150%" border="1" cellpadding="3"
cellspacing="1">
<tr height="20" style="font-size: 95%;"><td> </td></tr>
<tr height="20" style="font-size: 95%;"><td align="left"
valign="middle"><a href="TMPL_VAR NAME=SOME_DATA">NITIN</a></td></tr>
</table>
</td>
<table>
</BODY>
</HTML>
=====================================================================
I have a cgi script as below to open this tmpl file from the web
browser.
The cgi script is mentioned as below.
======================================================================
#!/usr/bin/perl -w
use strict;
use lib "site/lib/perl5/5.8.5/";
use lib "site/lib/perl5/5.8.5/i386-linux-thread-multi/";
use lib "site/lib/perl5/site_perl/5.8.5/";
use lib "site/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/";
use CGI::Pretty qw/:standard/;
use CGI;
use CGI::Session;
use HTML::Template;
my $site = "http://www.google.co.in";
my $cgi = new CGI;
print $cgi->header();
my $template = HTML::Template->new(filename => "//usr//local//apache2/
templates//test.tmpl");
$template->param(SOME_DATA=> $site);
print $template->output;
1;
======================================================================
My requirement is to link some other page like http://www.google.co.in
to the link in the main page "NITIN" AND i WANT TO USE HTML::TEMPLATE
FOR THIS BECAUSE I WILL BE LINKING A LOT OF THINGS IN THE SAME LINK IN
FUTURE.
But while running the script in the command line getting a error like
"
Content-Type: text/html; charset=ISO-8859-1
HTML::Template : Attempt to set nonexistent parameter 'some_data' -
this parameter name doesn't match any declarations in the template
file : (die_on_bad_params => 1) at 123.pl line 15
"
Can any body suggest me how to do this dynamic linking using
html::template module.
Or what is the eror in the script. where exactly the variable in
the .tmpl file is to be mentioned so that it will work.
regards
Nitin
------------------------------
Date: 6 Apr 2007 06:39:26 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: HTML::template Module in perl
Message-Id: <1175866766.860574.226010@d57g2000hsg.googlegroups.com>
On Apr 6, 4:26 am, "andy" <nitindutt2...@gmail.com> wrote:
> I have a html file named test.tmpl and containing the below lines.
> =====================================================================
> <html>
> <head>
> <title>Song Listing</title>
> </head>
> <body>
> <h1>My Songs</h1>
>
> <tr>
>
> <td valign="top">
> <table width="150%" border="1" cellpadding="3"
> cellspacing="1">
> <tr height="20" style="font-size: 95%;"><td> </td></tr>
>
> <tr height="20" style="font-size: 95%;"><td align="left"
> valign="middle"><a href="TMPL_VAR NAME=SOME_DATA">NITIN</a></td></tr>
change to:
<a href="<TMPL_VAR NAME=SOME_DATA>">NITIN</a>
Regards,
Xicheng
------------------------------
Date: Fri, 06 Apr 2007 13:45:22 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: perl OOP
Message-Id: <tvbc13h2c41ak0ohhcp3u4goau7m3vsape@4ax.com>
On Thu, 5 Apr 2007 22:20:38 -0500, Tad McClellan
<tadmc@augustmail.com> wrote:
>I was looking through someone else's list of Perlish quotes
>just earlier today, and lauching periodic gufaws over
>the cubicle wall:
>
> http://pq.tinita.de/?what=fortune
"tinita", eh? She must be <http://perlmonks.org/?node=tinita> (often
noticed the name in the "Other Users" nodelet) and in her home node I
can see a direct link to <http://www.perlquotes.de/>, which is
probably the preferable domain for the Perl quotes site.
>> - Alan J. Flavell in clpmisc, "Re: short script differences"
>
>
>God, I miss that man!
Me too. Seems people miss him much in other groups too, to which he
actively used to contribute.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 06 Apr 2007 13:47:00 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: perl OOP
Message-Id: <mncc13he170meicgkjfp60qd773pa900vc@4ax.com>
On Thu, 05 Apr 2007 14:01:34 +0200, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
>i've a grand scheme for a means for users to mail the authors of
>packages, which would be useful for users who want their mail address
>hidden. the problem with grand schemes is all those little devils
>that squirm out of the details...
>- Robin Fairbairns in clpmisc, "Re: CTAN has a new package: cool"
This is obviously misattributed to clpmisc, it should be ctt.
Correcting it on the fly!
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 6 Apr 2007 11:03:29 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: perl system command
Message-Id: <ev59li.108.1@news.isolution.nl>
keepyourstupidspam@yahoo.co.uk schreef:
> I am trying to run this command using system but it fails.
>
> gmake.exe -r -R --win32 --f makefile.mk 2>&1 | perl %SRC_DIR_XP%
> \scripts\tee.pl build.log
>
>
> @args1 = ("$SRC_DIR_XP\\make\\gmake.exe", "-r", "-R", "--win32",
> "--f", "$SRC_DIR_ISEE_NT\\makefile.mk", "2>&1", "|",
> "perl", "$SRC_DIR_XP\\scripts\\tee.pl", "build.log");
>
> system(@args1) == 0
> or die "system @args failed: $?";
>
> Anyone know how to get this to work?
Rewrite tee.pl to use open on the gmake, and deal with STDIN and STDERR
itself.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 06 Apr 2007 14:22:56 GMT
From: xhoster@gmail.com
Subject: Re: perl system command
Message-Id: <20070406102257.695$Ns@newsreader.com>
Tad McClellan <tadmc@augustmail.com> wrote:
> keepyourstupidspam@yahoo.co.uk <keepyourstupidspam@yahoo.co.uk> wrote:
> > Hi,
> >
> > I am trying to run this command using system but it fails.
> >
> > gmake.exe -r -R --win32 --f makefile.mk 2>&1 | perl %SRC_DIR_XP%
> > \scripts\tee.pl build.log
> >
> >
> > @args1 = ("$SRC_DIR_XP\\make\\gmake.exe", "-r", "-R", "--win32",
> > "--f", "$SRC_DIR_ISEE_NT\\makefile.mk", "2>&1", "|",
> > "perl", "$SRC_DIR_XP\\scripts\\tee.pl", "build.log");
> >
> > system(@args1) == 0
> > or die "system @args failed: $?";
>
> The "system PROGRAM LIST" (more that one argument) form of system()
> does not invoke a shell, so you cannot expect shell constructs,
> such as file redirection, to work.
Just a minor nit to pick. The "system PROGRAM LIST" form does not have a
comma between PROGRAM and LIST; it uses a syntax like print with a
filehandle does. And it does something different (lies about the program
name.)
The behavior you describe results from LIST having more than one element
(or being an array with more than one member), not from PROGRAM being
present.
I believe that the presence of PROGRAM and the difference in shell behavior
depending on the length of LIST are orthogonal features.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Fri, 06 Apr 2007 09:16:51 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: profiling - analyse by time "on behalf of"?
Message-Id: <060420070916510568%brian.d.foy@gmail.com>
In article <4610eb4d$0$8723$ed2619ec@ptn-nntp-reader02.plus.net>,
bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> I'm just trying to optimise some code.
>
> So I'm using profiling.
There are a couple of chapters about benchmarking and profiling in
_Mastering Perl_:
http://www.pair.com/comdog/mastering_perl
You can read the book online now, and it should ship in the next couple
of months.
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: 6 Apr 2007 05:09:46 -0700
From: keepyourstupidspam@yahoo.co.uk
Subject: read path from a file
Message-Id: <1175861386.598826.29300@d57g2000hsg.googlegroups.com>
Hi, I am reading a path from a file and want to set $ENV{'PATH'} with
this path. Then I call a command which will use this path, this
command happens to be gmake.exe but it fails.
Here is the path in the file:
PATH=C:\Program Files\Microsoft Visual Studio 8\VC\bin;C:\Program Files
\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft
Visual Studio 8\Common7\Tools\Bin;C:\Program Files\Microsoft Visual
Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\VC
\PlatformSDK\Bin;C:\bin\Perl\bin;C:\WINDOWS\system32
Here is my code that reads the Path from the file
foreach my $line (@lines) {
if ($line =~ /PATH=/) {
$path = substr($line,5);
$ENV{'PATH'} = "$path";
print "$path\n";
print "$ENV{'PATH'}"
}
}
But gmake.exe will fail, It will not fail If I hardcode the path in
the perl file but I need to read it from a file instead.
Anyone know what I am doing wrong?
Enda
------------------------------
Date: Fri, 06 Apr 2007 05:28:37 -0700
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: read path from a file
Message-Id: <R_GdncD1e6huoYvbnZ2dnUVZ_uiknZ2d@giganews.com>
keepyourstupidspam wrote:
> Here is the path in the file:
> PATH=C:\Program Files\Microsoft Visual Studio 8\VC\bin;C:\Program Files
> \Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft
> Visual Studio 8\Common7\Tools\Bin;C:\Program Files\Microsoft Visual
> Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\VC
> \PlatformSDK\Bin;C:\bin\Perl\bin;C:\WINDOWS\system32
Your example is not a path. I count seven paths.
> Here is my code that reads the Path from the file
> foreach my $line (@lines) {
>
> if ($line =~ /PATH=/) {
> $path = substr($line,5);
Your code does not open and read a file. Your code loops
through an array of unknown content.
Purl Gurl
------------------------------
Date: 6 Apr 2007 05:48:28 -0700
From: keepyourstupidspam@yahoo.co.uk
Subject: Re: read path from a file
Message-Id: <1175863708.552022.131180@e65g2000hsc.googlegroups.com>
On Apr 6, 1:28 pm, Purl Gurl <purlg...@purlgurl.net> wrote:
> keepyourstupidspam wrote:
> > Here is the path in the file:
> > PATH=C:\Program Files\Microsoft Visual Studio 8\VC\bin;C:\Program Files
> > \Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft
> > Visual Studio 8\Common7\Tools\Bin;C:\Program Files\Microsoft Visual
> > Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\VC
> > \PlatformSDK\Bin;C:\bin\Perl\bin;C:\WINDOWS\system32
>
> Your example is not a path. I count seven paths.
>
> > Here is my code that reads the Path from the file
> > foreach my $line (@lines) {
>
> > if ($line =~ /PATH=/) {
> > $path = substr($line,5);
>
> Your code does not open and read a file. Your code loops
> through an array of unknown content.
>
> Purl Gurl
Ok, I was leaving that to the imagination here is all the code..
my $pathFile="paths.dat";
open FILE, "<$pathFile" or die "ERROR $!";
my @lines = <FILE>;
foreach my $line (@lines) {
if ($line =~ /PATH=/) {
$path = substr($line,5);
$ENV{'PATH'} = "$path";
print "$path\n";
print "$ENV{'PATH'}"
}
}
close FILE;
Thanks,
Enda
------------------------------
Date: 6 Apr 2007 06:00:29 -0700
From: keepyourstupidspam@yahoo.co.uk
Subject: Re: read path from a file
Message-Id: <1175864429.786990.316360@p77g2000hsh.googlegroups.com>
On Apr 6, 1:48 pm, keepyourstupids...@yahoo.co.uk wrote:
> On Apr 6, 1:28 pm, Purl Gurl <purlg...@purlgurl.net> wrote:
>
>
>
>
>
> > keepyourstupidspam wrote:
> > > Here is the path in the file:
> > > PATH=C:\Program Files\Microsoft Visual Studio 8\VC\bin;C:\Program Files
> > > \Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft
> > > Visual Studio 8\Common7\Tools\Bin;C:\Program Files\Microsoft Visual
> > > Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\VC
> > > \PlatformSDK\Bin;C:\bin\Perl\bin;C:\WINDOWS\system32
>
> > Your example is not a path. I count seven paths.
>
> > > Here is my code that reads the Path from the file
> > > foreach my $line (@lines) {
>
> > > if ($line =~ /PATH=/) {
> > > $path = substr($line,5);
>
> > Your code does not open and read a file. Your code loops
> > through an array of unknown content.
>
> > Purl Gurl
>
> Ok, I was leaving that to the imagination here is all the code..
>
> my $pathFile="paths.dat";
>
> open FILE, "<$pathFile" or die "ERROR $!";
> my @lines = <FILE>;
>
> foreach my $line (@lines) {
>
> if ($line =~ /PATH=/) {
> $path = substr($line,5);
> $ENV{'PATH'} = "$path";
> print "$path\n";
> print "$ENV{'PATH'}"
> }
>
> }
>
> close FILE;
>
> Thanks,
> Enda- Hide quoted text -
>
> - Show quoted text -
I solved it by using chop to remove the last character from the string
I read from the file:
my $pathFile="paths.dat";
open FILE, "<$pathFile" or die "ERROR $!";
my @lines = <FILE>;
foreach my $line (@lines) {
if ($line =~ /PATH=/) {
$path = substr($line,5);
chop($path);
$ENV{'PATH'} = "$path";
print "$path\n";
print "$ENV{'PATH'}"
}
}
close FILE;
Bye,
Enda
------------------------------
Date: Fri, 6 Apr 2007 11:05:18 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Testing against a list of values ?
Message-Id: <slrnf1c3ae.1s2.hjp-usenet2@yoyo.hjp.at>
On 2007-04-06 00:31, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "R" == Ruud <rvtol+news@isolution.nl> writes:
>
> R> Uri Guttman schreef:
> >> a simple way to make a hash of keys with undef values is:
> >>
> >> my %isa_foo ;
> >> @isa_foo{ @values } = () ;
>
> R> IIRC there was a difference between the result of that and this:
>
> R> my %isa_foo ;
> R> @isa_foo{ @values } = () x @values ;
>
> R> (undef as status and undef as value)
>
> yep. you can tell the difference in the amount of storage used and
> probably with some internal probing with a scalar::util func or
> something.
I can't see a difference with perl 5.8.0 or 5.8.8 on Linux:
#!/usr/bin/perl
use warnings;
use strict;
my %x;
my (@a) = (1 .. $ARGV[1]);
my $m0 = mem();
if ($ARGV[0] eq '1') {
@x{@a} = (1) x @a;
} elsif ($ARGV[0] eq 'lx') {
@x{@a} = () x @a;
} elsif ($ARGV[0] eq 'le') {
@x{@a} = ();
}
print mem() - $m0, "\n";
sub mem {
open(my $f, '<', "/proc/$$/status");
while (<$f>) {
return $1 if (/VmSize:\s+(\d+) kB/);
}
}
yoyo:~/tmp 10:57 126% ./foo 1 100000
10520
yoyo:~/tmp 10:57 127% ./foo lx 100000
9116
yoyo:~/tmp 10:57 128% ./foo le 100000
9116
> and in both cases you test for a key in the set with exists. some like
> to assign 1 or some true value so they can just do a boolean test and
> drop the exists. either way is fine with me.
Assigning 1 does take a bit more memory.
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: Fri, 06 Apr 2007 10:45:28 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Testing against a list of values ?
Message-Id: <x7mz1l4l4n.fsf@mail.sysarch.com>
>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:
PJH> On 2007-04-06 00:31, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>>> "R" == Ruud <rvtol+news@isolution.nl> writes:
>>
R> Uri Guttman schreef:
>> >> a simple way to make a hash of keys with undef values is:
>> >>
>> >> my %isa_foo ;
>> >> @isa_foo{ @values } = () ;
>>
R> IIRC there was a difference between the result of that and this:
>>
R> my %isa_foo ;
R> @isa_foo{ @values } = () x @values ;
>>
R> (undef as status and undef as value)
>>
>> yep. you can tell the difference in the amount of storage used and
>> probably with some internal probing with a scalar::util func or
>> something.
PJH> I can't see a difference with perl 5.8.0 or 5.8.8 on Linux:
PJH> sub mem {
PJH> open(my $f, '<', "/proc/$$/status");
PJH> while (<$f>) {
PJH> return $1 if (/VmSize:\s+(\d+) kB/);
i wouldn't use a vmem thingy but try it with devel::size (iirc) which
will tell you the actual ram used by a perl structure.
>> and in both cases you test for a key in the set with exists. some like
>> to assign 1 or some true value so they can just do a boolean test and
>> drop the exists. either way is fine with me.
PJH> Assigning 1 does take a bit more memory.
so maybe it does use the undef flag in the hash entry in both cases. it
would be a nice optimization. i just recall they did different things
because of the generated code or whatever. in any case assigning an
empty list will be faster than making a list of undefs with x or map.
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: 6 Apr 2007 02:35:13 -0700
From: "geoffrobinson" <geoffrobinson@gmail.com>
Subject: Re: Use different modules based on variable
Message-Id: <1175852113.739595.72960@l77g2000hsb.googlegroups.com>
I know this is delayed, but I finally got around to try this out.
Worked well.
A belated thanks to everyone who replied within this thread.
>
> The main script:
>
> use Module_1 ();
> use Module_2 ();
>
> sub switch_version {
> my $version = shift;
> my @functions = qw( gick);
> for ( @functions ) {
> no strict 'refs';
> no warnings 'redefine';
> *$_ = \ &{ join '::', "Module_$version", $_ };
> }
> }
>
> switch_version 1;
> gick();
>
> switch_version 2;
> gick();
> __END__
>
> Module1.pm:
>
> package Module_1;
> use warnings; use strict;
>
> sub gick {
> print "this is version 1\n"
> }
> 1;
>
> Module2.pm
>
> package Module_2;
> use warnings; use strict;
>
> sub gick {
> print "this is version 2\n"
> }
> 1;
>
> Anno
------------------------------
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 V11 Issue 312
**************************************