[28787] in Perl-Users-Digest
Perl-Users Digest, Issue: 31 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 15 11:06:00 2007
Date: Mon, 15 Jan 2007 08:05:10 -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 Mon, 15 Jan 2007 Volume: 11 Number: 31
Today's topics:
Re: alarm() under W2003 <bol@adv.magwien.gv.at>
Any buddy looking for Job in software testing fhk6431@gmail.com
Re: Ascii characters in a loop anno4000@radom.zrz.tu-berlin.de
Re: Asynchronous alert (NOSPAM)
Re: backtick and system command <josef.moellers@fujitsu-siemens.com>
Re: cgi problem with "gt" and "lt" <nick@maproom.co.uk>
Re: Check for Print Queue? anno4000@radom.zrz.tu-berlin.de
convert Vbscript to Perl code <borsk@technion.ac.il>
Re: Evaluation context of C-style Logical And/Or truexueweizhong@hotmail.com
Re: Evaluation context of C-style Logical And/Or <someone@example.com>
Re: Evaluation context of C-style Logical And/Or truexueweizhong@hotmail.com
Re: Evaluation context of C-style Logical And/Or anno4000@radom.zrz.tu-berlin.de
Re: Graph in Perl <zentara@highstream.net>
Re: How to know datatype of a variable in perl ? anno4000@radom.zrz.tu-berlin.de
Re: Indirect function call via Name <ro.naldfi.scher@gmail.com>
Issue with CGI module and hidden fields info@misterdoo.co.uk
ithreads <xx@wp.pl>
Re: Parsing some input - easy to explain but lengthy to anno4000@radom.zrz.tu-berlin.de
Re: Parsing some input - easy to explain but lengthy to <glennj@ncf.ca>
Pointers problem <xx@wp.pl>
Re: Pointers problem anno4000@radom.zrz.tu-berlin.de
Re: Pointers problem <josef.moellers@fujitsu-siemens.com>
Re: Trying to extract Headings from a Word 2003 documen <kleefaj@gmail.com>
variables in substitution <nelis@nlr.nl>
Re: Video::Capture undefined value josvanr@gmail.com
Re: Video::Capture undefined value <zentara@highstream.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 15 Jan 2007 09:47:38 +0100
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: alarm() under W2003
Message-Id: <1168850859.595323@proxy.dienste.wien.at>
Purl Gurl:
> Alarm is only partially implemented in Perl 5.8 versions
> running on Windows machines. Because of incomplete programming
> for Perl ports to Win32, alarm cannot hook a command line.
>
> To work around this lack of effective programming by Perl porters,
> use a DOS based select command, specifically for timing out a
> command line standard input prompt.
[...]
Well, my code was just an example to show what didn't work.
Actually, I have to watch a Windows Service by executing
sc \\remotehost querex <service>
at regular intervals. Because this command sometimes hangs
(if the service goes into an improper state), I want to establish
a timeout to ensure it doesn't hang forever.
How can this be accomplished?
MTIA & kind greetings from Vienna,
BTW: This is perl 5.8.6 (build 811).
Ferry
--
Ing Ferry Bolhar
Magistrat der Stadt Wien - MA 14
A-1010 Wien
E-Mail: bol@adv.magwien.gv.at
------------------------------
Date: 15 Jan 2007 07:08:18 -0800
From: fhk6431@gmail.com
Subject: Any buddy looking for Job in software testing
Message-Id: <1168873698.566348.206740@51g2000cwl.googlegroups.com>
Hey..
My company is aggresively looking for people to hire in software
testing.. New graduates are welcome. You need to know how to do
whitebox and blackbox testing. Also have previous experience in writing
testcases in perl or any other language.
Contact me at fhk6431@gmail.com
------------------------------
Date: 15 Jan 2007 12:50:49 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Ascii characters in a loop
Message-Id: <511bl9F1idevcU4@mid.dfncis.de>
Peter J. Holzer <hjp-usenet2@hjp.at> wrote in comp.lang.perl.misc:
> On 2007-01-14 10:04, Mark Hobley <markhobley@hotpop.deletethisbit.com> wrote:
> > John Bokma <john@castleamber.com> wrote:
[...]
> > It seems strange that if I increment $l (which equals 'z') then I now have a
> > value that is comparitively less than 'z'.
>
> That's because the "le" operator doesn't define "less" and "greater" in
> the same sense as "++" increments. The same happens if you use numbers:
>
> for (my $l = 0; $l le 9; $l++) {
> print "$l ";
> }
>
> prints
>
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
> 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
> 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
> 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
>
> Because 90 is the first number which is greater than 9 in a string
> comparison.
>
> Only with numbers there is a simple solution (use "<=" instead of "le"),
> while there is no builtin comparison operator for "alphanumeric
> numbers".
That doesn't mean you can't define an appropriate comparison. In
terms of a sort block (untested):
{ length( $a) <= length( $b) and $a le $b }
Applied back to the OPs loop that results in
for (my $l = 'a'; length( $l) <= 1 and $l le 'z'; $l++) { #...
Anno
------------------------------
Date: Mon, 15 Jan 2007 01:39:30 -0600
From: "Mumia W. (NOSPAM)" <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Asynchronous alert
Message-Id: <eofb6i$jti$1@aioe.org>
On 01/14/2007 02:59 PM, * Tong * wrote:
> On Sun, 14 Jan 2007 15:23:56 -0600, Mumia W. (NOSPAM) wrote:
>
>>> I'm trying to write an alert detection script.
>>>
>>> Generally, the script loops to detect if the alert criteria is met,
>>> and if so, alert the user. Somewhat like this:
>
> my $alerted;
Doh! How did I miss that?
> for(;;){
> my $flag=detect_flag
> if($flag){
> alert_user unless $alerted;
> $alerted=1
> }
> }
>
>>> The 'alert_user' can be as simple as a pop up window via Xdialog. Once the
>>> alert goes off, it might take some time to resolve, but I don't want to
>>> alert user again and again, hence the '$alerted' var. The problem is that
>>> I need a way to clear the '$alerted' var. I think, to make it simple, the
>>> best time is when the user confirm the alert pop up window.
>>>
>>> Now, what's the easiest way to do it? The reason I wanted to use Xdialog is
>>> because it's extreme easy to code, but I can't think of a way to clear the
>>> '$alerted' var.
>>>
>>> please help
>>>
>>> thanks a lot
>>>
>> Most probably, making $alerted a package variable will do it. You might
>> also be able to solve the problem by putting "my $alerted" above the for
>> loop.
>
> thanks for the suggestion. please see above. Please note that, what I need
> is the simplest solution.
>
>> Since the program you posted is not complete, it's hard to comment
>> further.
>
> IMHO, as a *general purpose* *high-level* code snip, it is complete. What
> only lacks is the way/mechanism to reset $alerted asynchronous, which I
> don't know and is asking -- how to reset it determines how the alert_user()
> is coded, and there is no need to dive into the detect_flag() at all.
>
> thanks
>
Under what conditions do you want to clear the $alerted flag?
--
Windows Vista and your freedom in conflict:
http://techdirt.com/articles/20061019/102225.shtml
------------------------------
Date: Mon, 15 Jan 2007 11:17:40 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: backtick and system command
Message-Id: <eofkg2$h4f$1@nntp.fujitsu-siemens.com>
mail4ashok@gmail.com wrote:
> Hi
>=20
> I am trying to capture output from another script(Tcl) with in a Perl
> script. I read the FAQ's and usenet post's before I posted.
>=20
> My requirements are
> 1. Capture output from external script
> 2. Write the output on STDOUT
> 3. The output should be unbuffered( basically show output
> synchronously)
>=20
> I can capture and print to STDOUT using
> print ($a=3D`script`);
> but the o/p gets buffered. Setting $| has no effect.
>=20
> I can use Perl system function to redirect but I loose terminal output.=
>=20
> Sorry, If a method is explained in FAQ, it's possible that I did not
> understand.
>=20
> Any example to do this is appreciated.
It's not the Perl script's fault that the Tcl interpreter buffers its=20
output.
There is little you can do in your Perl script to correct that.
I almost wrote "nothing you can do" as there is a solution:
do not run your Tcl script through a pipe but rather set up a pseudo-tty =
between the Perl and the Tcl script. That way the Tcl script will assume =
a terminal on its stdout (which, in effect, it has) and will send=20
line-buffered output.
Expect (a Tcl based software) does that.
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Mon, 15 Jan 2007 09:21:33 +0000
From: Nick Wedd <nick@maproom.co.uk>
Subject: Re: cgi problem with "gt" and "lt"
Message-Id: <LXEAeKQde0qFFAOi@maproom.demon.co.uk>
In message <lZidnWghLpg4fjfYnZ2dnUVZ_t-mnZ2d@comcast.com>, Joe Smith
<joe@inwap.com> writes
>Nick Wedd wrote:
>> Here is the piece of my code that causes a problem:
>> foreach $cc ( param() ) {
>> $col = param($cc);
>> and here is a piece of my cgi argument list:
>> gl=6>=6&hn=6&mx=6&ni=8
>> It all works except for when $cc (the key) is "gt" or "lt".
>
>Try using ";" instead of "&" in the CGI argument list.
>
> gl=6;gt=6;hn=6;mx=6;ni=8
>
>http://www.w3.org/TR/html401/appendix/notes.html#ampersands-in-uris
Many thanks - yes - this was my problem.
Nick
--
Nick Wedd nick@maproom.co.uk
------------------------------
Date: 15 Jan 2007 14:23:30 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Check for Print Queue?
Message-Id: <511h32F1i3un5U2@mid.dfncis.de>
<murraymn@gmail.com> wrote in comp.lang.perl.misc:
Please don't top-post. I've moved your reply around.
> Sherm Pendley wrote:
> > murraymn@gmail.com writes:
> >
> > > Looking for suggestions/examples of a simple perl script to check the
> > > existence of a CUPS print queue.
> > >
> > > That's all it needs to do and no more with the queue. Yeah, I could
> > > search printers.conf, and may if I don't find anything a little more
> > > elegant and efficient.
> >
> > We heard you the first time.
> >
> > Did you try searching at <http://search.cpan.org> for CUPS?
> >
> The first post was slightly inaccurate.
How? The only difference between your first and second posting is a
trailing blank on one line. Don't fib on things that are easily
checked.
Anno
------------------------------
Date: Mon, 15 Jan 2007 15:31:21 +0200
From: "Boris Skoblo" <borsk@technion.ac.il>
Subject: convert Vbscript to Perl code
Message-Id: <eofvna$ugh$1@news.iucc.ac.il>
Hi All,
please help me convert following VBscript code to Perl code
..............................................................................................
strLDAP = "LDAP://CN=test,OU=users,DC=tech,DC=com"
set usr = GetObject(strLDAP)
Wscript.echo usr.TerminalServicesWorkDirectory
Wscript.echo usr.TerminalServicesInitialProgram
usr.TerminalServicesInitialProgram= "cmd.exe"
usr.TerminalServicesWorkDirectory= "D:\path"
usr.SetInfo
WScript.echo usr.TerminalServicesInitialProgram
Wscript.echo usr.TerminalServicesWorkDirectory
Can anyone help?
Thanks!
------------------------------
Date: 14 Jan 2007 21:17:53 -0800
From: truexueweizhong@hotmail.com
Subject: Re: Evaluation context of C-style Logical And/Or
Message-Id: <1168838273.335934.289780@11g2000cwr.googlegroups.com>
> $ perl -wle '@a = ( "a1", "a2" ); @b = ( "b1", "b2" ); @c = @a && @b; @a = ();
> @d = @a && @b; print for "@c", "@d"'
> b1 b2
> 0
So I believe now that @a is evalutated in SCALAR context.
But why @b is evaluated in LIST context?
------------------------------
Date: Mon, 15 Jan 2007 05:52:06 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Evaluation context of C-style Logical And/Or
Message-Id: <aEEqh.149531$YV4.57448@edtnps89>
truexueweizhong@hotmail.com wrote:
>>$ perl -wle '@a = ( "a1", "a2" ); @b = ( "b1", "b2" ); @c = @a && @b; @a = ();
>>@d = @a && @b; print for "@c", "@d"'
>>b1 b2
>>0
>
> So I believe now that @a is evalutated in SCALAR context.
> But why @b is evaluated in LIST context?
Because '@c =' forces list context on the assignment. The logical operators
are left associative so they only affect the context of the operand on the left.
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: 14 Jan 2007 22:09:52 -0800
From: truexueweizhong@hotmail.com
Subject: Re: Evaluation context of C-style Logical And/Or
Message-Id: <1168841392.557498.78640@s34g2000cwa.googlegroups.com>
>
> Because '@c =' forces list context on the assignment. The logical operators
> are left associative so they only affect the context of the operand on the left.
>
Yes, you tell me the perlop truth now.
Thanks so much.
Best regards
Weizhong Xue
Shanghai/China
------------------------------
Date: 15 Jan 2007 14:13:57 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Evaluation context of C-style Logical And/Or
Message-Id: <511gh5F1i3un5U1@mid.dfncis.de>
<truexueweizhong@hotmail.com> wrote in comp.lang.perl.misc:
> > $ perl -e '@a = (a1,a2); @b = (b1,b2); @c = @a or @b; print @c'
> > a1a2
>
> Now i know this one, because
> @c = @a or @b
> is equal to
> (@c = @a) or @b
> so it's not amazing any more.
>
> But I'm still confused about the following result:
>
> $ perl -e '@a = (a1,a2); @b = (b1,b2); @c = @a && @b; print @c'
> b1b2
> ------------- && , list context
> $ perl -e '@a = (a1,a2); @b = (b1,b2); @c = @a || @b; print @c'
> 2
> ------------- ||, scalar context
>
Re-read the documentation on && and || in perldoc. It's in there,
though obliquely. The second sentence says:
Scalar or list context propagates down to the right operand
if it is evaluated.
The left operand isn't mentioned, meaning it is evaluated in scalar
context. Now, with the && operation the result is determined by the
right operator which is in list context. With ||, the result is
the left operator which is in scalar context. Hence the difference.
By induction it follows that only the last operand in a chain of
&& and || can ever be in list context.
Anno
------------------------------
Date: Mon, 15 Jan 2007 13:17:04 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Graph in Perl
Message-Id: <8rumq2po5kjm1fl578j28k6esp00tcth4q@4ax.com>
On 14 Jan 2007 08:08:44 -0800, "jupiter" <anil.jupiter9@gmail.com>
wrote:
>
>I have seen this module it will create png file I dont want to make a
>file I want this graph to appear within program n update in real time
>as well, means as soon as new data comes it should update graph (data
>will be updated in mintues)
Is this for a cgi program? If so, you will need to create some sort of
file and update it and refresh your cgi. Maybe you could make some sort
of flash that would do it.
Otherwise, if it's a desktop app you want, the Tk script at
http://perlmonks.org?node_id=577181
does what you ask. Although you will need to customize it to suit
your situation.
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: 15 Jan 2007 12:19:59 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: How to know datatype of a variable in perl ?
Message-Id: <5119rfF1idevcU2@mid.dfncis.de>
Googy <cooldudevamsee@gmail.com> wrote in comp.lang.perl.misc:
> Hi,
>
> I am writing a program using AutoLoader and it has to simulate 10's of
> sub routines, the problem I have is every simulated function has
> different number of arguments and different number of argument types in
> different orders.
>
> Is there any method or sub routines to know the data type of the
> argument ?
Normally you don't have to do that when creating a sub through
autoload. Since you know the name of the missing sub, you know
the number and type of args the sub expects. Just create it
accordingly.
Anno
------------------------------
Date: 14 Jan 2007 23:09:52 -0800
From: "Ronny" <ro.naldfi.scher@gmail.com>
Subject: Re: Indirect function call via Name
Message-Id: <1168844992.189466.136290@m58g2000cwm.googlegroups.com>
Uri Guttman schrieb:
> >>>>> "R" == Ronny <ro.naldfi.scher@gmail.com> writes:
>
> R> anno4000@radom.zrz.tu-berlin.de schrieb:
> >> > our $func="bar";
> >> > # Of course the following would not work
> >> > &$func(@_);
> >>
> >> What makes you think it doesn't work? Switch off strict 'refs' and
> >> it does.
>
> R> Thanks a lot!! I should have known this already!
>
> you should still use a dispatch table as was mentioned before. it is
> safer and smarter.
Correct, but with a dispatch table, you kind of need in advance what
functions
are going to be called that way. In my particular case, safety is not
an issue.
Actually, I want to be able to supply at run-time the function name,
but the
knowledge *what* functions can be called that way are not known to the
program.
Of course this is a considerably security whole (passing function names
such
as 'unlink' or 'system' to my program could produce uncontrollable
damage), but
this is a very special case and so I don't care about this risk.
Actually, I already had considered passing a whole perl statement to
the program
and executing it with eval, but in this very particular case I found it
more useful
to pass the function name and the arguments separately. Hence, the
solution
with no strict 'refs' does exactly what I want.
Ronald
------------------------------
Date: 15 Jan 2007 05:40:19 -0800
From: info@misterdoo.co.uk
Subject: Issue with CGI module and hidden fields
Message-Id: <1168868419.309803.130750@m58g2000cwm.googlegroups.com>
Hi There,
Has anyone seen this behaviour before? If I do this:
print $page->hidden(-name=>'DeleteNoteVal',
-value=>$data->[$i][0]) ;
the value of $data->[$i][0] is sometimes incorrect (not always! - only
the first hidden variable in a form in this particular case) whereas,
if I use 'straight' html:
print "<input type='hidden' name='DeleteNoteVal'
value='$data->[$i][0]' />" ;
everything's fine.
Any ideas?
Cheers
Steve
------------------------------
Date: Mon, 15 Jan 2007 16:02:47 +0100
From: avlee <xx@wp.pl>
Subject: ithreads
Message-Id: <op.tl7aqx1q1sq83a@saturn>
Hello
What thread library do you use ?
I am thinkig about ithread - but i heard some applications does not work
with perl compiled with ithreads.
Is there any stable thread library ?
Thanx
------------------------------
Date: 15 Jan 2007 11:42:42 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Parsing some input - easy to explain but lengthy to code - suggestions?
Message-Id: <5117liF1idevcU1@mid.dfncis.de>
Bob Walton <see.sig@rochester.rr.com> wrote in comp.lang.perl.misc:
> doolittle wrote:
> > Hi,
> >
> > I have to check that some input conforms to some rules. Although the
> > rules are simple to expain, my perl function looks too complex/long,
> > can it be done more simply?
> >
> > The rule is that the first character must be a letter, and the second
> > and third characters must form a number between 1 and 25 (so the third
> > character is optional)
> >
> Try:
>
> use warnings;
> use strict;
> while(<DATA>){
> chomp;
> print "$_->".isOK($_)."\n";
> }
> sub isOK{
> my $str=shift;
> if($str=~/^[a-z](\d\d?)/i){
> return(($1>0 and $1<26)?1:0);
> }
> else{return 0}
> }
> __END__
[data snipped]
That's still more complicated than it has to be. Neither "if {} else
{}" nor the "?:" construct are necessary:
sub is_ok {
shift =~ /^[a-z](\d\d?)/i and 1 <= $1 and $1 <= 25;
}
The only difference is that your routine returns 0 for false while
is_ok() returns Perl's boolean false which prints as an empty string.
Anno
--
$anagram = 'Knuth heals rare project'; # by Abigail
push @{ $pos{ $_}}, $pos ++ for split //, lc $anagram;
print "print +(split //, '$anagram')[ $_]\n" for
join ', ', map shift @$_, @pos{ split //, lc "Just another Perl hacker"};
------------------------------
Date: 15 Jan 2007 15:17:33 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Parsing some input - easy to explain but lengthy to code - suggestions?
Message-Id: <slrneqn6od.huk.glennj@smeagol.ncf.ca>
At 2007-01-14 10:05AM, "Jürgen Exner" wrote:
> doolittle wrote:
> > The rule is that the first character must be a letter, and the second
> > and third characters must form a number between 1 and 25 (so the third
> > character is optional)
>
> UNTESTED!!!
>
> sub isOK {
> my $str = shift;
> if ($str =~ /^\w(\d{1,2}?)/
> # check for first character being a letter,
> # next 1 or 2 characters being digits and capture them
> and $1 > 0 and $1 < 25 ) {
> return 1;
> } else {
> return 0;
> }
You're not being greedy enough: \d{1,2}? will prefer one digit over
two, so the string "a31" will pass your test with $1 eq "3". Also, \w
matches numbers and underscore in addition to letters.
This is better: $str =~ /^[[:alpha:]](\d{1,2})/
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
------------------------------
Date: Mon, 15 Jan 2007 13:15:24 +0100
From: avlee <xx@wp.pl>
Subject: Pointers problem
Message-Id: <op.tl62zykr1sq83a@saturn>
Hello
In some place of my code i write down (return by function) address of th=
e =
list.
Then i try to use it to read elements from that list:
my @list =3D @$list_addr; #line 50
And everything works fine - but i receive warning on the screen:
Can't use an undefined value as an ARRAY reference at .....line 50
Why ? How to disable it ?
Thanx
------------------------------
Date: 15 Jan 2007 12:26:54 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Pointers problem
Message-Id: <511a8eF1idevcU3@mid.dfncis.de>
avlee <xx@wp.pl> wrote in comp.lang.perl.misc:
> Hello
>
> In some place of my code i write down (return by function) address of the
> list.
So what are you returning? You omitted the one crucial point.
> Then i try to use it to read elements from that list:
> my @list = @$list_addr; #line 50
>
> And everything works fine - but i receive warning on the screen:
> Can't use an undefined value as an ARRAY reference at .....line 50
That's not a warning, it's an error. Perl can't continue after that.
> Why ? How to disable it ?
You can't disable an error.
Apparently what you return from the sub is an undefined value. Return
an arrayref and all will be well.
Anno
------------------------------
Date: Mon, 15 Jan 2007 13:24:19 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Pointers problem
Message-Id: <eofrul$nna$1@nntp.fujitsu-siemens.com>
avlee wrote:
> Hello
>=20
> In some place of my code i write down (return by function) address of=20
> the list.
> Then i try to use it to read elements from that list:
> my @list =3D @$list_addr; #line 50
>=20
> And everything works fine - but i receive warning on the screen:
> Can't use an undefined value as an ARRAY reference at .....line 50
What is difficult to understand in this error message?
$list_addr ist undef!
> Why ? How to disable it ?
By assign a _defined_ value to $list_addr!
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 15 Jan 2007 07:45:56 -0800
From: "kleefaj@gmail.com" <kleefaj@gmail.com>
Subject: Re: Trying to extract Headings from a Word 2003 document using Perl
Message-Id: <1168875956.507570.105640@a75g2000cwd.googlegroups.com>
Mumia W. (on aioe) wrote:
> You're welcome.
>
> Did you read "perldoc perlref"?
Nope, not yet. It's on my "To read" list.
------------------------------
Date: 15 Jan 2007 07:07:56 -0800
From: "Wim" <nelis@nlr.nl>
Subject: variables in substitution
Message-Id: <1168873676.123386.149040@38g2000cwa.googlegroups.com>
Hello,
I am trying to make a substition using rules taken from an array. The
basics of the program are:
my @A= ( 'AName-9.45', 'Another-6.123' ) ;
my @NameMap= (
[ qr/^aname-(\d+)\.(\d+)$/io, 'groupzero-$1-$2' ],
[ qr/^another-(\d+)\.(\d+)$/io, q/groupone-$1-$2/ ] ) ;
foreach my $a ( @A ) {
printf "%-17s -> ", $a ;
$a=~ s/$$_[0]/$$_[1]/i foreach ( @NameMap ) ;
printf "$a\n" ;
}
Matching an input string (taken from @A) succeeds. However, replacing
$1 and $2 by the numbers matched between the parenthesis in de left
part fails. the literal string $1 appears in the result. Using
evaluation doesn't work: it will report an uninitialised value. How
can one take both substitute parameters from an array and use local
variables $1 at the same time?
Regards,
Wim Nelis.
------------------------------
Date: 15 Jan 2007 02:28:31 -0800
From: josvanr@gmail.com
Subject: Re: Video::Capture undefined value
Message-Id: <1168856910.959224.89010@q2g2000cwa.googlegroups.com>
> Line 103 defines the tuner (i.e. TV channel tuner), and I'm
> probably right, in that your camera has no tuner.... it's just
> a plain camera.
yes that seems to work, no error msg now. The camera led flashes
when I run the script. Now I only need to figure out how to save a
frame..
Jos
------------------------------
Date: Mon, 15 Jan 2007 13:17:05 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Video::Capture undefined value
Message-Id: <n2vmq2pi5m36b0ubfutconidaq7tfath2a@4ax.com>
On 15 Jan 2007 02:28:31 -0800, josvanr@gmail.com wrote:
>
>> Line 103 defines the tuner (i.e. TV channel tuner), and I'm
>> probably right, in that your camera has no tuner.... it's just
>> a plain camera.
>
>
>yes that seems to work, no error msg now. The camera led flashes
>when I run the script. Now I only need to figure out how to save a
>frame..
>Jos
Grabbing is kind of tricky, the thing to watch for is sometimes the
camera sends it out bgr instead of rgb, or upside down ,etc,
Also, you seem to need to grab 2, to get 1 image? I havn't
figured out why, I just know it works.
Finally, if you get a blue image, it means the camera was not
"initialized" properly. The "v4lctl" program is good for
this, you can run it thru system, or IPC.
I have an example of running it thru IPC at
http://perlmonks.org?node_id=486896
Heres a grabber:
#!/usr/bin/perl
use warnings;
use strict;
use Video::Capture::V4l;
use Imager;
use Tk;
use Tk::JPEG;
use MIME::Base64;
my $timestamp;
my $temp = '';
sub grab_one {
$temp = '';
$timestamp = scalar(localtime);
$timestamp =~ tr/ /_/;
$| = 1;
my $grab = new Video::Capture::V4l
or die "Unable to open Videodevice: $!";
# the following initializes the camera for NTSC
my $channel = $grab->channel(0);
my $tuner = $grab->tuner(0);
$tuner->mode(1);
$channel->norm(1);
$tuner->set;
$channel->set;
my $frame = 0;
my $fr = $grab->capture( $frame, 320, 240 );
my $count = 0;
for ( 0 .. 1 ) {
my $nfr = $grab->capture( 1 - $frame, 320, 240 );
$grab->sync($frame) or die "unable to sync";
unless ( $count == 0 ) {
# save $fr now, as it contains the raw BGR data
$temp = '';
open( JP, '>', \$temp ) or die $!;
print JP "P6\n320 240\n255\n"; #header
$nfr = reverse $nfr;
print JP $nfr;
close JP;
my $img = Imager->new();
$img->read( data => $temp, type => 'pnm' )
or warn $img->errstr();
$img->flip( dir => "hv" );
$img->write( data => \$temp, type => 'jpeg' )
or warn $img->errstr;
}
$count++;
$frame = 1 - $frame;
$fr = $nfr;
}
}
grab_one();
my $mw = MainWindow->new();
my $image = $mw->Photo( -data => encode_base64($temp) );
$mw->Label( -image => $image )->pack( -expand => 1, -fill => 'both' );
my $label =
$mw->Label( -text => $timestamp )->pack( -side => 'top', -padx => 3 );
my $center = $mw->Frame->pack( -anchor => 'center' );
$center->Button( -text => 'Quit', -command => [ destroy => $mw ] )
->pack( -side => 'left', -padx => 3 );
$center->Button( -text => 'Update', -command => \&update )
->pack( -side => 'left', -padx => 3 );
$center->Button( -text => 'Save', -command => \&save_it )
->pack( -side => 'left', -padx => 3 );
MainLoop;
sub save_it {
open( JP, "> $timestamp.jpg" ) or die $!;
print JP $temp;
close JP;
$label->configure( -text => "$timestamp.jpg SAVED" );
$label->update;
}
sub update {
grab_one();
$label->configure( -text => "$timestamp" );
$label->update;
$image->configure( -data => encode_base64($temp) );
$image->update;
$mw->update;
}
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
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 31
*************************************