[28634] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9998 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 22 18:10:16 2006

Date: Wed, 22 Nov 2006 15:10:09 -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           Wed, 22 Nov 2006     Volume: 10 Number: 9998

Today's topics:
    Re: DOS-Box script is running in set always on top <veatchla@yahoo.com>
    Re: DOS-Box script is running in set always on top <veatchla@yahoo.com>
    Re: DOS-Box script is running in set always on top <john@castleamber.com>
    Re: DOS-Box script is running in set always on top <rmay@popeslane.clara.co.uk>
        Export module hristov.milen@gmail.com
    Re: Export module anno4000@radom.zrz.tu-berlin.de
    Re: Extracting Date using Regular Expressions <shafa.fahad@gmail.com>
    Re: Extracting Date using Regular Expressions <mritty@gmail.com>
    Re: FAQ 6.19 What good is "\G" in a regular expression? <ddunham@redwood.taos.com>
        How to declare a var hash name ? <np@voila.fr>
    Re: How to declare a var hash name ? <mritty@gmail.com>
    Re: How to declare a var hash name ? <john@castleamber.com>
    Re: How to declare a var hash name ? <np@voila.fr>
    Re: How to declare a var hash name ? <mritty@gmail.com>
    Re: How to declare a var hash name ? <jurgenex@hotmail.com>
    Re: How to declare a var hash name ? <np@voila.fr>
    Re: How to declare a var hash name ? <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: How to read the Doctype Information out of an XML F <DJStunks@gmail.com>
    Re: Passing an object to a module <nobull67@gmail.com>
    Re: Passing an object to a module <jgibson@mail.arc.nasa.gov>
    Re: Passing an object to a module <sbryce@scottbryce.com>
    Re: Regex exactly 0, 1 or 2 matches, {0,2} not working <ggb667@gmail.com>
    Re: use print to write binary data to a filehandle seem <njus@larshaugseth.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 22 Nov 2006 10:39:51 -0600
From: l v <veatchla@yahoo.com>
Subject: Re: DOS-Box script is running in set always on top
Message-Id: <12m8vajl9lpp739@news.supernews.com>

John Bokma wrote:
> l v <veatchla@yahoo.com> wrote:
>  
>> Sure it would.  But then companies like Actual Tools couldn't sell their 
>> product. :)
> 
> There is a focus follows mouse power toy from Microsoft, for free, which 
> probably does the same. I never understood why the window with focus has 
> to pop to the front anyway.
> 

I did not read that the OP was looking for the X windows feel with the 
focus follows mouse option within TweakUI.  He can certainly drop 
something from windows explorer right on the dos box in the background, 
no need to raise it to the top as long as explorer is not maximized.  I 
thought the OP was looking for the "always on top" option in Task Manager.

One of the Actual Tools offers the ability to keep any window on top 
regardless of focus, like Windows Task Manager.

-- 

Len


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

Date: Wed, 22 Nov 2006 10:48:49 -0600
From: l v <veatchla@yahoo.com>
Subject: Re: DOS-Box script is running in set always on top
Message-Id: <12m8vrdl3cc0tb7@news.supernews.com>

Daniel Kelber wrote:
> John Bokma schrieb:
> 
>> If you want to keep an eye on things, why not open your own window on top
>> with Tk (I am quite sure this is possible)?
>>
>> --
>> John
> 
> Hi John,
> the aim is to drag a file from the windows explorer and drop it in the
> DOS-Box where the script is waiting  with
> 
> <STDIN>;
> 
> When I drag the file from windows explorer the DOS box gets in
> background so dropping is more complicated...
> 

I'm not exactly sure what "dropping is more complicated..." means, but 
Win32::GuiTest may work for you. It appears you can get the window 
handle from FindWindowLike() and SetFocus() and others.  You may need to 
read the modules code to find exactly what you are looking for.

-- 

Len


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

Date: 22 Nov 2006 17:14:51 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: DOS-Box script is running in set always on top
Message-Id: <Xns9883726A1599castleamber@130.133.1.4>

l v <veatchla@yahoo.com> wrote:

> John Bokma wrote:
>> l v <veatchla@yahoo.com> wrote:
>>  
>>> Sure it would.  But then companies like Actual Tools couldn't sell
>>> their product. :)
>> 
>> There is a focus follows mouse power toy from Microsoft, for free,
>> which probably does the same. I never understood why the window with
>> focus has to pop to the front anyway.
>> 
> 
> I did not read 

It was a suggestion.

> that the OP was looking for the X windows feel with the
> focus follows mouse option within TweakUI.  He can certainly drop 
> something from windows explorer right on the dos box in the
> background, no need to raise it to the top

If only the window chrome is visible, I get a "forbidden" sign. AFAIK, 
focus follows mouse will raise the window even if above window chrome.

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: Wed, 22 Nov 2006 19:27:55 +0000
From: Robert May <rmay@popeslane.clara.co.uk>
Subject: Re: DOS-Box script is running in set always on top
Message-Id: <apudnTtBPPQmOfnYnZ2dnUVZ8s2dnZ2d@pipex.net>

Daniel Kelber wrote:
> I want a perl script to set the DOS-Box it is running in to be "always
> on top".
> Maybe I can use SetWindowPos from user32.dll but therefor I need the
> window handle of the DOS-Box. How can I get out this handle?

On Win2000 and above there is an SPI call GetConsoleWindow() that gets 
the handle.  From MSDN:

The GetConsoleWindow function retrieves the window handle used by the 
console associated with the calling process.

      HWND GetConsoleWindow(void);

Regards,
Rob.




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

Date: 22 Nov 2006 10:07:07 -0800
From: hristov.milen@gmail.com
Subject: Export module
Message-Id: <1164218827.656894.52670@h54g2000cwb.googlegroups.com>

Hi,
I have a module, that I require in some script.

How can I require another module, inside mine and make it global.

For example, if I have in my Some.pm -> 'use strict'
how can I make the strict global, without require it in the main script
?



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

Date: 22 Nov 2006 19:35:56 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Export module
Message-Id: <4sjn4sF107nueU3@mid.dfncis.de>

 <hristov.milen@gmail.com> wrote in comp.lang.perl.misc:
> Hi,
> I have a module, that I require in some script.
> 
> How can I require another module, inside mine and make it global.
> 
> For example, if I have in my Some.pm -> 'use strict'
> how can I make the strict global, without require it in the main script
> ?

You can't.  "strict" is lexically scoped and a file is a maximal lexical
scope.

Anno


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

Date: 22 Nov 2006 07:18:00 -0800
From: "Kimi" <shafa.fahad@gmail.com>
Subject: Re: Extracting Date using Regular Expressions
Message-Id: <1164208680.631424.186610@j44g2000cwa.googlegroups.com>


John W. Krahn wrote:
> Kimi wrote:
> > Hi I am new to perl,
> >
> > I need some help in regular expressions....
> >
> > I have a string "Tue Nov  7 14:04:16 2006: Unable to open prev pos
> > file" in a variable "myvariable" and I need to extract "Tue Nov 7
> > 14:14:16 2006" to another variable..
> >
> > I also would like to know if there are any way to compare the above
> > result with Current date and find the difference of days/months
>
>
> $ perl -le'
> use POSIX q/mktime/;
>
> my $myvariable = "Tue Nov  7 14:04:16 2006: Unable to open prev pos file";
>
> my $week_day = qr/Mon|Tue|Wed|Thu|Fri|Sat|Sun/;
> my $mon_name = qr/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/;
>
> my ( $mon, $day, $hour, $min, $sec, $year ) = $myvariable =~ /$week_day \s+
> ($mon_name) \s+ (\d+) \s+ (\d+) : (\d+) : (\d+) \s+ (\d+)/x;
>
> print "$sec, $min, $hour, $day, $mon, $year";
>
> my $old_date = mktime $sec, $min, $hour, $day, ( index( $mon_name, $mon ) -
> index( $mon_name, q/Jan/ ) ) / 4, $year - 1900;
>
> my $current_date = time;
>
> my ( $diff_days, $diff_mons ) = ( gmtime $current_date - $old_date )[ 3, 4 ];
>
> print for scalar localtime $old_date, scalar localtime $current_date, "Days:
> $diff_days, Months: $diff_mons";
> '
> 16, 04, 14, 7, Nov, 2006
> Tue Nov  7 14:04:16 2006
> Wed Nov 22 05:48:51 2006
> Days: 15, Months: 0
>
>
>
>
> 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

Thanks John....

Regards,
Kimi



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

Date: 22 Nov 2006 11:51:53 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Extracting Date using Regular Expressions
Message-Id: <1164225113.691697.93090@m7g2000cwm.googlegroups.com>

John W. Krahn wrote:
> Kimi wrote:
> > I have a string "Tue Nov  7 14:04:16 2006: Unable to open prev pos
> > file" in a variable "myvariable" and I need to extract "Tue Nov 7
> > 14:14:16 2006" to another variable..
> >
> > I also would like to know if there are any way to compare the above
> > result with Current date and find the difference of days/months
>
>
> $ perl -le'
> use POSIX q/mktime/;
>
> my $myvariable = "Tue Nov  7 14:04:16 2006: Unable to open prev pos file";
>
> my $week_day = qr/Mon|Tue|Wed|Thu|Fri|Sat|Sun/;
> my $mon_name = qr/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/;
>
> my ( $mon, $day, $hour, $min, $sec, $year ) = $myvariable =~ /$week_day \s+
> ($mon_name) \s+ (\d+) \s+ (\d+) : (\d+) : (\d+) \s+ (\d+)/x;
>
> print "$sec, $min, $hour, $day, $mon, $year";
>
> my $old_date = mktime $sec, $min, $hour, $day, ( index( $mon_name, $mon ) -
> index( $mon_name, q/Jan/ ) ) / 4, $year - 1900;
>
> my $current_date = time;
>
> my ( $diff_days, $diff_mons ) = ( gmtime $current_date - $old_date )[ 3, 4 ];
>
> print for scalar localtime $old_date, scalar localtime $current_date, "Days:
> $diff_days, Months: $diff_mons";
> '
> 16, 04, 14, 7, Nov, 2006
> Tue Nov  7 14:04:16 2006
> Wed Nov 22 05:48:51 2006
> Days: 15, Months: 0

Or, if you didn't feel like doing all that work yourself, take
advantage of modules on CPAN, like Date::Manip...

#!/usr/bin/perl
use strict;
use warnings;
use Date::Manip;

my $var = "Tue Nov  7 14:04:16 2006: Unable to open prev pos file";
my ($dttm) = ($var =~ /^(.*\d{4}):/);
my $date = ParseDate($dttm);
die "Couldn't parse date!\n" unless $date;
my $today = ParseDate("today");
my ($Y, $M, $W, $D, $h, $m, $s) =
   (DateCalc($date, $today, \my $err, 1) =~ /\d+/g
);
print "Date was $Y year(s), $M month(s), $W week(s), $D day(s), $h
hour(s), $m minute(s) and $s second(s) ago\n";
__END__
Date was 0 year(s), 0 month(s), 2 week(s), 1 day(s), 0 hour(s), 47
minute(s) and 0 second(s) ago


Paul Lalli



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

Date: Wed, 22 Nov 2006 22:00:07 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: FAQ 6.19 What good is "\G" in a regular expression?
Message-Id: <HL39h.2727$yf7.1487@newssvr21.news.prodigy.net>

Dr.Ruud <rvtol+news@isolution.nl> wrote:

> Where is the c-flag (or should it be called the c-modifier)
  documented?

perlop and perlreref both describe those flags.

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: Wed, 22 Nov 2006 18:45:16 +0100
From: Nicolas Printemps <np@voila.fr>
Subject: How to declare a var hash name ?
Message-Id: <45648CAC.6CED80C8@voila.fr>

Hello,

Which synthax to use to declare a variable hashname ?

$tempo="popo"

my %$popo; does not seem to work..

Regards



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

Date: 22 Nov 2006 10:10:59 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: How to declare a var hash name ?
Message-Id: <1164219059.764512.143550@f16g2000cwb.googlegroups.com>

Nicolas Printemps wrote:
> Which synthax to use to declare a variable hashname ?
>
> $tempo="popo"
>
> my %$popo; does not seem to work..

Nor should it.

What makes you think you want to do this?  What is your *actual* goal,
that you think "variable hashname" is the solution to?

Have you read:
perldoc -q "variable name"
?

Paul Lalli



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

Date: 22 Nov 2006 18:27:11 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How to declare a var hash name ?
Message-Id: <Xns98837EAD68737castleamber@130.133.1.4>

Nicolas Printemps <np@voila.fr> wrote:

> Hello,
> 
> Which synthax to use to declare a variable hashname ?
> 
> $tempo="popo"
> 
> my %$popo; does not seem to work..

What's wrong with:

my %tempo;

and using

$tempo{ popo }{ key } = some value;

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: Wed, 22 Nov 2006 19:56:26 +0100
From: Nicolas Printemps <np@voila.fr>
Subject: Re: How to declare a var hash name ?
Message-Id: <45649D5A.C616BA32@voila.fr>

sorry

%$tempo does not seem to work.

I would like to declare a certain number a hashes that are included into
a list.



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

Date: 22 Nov 2006 11:10:51 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: How to declare a var hash name ?
Message-Id: <1164222651.642069.279430@m7g2000cwm.googlegroups.com>

Nicolas Printemps wrote:
> sorry

For what?

> %$tempo does not seem to work.

No.  It doesn't.  We've already established that.

> I would like to declare a certain number a hashes that are included into
> a list.

WHY!!!!???

Answer that question, and we can tell you how to do it correctly!  Stop
ignoring our responses in favor of just repeating your question!

Are you at all aware that perl has multi-dimensional structures?
Please read:
perldoc perlreftut
perldoc perldsc

Paul Lalli



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

Date: Wed, 22 Nov 2006 19:18:26 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to declare a var hash name ?
Message-Id: <6o19h.5519$IW2.1280@trndny03>

Nicolas Printemps wrote:
> sorry
>
> %$tempo does not seem to work.
>
> I would like to declare a certain number a hashes that are included
> into a list.

Ok. What's blocking you from using an AoH aka ArrayOfHash or more accurately 
array of hash references?

jue 




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

Date: Wed, 22 Nov 2006 23:12:45 +0100
From: Nicolas Printemps <np@voila.fr>
Subject: Re: How to declare a var hash name ?
Message-Id: <4564CB5D.C1B8C43F@voila.fr>

I will check. Thank you





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

Date: Wed, 22 Nov 2006 14:42:53 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: How to declare a var hash name ?
Message-Id: <dc0f34xsi7.ln2@goaway.wombat.san-francisco.ca.us>

On 2006-11-22, Nicolas Printemps <np@voila.fr> wrote:
> I will check. Thank you
>
>
>

You will check what?!?  Please quote context so that others know what
you are talking about.

--keith


-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



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

Date: 22 Nov 2006 08:22:08 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: How to read the Doctype Information out of an XML File
Message-Id: <1164212528.061680.276640@h54g2000cwb.googlegroups.com>

pod69@gmx.net wrote:
> Hello,
>
> How can i read the Doctype Information out of an xml file?
>
> <!DOCTYPE foo SYSTEM "foo.dtd"
>       [
>       <!ENTITY bla SYSTEM "bla.xml">
>       <!ENTITY foofoo SYSTEM "foofoo.xml">
>  ]
>
> So that i get out e.g. in an array bla.xml and foofoo.xml?

I would use XML::Parser and write an Entity handler which pushed the
Sysid onto a globally scoped array.  After it has parsed the whole file
your array will contain your entities.

-jp



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

Date: 22 Nov 2006 09:40:27 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Passing an object to a module
Message-Id: <1164217227.132718.27590@f16g2000cwb.googlegroups.com>



On Nov 22, 12:52 am, Scott Bryce <sbr...@scottbryce.com> wrote:
> gmills wrote:
> > Hello -
>
> >      I am creating a module that does some work for various CGI in my
> > system. I would like to pass the CGI object to subroutines in my
> > module, but I can't figure out how to do it. Right now, I'm taking a
> > reference to the variable that holds the object in my CGI, like this:<code snipped>
>
> That variable is a reference to a hash.

"That" is unclear.

By which I mean that is unclear to what you are referring by the
pronown "that".

The "variable that holds the [CGI] object" that the OP refers to is a
variable that holds a reference to a thingy (that happens to be a hash)
that's been blessed into the class 'CGI'.

I think the point you are trying to make is that objects in Perl are
always handled via references so an extra level of indirection is
unecessary.



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

Date: Wed, 22 Nov 2006 09:47:32 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Passing an object to a module
Message-Id: <221120060947329751%jgibson@mail.arc.nasa.gov>

In article <1164154712.595331.108720@h54g2000cwb.googlegroups.com>,
gmills <gmills@library.berkeley.edu> wrote:

> Hello -
> 
>      I am creating a module that does some work for various CGI in my
> system. I would like to pass the CGI object to subroutines in my
> module, but I can't figure out how to do it. Right now, I'm taking a
> reference to the variable that holds the object in my CGI, like this:
> 
> use CGI;
> use MYMODULE;
> 
> $q = new CGI;
> 
> MYMODULE::subroutine(\$q);
> 
>      But if, for example, in MYMODULE, I do this:
> 
> use CGI;
> 
> sub subroutine {
> 
>     $qref = shift;
>     $q = $$qref;
> 
>      foreach $name ($q->params) {
> 
> 
> I get the message that CGI::params is an undefined subroutine, when it
> should be the names of the parameters passed to the CGI script.

There is no params() method. Call param() in list context without
arguments to get the names of the parameters passed to the CGI script.

See 'perldoc CGI' for available methods and how to use them.


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

Date: Wed, 22 Nov 2006 12:05:09 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Passing an object to a module
Message-Id: <7uKdnd2CFYf-AvnYnZ2dnUVZ_sOdnZ2d@comcast.com>

Brian McCauley wrote:

> I think the point you are trying to make is that objects in Perl are 
> always handled via references so an extra level of indirection is 
> unecessary.

Yes. That is the point I was trying to make. Thank you for clarifying.


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

Date: 22 Nov 2006 14:47:07 -0800
From: "GGB667" <ggb667@gmail.com>
Subject: Re: Regex exactly 0, 1 or 2 matches, {0,2} not working
Message-Id: <1164235627.022827.286180@e3g2000cwe.googlegroups.com>

I was really hoping to keep it as a pure regular expression.  What I've
ended up doing was having a boatload of different expressions, EX: one
with a comma, 1 with a comma and a space, one with a comma, space and
number 1-9, and one with a comma, space, number 1-9 and 0-5 and one
with all that and a-f after it.  I also have one with - or --.  It's
ugly.  Now here's the kicker.  The numbers are not allowed to be
identical!

So 1a, 2b is OK, but 1a, 1f is not!

I have absolutely no idea how to implement that unless I use a program.

So basically how can you make a regular expression with 2 DIFFERENT
numbers?

I thought there was some backreference thing you could use, but I can't
seem to get it to work.

So say 1,5 or 1,3 or 1,7 but not 2,2 or 1,1.

AURGH!



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

Date: Wed, 22 Nov 2006 18:30:14 GMT
From: Lars Haugseth <njus@larshaugseth.com>
Subject: Re: use print to write binary data to a filehandle seems not correct
Message-Id: <87r6vvwdb7.fsf@durin.larshaugseth.com>


* John Bokma <john@castleamber.com> wrote:
> 
> Even easier (instead of writing yourself using binmode [1]), read the 
> LWP::UserAgent documentation:
>
> $ua->get( $url , $field_name => $value, ... )
>
> ...
>
>
>     Fields names that start with ``:'' are special. These will not 
> initialize headers of the request but will determine how the response 
> content is treated. The following special field names are recognized:
>
>         :content_file   => $filename
>
> so:
>
> $ua->get( $url, ':content_file' => $filename );

This can be done even simpler by using the LWP::Simple module and its
getstore() or mirror() methods.

-- 
Lars Haugseth

"If anyone disagrees with anything I say, I am quite prepared not only to
 retract it, but also to deny under oath that I ever said it." -Tom Lehrer


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

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


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