[22580] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4801 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 1 18:06:18 2003

Date: Tue, 1 Apr 2003 15:05:11 -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           Tue, 1 Apr 2003     Volume: 10 Number: 4801

Today's topics:
    Re: array or two hashes? ctcgag@hotmail.com
        creating virtual directories with urls (john harrold)
    Re: creating virtual directories with urls <eric.schwartz@hp.com>
    Re: Does Perl can do everything you need in unix shell  <vilain@spamcop.net>
    Re: Does Perl can do everything you need in unix shell  <no@no.com>
    Re: Does Perl can do everything you need in unix shell  (edu@rd c)
        execute perl by redirection (siddhartha mulpuru)
    Re: execute perl by redirection (Randal L. Schwartz)
        how to create own perl module (ramesh)
    Re: how to create own perl module <abigail@abigail.nl>
    Re: implementing a threaded serial device (or any other <goldbb2@earthlink.net>
    Re: Loading STDOUT into a variable (Tad McClellan)
    Re: modules using modules - shared objects <goldbb2@earthlink.net>
        Need Help : Pass ing Variables between a Script and a P (KP)
    Re: OO problem with Data::Dumper and IO::Scalar <alex@nospamhoopsie.com>
    Re: OO problem with Data::Dumper and IO::Scalar <tassilo.parseval@rwth-aachen.de>
    Re: passing variables to fork() ctcgag@hotmail.com
    Re: passing variables to fork() <jhayden@usa.com>
    Re: Perl & XPath <ngroups@ians-netNOSPAM.co.uk>
        perl module---returning values to anothe string (ramesh)
        perl noob question (banjo)
    Re: perl noob question <emschwar@pobox.com>
    Re: piped commands <user@someserver123abc.com>
        Problem with a subroutine executing another instance of <fdee@fesfs.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 01 Apr 2003 16:21:20 GMT
From: ctcgag@hotmail.com
Subject: Re: array or two hashes?
Message-Id: <20030401112120.198$Eo@newsreader.com>

hannes michalek <hannes@michalek.de> wrote:
> i have two sub's in my script:
> 1) takes a directory and returns a list of files in that directory

hash of lists.

> 2) takes a directory and returns the text of a certain line in a certain
> file in that directory.

Since it takes only a directory, I assume the certain line and certain file
are determined internally by the sub's logic.  So, a simple hash.


> the problem is: the script does that very often and many times for the
> same directories. so i want to scan all directories at the beginning,
> storing filenames and text and using the stored ones later in the
> program.
>
> my question is, then:
> is it faster

Faster to execute, or faster for you to code and debug?

> to use an array (directory,filenames,text)

I don't understand what you are saying here, it isn't sufficiently
Perlish .  Do you mean:
($directory1, [@filenames1], $text1, $directory2, [@filenames2],$text2...)

i.e. a sequence of triplets?  That seems like an aweful way to do it.

> or two hashes
> (directory, filelist) and (directory,text)?

$listhash{$directory}=[@filelist]; $texthash{$directory}=$text;

If the subs are used mostly independently, I would do it this way.



Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 1 Apr 2003 13:47:45 -0800
From: jmh17@pitt.edu (john harrold)
Subject: creating virtual directories with urls
Message-Id: <31d0e2b6.0304011347.59abc842@posting.google.com>

my current setup is something like this. i have a url:

http://a.org/f.pl?hash=abcd&id=34         (1)

which i want to access like this:

http://a.org/file/abcd-34/bob.jpg         (2)

now keep in mind that the directory /file and /file/abcd-34 do not
exist. in perl i can get the url. from the url i can get the relevent
information. what i dont know is how to make apache execute a
perlscript when a path like:

http://a.org/file/xxxx-xxxx/

that doesn't exist is called. i thought about trying to trap the 404
error and have it redirect to a page, but i dont really want the url
to change since (2) is cleaner than (1). can someone tell me how to do
this, preferably using the .htaccess file. i realize i'm not talking
about virtual directories in the apache directive sense.


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

Date: 01 Apr 2003 15:22:57 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: creating virtual directories with urls
Message-Id: <etoel4l6eny.fsf@wormtongue.emschwar>

jmh17@pitt.edu (john harrold) writes:
> now keep in mind that the directory /file and /file/abcd-34 do not
> exist. in perl i can get the url. from the url i can get the relevent
> information. what i dont know is how to make apache execute a
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> perlscript when a path like:
  ^^^^^^^^^^

So you know the problem is with Apache configuration, and yet you ask
on a Perl language newsgroup?  Um, okay.  That makes no sense to me,
but presumably you think we're better suited than the people over on
c.i.w.s.*.  Me, I'd have asked comp.lang.forth, since I know somebody
who writes CGI in Forth.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Tue, 01 Apr 2003 09:22:11 -0800
From: "Michael Vilain <vilain@spamcop.net>"
Subject: Re: Does Perl can do everything you need in unix shell scripting?what about PHP?
Message-Id: <news-D80351.09221101042003@news.tdl.com>

In article <1e1c9a33.0303311430.2143c5e@posting.google.com>,
 ecleofe7@yahoo.com (edu@rd c) wrote:

> hi Guys,
>         Need your advice.This could be helpfull for those newbie.I
> want to learn shell scripting.I just want to know that if you master
> the Perl you can overcome all the shell scripting needed in unix,on
> w/c you dont need to study those csh,bsh,bash and so on.But what about
> PHP,since they are just the same function with perl and this is much
> easier to learn?
>         Thanks in advanced.God Bless to all...
> .

Now I know this is a troll.  Google for the discussion you started on 
this last week.  Bless you too.  Now go away.

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...





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

Date: Tue, 1 Apr 2003 10:05:45 -0800
From: "EB" <no@no.com>
Subject: Re: Does Perl can do everything you need in unix shell scripting?what about PHP?
Message-Id: <3e89d745$1@usenet01.boi.hp.com>

Init scripts in PHP?  Been done:

http://neon1.net/m0n0wall/index.html

"Brendon Caligari" <bcaligari@fubar.fireforged.com> wrote in message
news:3e88c538$0$66672$bed64819@news.gradwell.net...
>
> "edu@rd c" <ecleofe7@yahoo.com> wrote in message
> news:1e1c9a33.0303311430.2143c5e@posting.google.com...
> > hi Guys,
> >         Need your advice.This could be helpfull for those newbie.I
> > want to learn shell scripting.I just want to know that if you master
> > the Perl you can overcome all the shell scripting needed in unix,on
> > w/c you dont need to study those csh,bsh,bash and so on.But what about
> > PHP,since they are just the same function with perl and this is much
> > easier to learn?
> >         Thanks in advanced.God Bless to all...
>
> hi Troll
> I'd love to see unix init scrips written in php.
> B
>
>




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

Date: 1 Apr 2003 13:44:53 -0800
From: ecleofe7@yahoo.com (edu@rd c)
Subject: Re: Does Perl can do everything you need in unix shell scripting?what about PHP?
Message-Id: <1e1c9a33.0304011344.76719833@posting.google.com>

Hi Guys,
       Thanks for all your advice.It enlighnten me.
        Your all the best.If im become master or novice on my field I
will never hesitate to help others too.
        God bless to all...

edu@rd



Michael Heiming <michael+USENET@www.heiming.de> wrote in message news:<p3cb6b.9f5.ln@news.heiming.de>...
> In comp.unix.shell edu@rd c <ecleofe7@yahoo.com> wrote:
> > hi Guys,
> >         Need your advice.This could be helpfull for those newbie.I
> > want to learn shell scripting.I just want to know that if you master
> > the Perl you can overcome all the shell scripting needed in unix,on
> > w/c you dont need to study those csh,bsh,bash and so on.But what about
> > PHP,since they are just the same function with perl and this is much
> > easier to learn?
> 
> Forget about PHP, perl is great to know and comes in handy for many 
> purposes, but you should first learn the shell (sh/bash/ksh) and
> probably awk is nice to know, you'll find it on almost every *nix,
> perl might not even be installed per default on many *nix. So it
> won't help you much.


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

Date: 1 Apr 2003 11:19:51 -0800
From: justkule@yahoo.com (siddhartha mulpuru)
Subject: execute perl by redirection
Message-Id: <78e9cb22.0304011119.3081e9d2@posting.google.com>

HI All,
     I am trying to implement something like this ..  If someone
clicks a link on page A he is forwarded to Page B and i am sending a
value from the page A to Page B through url eg:
http://tnet.tripos.com/admin/offices/stl/map/redirect.html?userid=sburkett

now on page he sees a message and is automatically redirected to a
perl script which takes the value passed from the page A in the url as
its parameter to execute.

I donno how to read thjis value in the url in a html page and send it
to the perl script and does the perl script get executed when i
redirect to it using

META HTTP-EQUIV="Refresh"
        Content="1;URL=http://xxx.com/cgi-bin/admin/offices/map_search.pl"
        Type=text/html target="right"
 without a submit ?

It would be great help if someone has an idea to implement this.

Thanks
Sid


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

Date: Tue, 01 Apr 2003 19:41:35 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: justkule@yahoo.com (siddhartha mulpuru)
Subject: Re: execute perl by redirection
Message-Id: <4cd70e47d1edf16781639204e96971cd@news.teranews.com>

>>>>> "siddhartha" == siddhartha mulpuru <justkule@yahoo.com> writes:

siddhartha> META HTTP-EQUIV="Refresh"
siddhartha>         Content="1;URL=http://xxx.com/cgi-bin/admin/offices/map_search.pl"
siddhartha>         Type=text/html target="right"
siddhartha>  without a submit ?

If the answer is a Meta-refresh to get away from one URL immediately
to another, you've asked the wrong question.

Please back up and rethink your strategy.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 1 Apr 2003 10:25:02 -0800
From: rpalla@kentlaw.edu (ramesh)
Subject: how to create own perl module
Message-Id: <2b0865a8.0304011025.521e9091@posting.google.com>

hi

I want to create my own perl module.  How can i do that.

My program returns some value and i want to use that value as input to
another program. how can i do that.



for example 

program 1.

sub addition {
string a ;
string b;
string c = a + b;
return c ;

}


i want to make this as perl module and want to use the output in
another program.

can somebody help me please.


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

Date: 01 Apr 2003 20:22:53 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: how to create own perl module
Message-Id: <slrnb8jt8p.t5l.abigail@alexandra.abigail.nl>

ramesh (rpalla@kentlaw.edu) wrote on MMMD September MCMXCIII in
<URL:news:2b0865a8.0304011025.521e9091@posting.google.com>:
!!  
!!  I want to create my own perl module.  How can i do that.

    $ cat > MyOwnModule.pm
    package MyOwnModule;
    ^D
    $

See also 'man perlmod'.

!!  My program returns some value and i want to use that value as input to
!!  another program. how can i do that.

    $ program1.pl
    $ program2.pl $?

!!  for example 
!!  
!!  program 1.
!!  
!!  sub addition {
!!  string a ;
!!  string b;
!!  string c = a + b;
!!  return c ;
!!  
!!  }


This program doesn't return anything, explicitely, so 0 will be
returned. You do have a function that returns something, but
functions are not programs.

!!  i want to make this as perl module and want to use the output in
!!  another program.

Now you got me confused. Do you want to use output, or return values
as input to another program? And what's the output of a module?

!!  can somebody help me please.


I think you first need to sit down and formulate what you want. A posting
like this will only make people guess, and most likely, guess wrong. That
doesn't help you, and frustrates the people who are willing to help you,
perhaps to a point they won't bother helping you again.




Abigail
-- 
perl -swleprint -- -_=Just\ another\ Perl\ Hacker


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

Date: Tue, 01 Apr 2003 13:23:53 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: implementing a threaded serial device (or any other parallelway)
Message-Id: <3E89D939.B74B2E45@earthlink.net>

Alexander Eisenhuth wrote:
[snip]
>         my $comObj = bless {}, $packageName;

Here, you create a blessed reference.

>         threads::shared::share $comObj;

Now, you share it.

>         my $comObj = {
>                 inputBuffer=>"",
>                 running=>1,
>                 watchThread=>0,
>                 internalCounter=>0
>         };

Now, you've *discarded* the blessed, shared, reference, and created a
new, unblessed reference, in a new lexical variable (unrelated to the
old one, except by name), and are not using the old blessed, shared,
reference at all.

WHY?

[snip]
> output:
> CComClass::new - 1 :CComClass=HASH(0x813b218)
> threadLoop comObj >>>CComClass=HASH(0x825e174)<<<
> threadLoop(1)
> CComClass::new - 2 :CComClass=HASH(0x813b218)
> main: comDev:CComClass=HASH(0x813b218)
> threadLoop(1)
> threadLoop(1)
> 
> The thread seems to copy the blessed comObj.

I already told you, the child thread gets a new hash object.

In both the child thread and parent thread, the hash object is tied.

In both the child thread and parent thread, they are tied *to the same
object*.

You CANNOT simply print out $comObj, and expect it to look the same.

The contents (behind the tie) are the same, but the hashrefs are
different.

> In the doc of threads::shared there
> is written amoung BUGS:
> [...]
> bless is not supported on shared references.

So if a reference *has been* shared, you cannot bless it.

> In the current version, bless will only bless the thread local
> reference and the blessing will not propagate to the other threads.

If you have a shared reference, and two threads refer to it, and you
bless in one thread, then the blessing will not be seen in other
threads.

> This is expected to be implemented in a future version of Perl.
> [..]
> 
> That sounds to me, that threads, sharing "objects" won't work in perl
> :-(, and so I'm also expecting problems using Device::SerialPort.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Tue, 1 Apr 2003 15:18:55 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Loading STDOUT into a variable
Message-Id: <slrnb8k0hv.3tn.tadmc@magna.augustmail.com>

Stephan Bour <sbour@niaid.nih.gov> wrote:
> in article slrnb8i0a4.27c.tadmc@magna.augustmail.com, Tad McClellan at
> tadmc@augustmail.com wrote on 3/31/03 22:02:
> 
>> Stephan Bour <sbour@niaid.nih.gov> wrote:
>> 
>>> system("ifconfig");
>> 
>>> there any way to assign the content of STDOUT to a variable
>> 
>>  perldoc -f system
>> 
>> *plonk*
>> 
> Thanks to those who actually provided help. 


You're welcome.

( the help I offered was: you should read the docs for the functions
  that you use, else you will not know what to expect when you
  call them.
)


> I realize that most of the
> newbie questions I (and others) ask can be solved by reading a FAQ or help
> file somewhere. What you pros have to understand is that beginners don't
> always know where and how to look for those simple answers. 


I already do understand that.

I don't killfile for asking a FAQ (and that isn't what you did).

I killfile people that sign contracts without reading them,
which _is_ what you did.

Now I know that in the real world folks don't read the docs for
the functions they invoke, but at the *very first* sign of
trouble they should know to go fix that.

Those that don't will be a time-sink that draws time away from
more deserving posters.


> I never post a
> question before doing my very best to answer it myself with the resources I
> have. Please forgive me if that sometimes is not good enough.


Are you saying that you did not know how to look up Perl functions?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 01 Apr 2003 13:15:03 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: modules using modules - shared objects
Message-Id: <3E89D727.3DC9A10F@earthlink.net>

Matt wrote:
> 
> Benjamin Goldberg <goldbb2@earthlink.net> writes:
> <snip>
> > What you would have to do instead would be:
> >
> >    package MyDBI;
> >    use DBI ();
> >    sub connect {
> >       my $thisclass = shift;
> >       my $self = DBI->connect( @_ );
> >       my $old_class = ref $self;
> >       my $new_class = $old_class . "::$thisclass Mixin";
> >       @{ $new_class . "::ISA" } = ( $thisclass, $old_class );
> >       return bless $self, $new_class;
> >    }
> >    sub selectSomething {
> >       my $dbh = shift;
> >       my ($a) = $dbh->selectrow_array("select something from nothing");
> >       return $a;
> >    }
> >    1;
> >    __END__
> >    [and the main script as already described]
> >
> > [untested]
> >
> > Even this might not work.  I think it should.
> 
> It does. Thanks, this is helping me a lot. Can you explain what
> `Mixin' is/does. Whats going on with line 8? It translates into:
> 
>         @{ "DBI::db::MyDBI Mixin::ISA" } = ( "MyDBI", "DBI::db" );

The term "Mixin" isn't perl specific -- it refers to defining a class
which only defines methods, without adding data.  It comes from
languages where true multiple inheritance (where two or more different
ancestor classes both define member data) is illegal, due to the
complications that can arise.

In this case, I this line is setting the @ISA array in a new, made up
class "DBI::db::MyDBI Mixin" (yes, the space is part of the class name),
so that that new class inherits from MyDBI and DBI::db.

Then, the database handle is re-blessed into that newly made up class.
Since the new class inherits from DBI::db, you can still call all the
old methods on it that you used to be able to call, and since it also
inherits from MyDBI, you can call on it any methods defined in package
MyDBI.

(Unlike the normal sense of mixin, it's MyDBI that's acting as a mixin
class, and "...::MyDBI Mixin" isn't itself a mixing, but is using one.)

################

I would seriously suggest that you *not* write code like in the example
bit that you quoted.  Instead, write it like the following:

package MyDBI;
@MyDBI::db::ISA = "DBI::db";
@MyDBI::st::ISA = "DBI::st";
sub MyDBI::db::selectSomething {
   my $dbh = shift;
   ($dbh->selectrow_array("select something from nothing"))[0];
}
1;
__END__


-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: 1 Apr 2003 11:35:37 -0800
From: snazystyl@hotmail.com (KP)
Subject: Need Help : Pass ing Variables between a Script and a Perl Module.
Message-Id: <dc2b0830.0304011135.71171446@posting.google.com>

I'm having problem figuring out how to Pass Variables between a Script
and Perl Module.

When everything is in the same scope I had no problems. I moved two
functions into the Perl Module and now I keep getting Can't call
method "Result" on an undefined value.

Trying to have Main.PL begin and call the First Function after it
completes it then calls the Second Functino which resides in the Perl
Module. Once complete it executes the Third Function and so on. When
variables being passing in Main.PL I'm not having a problem with. The
Perl Module sees $Var1 and $Var2 and it works but after that Function
completes I can't get it to Pass the variable so that Functions 3 - 6
can use $Var1 and $Var2.

#/// Main.PL ///#
First( );
my $Var1,$Var2 = Perl::Second(\$Var1,\$Var2);
my $Var3 = Third(\$Var1,\$Var2);
my $Var4 = Third(\$Var1,\$Var2,$Var3);
my $Var5 = Third(\$Var1,\$Var2,,$Var3,$Var4);
my $Var6 = Third(\$Var1,\$Var2,Var5);

sub First
{
Print "This is the First Function";
   
}

sub Third
{
My $Var1Ref = shift;
My $Var2Ref = shift;            

$$Var1Ref->Result
    (
    E_FAIL,
    ERROR_TYPE_HRESULT,
    __WFILE__,
    __LINE__,
    "FAIL",
    $$Var2Ref
    );
}

 ... Snippet 

#/// Perl.PM ///#
package Perl;
use Exporter();
@ISA = qw(Exporter);
@EXPORT = qw(ERROR_TYPE_HRESULT);
use constant ERROR_TYPE_HRESULT => 1;

sub Second
{
My $Var1Ref = shift;
My $Var2Ref = shift;           

$$Var1Ref = Win32::OLE->new
    (
    'Logger.Log'
    );
 
$$Var2Ref = $$Var1Ref ->Create
    (
    '$Console'
    );

$$Var1Ref ->Start
    (
    "File",
    $$Var2Ref
    );        
}  

 ... Snippet


I'm still pretty new to perl so any help on how to achieve this would
be greatly appreciated. I have read other posts on this Topic in
Google Groups but none of the answers or snippets made any sense to
me.

Thanks,
 KP


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

Date: Tue, 01 Apr 2003 19:42:47 GMT
From: <alex@nospamhoopsie.com>
Subject: Re: OO problem with Data::Dumper and IO::Scalar
Message-Id: <XYlia.292218$L1.83994@sccrnsc02>

alex@nospamhoopsie.com wrote:

> When I run the above script, I get the following error:

> Can't locate object method "FETCH" via package "IO::Scalar" 
> (perhaps you forgot to load "IO::Scalar"?) 
> at /usr/lib/perl5/5.6.1/i386-linux/Data/Dumper.pm line 150.

I've managed to isolate the problem further.  It turns out that it is 
not related to OO at all. Simply something between IO::Scalar and 
Data::Dumper.  The script below is all that is needed to recreate
the error:

--------------------------------------------
#!/usr/bin/perl -w

use strict;

use Data::Dumper;
use IO::Scalar;

my $data = 'hello';

my $h = new IO::Scalar \$data;
print "h:\n", Dumper($h);
--------------------------------------------

Again, any help would be appreciated.  In the meantime, I'll keep drilling
the perldocs :)

--Alex


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

Date: 1 Apr 2003 20:10:03 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: OO problem with Data::Dumper and IO::Scalar
Message-Id: <b6crmr$fiq$1@nets3.rz.RWTH-Aachen.DE>

Also sprach <alex@nospamhoopsie.com>:

> alex@nospamhoopsie.com wrote:
> 
>> When I run the above script, I get the following error:
> 
>> Can't locate object method "FETCH" via package "IO::Scalar" 
>> (perhaps you forgot to load "IO::Scalar"?) 
>> at /usr/lib/perl5/5.6.1/i386-linux/Data/Dumper.pm line 150.
> 
> I've managed to isolate the problem further.  It turns out that it is 
> not related to OO at all. Simply something between IO::Scalar and 
> Data::Dumper.  The script below is all that is needed to recreate
> the error:
> 
> --------------------------------------------
> #!/usr/bin/perl -w
> 
> use strict;
> 
> use Data::Dumper;
> use IO::Scalar;
> 
> my $data = 'hello';
> 
> my $h = new IO::Scalar \$data;
> print "h:\n", Dumper($h);
> --------------------------------------------

The above runs fine for me on 5.8.0 ($Data::Dumper::VERSION = 2.12). I
get the errors you mentioned with 5.6.1 and Data::Dumper version 2.102.
The Data::Dumper as available from CPAN is already the aforementioned
2.102 and I wasn't able to compile the one from the perl5.8.0
distribution for Perl5.6.1.

Therefore, the most obvious solution would be to use 5.8.0.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 01 Apr 2003 16:05:12 GMT
From: ctcgag@hotmail.com
Subject: Re: passing variables to fork()
Message-Id: <20030401110512.385$ag@newsreader.com>

"ravlin" <jhayden@usa.com> wrote:
> Hi all,
>
> Is there a way I can pass a variable to fork, change the value of the
> variable in the fork'd process and get the value back?

I'd just have the child talk to the parent:

# my changes marked by ##.
# Note diagnostics print changed to warn, because stdout now goes to
parent. my $test = "parent";
{
    if(! defined(my $pid = open FH, "-|")) {  ##
       die "Cannot fork: $!";
    } elsif ($pid) {
       # I'm the parent
    } else {
                warn("test is $test\n");      ##
                $test = "child";
                print "child";                ##
                warn("test is $test\n");      ##
                exit (0);
        }
}
$test = <FH>;                                 ## Do not "wait" here
print("test is $test\n");
close FH or die $!;                           ## close will wait for you
                                              ## (I think)


> Any idea on how I can do this?

I think you can set up shared variables, but I've never needed them
enough to bother to figure them out.  For one thing, how does the parent
know when the child is going to make the change?  Here, the parent controls
when it wants to listen to the child.

> I even tried passing the variable as a
> reference and it still didn't work.

No, you didn't.  There is no passage in your code.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Tue, 1 Apr 2003 11:27:55 -0500
From: "ravlin" <jhayden@usa.com>
Subject: Re: passing variables to fork()
Message-Id: <g6jia.2$HH2.161@chrome-fe.eng.netapp.com>


<ctcgag@hotmail.com> wrote in message
news:20030401110512.385$ag@newsreader.com...
> "ravlin" <jhayden@usa.com> wrote:
> > Hi all,
> >
> > Is there a way I can pass a variable to fork, change the value of the
> > variable in the fork'd process and get the value back?
>
> I'd just have the child talk to the parent:
>
> # my changes marked by ##.
> # Note diagnostics print changed to warn, because stdout now goes to
> parent. my $test = "parent";
> {
>     if(! defined(my $pid = open FH, "-|")) {  ##
>        die "Cannot fork: $!";
>     } elsif ($pid) {
>        # I'm the parent
>     } else {
>                 warn("test is $test\n");      ##
>                 $test = "child";
>                 print "child";                ##
>                 warn("test is $test\n");      ##
>                 exit (0);
>         }
> }
> $test = <FH>;                                 ## Do not "wait" here
> print("test is $test\n");
> close FH or die $!;                           ## close will wait for you
>                                               ## (I think)
>
Thanks for the help.  I tried it and got this output:

test is parent
test is child
Use of uninitialized value in concatenation (.) or string at mytest.pl line
19.
test is

Line 19 is "$test = <FH>;"

>
> > Any idea on how I can do this?
>
> I think you can set up shared variables, but I've never needed them
> enough to bother to figure them out.  For one thing, how does the parent
> know when the child is going to make the change?  Here, the parent
controls
> when it wants to listen to the child.
>
> > I even tried passing the variable as a
> > reference and it still didn't work.
>
> No, you didn't.  There is no passage in your code.

Right.  I meant I tried passing the variable as a reference already, but not
in this example.

>
> Xho
>
> --
> -------------------- http://NewsReader.Com/ --------------------
> Usenet Newsgroup Service              New Rate! $9.95/Month 50GB




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

Date: Tue, 01 Apr 2003 21:45:29 +0100
From: Ian Gregory <ngroups@ians-netNOSPAM.co.uk>
Subject: Re: Perl & XPath
Message-Id: <b6ctos$ikc$1@godfrey.mcc.ac.uk>

In case it's useful to anyone - I ended up creating an XSL stylesheet on 
the fly (using the XPath expression and the new XML) and used that to 
convert the initial XML into the result.

Cheers,

Ian

Ian Gregory wrote:
> Hi,
> 
> I'm trying to change parts of an XML file which are identified by an 
> XPath expression. I have a variable $xpath which identifies the part of 
> the file to be changed and $newxml which contains a textual 
> representation of the XML to be added at that point. I've been using the 
> XML::Xpath module which allows be to change the text of a node - but it 
> doesn't seem to have a 'setNodeXML' method?
> 
> my $xp = XML::XPath->new(xml => $xml);
> print $xp->setNodeText($xpath ,$newxml);
> 
> Am I going about this the right way or is there a better way of doing 
> this (I use XML::LibXML elsewhere so if it can be done with that...)
> 
> Thanks in advance,
> 
> Ian
> 



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

Date: 1 Apr 2003 14:50:05 -0800
From: rpalla@kentlaw.edu (ramesh)
Subject: perl module---returning values to anothe string
Message-Id: <2b0865a8.0304011450.39242614@posting.google.com>

hi

I want to create my own perl module.  How can i do that.

My program returns some value and i want to use that value as input to
another program. how can i do that.



for example 

program 1.

sub addition {
string a ;
string b;
string c = a + b;
return c ;

}


i want to make this as perl module and want to use the output in
another program.

can somebody help me please.


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

Date: 1 Apr 2003 13:22:31 -0800
From: c_sheehanuk@hotmail.com (banjo)
Subject: perl noob question
Message-Id: <59387f51.0304011322.288d8bf3@posting.google.com>

Hi,
I'm totally new to perl so go easy please :)

I want to append the name of an array with a counting variable
so that a new array is created each time the loop executes,giving,

@array1
@array2
@array3 etc

but I can't find the syntax for appending the array name. I've tried
@array$count = @list
@array.$count = @list
@array."$count" = @list

thx


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

Date: 01 Apr 2003 14:34:34 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: perl noob question
Message-Id: <etoof3p6gwl.fsf@wormtongue.emschwar>

c_sheehanuk@hotmail.com (banjo) writes:
> I'm totally new to perl so go easy please :)

Okay.

Please put the subject of your post in the Subject: of your post.  The
vast majority of regulars skip over posts with subjects like yours,
and you'd surely benefit from their input.  Compare:

   [  16: banjo               ] perl noob question

with 

   [  16: banjo               ] Creating arrays with sequential names

Which one do you suppose indicates more clearly what the article's
about?  And WTF is a 'noob' anyway?  (Yeah, I know, it's an illiterate
'ky00t3' spelling of 'newbie', but still...)

> I want to append the name of an array with a counting variable
> so that a new array is created each time the loop executes,giving,
> 
> @array1
> @array2
> @array3 etc
> 
> but I can't find the syntax for appending the array name.

Don't Do That(tm).

Use an array of array references instead:

my @bigarray = ();
foreach my $i (0...100) {
   my @list = some_function();
   $bigarray[$i] = [@list];
   # or better yet: $bigarray[$i] = [ some_function() ];
}

To dereference:

foreach my $arrayref (@bigarray) {
    print 'First element of array: ['. $arrayref->[0] . "]\n";
    print 'Second element of array: ['. $arrayref->[1] . "]\n";
}

Then run 'perldoc perlref' to find out more about how references
really work.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Tue, 01 Apr 2003 14:45:34 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: Re: piped commands
Message-Id: <3E89EC5E.81617534@someserver123abc.com>



Josef Möllers wrote:
> 
> stinkbomb wrote:
> >
> What's so bad about
>         $x =~ s/hello/goodbye/gi;
>         $x =~ s/world/planet/gi;
>         $x =~ s/!/\?/gi;
> apart from some optimizations?
> 

would it be slower that we're calling the function and setting variables
many times?
or not?


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: Tue, 1 Apr 2003 17:12:01 -0500
From: "Jay" <fdee@fesfs.com>
Subject: Problem with a subroutine executing another instance of itself
Message-Id: <z8oia.104257$Y47.701418@weber.videotron.net>

Hi,

I am trying to do a simple script that would perform the same action as the
good old "copy-paste" from windows, but it seems that I am having trouble
with it being recursive. Here is my current code:

----------------------------------------------
#!/usr/bin/perl

$cdrom = "C:\\copyfrom";
$destination = "C:\\copyto";

$issuccess = &copyfiles("$cdrom", "$destination");

sub copyfiles{
 my ($fromdir, $todir) = @_;
 my @fileslisting = `dir /A-D /b $fromdir`;
 chomp(@fileslisting);
 foreach $file(@fileslisting){
  if($file != "File Not Found" && $file != ""){
   print "Copying file $fromdir\\$file to $todir\\$file\n";
   `copy $fromdir\\$file $todir\\$file`;
  }
 }
 my @directorylisting = `dir /AD /b $fromdir`;
 chomp(@directorylisting);
 foreach $directory(@directorylisting){
  if($directory != "File Not Found" && $directory != ""){
   print "\nStarting to work in subdirectory $fromdir\\$directory\n";
   `mkdir $todir\\$directory`;
   $issuccess = &copyfiles("$fromdir\\$directory", "$todir\\$directory");
  }
 }
}

1;

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

It seems that the program stops after copying the content of the first
subdirectory (i.e.: I have two subdirectories in my copied folder, called 1
and 2, and they only contain files. the program stops after it copies the
content from the subdirectory 1).

I am pretty sure it has to do with the subrouting calling another execution
of itself inside its code, but I have no idea how I could go around that.
Anyone here knows of a way I could use to circumvent this problem?

For those who wonder why I would want to use such a script instead of simply
doing a copy and paste, it's because windows stops copying files as soon as
it encounters an error with any file. This script would keep on copying all
the subsequent files, and simply skip the problematic file.

Please let me know if you can help.

Dje




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

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.  

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


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