[28604] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9968 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 14 18:05:47 2006

Date: Tue, 14 Nov 2006 15:05:05 -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, 14 Nov 2006     Volume: 10 Number: 9968

Today's topics:
    Re: "Did not find leading dereferencer" - new findings  <benmorrow@tiscali.co.uk>
    Re: Call graph analysis of perl source? <benmorrow@tiscali.co.uk>
    Re: Confused about namespaces (reading news)
    Re: Confused about namespaces <mritty@gmail.com>
    Re: Confused about namespaces <anon40629@hotmail.com>
    Re: Confused about namespaces <spamtrap@dot-app.org>
    Re: Hashes and subroutines <glex_no-spam@qwest-spam-no.invalid>
    Re: Hashes and subroutines <someone@example.com>
    Re: Hashes and subroutines (reading news)
    Re: I have no problems eating cereal...after it softens <john@castleamber.com>
    Re: Perl Packager, pp, compilation <benmorrow@tiscali.co.uk>
    Re: Returning values from a parsed file (design issue) <spam.meplease@ntlworld.com>
    Re: running dos commands from perl script edwells@statestreet.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 14 Nov 2006 21:54:03 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: "Did not find leading dereferencer" - new findings to an old puzzle
Message-Id: <rgqp24-36a.ln1@osiris.mauzo.dyndns.org>

[please don't repost a whole article just to correct a typo]
[it would be helpful if you could wrap your articles decently]

Quoth "Ronny" <ro.naldfi.scher@gmail.com>:
> Peter J. Holzer schrieb:
> > On 2006-11-13 12:37, Ronny <ro.naldfi.scher@gmail.com> wrote:
> > > Peter J. Holzer schrieb:
> > >> > The use Switch was in the code only for historic reason, and I have
> > >> > removed it. I don't know of course if *this* was sufficient to make
> > >> > the error go away: After all, the removal of the statement made the
> > >> > code a little bit smaller, so the problem might simply have
> > >> > disappeared for *this* reason (removing a comment line instead of the
> > >> > use Switch would have had the same effect).
> > >> Possible, but unlikely. Unless you use another module which uses
> > >> Text::Balanced, you aren't calling Text::Balanced any more and hence
> > >> can't get any error messages from it any more.
> > > even
> > > when I do a "use Switch", I never actually *write* a switch statement.
> >
> > That's irrelevant. The Switch module can't know whether you use a switch
> > statement or not not before it has parsed your code.
> 
> My main problem was seeing *where* (at compile time) Switch.pm would
> parse my code, since I thought such an attempt on parsing would have to
> be done within a BEGIN block, which is not present in Switch.pm.

Firstly, use statements are always implicitly in a BEGIN block.
Secondly, Switch uses Filter::Util::Call, which inserts some Perl code
between the source file and the lexer through some black magic.

> However I now agree with you that there indeed seems to be some parsing
> going on, although it looks a bit like magic to me, and you are right
> that this parsing seems to be done with the help of the module
> Filter::Util::Call
> (which, according to its description, is intended to write source
> transformation
> modules and which seems to rely on some support code written in C

While bits of F::U::C are written in C (or rather XS, which is a form of
preprocessed C used to write Perl extensions), that code is not a
problem in your case. The problem lies in Text::Balanced's parsing of
(invalid, in this case) Perl, and T::B is entirely written in Perl. It's
just not a terribly robust Perl parser: hardly surprisingly, as parsing
Perl is a *very* hard problem (impossible, in the general case).

> Given the observation above, that source filtering utilizes C code
> (with the notorious "buffer overflow problem" which often plagues C
> programmers), I guess the right answer to the puzzle is a combination
> of both:
> 
> The error seems to be triggered whenever some source filtering is
> active, but the problem is not necessarily, that the code is somehow
> to complicated to parse (as you suspected - or did I misunderstand you
> here?), but is more likely related to a buffer overrun in the
> supporting C code - simply because if removing "irrelevant" characters
> from a code (irrelevant in the sense of the parsing algorithm) makes a
> certain error go away, is very, very typical for buffer overrun.

No. The parsing code is all written in Perl, and thus does not suffer
from buffer overrun problems.

> > > In addition, I would like to point out that I had the same error
> > > message a few months ago in a different context.
> >
> > Yes, I've remember the thread. You were directed towards Text::Balanced
> > by somebody at the time, but you ignored that advice.
> 
> Yes, because another advice which told me to remove the prototype of a
> function definition, also made the error go away. The poster of that
> advice suggested to me that having prototypes in a bad idea in most
> cases anyway, and it seemed to me simpler to do than hunting for a
> Text::Balanced buried deep in the module nesting hierarchy (I wonder
> whether there is a simple way to find out what modules are - directly
> or indirectly - included in a program, and by whom ....  kind of an
> "invocation graph").

Putting

    package CheckINC;

    unshift @INC, sub {
        my (undef, $mod) = @_;
        my $from = caller;
        warn "loading $mod from $from";
        return undef;
    };

    1;

into CheckINC.pm and running your script with perl -MCheckINC will give
you a list of all the modules loaded, and where they were loaded from
*first*. That is, you will only get one answer for, say, strict.pm, even
though it's used lots of times. Getting a better answer than this is
rather tricky (you'd have to use the source-filter-in-@INC hook to add a
delete $INC{...}; to the start of each module).

Ben

-- 
  Joy and Woe are woven fine,
  A Clothing for the Soul divine       William Blake
  Under every grief and pine          'Auguries of Innocence'
  Runs a joy with silken twine.                         benmorrow@tiscali.co.uk


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

Date: Tue, 14 Nov 2006 03:19:17 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Call graph analysis of perl source?
Message-Id: <l6pn24-ut.ln1@osiris.mauzo.dyndns.org>


Quoth Roy Smith <roy@panix.com>:
> I have been given the "interesting" task of figuring out and documenting 
> 16,000 lines perl.  It's typical crud -- no comments, lots of global 
> variables, etc.
> 
> After poking at it for a while, it's obvious that what I need to do is 
> build a call graph.  Are there any tools to help me do this?

B::Xref

Ben

-- 
Many users now operate their own computers day in and day out on various
applications without ever writing a program. Indeed, many of these users
cannot write new programs for their machines...
    -- F.P. Brooks, 'No Silver Bullet', 1987      [benmorrow@tiscali.co.uk]


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

Date: Tue, 14 Nov 2006 20:04:44 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: Confused about namespaces
Message-Id: <wjp6h.6242$0r.4815@newsread1.news.pas.earthlink.net>

On 11/14/2006 11:45 AM, Mark wrote:
> Good morning.
> 
> I clearly do not understand namespaces.
> 
> I was attempting to subclass a module from CPAN, and I continually
> ran into errors relating to @ISA. So I decided to try some _very_ simple
> package examples, and I found a few here:
> 
> http://www.netalive.org/tinkering/serious-perl/#namespaces
> 
> I grabbed their first example and tried to run it. I received essentially
> the same error I had been receiving before:
> 
> Can't locate Sophie.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib 
> ..) at test.pl line 7.
> BEGIN failed--compilation aborted at test.pl line 7.
> 
> Can someone please tell me what I am doing wrong? Here is the sample code:
> 
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
> package Sophie;
> sub say_hello {
>     print "Hi World!";
> }
> 
> package Clara;
> use Sophie;           # loads the package but does NOT import any methods
> #say_hello();          # blows up
> Sophie->say_hello();  # correct usage
> #Sophie::say_hello();  # works, but not for inherited methods
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
> 
> Thanks
> -Mark
> 
> 
> 

Below when I write "perldoc perl", I mean something like this:
Start->Run->"perldoc perl"

Read these documents:
perldoc -f use
perldoc perlmod

When you use "use," the package (namespace) you "use" should be in a 
separate file.


-- 
paduille.4060.mumia.w@earthlink.net


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

Date: 14 Nov 2006 12:20:26 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Confused about namespaces
Message-Id: <1163535626.322665.176400@b28g2000cwb.googlegroups.com>

Mark wrote:
> I clearly do not understand namespaces.
>
> I was attempting to subclass a module from CPAN, and I continually
> ran into errors relating to @ISA. So I decided to try some _very_ simple
> package examples, and I found a few here:
>
> http://www.netalive.org/tinkering/serious-perl/#namespaces
>
> I grabbed their first example and tried to run it. I received essentially
> the same error I had been receiving before:
>
> Can't locate Sophie.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib
> .) at test.pl line 7.
> BEGIN failed--compilation aborted at test.pl line 7.
>
> Can someone please tell me what I am doing wrong? Here is the sample code:
>
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
> package Sophie;
> sub say_hello {
>     print "Hi World!";
> }
>
> package Clara;
> use Sophie;           # loads the package but does NOT import any methods

This comment is misleading at best, and wrong at worst.  The line
doesn't import any methods only because Sophie didn't export any by
default.  If you want to make *sure* that nothing is imported, you'd
change that to:
use Sophie();

> #say_hello();          # blows up
> Sophie->say_hello();  # correct usage
> #Sophie::say_hello();  # works, but not for inherited methods
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

You have left out at least two very important pieces of information:
1) the code for test.pl
2) the name of the file you've shown above.

Alternatively, 1 & 2 cancel out, and the code you've shown above *is*
test.pl.  If that's the case, it is not namespaces that you don't
understand, it's 'use'.  The 'use' function looks for a file named by
it's argument, with .pm appended.  In other words, your code above is
trying to find a file named Sophie.pm, which does not exist.

In general, when you define a package, you put that package's code into
it's own file.  So above, everything from `package Sophie;`  to the
right curly-brace should be in a file named Sophie.pm.  Everything from
`package Clara;` to the end of the file should be in Clara.pm.

In your case, you're defining multiple packages all in the same file.
There is no external file to load.  Therefore, there is no reason for
the `use` statement.  Remove it from your code, and everything should
work fine.

Paul Lalli



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

Date: Tue, 14 Nov 2006 13:13:25 -0800
From: "Mark" <anon40629@hotmail.com>
Subject: Re: Confused about namespaces
Message-Id: <1163538800.75680@bubbleator.drizzle.com>

"Paul Lalli" <mritty@gmail.com> wrote:
>
> In your case, you're defining multiple packages all in the same file.
> There is no external file to load.  Therefore, there is no reason for
> the `use` statement.  Remove it from your code, and everything should
> work fine.

Ah. Thanks.




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

Date: Tue, 14 Nov 2006 17:06:55 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Confused about namespaces
Message-Id: <m2irhhisxs.fsf@Sherm-Pendleys-Computer.local>

"Paul Lalli" <mritty@gmail.com> writes:

> In general, when you define a package, you put that package's code into
> it's own file.  So above, everything from `package Sophie;`  to the
> right curly-brace should be in a file named Sophie.pm.

Also, you should add an expression at the end of the file that evaluates
to a true value:

# happy perl
1;

Unless a module returns a true value, it'll produce an error when you try
to "use" it. Since Perl doesn't require an explicit return statement, you
can return a true value by accident very easily. But that's fragile and
undependable; it's much better to do so explicitly.

The "happy perl" comment is, of course, optional. :-)

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Tue, 14 Nov 2006 13:22:14 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Hashes and subroutines
Message-Id: <455a1782$0$10306$815e3792@news.qwest.net>

deadpickle wrote:
> What I want to do is search a text file for the correct station ID. I
> hope this is clearer from the code. I run it and it returns the correct
> values but I get the warning "Odd number of elements in hash assignment
> at search1.pl line 15, <ID> line 6." Im not sure what this means. Any
> help?

Look in perldiag:

perldoc perldiag


"Odd number of elements in hash assignment

(W misc) You specified an odd number of elements to initialize a hash,
which is odd, because hashes come in key/value pairs."


> Also I want to pass a few variables to a subroutine but am not sure how
> to do this.

perldoc perlsub

> 
> Text file
> ===================================================================
> KLNK 261412Z 04011KT 3/4SM R36/5500VP6000FT BR OVC003 07/06 A2992 RMK
> AO2
> KCHS 131656Z 15009KT 10SM -RA FEW027 BKN044 24/20 A2994 RMK AO2 RAB44
> SLP137 P0000 T02440200
> KEMP 101653Z AUTO 33016KT 10SM BKN065 BKN090 07/00 A2993 RMK AO2 PK WND
> 33027/1559 SLP136 T00670000
> KHSI 101653Z AUTO 36015KT 7SM OVC007 03/01 A3013 RMK AO2 SLP214
> T00280006
> KRSL 101653Z AUTO 35021G27KT 10SM BKN018 OVC030 06/00 A3009 RMK AO2 PK
> WND 35027/1649 SLP194 T00560000
> KRWL 101653Z AUTO 25018G22KT 10SM CLR M02/M07 A3027 RMK AO2 SLP273
> T10171067
> 
> My Program
> ===================================================================
> #=========================================================
> #	This code is used to search a text file for the correct
> # ASOS sites are then runs the metarcode subroutine to
> # create the placefile that GRLevel3 needs.
> #=========================================================
> use strict;
> use warnings;
> $\ = "\n";
> # Open the text file containing the stations
> open (ID, "stations.txt");
What if it fails??

open( my $ids, '<', 'stations.txt' ) or die "Can't open stations.txt: $!";

> while (my $stations = <ID>) {
while ( my $stations = <$ids> ) {
> 	my @station = split (/\n/,$stations);  # enter each line into an array

You're already reading one line at at time, by default.

> 	foreach (@station) {  # Search the array for the correct stations
> 		print $_;
> 		if (my %stid = $_ =~ m/^KRWL/) {
You're setting a hash to one value.  A hash has a key and a value, hence 
your error.

> 			my $id = $_;
> 			print $id;
> 		}
> 	}
> }

open( my $station_data, '<', 'stations.txt' )
      or die "Can't open stations.txt: $!";
while( my $station = <$station_data> ) {
         print $station if $station =~ /^KRWL/;
}
close ( $station_data );


> 
> This is a prelimanary program so it does not pass the variables to the
> subroutine. I want to pass three variables to the subroutine: 1) the
> array resulting from the search;2) the latitude of the site; 3) the
> longitude. THe lat and long need to be inserted into a variable on the
> subroutine and so does the array. I am not sure on how to do this and
> any help wouild be great. Thanks.

sub some_sub
{
	my $data      = shift;
	my $latitude  = shift;
	my $longitude = shift;

	# do something

}

my @data = qw ( value1 value2 );
some_sub( \@data, '12.003', '34.45' );

See: perlsub for a lot of documentation on subroutines.


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

Date: Tue, 14 Nov 2006 19:23:44 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Hashes and subroutines
Message-Id: <4Jo6h.6159$gy2.1584@edtnps90>

deadpickle wrote:
> What I want to do is search a text file for the correct station ID. I
> hope this is clearer from the code. I run it and it returns the correct
> values but I get the warning "Odd number of elements in hash assignment
> at search1.pl line 15, <ID> line 6." Im not sure what this means.

It means that you have to assign an even number of elements to a hash.

> Also I want to pass a few variables to a subroutine but am not sure how
> to do this.
> 
> Text file
> ===================================================================
> KLNK 261412Z 04011KT 3/4SM R36/5500VP6000FT BR OVC003 07/06 A2992 RMK
> AO2
> KCHS 131656Z 15009KT 10SM -RA FEW027 BKN044 24/20 A2994 RMK AO2 RAB44
> SLP137 P0000 T02440200
> KEMP 101653Z AUTO 33016KT 10SM BKN065 BKN090 07/00 A2993 RMK AO2 PK WND
> 33027/1559 SLP136 T00670000
> KHSI 101653Z AUTO 36015KT 7SM OVC007 03/01 A3013 RMK AO2 SLP214
> T00280006
> KRSL 101653Z AUTO 35021G27KT 10SM BKN018 OVC030 06/00 A3009 RMK AO2 PK
> WND 35027/1649 SLP194 T00560000
> KRWL 101653Z AUTO 25018G22KT 10SM CLR M02/M07 A3027 RMK AO2 SLP273
> T10171067
> 
> My Program
> ===================================================================
> #=========================================================
> #	This code is used to search a text file for the correct
> # ASOS sites are then runs the metarcode subroutine to
> # create the placefile that GRLevel3 needs.
> #=========================================================
> use strict;
> use warnings;
> $\ = "\n";
> # Open the text file containing the stations
> open (ID, "stations.txt");

You should *ALWAYS* verify that the file opened correctly:

open ID, '<', 'stations.txt' or die "Cannot open 'stations.txt' $!";


> while (my $stations = <ID>) {
> 	my @station = split (/\n/,$stations);  # enter each line into an array

Because you haven't modified $/ the value in $stations should have just one
newline at the end of $stations.


> 	foreach (@station) {  # Search the array for the correct stations
> 		print $_;
> 		if (my %stid = $_ =~ m/^KRWL/) {

You are assigning a single value to the hash %stid which is why you get the
warning.


> 			my $id = $_;
> 			print $id;
> 		}
> 	}
> }

Your while loop could be written more simply as:

while ( <ID> ) {
    chomp;
    if ( /^KRWL/ ) {
        print;
    }
}


> This is a prelimanary program so it does not pass the variables to the
> subroutine.

There is no subroutine in your example.

> I want to pass three variables to the subroutine: 1) the
> array resulting from the search;2) the latitude of the site; 3) the
> longitude. THe lat and long need to be inserted into a variable on the
> subroutine and so does the array. I am not sure on how to do this and
> any help wouild be great. Thanks.

Which fields contain the lat and long?




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: Tue, 14 Nov 2006 20:04:45 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: Hashes and subroutines
Message-Id: <xjp6h.6243$0r.6171@newsread1.news.pas.earthlink.net>

On 11/14/2006 12:52 PM, deadpickle wrote:
> What I want to do is search a text file for the correct station ID. I
> hope this is clearer from the code. I run it and it returns the correct
> values but I get the warning "Odd number of elements in hash assignment
> at search1.pl line 15, <ID> line 6." Im not sure what this means. Any
> help?
> Also I want to pass a few variables to a subroutine but am not sure how
> to do this.
> 
> Text file
> ===================================================================
> KLNK 261412Z 04011KT 3/4SM R36/5500VP6000FT BR OVC003 07/06 A2992 RMK
> AO2
> KCHS 131656Z 15009KT 10SM -RA FEW027 BKN044 24/20 A2994 RMK AO2 RAB44
> SLP137 P0000 T02440200
> KEMP 101653Z AUTO 33016KT 10SM BKN065 BKN090 07/00 A2993 RMK AO2 PK WND
> 33027/1559 SLP136 T00670000
> KHSI 101653Z AUTO 36015KT 7SM OVC007 03/01 A3013 RMK AO2 SLP214
> T00280006
> KRSL 101653Z AUTO 35021G27KT 10SM BKN018 OVC030 06/00 A3009 RMK AO2 PK
> WND 35027/1649 SLP194 T00560000
> KRWL 101653Z AUTO 25018G22KT 10SM CLR M02/M07 A3027 RMK AO2 SLP273
> T10171067
> 
> My Program
> ===================================================================
> #=========================================================
> #	This code is used to search a text file for the correct
> # ASOS sites are then runs the metarcode subroutine to
> # create the placefile that GRLevel3 needs.
> #=========================================================
> use strict;
> use warnings;
> $\ = "\n";
> # Open the text file containing the stations
> open (ID, "stations.txt");
> while (my $stations = <ID>) {
> 	my @station = split (/\n/,$stations);  # enter each line into an array
> 	foreach (@station) {  # Search the array for the correct stations
> 		print $_;
> 		if (my %stid = $_ =~ m/^KRWL/) {

If KRWL is found, this statement assigns (1) to the hash %stid--a hash 
that seems to have no reason to exist since it's lexically scoped to the 
if statement. Hashes expect to be initialized with even numbers of 
initializers, e.g., this is usually an error:

my %stid = (1);


> 			my $id = $_;
> 			print $id;
> 		}
> 	}
> }
> 
> This is a prelimanary program so it does not pass the variables to the
> subroutine. I want to pass three variables to the subroutine: 1) the
> array resulting from the search;2) the latitude of the site; 3) the
> longitude. THe lat and long need to be inserted into a variable on the
> subroutine and so does the array. I am not sure on how to do this and
> any help wouild be great. Thanks.
> 

I don't know anything about that.


-- 
paduille.4060.mumia.w@earthlink.net


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

Date: 14 Nov 2006 19:31:10 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <Xns987B8986C4C70castleamber@130.133.1.4>

"Brian" <bwilkins@gmail.com> wrote:

> wrote. Your comments, while technically correct, were out of context
> and you should learn a better way to constructively criticize rather
> than pick apart code that was admittedly not tested.

Bad code should always be beaten death with a stick made of oak wood 
that's at least 200 years old. If you stand too close you might get hit a 
few times.

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

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


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

Date: Tue, 14 Nov 2006 22:05:05 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Perl Packager, pp, compilation
Message-Id: <h5rp24-36a.ln1@osiris.mauzo.dyndns.org>


Quoth mathieu.lory@gmail.com:
> 
> I saw "Perl Packager" sur CPAN :
> http://search.cpan.org/~autrijus/PAR-0.85/script/pp
> 
> I can use it locally, the binary works well on my computer, but not on
> other computers.
> 
> This is the error message when I run it on other computer :
> Can't load
> '/tmp/par-mathieu/cache-708ca5057424e91f75390798270f708076161471/e86591d6.so'
> for module Gtk2::MozEmbed: libgtkembedmoz.so: Ne peut ouvrir le fichier
> d'objet partagé: Aucun fichier ou répertoire de ce type at
> /usr/lib/perl/5.8/DynaLoader.pm line 225.
>  at /usr/share/perl5/PAR/Heavy.pm line 107
> Compilation failed in require at script/script.pl line 5.,
> 
> But, with pp command, I've added the libgtkembedmoz.so to the .PAR file
> (with --addlist parameter)

You don't use -A for dependant libraries, you use -l, e.g.

    pp -o mozembed -l gtkembedmoz mozembed.pl

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos. |
Musica truces mollit animos, tristesque mentes erigit.|benmorrow@tiscali.co.uk
Musica vel ipsas arbores et horridas movet feras.     |


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

Date: 14 Nov 2006 13:52:42 -0800
From: "doolittle" <spam.meplease@ntlworld.com>
Subject: Re: Returning values from a parsed file (design issue)
Message-Id: <1163541162.154873.232760@b28g2000cwb.googlegroups.com>

I decided to put everything in list form, so the general rule to get
some data is:

  my $foo = ($object->property) ? $object->property : 'null value';
  for (split ( ',', $foo ) ) {processfoo ( dosomething )}

dan

Michele Dondi wrote:

> Despite your being verbose enough I'm not really sure IIUC. IIUC...
> don't reivent the wheel, just use some data serialization format for
> the output, say xml or yaml, suitable for your situation. Or else... I
> don't have the slightest idea.
> 
> 
> Michele



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

Date: 14 Nov 2006 13:24:28 -0800
From: edwells@statestreet.com
Subject: Re: running dos commands from perl script
Message-Id: <1163539468.580636.130040@b28g2000cwb.googlegroups.com>

Thanks,
That worked perfectly.


Sherm Pendley wrote:
> edwells@statestreet.com writes:
>
> > My apologies for posting on this over hashed subject, but I need to set
> > up environment variables in DOS(XP) then execute a program using the
> > vars. I'm not having any problem with the individual commands, but
> > can't get the executable to to use the previously set variables.
> > Here's my code:
> >
> > !/usr/bin/perl -w
> >
> > system 'set var_1';
> > system 'set var_2';
> > system ' c:\progs~1\runexe.exe jobname >c:\xx.xx';
>
> Each call to system() launches a new child task, each of which has its own
> set of environment variables that are unrelated to the previous child task.
>
> But, a child's environment variables are inherited from the parent. So what
> you could do is manipulate %ENV (perldoc perlvar) in your parent script
> instead of using system() to run "set" commands. Something like this:
>
> #!/usr/bin/perl
>
> use warnings; # Preferable over -w
> use strict;   # You forgot that...
>
> # obviously just example values and command...
> $ENV{'var_1'} = 'val_1';
> $ENV{'var_2'} = 'val_2';
> system 'do stuff';
>
> sherm--
>
> --
> Web Hosting by West Virginians, for West Virginians: http://wv-www.net
> Cocoa programming in Perl: http://camelbones.sourceforge.net



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

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


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