[29793] in Perl-Users-Digest
Perl-Users Digest, Issue: 1036 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 15 14:10:24 2007
Date: Thu, 15 Nov 2007 11:09:17 -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, 15 Nov 2007 Volume: 11 Number: 1036
Today's topics:
Re: 100% cpu loop of time() ... xhoster@gmail.com
Re: Automatic document generation <bik.mido@tiscalinet.it>
Re: Automatic document generation <paduille.4061.mumia.w+nospam@earthlink.net>
Re: Binary to Decimal for >2**32 <paduille.4061.mumia.w+nospam@earthlink.net>
Re: Binary to Decimal for >2**32 <usenet05@drabble.me.uk>
Re: Binary to Decimal for >2**32 <paduille.4061.mumia.w+nospam@earthlink.net>
Connector Macro Help joey_costanza@msn.com
Re: Connector Macro Help <SubstituteMyFirstNameHere@pherber.com>
Counting the repetition count of repeated substrings <bik.mido@tiscalinet.it>
Re: error in tkGlue.c when building Tk mariakvelasco@gmail.com
Re: error in tkGlue.c when building Tk mariakvelasco@gmail.com
Re: how to check whether the field is filled or empty i <hara.acharya@gmail.com>
Perlscript asp object syntax problem <lesliewbell@gmail.com>
Re: Perlscript asp object syntax problem <paduille.4061.mumia.w+nospam@earthlink.net>
Re: Rename files using directory names <krahnj@telus.net>
Re: Two Perl programming questions <bik.mido@tiscalinet.it>
Re: Two Perl programming questions <TimKnoll@gmail.com>
Re: Two Perl programming questions <mritty@gmail.com>
Re: Two Perl programming questions <TimKnoll@gmail.com>
Re: Two Perl programming questions <jurgenex@hotmail.com>
Re: Two Perl programming questions <TimKnoll@gmail.com>
Re: Two Perl programming questions <TimKnoll@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Nov 2007 17:06:25 GMT
From: xhoster@gmail.com
Subject: Re: 100% cpu loop of time() ...
Message-Id: <20071115120626.768$86@newsreader.com>
Yakov <iler.ml@gmail.com> wrote:
> One perl daemon happens to go sometimes into 100% cpu state.
> When I do strace or ltrace on it, I see infinite sequence of time()
> calls,
> and nothing in between.
>
> But the source code, although has couple of calls to time(), nowhere
> has possibility of infinite lop of time(). I wonder whether perl
> interpreter can be doing this inside it, maybe restarting on signals
> or something ?
If it were restarting on signals, then the signal events should be evident
in the strace along with the "time" calls.
> The code is single-threaded. Wrt to signals, it either
> ignores
> signals, or dies on signals.
Does it do any forking, either explicit or implicit (implicit meanings
with back-ticks, system, piped open, etc.)
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Thu, 15 Nov 2007 15:56:55 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Automatic document generation
Message-Id: <7cnoj3lgvncbv8cpenpf0p5mbkrdua4g7g@4ax.com>
On Thu, 15 Nov 2007 04:06:44 -0500, Sherman Pendley
<spamtrap@dot-app.org> wrote:
>"A. Sinan Unur" <1usa@llenroc.ude.invalid> writes:
>
>> howa <howachen@gmail.com> wrote in news:25a3dadf-c212-452f-ac08-
>> 46f9fbdb6da0@s19g2000prg.googlegroups.com:
>>
>>> Anyone is using automatic document generation in Perl (like Javadoc,
>>> which generate HTML pages for API references)
>>>
>>> Any suggestions?
>>
>> perldoc perlpod
>
>Also:
>
> perldoc pod2html
> perldoc pod2latex
> perldoc pod2man
> perldoc pod2text
In addition to good ol' POD, at the following link you'll find some
pointers to alternatives, including a way to use Doxygen with Perl and
POD:
http://perlmonks.org/?node_id=604671
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: Thu, 15 Nov 2007 09:07:06 -0600
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Automatic document generation
Message-Id: <13josnsek2vdq05@corp.supernews.com>
On 11/14/2007 08:41 PM, howa wrote:
> Hello,
>
> Anyone is using automatic document generation in Perl (like Javadoc,
> which generate HTML pages for API references)
>
> Any suggestions?
>
You can use Pod::Html to help with this.
------------------------------
Date: Thu, 15 Nov 2007 09:22:58 -0600
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Binary to Decimal for >2**32
Message-Id: <13josnthp90su07@corp.supernews.com>
On 11/14/2007 02:45 PM, Graham Drabble wrote:
> Hi all,
>
> I have been using a binary to decimal converter for number <2**16 for
> a while now using
>
> $bin = sprintf("%016b",$dec)
>
> which works fine.
>
> I've now had to try and do the same conversion for numbers up to 2**
> 48 and have discovered that this does not work for numbers >=2**32
> (everything >=2**32 returns the same as (2**32)-1 ).
>
> I'm currently getting round this with
>
> use strict;
> use warnings;
> use Math::BigInt;
>
> my $num = new Math::BigInt 2**47 + 2**31 + 2**30;
> if ($num >= 2**32){
> my $upper = int($num / (2**32));
> my $lower = $num % 2**32;
>
> $upper = sprintf ("%016b",$upper);
> $lower = sprintf ("%032b",$lower);
> print "$upper$lower\n";
> }
> else
> {
> printf ("%048b\n",$num);
> }
>
> Which works but seems very inelegant. Does anyone have a better
> suggestion?
>
> Also hex() returns a warning when given a hex string >2**32 but
> returns the correct result. Is this something that can be relied on
> or do I need to find a work around for that as well?
>
Use the 'as_bin' method, e.g.:
my $num = new Math::BigInt 2**47 + 2**31 + 2**30;
print $num->as_bin, "\n";
The output will be prefixed with "0b" which you can remove.
------------------------------
Date: Thu, 15 Nov 2007 17:40:36 +0100
From: Graham Drabble <usenet05@drabble.me.uk>
Subject: Re: Binary to Decimal for >2**32
Message-Id: <Xns99E9B3D118357grahamdrabblelineone@ID-77355.user.dfncis.de>
On 15 Nov 2007 "Mumia W."
<paduille.4061.mumia.w+nospam@earthlink.net> wrote in
news:13josnthp90su07@corp.supernews.com:
> Use the 'as_bin' method, e.g.:
>
> my $num = new Math::BigInt 2**47 + 2**31 + 2**30;
> print $num->as_bin, "\n";
>
> The output will be prefixed with "0b" which you can remove.
D'oh. Very much simpler thanks. Need to pad it out to 48bits as well
but that's trivial.
Anyone got any advice regarding a substitute for hex()? Whilst it works
on all the environments I see I don't like to rely on something working
when the docs say it won't and the error message will worry users.
Unfortunately using 64bit Perl isn't an option.
--
Graham Drabble
http://www.drabble.me.uk/
------------------------------
Date: Thu, 15 Nov 2007 12:15:21 -0600
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Binary to Decimal for >2**32
Message-Id: <13jp36qadjsdu5a@corp.supernews.com>
On 11/15/2007 10:40 AM, Graham Drabble wrote:
> [...]
> Anyone got any advice regarding a substitute for hex()? Whilst it works
> on all the environments I see I don't like to rely on something working
> when the docs say it won't and the error message will worry users.
> Unfortunately using 64bit Perl isn't an option.
>
my $num2 = Math::BigInt->new('0x8000c0000000');
print $num2, "\n";
:-)
I hope I made your day a little brighter.
------------------------------
Date: Thu, 15 Nov 2007 08:54:29 -0800 (PST)
From: joey_costanza@msn.com
Subject: Connector Macro Help
Message-Id: <db0e3533-c533-4a93-92d9-f633f206381e@i29g2000prf.googlegroups.com>
Hello Everyone,
I am very stuck and I was wondering if any of you could give me a
hand. I'm trying to write a Perl or VB script to connect some
rectangles in Visio with a 'connector'. I have found there is very
little help online in the way of making Visio macros with Perl. I have
found Perl can translate directly in to Visual Basic in most cases by
substituting "->" in for ".". For some reason, however, I am not able
to say
$Visio->ActivePage->Drop($Visio->ConnectorToolDataObject, 2, 2);
where $Visio is the Visio Application. I am using the Win32::OLE
library by the way.
Fortunatly, I am able to connect the shapes with the connector by
having it select the two rectangles and using
$Visio->ActiveWindow->Select($square1, 2);
$Visio->ActiveWindow->Select($square2, 2);
$Visio->ActiveWindow->Selection->ConnectShapes;
Anyway...my main goal is to change the color of the connector. Is
there anyway to do this by way of the method I am using. I think I
need to set the connector it created equal to a variable somehow, that
way I can use the $connector->cells("LineColor")->{Formula} = color. I
am not currently sure how to define it. I was hoping one of you would
know some clever way to do it. If you know how to do this in VB,
without using the Drop way I would REALLY appriciate it, and hopefully
I will be able to translate it to Perl. I've been going around in
circles about this for days. If you know how to use the Drop way I
talked about above in Perl, first, you are awesome, second can you
please tell me how?
If you know the answer to this, seriously you are a genious.
Thanks,
Joe
------------------------------
Date: Thu, 15 Nov 2007 17:18:09 +0000
From: Paul Herber <SubstituteMyFirstNameHere@pherber.com>
Subject: Re: Connector Macro Help
Message-Id: <lgvoj3dv3b750dfd3fii1k44v7lp8ov6hu@news.gradwell.net>
On Thu, 15 Nov 2007 08:54:29 -0800 (PST), joey_costanza@msn.com wrote:
>Hello Everyone,
>I am very stuck and I was wondering if any of you could give me a
>hand. I'm trying to write a Perl or VB script to connect some
>rectangles in Visio with a 'connector'. I have found there is very
>little help online in the way of making Visio macros with Perl. I have
>found Perl can translate directly in to Visual Basic in most cases by
>substituting "->" in for ".". For some reason, however, I am not able
>to say
>
>$Visio->ActivePage->Drop($Visio->ConnectorToolDataObject, 2, 2);
>where $Visio is the Visio Application. I am using the Win32::OLE
>library by the way.
>
>Fortunatly, I am able to connect the shapes with the connector by
>having it select the two rectangles and using
>
>$Visio->ActiveWindow->Select($square1, 2);
>$Visio->ActiveWindow->Select($square2, 2);
>$Visio->ActiveWindow->Selection->ConnectShapes;
The ConnectShapes method will return an object, the shape object of
your new connector. This will be your $connector.
(I haven't tried or checked this.)
>Anyway...my main goal is to change the color of the connector. Is
>there anyway to do this by way of the method I am using. I think I
>need to set the connector it created equal to a variable somehow, that
>way I can use the $connector->cells("LineColor")->{Formula} = color.
use an RGB(r,g,b) string for your colour.
--
Regards, Paul Herber, Sandrila Ltd.
Electronics for Visio http://www.electronics.sandrila.co.uk/
------------------------------
Date: Thu, 15 Nov 2007 16:38:23 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Counting the repetition count of repeated substrings
Message-Id: <ahpoj310dn0ijtbril6k60d7dvo45np5t3@4ax.com>
This is the subject of the following PM node:
http://perlmonks.org/?node_id=650761
I am the author of the node and to briefly summarize, the problem is:
"to calculate the repetition count of repeated substrings of length 2
or more of a given string."
Currently, the most interesting code suggestions are within the
respective subs of the following benchmark:
(For definiteness the subs take the given string as an argument and
return a hashref of the counts.)
#!/usr/bin/perl
use strict;
use warnings;
use constant MIN => 2;
use Benchmark qw/:all :hireswallclock/;
my $str='aabcdabcabcecdecd';
sub oha {
my $s=shift;
my %saw;
while($s =~ /(..+)(?=.*?\1)/g) {
for my $x (0..length $1) {
@saw{ map {substr $1, $x, $_} $x+2..length $1 } = ();
}
}
$saw{$_} =()= $s =~ /\Q$_/g for keys %saw;
\%saw;
}
sub kramba {
my %count;
my $count;
$count = sub {
my( $string) = @_;
my $length = length( $string );
if ($length < MIN) {
$count{$_} == 1 and delete $count{$_} for keys %count;
return \%count;
}
for my $l (MIN..$length) {
my $s = substr( $string, 0, $l );
$count{ $s } += 1;
}
$count->( substr( $string, 1 ) );
};
$count->(shift);
for (keys %count) {
delete $count{$_} unless
$count{$_} >= 2 and length($_) >= MIN;
}
\%count;
}
sub ikegami {
my $str = shift;
local our %counts;
$str =~ /
(.{2,}) # or (.+)
(?(?{ !$counts{$1} })(?=.*\1))
(?{ ++$counts{$1} })
(?!)
/x;
\%counts;
}
sub lodin {
my $str = shift;
local our %count;
$str =~ /
(.{2,})
(?(?{ $count{$1} })
(?!)
)
.*
\1
(?{ ($count{$1} ||= 1)++ })
(?!)
/x;
\%count;
}
cmpthese 10_000 => {
oha => sub { oha $str },
kramba => sub { kramba $str },
ikegami => sub { ikegami $str },
lodin => sub { lodin $str },
};
__END__
Note: benchmarking is interesting but I'm also interested in other
charachteristics, e.g. readability, intuitiveness and so on.
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: Thu, 15 Nov 2007 07:26:56 -0800 (PST)
From: mariakvelasco@gmail.com
Subject: Re: error in tkGlue.c when building Tk
Message-Id: <b5e319df-32d4-4aee-90c4-869cf5acf736@d4g2000prg.googlegroups.com>
On Nov 13, 3:52 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth mariakvela...@gmail.com:
>
>
>
> > We are trying to install Tk-804.027_501 on Solaris 10 using Perl
> > version 5.8.4. We were able to create the makefile through the command
> > perl Makefile.PL; however, when running make, we are getting errors
> > regarding the file tkGlue.c
>
> > tkGlue.c: In function `do_comp':
> > tkGlue.c:5250: warning: passing arg 1 of `Perl_pregcomp' from
> > incompatible pointer type
> > tkGlue.c:5250: warning: passing arg 2 of `Perl_pregcomp' makes pointer
> > from integer without a cast
> > tkGlue.c:5250: too few arguments to function `Perl_pregcomp'
>
> This is typically the result of an ithreads/no-ithreads mismatch. Do you
> have some other version of perl whose headers are being picked up by
> accident? Is your perl built for threads (or rather, for multiplicity;
> check with perl -V:useithreads -V:usemultiplicity).
>
> > tkGlue.c: In function `Tcl_GetRegExpFromObj':
> > tkGlue.c:5319: `RXf_UTF8' undeclared (first use in this function)
> > tkGlue.c:5319: (Each undeclared identifier is reported only once
> > tkGlue.c:5319: for each function it appears in.)
> > tkGlue.c:5319: `RXf_PMf_FOLD' undeclared (first use in this function)
>
> RXf_* are new in bleadperl, they aren't present in any version of 5.8.
> Do you have 5.9.* or perl-current installed anywhere? Does your
> pTk/tkConfig.h contain the line
>
> #define HAS_PMOP_EXTRA_FLAGS 1
>
> ? What happens if you run
>
> perl -I. -MConfig -MTk::MMtry -e'
> $Tk::MMtry::VERBOSE = 1;
> try_compile("config/pmop.c", ["-I$Config{archlibexp}/CORE"])
> or die "try_compile failed: $?";'
>
> (all on one line, of course)? What does perl -V:archlibexp print? Is
> that correct (it should be the path to your arch-specific perl core lib
> directory, something like /usr/lib/perl5/5.8.4/sun4-solaris)?
>
> Ben
Hello,
Here are our results:
1.) After typing the command perl -V:useithreads -V:usemultiplicity
------------------------------
Date: Thu, 15 Nov 2007 07:36:17 -0800 (PST)
From: mariakvelasco@gmail.com
Subject: Re: error in tkGlue.c when building Tk
Message-Id: <f99d83b6-8a7f-4aef-8f58-065504ff52f2@b40g2000prf.googlegroups.com>
On Nov 15, 7:26 am, mariakvela...@gmail.com wrote:
> On Nov 13, 3:52 pm, Ben Morrow <b...@morrow.me.uk> wrote:
>
>
>
>
>
> > Quoth mariakvela...@gmail.com:
>
> > > We are trying to install Tk-804.027_501 on Solaris 10 using Perl
> > > version 5.8.4. We were able to create the makefile through the command
> > > perl Makefile.PL; however, when running make, we are getting errors
> > > regarding the file tkGlue.c
>
> > > tkGlue.c: In function `do_comp':
> > > tkGlue.c:5250: warning: passing arg 1 of `Perl_pregcomp' from
> > > incompatible pointer type
> > > tkGlue.c:5250: warning: passing arg 2 of `Perl_pregcomp' makes pointer
> > > from integer without a cast
> > > tkGlue.c:5250: too few arguments to function `Perl_pregcomp'
>
> > This is typically the result of an ithreads/no-ithreads mismatch. Do you
> > have some other version of perl whose headers are being picked up by
> > accident? Is your perl built for threads (or rather, for multiplicity;
> > check with perl -V:useithreads -V:usemultiplicity).
>
> > > tkGlue.c: In function `Tcl_GetRegExpFromObj':
> > > tkGlue.c:5319: `RXf_UTF8' undeclared (first use in this function)
> > > tkGlue.c:5319: (Each undeclared identifier is reported only once
> > > tkGlue.c:5319: for each function it appears in.)
> > > tkGlue.c:5319: `RXf_PMf_FOLD' undeclared (first use in this function)
>
> > RXf_* are new in bleadperl, they aren't present in any version of 5.8.
> > Do you have 5.9.* or perl-current installed anywhere? Does your
> > pTk/tkConfig.h contain the line
>
> > #define HAS_PMOP_EXTRA_FLAGS 1
>
> > ? What happens if you run
>
> > perl -I. -MConfig -MTk::MMtry -e'
> > $Tk::MMtry::VERBOSE = 1;
> > try_compile("config/pmop.c", ["-I$Config{archlibexp}/CORE"])
> > or die "try_compile failed: $?";'
>
> > (all on one line, of course)? What does perl -V:archlibexp print? Is
> > that correct (it should be the path to your arch-specific perl core lib
> > directory, something like /usr/lib/perl5/5.8.4/sun4-solaris)?
>
> > Ben
>
> Hello,
>
> Here are our results:
>
> 1.) After typing the command perl -V:useithreads -V:usemultiplicity- Hide quoted text -
>
> - Show quoted text -
Sorry about the previous post.
Let me continue...
1.) After typing the command perl -V:useithreads -V:usemultiplicity
root % perl -V:useithreads -V:usemultiplicity
useithreads='undef';
usemultiplicity='undef';
Does this mean the perl was built for neither threads or multiplicity?
2.) It looks as if we have the following versions of Perl installed:
5.6.1, 5.8.3, 5.8.4, but not 5.9.*
3.) The file pTk/tkConfig.h does not contain the line #define
HAS_PMOP_EXTRA_FLAGS 1
4.) After running the following
usir-solaris:root % perl -I. -MConfig -MTk::MMtry -e'
$Tk::MMtry::VERBOSE = 1; try_compile("config/pmop.c", ["-I
$Config{archlibexp}/CORE"]) or die "try_compile failed: $?";'
This is the result we get:
Can't locate Tk/MMtry.pm in @INC (@INC contains: . /usr/perl5/5.8.4/
lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/
sun4-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl/
5.8.4/sun4-solaris-64int /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/
perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/
perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/
5.8.4/sun4-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/
vendor_perl .).
BEGIN failed--compilation aborted.
5.) After running the command perl -V:archlibexp we get the following:
root % perl -V:archlibexp
archlibexp='/usr/perl5/5.8.4/lib/sun4-solaris-64int';
Can anyone see the cause of our problem from the information
provided? Thanks so much for the help.
Note: Ben, I think I emailed you with the same information I wrote
above.
Thanks again!
------------------------------
Date: Thu, 15 Nov 2007 07:17:48 -0800 (PST)
From: king <hara.acharya@gmail.com>
Subject: Re: how to check whether the field is filled or empty in perl TK
Message-Id: <ad845d06-7c41-43f2-9b7c-11b57d1c664b@a39g2000pre.googlegroups.com>
On Nov 14, 10:12 pm, Jim Gibson <jimsgib...@gmail.com> wrote:
> In article <1195050096.604403.314...@k35g2000prh.googlegroups.com>,
>
>
>
> king <hara.acha...@gmail.com> wrote:
> > I have a perl TK UI. Where the user will feed the Register value.
>
> > ######################################################################
> > our $t2=$left1->Label(-text=>'Register',-background=>'cyan')->pack();
>
> > our $pre1=$left2->Label(-background=>'green', -width=>12,-
> > borderwidth=>2, -relief=>'sunken')->Entry()-> pack();
> > our $ent1=$left2->Entry(-background=>'green', -width=>12,-
> > borderwidth=>2, -relief=>'sunken')->pack();
>
> > $Register_1=$ent1->get();
> > ####################################################################
>
> > I want to check whether the user has feeded the register value or kept
> > it null.
>
> > so if i am doing a check like
>
> > if (defined $Register_1) { do this}
> > else { do this}
>
> > but its not working. How can i check whether the user has given some
> > value in the register block or not.
>
> Check if length($Register_1) is equal to 0.
>
> --
> Jim Gibson
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com
Thanks for your valuble suggestion. Now its working for my
requirement.
But lets say I have put a value 2 in that field.
and if the value is 2 do something else do something else.
Like
if ($Register_1 == 2) { do this}
> > else { do this}
But value matching is also not working. Is there anyway to check that
value exactly matches or not.
------------------------------
Date: Thu, 15 Nov 2007 06:11:51 -0800 (PST)
From: Les <lesliewbell@gmail.com>
Subject: Perlscript asp object syntax problem
Message-Id: <34a8a523-87e4-48cd-963c-cb312e8b5aae@c30g2000hsa.googlegroups.com>
I am using a
$obj = $Server->CreateObject("customdll.object") command successfully.
I get the correct output from a call such as
$obj->{something};
but I can't get the correct syntax for a method which in vbscript
works fine as
objAuth.OutputField("message")
When I use my best guess
$strMessage = "$obj->{OutputField}->{'message'}";
$Response->Write("message is: $strMessage ." );
there is no error but the output is just "message is:."
though I am sure there would be a message.
At the head of the page I have
use Data::Dumper;
use Win32::OLE;
use Win32::OLE::Variant; #this gets the dates out of the database
right.
use Time::Local;
and tried
for my $item ($obj){
$Response->Write("Got first, " . Dumper($item) . "<br>");
}
but the output of that is
Got first, $VAR1 = bless( {}, 'Win32::OLE' );
It would be much appreciated if I could be told the correct syntax.
Les
------------------------------
Date: Thu, 15 Nov 2007 09:57:21 -0600
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Perlscript asp object syntax problem
Message-Id: <13josnujavr4m09@corp.supernews.com>
On 11/15/2007 08:11 AM, Les wrote:
> I am using a
>
> $obj = $Server->CreateObject("customdll.object") command successfully.
>
> I get the correct output from a call such as
>
> $obj->{something};
>
> but I can't get the correct syntax for a method which in vbscript
> works fine as
>
> objAuth.OutputField("message")
>
> When I use my best guess
>
> $strMessage = "$obj->{OutputField}->{'message'}";
>
> $Response->Write("message is: $strMessage ." );
>
> there is no error but the output is just "message is:."
>
> though I am sure there would be a message.
> [...]
I have no access to a Windows/IIS/ASP/Perl system for testing, but my
guess is that you have to do this:
$strMessage = $obj->OutputField("message");
------------------------------
Date: Thu, 15 Nov 2007 18:53:51 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: Rename files using directory names
Message-Id: <473C959D.2992BC4C@telus.net>
Peter Jamieson wrote:
>
> I have inherited many .rtf files contained in a directory structure like:
> patient_data/patient1/2007_07_11/test1.rtf
> where there are many patient directories such as patient1, patient2 etc
> and many date directories such as 2007_07_11, 2007_07_09 etc
> and there may be many .rtf files per patient and date combination.
>
> What I would like to do is create new unique names for each .rtf file
> based on the directory names: eg patient1_2007_07_11.test1.rtf
> and put them into a new directory named patient_files.
>
> I have checked out File::Find and tested the following script.
> It lists all the files OK as expected like test1.rtf, test2.rtf etc
> It merely replaces "_" with " " just as a test script.
>
> However I cannot figure out how to do a rename for what
> I would like the new file names to be namely in the
> form of: patient1_2007_07_11.test1.rtf
>
> Any help appreciated!, Cheers Peter
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> use File::Find;
>
> my $dir = '/patient_data/patient';
>
> find(\&underscores, $dir);
>
> sub underscores {
> next if -d $_;
> next if /^\./;
> next unless /_/;
You shouldn't use next from within a subroutine you should use return
instead. According to your example above your file names do not contain
a '_' character?
> my $new_name = $_;
> $new_name =~ s/_/ /g; # just for testing!
> chdir($File::Find::dir);
By default File::Find::find() already has you in the $File::Find::dir
directory so this is superfluous. You should always verify that system
functions like chdir() have worked, but it doesn't matter if it failed
as you are already in the $File::Find::dir directory!
> rename($_, $new_name) or die $!;
You are trying to move the current file to the same directory. You
probably want to include the new path name in the target:
"patient_files/$new_name" but you probably want to use an absolute path
instead of a relative path.
> print "$new_name \n";
> }
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 15 Nov 2007 16:02:10 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Two Perl programming questions
Message-Id: <2pnoj3dq77ul2dq02ar7fhijn7k1ae3ibo@4ax.com>
On Thu, 15 Nov 2007 05:22:50 -0800 (PST), Tim <TimKnoll@gmail.com>
wrote:
>1) I want to be able to read a file and populate an HTML drop-down
>list using Perl. How can I do this? I've found a Perl example to
>read the contents of a text file and populate an array like this:
This may help:
perldoc -q menu
>2) I want to be able to read a directory structure on the server and
>use the directory names to populate an HTML dropdown list using Perl.
>How can I do this?
You probably want File::Find or one of its relatives.
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: Thu, 15 Nov 2007 08:00:39 -0800 (PST)
From: Tim <TimKnoll@gmail.com>
Subject: Re: Two Perl programming questions
Message-Id: <ba24498a-5357-4cc1-88b5-8e38faa8fcfe@w73g2000hsf.googlegroups.com>
File::Find works great to the get the values I need and I know how to
read the values from a flat file. Would my Perl just create the HTML
as output? I have two dropdowns. I wanted to make the second ones
contents dynamic based off what they select for the first. I wanted
to fill the first with values from the sever directories. Is this
possible with Perl? I also wanted to call a different Perl script on
a post which seems pretty easy. Something like this:
<form name="StartForm" action="SomePerlScript.pl" method="POST">
Let me know. Thank you for your help.
Tim.
------------------------------
Date: Thu, 15 Nov 2007 08:07:34 -0800 (PST)
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Two Perl programming questions
Message-Id: <95a83ee5-463d-4ef6-9a3d-0b978cb7dfe5@d61g2000hsa.googlegroups.com>
On Nov 15, 8:22 am, Tim <TimKn...@gmail.com> wrote:
> I'm just starting out with Perl and I have two questions:
http://learn.perl.org
is a great place to find some tutorials to read.
> 1) I want to be able to read a file and populate an HTML drop-down
> list using Perl. How can I do this? I've found a Perl example to
> read the contents of a text file and populate an array like this:
>
> $data_file="SomeInput.txt";
> open(DAT, $data_file) || die("Could not open file!");
> @raw_data=<DAT>;
> close(DAT);
Very bad code. Do not use. Among the problems with it:
* using global filehandles
* using two-arg form of open
* not including open failure reason in error message
* reading entire file into memory at once.
> The data is in the raw_data array. How can I return this value
> back to HTML?
You need a very basic tutorial. I suggest you start with the
tutorials at the learn.perl.org site. When you've completed it, have
a read of:
perldoc -f open
perldoc -f readline
perldoc -f print
perldoc perlsyn
perldoc perldata
by typing each of those commands at your console.
Those will show you how to 1) Open the file, 2) Loop through the open
file, reading one line at a time, 3) print out a string containing the
values you've read from the file. Your string in this case will
obviously be the HTML text you'd like to print.
> 2) I want to be able to read a directory structure on the server
> and use the directory names to populate an HTML dropdown list
> using Perl. How can I do this?
perldoc -f opendir
perldoc -f readdir
Paul Lalli
------------------------------
Date: Thu, 15 Nov 2007 08:46:03 -0800 (PST)
From: Tim <TimKnoll@gmail.com>
Subject: Re: Two Perl programming questions
Message-Id: <4827ed8c-76a0-4e6a-afe5-09ab1b92817d@c29g2000hsa.googlegroups.com>
I get the basics of retriving text from a flat file and getting
directory names using Perl. I can debug through my Perl script and
see I'm geting those. How would Perl create the dynamic HTML that I
want? Does it just do it by Print statements? So my Perl script
would generate all the HTML? Would the Perl sciprt be called first
instead of my HTML? I have two dropdowns. The second dropdown I
wanted to have dynamic results based off what was entered for the
first. Is this possible?
Thanks for your help.
Tim.
------------------------------
Date: Thu, 15 Nov 2007 17:09:43 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Two Perl programming questions
Message-Id: <r3%_i.2013$eV.1709@trndny04>
Tim wrote:
> I get the basics of retriving text from a flat file and getting
> directory names using Perl. I can debug through my Perl script and
> see I'm geting those. How would Perl create the dynamic HTML that I
> want?
Perl is general purpose programming language. As such the programming
language does not "create <some text format>" automatically.
> Does it just do it by Print statements?
That would be one way, albeigh not the recommended way. I am guessing you
are talking about web programming using the Common Gateway Interface. In
that case most people would recommend to use the CGI module. Of course you
can use any of the HTML::Template modules to create HTML-text, too.
> So my Perl script would generate all the HTML? Would the Perl sciprt be
> called first
> instead of my HTML?
_Your_ HTML? You invented your own HyperText Markup Language? :-)
This may seem like nitpicking, but actually terminology is very important.
In this case what do you mean by "call my HTML"? Who is the caller and what
exactly is the callee? HTML is text. It cannot be executed, therefore the
notion of calling HTML is non-sensical.
Are you talking about a browser requesting an HTTP response? In that case
the response would be an HTML text (among many other possible formats, of
course) and that text would have to come from somewhere, e.g. from a file or
being dynamically generated by e.g. a CGI script written in Perl.
> I have two dropdowns. The second dropdown I
> wanted to have dynamic results based off what was entered for the
> first. Is this possible?
Assuming you are talking about a standard CGI application (you didn't even
tell if that is the case) then this question has nothing to do with Perl but
everything with depending on how you implement it either dynamic HTML (*) or
programming in the CGI-environment (**).
*: loading a single page in the browser and then using JavaScript to
dynamically alter the second dropdown whenever the value of the first is
being changed
**: reloading a new page with a different second drop-down each time the
user selects a value from the first one.
But as I said before, neither has anything to do with Perl.
jue
------------------------------
Date: Thu, 15 Nov 2007 11:02:25 -0800 (PST)
From: Tim <TimKnoll@gmail.com>
Subject: Re: Two Perl programming questions
Message-Id: <13333533-53df-4896-bb89-9c854a78b953@b15g2000hsa.googlegroups.com>
This is a standard CGI application. Its a single HTML document with 2
dropdowns and a single Perl script. The Perl script is called to
perform an action on a Post from the HTML document:
<form name="SomeForm" action="PerlScript.pl" method="POST">
The dropdowns are currently hardcoded in the single HTML document
something like this:
<option name="Color" value="Green">Green</option>
I wanted to externalize one dropdowns values in a flat file. I also
wanted to fill in the other dropdown with directories on the server.
I wanted to see if I could do both of these tasks using Perl. In your
message you say its not recommended to do this through Perl print
statements. What would be your recommended way?
Tim.
------------------------------
Date: Thu, 15 Nov 2007 11:09:02 -0800 (PST)
From: Tim <TimKnoll@gmail.com>
Subject: Re: Two Perl programming questions
Message-Id: <4aacfcff-09c4-4d12-b874-9692762bef2c@p69g2000hsa.googlegroups.com>
Its a standard CGI application. One HTML document, one perl script.
The perl script is called from a post in the HTML document:
<form name="Someform" action="SomeScript.pl" method="POST">
The HTML document has two dropdowns, both of which are populated from
within the HTML like this:
<option name="Color" value="Blue">Blue</option>
I want to externalize the dropdown lists to 1) a flat file, and 2)
directory paths on the server. I wanted to see if I could create this
dynamic HTML with Perl. You mention that doing this through print
statements isn't recommended. What would be the best way to do this
using HTML and Perl? Thanks.
Tim.
------------------------------
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 1036
***************************************