[29973] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1216 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 20 11:09:45 2008

Date: Sun, 20 Jan 2008 08:09: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           Sun, 20 Jan 2008     Volume: 11 Number: 1216

Today's topics:
        (WW.CN-CIRCLE.COM) cheape wholesale tupac, gucci, timbe <huangcba3@gmail.com>
        A do-file location: how the code inside that do-file fi <arifsaha@yahoo.com>
    Re: A do-file location: how the code inside that do-fil <noreply@gunnar.cc>
    Re: A do-file location: how the code inside that do-fil <amphetamachine@gmail.com>
    Re: A do-file location: how the code inside that do-fil <hjp-usenet2@hjp.at>
    Re: A do-file location: how the code inside that do-fil <noreply@gunnar.cc>
    Re: A do-file location: how the code inside that do-fil <abigail@abigail.be>
    Re: Chat client/server print failed <zentara@highstream.net>
    Re: How do you use IPC::Open3.... <zentara@highstream.net>
    Re: incorrect errno/perror with IO::socket->new <rvtol+news@isolution.nl>
    Re: PERL MAP HELP <mailursubbu@gmail.com>
    Re: Wait for background processes to complete <pgodfrin@gmail.com>
    Re: Wait for background processes to complete <hjp-usenet2@hjp.at>
    Re: xml-to-word document <hjp-usenet2@hjp.at>
    Re: xml-to-word document <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 20 Jan 2008 04:58:45 -0800 (PST)
From: tt <huangcba3@gmail.com>
Subject: (WW.CN-CIRCLE.COM) cheape wholesale tupac, gucci, timberland, parade,  NBA shoes, N, H, UGG,Ice bream,4us,bape outlet shoes, discount hoodies, jeans
Message-Id: <e1bbba30-9edc-4212-863d-7fa05df7cb85@p69g2000hsa.googlegroups.com>

(WW.CN-CIRCLE.COM) cheape wholesale tupac, gucci, timberland, parade,
NBA shoes, N, H, UGG,Ice bream,4us,bape outlet shoes, discount
hoodies, jeans
(WWW.CN-CIRCLE.C(WW.CN-CIRCLE.COM) cheape wholesale tupac, gucci,
timberland, parade, NBA shoes, N, H, UGG,Ice bream,4us,bape outlet
shoes, discount hoodies, jeans
(WWW.CN-CIRCLE.COM) discount wholesale nike jordans, shox ,dunk,
airmax ,and ed hoodeis, jeans(www.cn-circle.com) cheap wholesale
Sunglasses 1).Gucci Sunglasses (www.cn-circle.com) cheap wholesale
Burse & Handbag 1).LV Bag 2).Gucci
(www.cn-circle.com) cheap wholesale Air Force One Air Force one (low)
Air Force one (High) Air Force
one (Mid) Air Force one (clear) Air Force One 25 year
(www.cn-circle.com) cheap wholesale SHOX  Shox R3 Shox R4 Shox R5
Shox
Our website:http://www.cn-circle.com and http://nikesneakertrade.photo.163.com
OM) discount wholesale nike jordans, shox ,dunk,
airmax ,and ed hoodeis, jeans(www.cn-circle.com) cheap wholesale
Sunglasses 1).Gucci Sunglasses (www.cn-circle.com) cheap wholesale
Burse & Handbag 1).LV Bag 2).Gucci
(www.cn-circle.com) cheap wholesale Air Force One Air Force one (low)
Air Force one (High) Air Force
one (Mid) Air Force one (clear) Air Force One 25 year
(www.cn-circle.com) cheap wholesale SHOX  Shox R3 Shox R4 Shox R5
Shox
Our website:http://www.cn-circle.com and http://nikesneakertrade.photo.163.com


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

Date: Sun, 20 Jan 2008 00:32:06 -0500
From: S P Arif Sahari Wibowo <arifsaha@yahoo.com>
Subject: A do-file location: how the code inside that do-file find it?
Message-Id: <alpine.OSX.0.9999.0801200031021.343@imac2006.local>

Hi!

Let's say script A call a subscript B either by do, require, or 
use. Now the code inside subscript B need to know what the file 
location of subscript B. How this can be done?

The perldoc page of do mentioned that perl will keep track the 
file name (e.g. for error reporting), how to get access to this 
file name recorded by perl?

Thanks!

-- 
                              (stephan paul) Arif Sahari Wibowo
    _____  _____  _____  _____
   /____  /____/ /____/ /____
  _____/ /      /    / _____/      http://www.arifsaha.com/


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

Date: Sun, 20 Jan 2008 07:28:22 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: A do-file location: how the code inside that do-file find it?
Message-Id: <5vg80dF1lla4iU1@mid.individual.net>

[ followup set to comp.lang.perl.misc ]

S P Arif Sahari Wibowo wrote:
> Let's say script A call a subscript B either by do, require, or use. Now 
> the code inside subscript B need to know what the file location of 
> subscript B. How this can be done?
> 
> The perldoc page of do mentioned that perl will keep track the file name 
> (e.g. for error reporting), how to get access to this file name recorded 
> by perl?

Read about the $0 variable in "perldoc perlvar".

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sat, 19 Jan 2008 22:52:43 -0800 (PST)
From: h3xx <amphetamachine@gmail.com>
Subject: Re: A do-file location: how the code inside that do-file find it?
Message-Id: <56072f25-067b-4f11-bbc1-05554a24fba4@i7g2000prf.googlegroups.com>

On Jan 19, 11:32 pm, S P Arif Sahari Wibowo <arifs...@yahoo.com>
wrote:
> Hi!
>
> Let's say script A call a subscript B either by do, require, or
> use. Now the code inside subscript B need to know what the file
> location of subscript B. How this can be done?
>
> The perldoc page of do mentioned that perl will keep track the
> file name (e.g. for error reporting), how to get access to this
> file name recorded by perl?
>
> Thanks!
>
> --
>                               (stephan paul) Arif Sahari Wibowo
>     _____  _____  _____  _____
>    /____  /____/ /____/ /____
>   _____/ /      /    / _____/      http://www.arifsaha.com/

Looks like the %INC hash is the key. For instance, let's say you have
a perl module with extension `.pm' somewhere on Per's include path:

package foo;

sub where_am_i {
  %INC{'foo.pm'}
}

Then calling &foo::where_am_i should produce the absolute file name
where Perl [first] found the file containing the where_am_i() sub.

For individual scripts, it's a bit easier:

#!/usr/bin/perl -w
print "I'm being called from $0\n";


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

Date: Sun, 20 Jan 2008 12:50:43 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: A do-file location: how the code inside that do-file find it?
Message-Id: <slrnfp6dcj.698.hjp-usenet2@hrunkner.hjp.at>

On 2008-01-20 06:28, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> [ followup set to comp.lang.perl.misc ]
>
> S P Arif Sahari Wibowo wrote:
>> Let's say script A call a subscript B either by do, require, or use. Now 
>> the code inside subscript B need to know what the file location of 
>> subscript B. How this can be done?

Why does it need to know that?


>> The perldoc page of do mentioned that perl will keep track the file name 
>> (e.g. for error reporting), how to get access to this file name recorded 
>> by perl?
>
> Read about the $0 variable in "perldoc perlvar".

%INC seems to be more like what the OP wants.

	hp


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

Date: Sun, 20 Jan 2008 13:09:34 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: A do-file location: how the code inside that do-file find it?
Message-Id: <5vgs06F1kgk9oU1@mid.individual.net>

Peter J. Holzer wrote:
> On 2008-01-20 06:28, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> [ followup set to comp.lang.perl.misc ]
>>
>> S P Arif Sahari Wibowo wrote:
>>> Let's say script A call a subscript B either by do, require, or use. Now 
>>> the code inside subscript B need to know what the file location of 
>>> subscript B. How this can be done?
> 
> Why does it need to know that?
> 
>>> The perldoc page of do mentioned that perl will keep track the file name 
>>> (e.g. for error reporting), how to get access to this file name recorded 
>>> by perl?
>>
>> Read about the $0 variable in "perldoc perlvar".
> 
> %INC seems to be more like what the OP wants.

You are right; I replied too hasty. Thanks for pointing it out!

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 20 Jan 2008 12:11:50 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: A do-file location: how the code inside that do-file find it?
Message-Id: <slrnfp6ek6.gm.abigail@alexandra.abigail.be>

                                                     _
S P Arif Sahari Wibowo (arifsaha@yahoo.com) wrote on VCCLV September
MCMXCIII in <URL:news:alpine.OSX.0.9999.0801200031021.343@imac2006.local>:
<>  Hi!
<>  
<>  Let's say script A call a subscript B either by do, require, or 
<>  use. Now the code inside subscript B need to know what the file 
<>  location of subscript B. How this can be done?
<>  
<>  The perldoc page of do mentioned that perl will keep track the 
<>  file name (e.g. for error reporting), how to get access to this 
<>  file name recorded by perl?

say __FILE__;



Abigail
-- 
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Sun, 20 Jan 2008 10:27:32 -0500
From: zentara <zentara@highstream.net>
Subject: Re: Chat client/server print failed
Message-Id: <ulp6p3pu15cq7tr9rnt6hujrc4c62a15hl@4ax.com>

On Fri, 18 Jan 2008 07:59:10 -0800 (PST), deadpickle
<deadpickle@gmail.com> wrote:

>I suspect it is the Glib::Timeout that is not working right. I tried
>putting a print statement in the wait_for_msg sub and it only printed
>once and it should be printing continuously. Is there a better way to
>create a timer in Gtk2?

It dawned on me in a dream, that using a timer to keep the socket
open( as you are tring to do ) is wrong.

What you need to do is use a Gtk2::Helper (which is like Tk's
fileevent), NOT a TIMER, to keep a select read open on the socket.

#add a Gtk2::Helper watch on any incomming connections

Gtk2::Helper->add_watch ( fileno $sock, 'in',sub{
        my ($fd,$condition,$fh) = @_;
        #call 'watch_callback' to handle the incomming data
        \&watch_callback($fh,$tview);
        },$sock);
                     
sub watch_callback {

        my ($fh,$tview) = @_;
        my $msg;
        $fh->recv($msg, $MAXLEN) or die "recv: $!";
                print $msg."\n";
                my $buffer = $tview->get_buffer();
                &update_buffer($buffer,$msg,FALSE);

        return 1;
}


goodluck,
zentara




-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: Sun, 20 Jan 2008 10:27:32 -0500
From: zentara <zentara@highstream.net>
Subject: Re: How do you use IPC::Open3....
Message-Id: <9fp6p3lvt4g9cgltj9qpp2toh4gvn1h0qf@4ax.com>

On Sat, 19 Jan 2008 14:11:15 -0800 (PST), grocery_stocker
<cdalten@gmail.com> wrote:

>to start a process in the background? I'm drawing a total blank.

Go to http://groups.google.com and search for "perl IPC::Open3"
and you will find many examples.

Searching http://perlmonks.org will also yield many examples.

zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: Sun, 20 Jan 2008 13:17:53 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: incorrect errno/perror with IO::socket->new
Message-Id: <fmvhuc.1k4.1@news.isolution.nl>

Uri Guttman schreef:

> if the call to IO::Socket->new doesn't
> return undef, there is NO point in checking out $! or $@. they will be
> meaningless and may be set to some irrelevant value. i have never had
> to clear those before making any lib or system calls. i only check
> them if there is an indicator of an error. checking them directly is
> wrong in almost every case. they could be changed due to some
> internal call that is redone or worked around and yet your call will
> still have succeeded.


Idem with

   eval {
       ...;
       1;
   } or do {
      ...
   };

v.s.


   eval {
       ...;
   };
   if ($@) {
      ...
   };

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Sun, 20 Jan 2008 06:13:55 -0800 (PST)
From: Subra <mailursubbu@gmail.com>
Subject: Re: PERL MAP HELP
Message-Id: <8db99d7c-cd1b-4597-825d-012f1808cf8e@s8g2000prg.googlegroups.com>

Thanks a lot Brian for detailed reply...
Its really helpful...


On Jan 19, 6:58 pm, Brian McCauley <nobul...@gmail.com> wrote:
> On Jan 19, 12:03 pm, Subra <mailursu...@gmail.com> wrote:
>
> > Hi,
>
> >  Can some one tell me how the below code works ???
>
> An explanation of the sematics of...
>
> map { BLOCK } LIST
>
> ...can be found in the Perl reference manual.
>
> If there's anything you find unclear in there please let us know what.
>
> Any off-the-cuff explanation that someone could post to a newsgroup is
> unlikely to be better than the one in the manual.
>
> > 605:            @cherou= map {
> > 606:                    ($nf,@narg)=split(/:/,$_);
> > 607:                    &{$::{"setup_$nf"}}($type,@narg); #returns the
> > subformat above
> > 608:            }  exists $setupstuff{$ap} ? @{$setupstuff{$ap}} :
> > () ;
>
> >  And also pls let me know wts mean by &{$::{"setup_$nf"}}
> > ($type,@narg).
>
> >  Is $:: used to access the defs from the other packages ???
>
> $::{ whatever } is actually a simply a hash lookup in the special hash
> called %:: which is the root of the Perl symbol table. %:: is actually
> the same hash as %main:: which is the symbol table of the default
> package 'main'.  Using this syntax you can only access symbols  form
> the default package main.
>
> Therefore supping $nf='foo' the expression $::{"setup_$nf"} therefore
> returns the symbol table entry (GLOB) from the package main for the
> symbol setup_foo (aka *main::setup_foo ). Indeed $::{"setup_$nf"} is
> almost the same as saying *{"main::setup_$nf"} except using the
> explicit symbolic GLOBref will auto-vivify the GLOB and makes the
> intent much clearer.
>
> &{ whatever } will they coerce whatever into a CODEref. Since whatever
> is *main::setup_foo the whatever gets coerced into
> *main::setup_foo{CODE} aka \&main::setup_foo.
>
> &{$::{"setup_$nf"}}($type,@narg)  is therefore equivalent to
> main::setup_foo($type,@narg). OK that's a slight simplification in
> that I'm assuming &main::setup_foo doesn't have a prototype - usually
> a safe assumption.
>
> All in all I'd just say
>
> "main::setup_$nf"->($type,@narg);
>
> Now, I hear you all (and indeed strict.pm) cry "you're using symrefs".
> Yes I am. So I'd need actually to say:
>
> no strict 'refs';
> "main::setup_$nf"->($type,@narg);
>
> But it is important to note is that using symrefs is not evil just
> because some pseudo-deity declared that it should be the case. It's
> evil because mucking about with the symbol table is fraught with
> dangers. If you are going to do this anyhow then do it with the
> simplest syntax Perl offers and put a nice big red flag "no strict" so
> that it is obvious what you're doing. Don't go using a more obfuscated
> approach to avoid the need for "no strict".
>
> Also the construct
>   exits( EXPR )? @{ EXPR } : ();
>
> Seems unduly complex. If EXPR does not exist then it'll also be false
> so it's simpler to say
>
>   @{ EXPR || [] };
>
> Oh, and the original code was missing at least one my().
>
>             my @cherou= map {
>                    my ($nf,@narg)=split /:/;
>                    no strict 'refs';
>                    "main::setup_$nf"->($type,@narg);
>              } @{$setupstuff{$ap} || []};



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

Date: Sat, 19 Jan 2008 20:47:14 -0800 (PST)
From: pgodfrin <pgodfrin@gmail.com>
Subject: Re: Wait for background processes to complete
Message-Id: <f0e4d724-23ad-44b7-b0b5-ce31c15f6a2c@s13g2000prd.googlegroups.com>

On Jan 19, 6:12 pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2008-01-19 23:37, pgodfrin <pgodf...@gmail.com> wrote:
>
> > On Jan 18, 3:17 pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> >> On 2008-01-18 17:47, pgodfrin <pgodf...@gmail.com> wrote:
>
> >> > This was a lot of fun. I would like to respond to the various
> >> > observations, especially the ones about the Perl Documentation being
> >> > misleading.
> >> [...]
> [76 lines snipped]
> >> > Furthermore, while the perlipc section is quite verbose, nowhere is
> >> > the code snippet  do {$x=wait; print "$x\n"} until $x==-1 or any
> >> > variation of that wait() call mentioned.
>
> >> Again, this is a solution to your specific problem. You said you wanted
> >> to wait for all children, so Xho wrote a loop which would do that. This
> >> is a rather rare requirement - I think I needed it maybe a handful of
> >> times in 20+ years of programming outside of a child reaper function.
>
> [109 lines snipped - please quote only the relevant parts of the
> articles you reply to]
>
> > Thanks - you've been quite fair. The only point I would argue is how
> > many times you needed to wait for background tasks.
>
> I need to wait for background tasks quite often. But usually either I
> need to wait for only one of them or some of them, but rarely all of
> them. But I don't see how it matters. If you know how to wait for one
> process, and you know how to write a loop, it is trivial to wait for all
> processes.
>
> > I guess the salient point is - I'm not a systems programmer - so I use
> > Perl like shell scripting and because I think it's stupid to do if-fi
> > and case- esac pairs.
>
> That's ok. Perl just gives you a lot more flexibility than the shell,
> at the price of higher complexity. For example, it would be quite easy
> to change your script to do a configurable number of copies in parallel
> - this is rather hard to do in the shell.
>
> > p.s. what's an OP ?
>
> "original poster": The person who started a thread, i.e. you in this case.
>
>         hp

cool - that is in fact my next goal - to have an option that throttle
how may concurrent tasks...

regards from the OP :)
pg


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

Date: Sun, 20 Jan 2008 12:35:40 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Wait for background processes to complete
Message-Id: <slrnfp6cgf.698.hjp-usenet2@hrunkner.hjp.at>

On 2008-01-20 02:03, xhoster@gmail.com <xhoster@gmail.com> wrote:
> "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>> Xho's solution is safe (and was so in all perl
>> versions and does what the OP wants. Well, almost - wait can return -1
>> if it is interrupted so one should check $! in addition to the return
>> value.
>
> Are you sure that that is the case?

No. It's more a "it does happen in C and it isn't documented so better
add an extra check just in case" kind of reaction.

> I figured it would return undef on
> error.  Upon experimenting (with both >5.8 and <5.8) I found that (on my
> system) wait returns neither -1 nor undef due to signals, because it
> never returns due to signals.  The Perl wait behind the scenes just keeps
> recalling the system-level wait either until something is reaped, or until
> the program dies, or until a die/eval pair causes it to jump out of the
> execution path without actually returning.

Good to know. If this is generally the case (not just on your system) it
would be good if this information could be added to perlfunc.

	hp


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

Date: Sun, 20 Jan 2008 12:48:17 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: xml-to-word document
Message-Id: <slrnfp6d86.698.hjp-usenet2@hrunkner.hjp.at>

On 2008-01-20 01:03, Jürgen Exner <jurgenex@hotmail.com> wrote:
> Moti <motic.mail@gmail.com> wrote:
>>I would like to perform xml-to-word conversion.
>
> I don't understand what you are looking for. XML is just plain text with
> specific syntax rules. Microsoft Office Word will open an XML file just
> fine.

Any XML file, or just XML files with a DTD it recognizes? If the former,
it probably just opens them as text files, which is trivially possible
but not very useful.

> There is no need for any conversion.

There is, but it depends almost certainly on the DTD. For example, when
you convert a DocBook document, you would want to convert a title
element within a section element to a paragraph with the appropriate
heading style.

	hp


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

Date: Sun, 20 Jan 2008 12:46:43 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: xml-to-word document
Message-Id: <3bg6p3him0dmud4kp1us7s7locol2a8fft@4ax.com>

"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>On 2008-01-20 01:03, Jürgen Exner <jurgenex@hotmail.com> wrote:
>> Moti <motic.mail@gmail.com> wrote:
>>>I would like to perform xml-to-word conversion.
>>
>> I don't understand what you are looking for. XML is just plain text with
>> specific syntax rules. Microsoft Office Word will open an XML file just
>> fine.
>
>Any XML file, or just XML files with a DTD it recognizes? If the former,
>it probably just opens them as text files, which is trivially possible
>but not very useful.

Any XML file. And I agree with both of your assessments :-)

>> There is no need for any conversion.
>
>There is, but it depends almost certainly on the DTD. For example, when
>you convert a DocBook document, you would want to convert a title
>element within a section element to a paragraph with the appropriate
>heading style.

Sooooo, first of all we need to know more about what kind of XML files the
OP is talking about and _how_ he wants to convert them. 

jue


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

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


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