[26232] in Perl-Users-Digest
Perl-Users Digest, Issue: 8417 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 14 11:05:24 2005
Date: Wed, 14 Sep 2005 08:05:06 -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 Wed, 14 Sep 2005 Volume: 10 Number: 8417
Today's topics:
Re: File Modification Date <nobull@mail.com>
Re: File Modification Date <tadmc@augustmail.com>
Re: File Modification Date <jurgenex@hotmail.com>
Re: How to remove `` \x{d} metacharacters from strings (Anno Siegel)
Re: Need a regex (Anno Siegel)
Re: Need a regex <tadmc@augustmail.com>
Re: Need a regex <1usa@llenroc.ude.invalid>
Open variable txt file <tony@big-giant-head.com>
Re: Perl core dumping - possible bug? (Anno Siegel)
Re: Simple question for you's...... <nobull@mail.com>
Re: Simple question for you's...... <unmailable@duetospam.com>
Using a dotNet dll from Perl to control Word <nospam@nospam.com>
Re: Using a dotNet dll from Perl to control Word <sisyphus1@nomail.afraid.org>
Zombie problem when creating a listening Socket <vikrantREMOVE@DELETEsaysnetsoft.com>
Re: Zombie problem when creating a listening Socket (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 14 Sep 2005 13:20:04 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: File Modification Date
Message-Id: <dg94hk$rsl$2@redhat2.bham.ac.uk>
Josef Moellers wrote:
> perldoc perlfunc
> then search for -M
Actually, although it seems counter-intuative, you _can_ do:
perldoc -f -M
See also
perldoc -f stat
------------------------------
Date: Wed, 14 Sep 2005 07:43:01 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: File Modification Date
Message-Id: <slrndig6ml.30j.tadmc@magna.augustmail.com>
Vance M. Allen <vma_nntp@vmacs.us> wrote:
> Subject: File Modification Date
^^^^^^^^^^^^
> date and/or time that a file was
> created
^^^^^^^
> the file modified timestamp.
^^^^^^^^
Modified: 2
Created: 1
Which is it?
Many filesystems do not keep track of when a file is created.
> If anyone can help me with the libraries
You don't need _any_ libraries to get the modified time stamp:
perldoc -f stat
see also:
perldoc -f -X
and maybe:
perldoc -f localtime
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 14 Sep 2005 12:52:07 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: File Modification Date
Message-Id: <X1VVe.3433$YI6.3424@trnddc05>
Vance M. Allen wrote:
> I'm trying to find out how to determine the date and/or time that a
> file was created in a simple procedure.
Are you looking for stat()?
[...]
8 atime last access time in seconds since the epoch
9 mtime last modify time in seconds since the epoch
10 ctime inode change time (NOT creation time!) in seconds
since
the epoch
jue
------------------------------
Date: 14 Sep 2005 10:26:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to remove `` \x{d} metacharacters from strings ...
Message-Id: <dg8tt3$bb3$3@mamenchi.zrz.TU-Berlin.DE>
C. Colin Backslas <ckb@reboot.erg> wrote in comp.lang.perl.misc:
> Howdy,
>
> I've got a Perl-Tk/Net::Telnet command generator [Tl1] to build commands
> and send them to a box and display the responses back to a
> Tk::Text entry. In each of the response strings I have ``\x{d}''
> at the beginning or end of each string.
>
> How can I remove these characters?
> Any help would be greatly appreciated.
Do you mean, the five characters \x{d} appear literally in the strings?
If so, that is most likely a bug in the program that generates them.
In a double-quotish context, "\x{d}" expands to ASCII character 13
(d in hex), which is a carriage return (CR). For some reason, the
expansion doesn't seem to happen.
How to get rid of them? Short term: s/\\x{d}//g. Long term: Mail
the author.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: 14 Sep 2005 11:41:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need a regex
Message-Id: <dg929f$g4l$1@mamenchi.zrz.TU-Berlin.DE>
A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in comp.lang.perl.misc:
> Shane <shane@weasel.is-a-geek.net> wrote in
> news:pan.2005.09.13.21.28.25.356154@weasel.is-a-geek.net:
>
> > On Tue, 13 Sep 2005 21:20:38 +0000, Randy Harris wrote:
> >
> >> I would appreciate help creating a regex. I have a file that
[...]
> Here is something that will actually work:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> while(<DATA>) {
> if( /^([\d-]+\d+)-/ ) {
> print "$1\n";
> }
> }
>
> __DATA__
> 123-12-23-Bottom Bracket
> 561-318-001-Cowling Spacer 2
> 453-2193-Fitting Hose
>
> D:\Home\asu1\UseNet\clpmisc> www
> 123-12-23
> 561-318-001
> 453-2193
...or a regex-reduced version:
print join( '-', grep !/\D/, split /-/), "\n" while <DATA>;
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Wed, 14 Sep 2005 07:34:44 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Need a regex
Message-Id: <slrndig674.30j.tadmc@magna.augustmail.com>
Tom Potter <tompotter@hotmail.com> wrote:
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
> news:Xns96D0B43E61878asu1cornelledu@127.0.0.1:
>> Shane <shane@weasel.is-a-geek.net> wrote in
>> news:pan.2005.09.13.21.28.25.356154@weasel.is-a-geek.net:
>>> On Tue, 13 Sep 2005 21:20:38 +0000, Randy Harris wrote:
>> To the OP: This is not a "write my code for me" service. If you do not
>> put any effort into helping others help you, you cannot expect others to
>> put much effort into helping you.
[ snip silly (I'd say trollish) code ]
>> Now, Shane,
[ snip a litany of the silliness ]
>> Here is something that will actually work:
[ snip answer to OP's question! ]
>> Please read the posting guidelines for this group.
Always good advice.
> Please don't take it otherwise,
That sentence makes no sense, unless you indicate other than *what*.
I think you are hoping to stay out of scorefiles, but I must say that
you are teetering on the brink of getting in anyway.
> I would never understand why pepople act so pricy in answering queries
Maybe it is because you don't have the same context and experiences
as those you are observing.
Have you been observing here daily for months or years?
> for
> a freeware like perl,
Perl (and perl) is _better_ than freeware.
Perl is open source, it is _both_ kinds of "free".
I fail to see how the business model of the subject would make a
difference in what to expect in a Usenet newsgroup about that subject.
Are folks "nice" in some other high-traffic newsgroup that discusses
some "closed" software?
Usenet is not a help desk, even when the group's topic is a
commercial program.
> look at Tad's answer, short and simple,
I had decided not to respond to the OP for exactly the reason
given in ASU's "To the OP" note above.
It was only after seeing several followups that failed to notice
the possible simplification of the requirements that I had seen
did I decide to post to this thread.
I posted for the benefit of the thread's readers rather than for the OP.
> few maybe
> more people don't do serious programing in perl ,they do it cause they
> think its better,efficient and easy then writing a batch file,
That is a primary reason underlying the angst that we have here in
clp.misc versus most other comp.lang.* newsgroups.
Some here are (expert?) professional programmers while some are not.
Perl is easy enough to use that hobbyists can get things done with it.
When the hobbyist can't get "Hello world" to run in Java or C++, they
give up, so the proportion of professional programmers is much higher
in their newsgroups than it is here.
Some impedance mismatch is to be expected when groups from opposite
ends of a spectrum interact with each other.
> why do such
> persons get a arrogant answer or anybody,
Arrogant?
What, exactly, did you see as arrogant?
Was it ASU's reply to the OP or to Shane?
We can't tell because you did a full-quote.
You know what I see as arrogant?
Someone who just got here (as far as I can tell) telling us
how to do it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 14 Sep 2005 14:59:46 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Need a regex
Message-Id: <Xns96D16FDC6DAAFasu1cornelledu@132.236.56.8>
Tad McClellan <tadmc@augustmail.com> wrote in
news:slrndiek5q.co.tadmc@magna.augustmail.com:
> Randy Harris <randy@SpamFree.com> wrote:
>
>> followed by a
>> dash and then non digit data. For example:
>>
>> 123-12-23-Bottom Bracket
>> 561-318-001-Cowling Spacer 2
>> 453-2193-Fitting Hose
>>
>> I need to capture the numeric portion, up to but not including the last
>> dash. From the above samples I would want:
...
> while ( <DATA> ) {
> print "$1\n" if /(.*)-/;
> }
Now, I had not thought of that :)
This would absolutely do what the OP asked for when the data contained
exactly what he showed.
On the other hand, (maybe I'm thinking too much in terms of processing CGI
form submissions these days) I try to write my regexes to match only the
things I want them to match.
Thanks,
Sinan
------------------------------
Date: Wed, 14 Sep 2005 15:04:51 GMT
From: Tony Heagren <tony@big-giant-head.com>
Subject: Open variable txt file
Message-Id: <2005091416045216807%tony@biggiantheadcom>
Hi All,
new to this so forgive if this is a very obvious question.
Is there a way to tell perl to open a txt file from a variable passed
(in this case) from Flash.
ie instead of using this:
open(FILE,">../www/folder/exact_filename.txt") or print "response=trouble";
could I use something like this:
open(FILE,">$a_txt_file_name_passed_from_flash_as_a_variable") or print
"response=trouble";
All and any help much appreciated
Tony
------------------------------
Date: 14 Sep 2005 13:13:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl core dumping - possible bug?
Message-Id: <dg97lb$jrj$1@mamenchi.zrz.TU-Berlin.DE>
<xhoster@gmail.com> wrote in comp.lang.perl.misc:
> Ala Qumsieh <notvalid@email.com> wrote:
> > Hi all,
> >
> > The following snippet coredumps in both perl5.6.1 and perl5.8.3 on both
> > linux and solaris, as well as perl5.8.0 on winXP:
> >
> > % perl -Mstrict -wle 'map {map {print "x" for 1 .. 5} 1..5} 1..5'
> >
> > Interestingly, the following coredumps in 5.6.1, but not in 5.8.0 or
> > 5.8.3:
> >
> > % perl -Mstrict -wle 'map {print "x" for 1 .. 5} 1..5'
> >
> > Am I doing something wrong, or have I stumbled upon some Perl bug?
>
> I'd say both. The desire to do this seems perverse, to me. But it
> still shouldn't seg fault.
>
> > Can someone please confirm with the latest stable release 5.8.7?
>
> Confirmed on 5.8.7 on Linux.
Seen here too, but only with three-deep nesting.
The for loop in a map block seems to be the problem. Map wants to collect
the values of the last statement in that block, but a for loop has no
value. Changing the innermost block to
{print "x" for 1 .. 5; 1}
helps. Of course, things like "sub {}" don't return a value either
and can be called in map. It shouldn't segfault.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Wed, 14 Sep 2005 13:17:31 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Simple question for you's......
Message-Id: <dg94cr$rsl$1@redhat2.bham.ac.uk>
Anno Siegel wrote:
>>"Brian McCauley" <nobull@mail.com> wrote
>>>
>>> s/.+?(?=\/.{0,46}$)/.../ if length > 50;
>
> Very nice. I believe the final "$" can go, the last part is greedy
> anyhow.
No, that would match upto the first '/' anywhere in the string. The OP
wants to match upto first '/' within the last 47 characters of the string.
------------------------------
Date: Wed, 14 Sep 2005 14:51:41 +0100
From: "Slow Learner" <unmailable@duetospam.com>
Subject: Re: Simple question for you's......
Message-Id: <dg99sc$acg$1$8300dec7@news.demon.co.uk>
I see Retention is rife in the Perl programming news-group.
"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in message
news:Pine.LNX.4.62.0509140941061.26350@ppepc56.ph.gla.ac.uk...
> On Wed, 14 Sep 2005, Slow Learner top-posted:
>
>>
>>
>> Hmmmmm interesting. Gibberish but interesting....... :)
>>
>>
>
> Good news: your application for fast-track entry to the killfile was
> overwhelmingly approved.
>
> SCNR.
------------------------------
Date: Wed, 14 Sep 2005 11:57:22 +0000 (UTC)
From: "Vic Russell" <nospam@nospam.com>
Subject: Using a dotNet dll from Perl to control Word
Message-Id: <dg9372$c2b$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>
Hi,
I need to write a dotNet dll which will control Word (open documents, add
templates, set options etc) and which will be invoked from within Perl which
our application is written in. Can anyone give me some pointers? Has anyone
got any relevant examples?
Regards,
Vic Russell
------------------------------
Date: Wed, 14 Sep 2005 22:43:39 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Using a dotNet dll from Perl to control Word
Message-Id: <43281b2d$0$17392$afc38c87@news.optusnet.com.au>
"Vic Russell" <nospam@nospam.com> wrote in message
news:dg9372$c2b$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
> Hi,
>
> I need to write a dotNet dll which will control Word (open documents, add
> templates, set options etc) and which will be invoked from within Perl
which
> our application is written in. Can anyone give me some pointers? Has
anyone
> got any relevant examples?
>
You could access the functions in the dll using Win32::API. (Win32::API used
to work only with dll's that used stdcall calling convention. I think that
has now changed, but it might be better to use stdcall in your dll if that's
an option.)
You could also use Inline::C to access the functions - though you'll also
need an import lib ('.lib') file for linking purposes if you go down that
path. See 'perldoc Inline::C-Cookbook'. Find the example 'How do I access
Win32 DLL-s using Inline?'.
Cheers,
Rob
------------------------------
Date: Wed, 14 Sep 2005 17:09:16 +0530
From: vikrant <vikrantREMOVE@DELETEsaysnetsoft.com>
Subject: Zombie problem when creating a listening Socket
Message-Id: <dg928j$15r$1@domitilla.aioe.org>
Hi
I have written a code for Listening socket(Server) that serve multiple
clients request.The Socket(Server) accept the data from clients and send
back them the same data for validation.
But,I am facing a problem while running the following code .The code
creating a Zombie for each client request.
-----------------------------------------------------------------
#!/usr/bin/perl
use IO::Select;
use IO::Socket::INET;
#LISTENING SOCKET
$sListening_Socket = new IO::Socket::INET (LocalPort => 36545,
Proto => "tcp",
Listen => 4,
Type => SOCK_STREAM)
or die "Could not create socket";
REQUEST:
while ($sNew_Socket = $sListening_Socket->accept())
{
if($iChild_Pid=fork) #Check the Child Process ID
{
close ($sNew_Socket); #Parent closes unused handle
next REQUEST;
} defined($iChild_Pid) or die "Cannot fork";
close ($sListening_Socket); #Child closes unused Handle
$obSelected_Socket = IO::Select->new($sNew_Socket);
while( $obSelected_Socket->can_read(20)) #Wait for 20 seconds
{
sysread($sNew_Socket,$sBuffer,1<<10);
$sData_Recevied.=$sBuffer;
if($sBuffer =~/\/message_end>/)
{
last;
}
}
$sNew_Socket->send($sData_Recevied);
close($sNew_Socket);
exit;
}
------------------------------------------------------------------------------------
Also,when i run the following command
ps -A|grep perl
3466 pts/1 00:00:00 perl
3469 pts/1 00:00:00 perl <defunct>
3473 pts/1 00:00:00 perl <defunct>
3478 pts/1 00:00:00 perl <defunct>
3482 pts/1 00:00:00 perl <defunct>
3486 pts/1 00:00:00 perl <defunct>
3490 pts/1 00:00:00 perl <defunct>
please known me if i am missing something.
With Regards
Vikrant
------------------------------
Date: 14 Sep 2005 11:51:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Zombie problem when creating a listening Socket
Message-Id: <dg92rl$g4l$2@mamenchi.zrz.TU-Berlin.DE>
vikrant <vikrantREMOVE@DELETEsaysnetsoft.com> wrote in comp.lang.perl.misc:
> Hi
>
> I have written a code for Listening socket(Server) that serve multiple
> clients request.The Socket(Server) accept the data from clients and send
> back them the same data for validation.
>
> But,I am facing a problem while running the following code .The code
> creating a Zombie for each client request.
Your code doesn't care about its kids, sure they end up becoming zombies.
Try setting $SIG{ CHLD} = 'IGNORE' in the parent. If that doesn't help,
install a reaper. Look for "zombie" and "REAPER" in perlipc for more.
Anno
[original code]
> -----------------------------------------------------------------
>
> #!/usr/bin/perl
> use IO::Select;
> use IO::Socket::INET;
>
> #LISTENING SOCKET
> $sListening_Socket = new IO::Socket::INET (LocalPort => 36545,
> Proto => "tcp",
> Listen => 4,
> Type => SOCK_STREAM)
> or die "Could not create socket";
>
> REQUEST:
> while ($sNew_Socket = $sListening_Socket->accept())
> {
> if($iChild_Pid=fork) #Check the Child Process ID
> {
> close ($sNew_Socket); #Parent closes unused handle
> next REQUEST;
> } defined($iChild_Pid) or die "Cannot fork";
>
> close ($sListening_Socket); #Child closes unused Handle
>
> $obSelected_Socket = IO::Select->new($sNew_Socket);
> while( $obSelected_Socket->can_read(20)) #Wait for 20 seconds
> {
> sysread($sNew_Socket,$sBuffer,1<<10);
> $sData_Recevied.=$sBuffer;
> if($sBuffer =~/\/message_end>/)
> {
> last;
> }
> }
>
> $sNew_Socket->send($sData_Recevied);
> close($sNew_Socket);
> exit;
> }
> ------------------------------------------------------------------------------------
> Also,when i run the following command
>
> ps -A|grep perl
>
> 3466 pts/1 00:00:00 perl
> 3469 pts/1 00:00:00 perl <defunct>
> 3473 pts/1 00:00:00 perl <defunct>
> 3478 pts/1 00:00:00 perl <defunct>
> 3482 pts/1 00:00:00 perl <defunct>
> 3486 pts/1 00:00:00 perl <defunct>
> 3490 pts/1 00:00:00 perl <defunct>
>
> please known me if i am missing something.
>
> With Regards
>
> Vikrant
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
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 8417
***************************************