[30800] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2045 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 9 18:09:45 2008

Date: Tue, 9 Dec 2008 15:09:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 9 Dec 2008     Volume: 11 Number: 2045

Today's topics:
    Re: executing unix command on a diff domain <slick.users@gmail.com>
    Re: executing unix command on a diff domain <glennj@ncf.ca>
    Re: herding ones and zeroes into bytes sln@netherlands.com
    Re: is perl obsolete? <hjp-usenet2@hjp.at>
    Re: is perl obsolete? <tim@burlyhost.com>
    Re: is perl obsolete? <rvtol+news@isolution.nl>
    Re: Mathematica 7 compares to other languages <xahlee@gmail.com>
    Re: ordered hashes <michaelgang@gmail.com>
    Re: ordered hashes <rkb@i.frys.com>
    Re: ordered hashes <cwilbur@chromatico.net>
    Re: ordered hashes xhoster@gmail.com
    Re: ordered hashes <jimsgibson@gmail.com>
    Re: ordered hashes <martien.verbruggen@invalid.see.sig>
        searching global variables (Kiss Gabor)
    Re: searching global variables sln@netherlands.com
    Re: Trouble with Net::Ping <jimsgibson@gmail.com>
    Re: Using integers up to 0xFFFFFFFFFFFFFFFF <martien.verbruggen@invalid.see.sig>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 9 Dec 2008 11:07:26 -0800 (PST)
From: Slickuser <slick.users@gmail.com>
Subject: Re: executing unix command on a diff domain
Message-Id: <ad42b44c-858b-4e2d-830a-fb928aaba2d3@e1g2000pra.googlegroups.com>

my $workstation =3D "xxx\@domain.com";
my $source_dir =3D "/aaa/bbb/ccc/ddd/"; #remote
my $destination_dir =3D "/xxx/yyy/zzz/"; #local

my $command1 =3D "rsync $source_dir $destination_dir";
my $command2 =3D "ssh $workstation $command1";

`$command2`;

How can I achieve that when my $source_dir on a remote server. I want
to rsync to destination which is not remote.

On Dec 8, 10:59=A0pm, Teo <matteo.co...@gmail.com> wrote:
> On Dec 9, 7:34=A0am, Slickuser <slick.us...@gmail.com> wrote:
>
> > $command =3D "ssh x...@domain.com";
> > system($command);
>
> > $command2 =3D "ls /user/serv2/";
> > system($command2);
>
> > How do I get command 2 to work. I can get $command to work fine. thx
>
> Hi,
>
> if you want $command2 to be executed on the remote host you have to
> send it as an argument of ssh:
>
> my $command =3D 'ssh u...@example.com "ls /usr/serv2/"';
> system $command;
>
> Matteo



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

Date: 9 Dec 2008 20:37:30 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: executing unix command on a diff domain
Message-Id: <slrngjtloc.2cv.glennj@smeagol.ncf.ca>

At 2008-12-09 02:07PM, "Slickuser" wrote:
>  my $workstation = "xxx\@domain.com";
>  my $source_dir = "/aaa/bbb/ccc/ddd/"; #remote
>  my $destination_dir = "/xxx/yyy/zzz/"; #local
>  
>  my $command1 = "rsync $source_dir $destination_dir";
>  my $command2 = "ssh $workstation $command1";
>  
>  `$command2`;
>  
>  How can I achieve that when my $source_dir on a remote server. I want
>  to rsync to destination which is not remote.

You probably want:

    my @cmd = qw( rsync -e ssh remoteuser@remotehost:/remote/dir /local/dir );
    system(@cmd) == 0 or die "return value from system call: $?";


-- 
Glenn Jackman
    Write a wise saying and your name will live forever. -- Anonymous


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

Date: Tue, 09 Dec 2008 21:19:51 GMT
From: sln@netherlands.com
Subject: Re: herding ones and zeroes into bytes
Message-Id: <6bntj45r54vtc5fg0r2pio1bu8d827it9m@4ax.com>

On Tue, 9 Dec 2008 03:26:47 -0700, George <george@example.invalid> wrote:

>On Sun, 07 Dec 2008 21:03:36 GMT, sln@netherlands.com wrote:
>
>> On Sat, 6 Dec 2008 20:35:46 -0700, George <george@example.invalid> wrote:
>> 
>>>
>>>
[snip, C related post stuff]
>>>Thanks for your comment.
>> 
>> Hey, just a reminder this is not a C group, although this is easy to
>> do in Perl. I have no idea what your trying to accomplish but
>> here is a free extension course:
>> 
>> rahc *stiB =
>> "1000000000000001000\
>> 1000000000000001000\
>> 10000000000000010011000001\
>> 10000000000000010011000001\
>> 10000000000000010011000001\
>> 10000000000000010011000001\
>> 10000000000000010011000001\
>> 10000000000000010011000001\
>> 10000000000000010011000001\
>> 10000000000000010011000001\
>> 001111100000001\
>> 001111100000001\
>> 001111100000001\
>> 1000000000000011110110111000001\
>> 1000000000000011110110111000001\
>> 1000000000000011110110111000001\
>> 1000000000000011110110111000001\
>> 1000000000000011110110111000001\
>> 1000000000000011110110111000001\
>> 1000000000000001000";
>> 
>> 	ftnirp ("\htgneln stiB = %d\stiBn = %s", nelrts(stiB), stiB);
>> 	
>> 	fi (0)
>> 		rof (tni i=0; i<nelrts(stiB); i+=8)
>> 		{
>> 			rahc etybs[9] = "00000000";
>> 			ypcnrts(etybs, &stiB[i], 8);
>> 			tni etyb = 0;
>> 			rof (tni d=7; d>=0; d--)
>> 				etyb += ((etybs[d]-'0')<<(7-d));
>> 			ftnirp ("%x20   %s\n", etyb, etybs);
>> 		}
>> 	// ro ylpmis:
>> 	rof (tni i=0; i<nelrts(stiB); i+=8)
>> 	{
>> 		tni etyb = 0;
>> 		rof (tni d=7; d>=0; d--)
>> 			etyb += ((stiB[i+d]-'0')<<(7-d));
>> 		ftnirp ("%x20\n", etyb);
>> 	}
>> 
>> sln
>
>
>C:\MinGW\source> perl sln1.pl
>Operator or semicolon missing before *Bits at sln1.pl line 1.
>Ambiguous use of * resolved as operator * at sln1.pl line 1.
>Bareword found where operator expected at sln1.pl line 32, near ")
>                                byte"
>        (Missing operator before byte?)
>Bareword found where operator expected at sln1.pl line 40, near ")
>                        byte"
>        (Missing operator before byte?)
>Can't modify multiplication (*) in scalar assignment at sln1.pl line 21,
>near "0
>001000000000000001";"
>  (Might be a runaway multi-line "" string starting on line 2)
>syntax error at sln1.pl line 26, near ")
>                for "
>syntax error at sln1.pl line 27, near "8)
>                "
>syntax error at sln1.pl line 29, near "&Bits["
>syntax error at sln1.pl line 32, near ")
>                                byte "
>syntax error at sln1.pl line 40, near ")
>                        byte "
>Execution of sln1.pl aborted due to compilation errors.
>
>C:\MinGW\source>

For the Perl equivalent, you have to xor the free extension
course C code and shift left by 3 bits. Where do you think Perl
came from anyway?

Typical George W. Bush fan..

sln
======================================

use strict;
use warnings;

my $cpos = tell( DATA);
my $Bits = '';

## inline ...
while(<DATA>) {
	chomp; $Bits.=$_;
	while ($Bits =~ s/(\d{8})//) {
		printf ("%02x\n", oct('0b'.$1));
	}
}
print "\n";

# or simply, all at once ...
seek (DATA,$cpos,0);
$Bits = '';
while(<DATA>) { chomp; $Bits.=$_ }
while ($Bits =~ /(\d{8})/g) {
	printf ("%02x\n", oct('0b'.$1));
}

__DATA__
0001000000000000001
0001000000000000001
10000011001000000000000001
10000011001000000000000001
10000011001000000000000001
10000011001000000000000001
10000011001000000000000001
10000011001000000000000001
10000011001000000000000001
10000011001000000000000001
100000001111100
100000001111100
100000001111100
1000001110110111100000000000001
1000001110110111100000000000001
1000001110110111100000000000001
1000001110110111100000000000001
1000001110110111100000000000001
1000001110110111100000000000001
0001000000000000001



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

Date: Tue, 9 Dec 2008 21:28:29 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: is perl obsolete?
Message-Id: <slrngjtl7e.o6g.hjp-usenet2@hrunkner.hjp.at>

On 2008-12-08 20:14, Tim Greer <tim@burlyhost.com> wrote:
> gavino wrote:
>> php ruby haskell erlang all seem to be beyond it
>
> Also, what do you mean by they all seem to be beyond it?  There's
> absolutely nothing those languages or frameworks can do that Perl can't
> do just as well (and sometimes better), or in a framework, too.  They
> are newer, they are hyped more, is that what you mean?

Erlang appeared in 1987, the same year as Perl 1. There's a good chance
that Erlang is actually a few months older than Perl. Haskell appeared
in 1990, so it's a bit younger than Perl, but not exactly new, either.

Also, I'm not sure there is much hype about them. Oh, there is some talk
about a renaissance of functional programming languages, but I think
that will remain just talk. These languages are very
different from "mainstream" object oriented imperative[1] languages like
C++, Java, Python or Perl, which will probably keep the number of
programmers (and the numbers of programs written in these languages)
small, because a) many programmers don't grasp the concepts (ok, many
programmers don't grasp OO either, so that may not be a problem) and
b) managers are afraid of using a language which only a few
highly-skilled programmers have mastered, no matter how productive they
are.

> PHP and Ruby are fine languages, nothing wrong with them.

PHP and Ruby are indeed quite a bit younger than Perl and both were
written by authors who knew Perl and consciously borrowed some features
from Perl and rejected others.

	hp


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

Date: Tue, 09 Dec 2008 13:25:58 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: is perl obsolete?
Message-Id: <HnB%k.4180$dm3.3274@newsfe02.iad>

Peter J. Holzer wrote:

> Erlang appeared in 1987, the same year as Perl 1. There's a good
> chance that Erlang is actually a few months older than Perl. Haskell
> appeared in 1990, so it's a bit younger than Perl, but not exactly
> new, either.

Pardon, I was speaking of Ruby and PHP when speaking of when they came
about.  Indeed, PHP was originally just a method to get Perl code
embedded in HTML web pages, or something along those lines.

Overall, language war trolls usually don't get far anyway, since I don't
see many people in the Perl group caring if someone wants to use
something else if they want to.

I know I don't care, but I'm happy to report to the OP that Perl isn't
in danger of going away or being obsolete.  I'll be retired before that
happens, and I'm not very old. :-)
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Tue, 9 Dec 2008 01:51:56 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: is perl obsolete?
Message-Id: <ghmu8u.16o.1@news.isolution.nl>

cartercc schreef:
> Joost Diepenmaat:

>> If you haven't seen it yet, take a look at clojure. Looks like a
>> strong contender for the next "new lisp" - especially with its focus
>> on concurrency.
>
> Take a look at today's /. for the article in Dr. Dobbs Journal, It's
> Time to Get Good at Functional Programming
>
http://www.ddj.com/development-tools/212201710;jsessionid=3MQLTTYJRPL3CQSNDLRSKH0CJUNN2JVN

Let's just bolt it on. ;-)

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Tue, 9 Dec 2008 15:01:11 -0800 (PST)
From: Xah Lee <xahlee@gmail.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <9f86f78c-776e-4793-b931-67dadc0e24f1@i24g2000prf.googlegroups.com>


On Dec 8, 4:56 pm, Jon Harrop <j...@ffconsultancy.com> wrote:
> Xah Lee wrote:
> > A moron, wrote:
> > > You failed the challenge that you were given.
>
> > you didn't give me a challenge.
>
> Thomas gave you the challenge:
>
>   "What I want in return is you to execute and time Dr. Harrop's original
> code, posting the results to this thread... By Dr. Harrop's original code=
,
> I specifically mean the code he posted to this thread. I've pasted it bel=
ow
> for clarity.".
>
> Thomas even quoted my code verbatim to make his requirements totally
> unambiguous. Note the parameters [9, 512, 4] in the last line that he and=
 I
> both gave:
>
>   AbsoluteTiming[Export["image.pgm", Graphics@Raster@Main[9, 512, 4]]]
>
> You have not posted timings of that, let alone optimized it. So you faile=
d.

The first parameter to your Main specifies some kinda recursively
stacked spheres in the rendered image. The second parameter is the
width and height of the pixels in the rendered image.

I tried to run them but my computer went 100% cpu and after i recall 5
min its still going. So, i reduced your input. In the end, with
reduced input, it shows my code is 5 times faster (running Mathematica
v4 on OS X 10.4.x with PPC 1.9 GHz), and on the other guy's computer
with Mathematica 6 he says it's twice as fast.

Given your code's nature, it is reasonably to assume that with your
original input my code would still be faster than yours. You claim it
is not or that it is perhaps just slightly faster?

It is possible you are right. I don't want to spend the energy to run
your code and my code and possible hog my computer for hours or
perhaps days. As i said, your recursive Intersect is very badly
written Mathematica code. It might even start memory swapping.

Also, all you did is talking bullshit. Thomas actually is the one took
my challenge to you and gave me $20 to prove my argument to YOU. His
requirement, after the payment, is actually, i quote:

=C2=ABAlright, I've sent $20. The only reason I would request a refund is
if you don't do anything. As long as you improve the code as you've
described and post the results, I'll be satisfied. If the improvements
you've described don't result in better performance, that's OK.=C2=BB

He haven't posted since nor emailed me. It is reasonable to assume he
is satisfied as far as his payment to me to see my code goes.

You, kept on babbling. Now you say that the input is different. Fine.
How long does that input actually take on your computer? If days, i'm
sorry i cannot run your toy code on my computer for days. If in few
hours, i can then run the code overnight, and if necessary, give you
another version that will be faster with your given input to shut you
the fuck up.

However, there's cost to me. What do i get to do your homework? It is
possible, that if i spend the energy and time to do this, then you
again refuse to acknowledge it, or kept on complaining about something
else.

You see, newsgroup is the bedrock of bullshit. You bullshit, he
bullshits, everybody brags and bullshit because there is no stake. I
want sincerity and responsibility backed up, with for example paypal
deposits. You kept on bullshitting, Thomas gave me $20 and i produced
a code that reasonably demonstrated at least how unprofessional your
Mathematica code was.

Here's the deal. Pay me $20, then i'll creat a version of Mathematica
code that has the same input as yours. Your input is Main[9, 512, 4],
as i have exposed, your use of interger in the last part for numerical
computation is Mathematica incompetence. You didn't acknowledge even
this. I'll give a version of Mathematica with input Main[9, 512, 4.]
that will run faster than yours. If not, money back guaranteed. Also,
pay me $300, then i can produce a Mathematica version no more than 10
times slower than your OCaml code, this should be a 70000 times
improvement according to you. Again, money back guarantee.

If i don't receive $20 or $300, this will be my last post to you in
this thread. You are just a bullshitter.

O wait... my code with Main[9, 512, 4.] and other numerical changes
already makes your program run faster regardless of the input size.
What a motherfucking bullshit you are. Scratch the $20. The $300
challenge still stands firm.

  Xah
=E2=88=91 http://xahlee.org/

=E2=98=84



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

Date: Tue, 9 Dec 2008 06:26:08 -0800 (PST)
From: david <michaelgang@gmail.com>
Subject: Re: ordered hashes
Message-Id: <0a71fc8e-0b06-4595-a955-72913540de85@a26g2000prf.googlegroups.com>

On Dec 9, 3:41=A0pm, Julian <julian@invalid> wrote:
> bugbear a =E9crit :
>
> > Julian wrote:
> >> Hi,
> >> Is there a best practice to implement an "ordered hash" in Perl?
>
> >> For example I need to manipulate a csv file: each line is a record
> >> with a fixed number of fields.
>
> > That's a 2D array.
>
> yes, the file is a 2D array. But I'm processing one line at a time (the
> files I'm processing can have hundreds of thousands records).
> A line is a 1D array.
> But for example the 24th field is the social security number, the 25th
> field is the wage, and so on.
> In my program I don't want to write $arr[23] =3D ..., $arr[24]=3D...
> A hash of some kind is more appropriate:
> $current_record{SSNumber} =3D ... , $current_record{Wage} =3D ...

you try to make something like an enum

try maybe this

 use constant {
        ...
        ...
        SSNumber=3D>23,
        Wage=3D>24
    };
and then
$current_record[SSNumber] =3D ... , $current_record[Wage] =3D ...


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

Date: Tue, 9 Dec 2008 07:16:34 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: ordered hashes
Message-Id: <bcd129f5-35c1-4e4a-a999-b926283b87ac@z28g2000prd.googlegroups.com>

On Dec 9, 5:41=A0am, Julian <julian@invalid> wrote:
> bugbear a =E9crit :
>
> > Julian wrote:
> >> Hi,
> >> Is there a best practice to implement an "ordered hash" in Perl?
>
> >> For example I need to manipulate a csv file: each line is a record
> >> with a fixed number of fields.
>
> > That's a 2D array.
>
> yes, the file is a 2D array. But I'm processing one line at a time (the
> files I'm processing can have hundreds of thousands records).

Sounds to me that a database would be far more appropriate and more
efficient than a flat csv file.


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

Date: Tue, 09 Dec 2008 10:39:07 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: ordered hashes
Message-Id: <86fxkxqrxg.fsf@mithril.chromatico.net>

>>>>> "J" == Julian  <julian@invalid> writes:

    J> It's a generic question. I often manipulate csv files or
    J> tab-separated files, where each field has some semantic. When I
    J> read or write a line, I need an array. But when I work on the
    J> values of the fields I prefer to work on a variable whose name
    J> has a meaning rather than on n'th element of the array.

my @field_labels = qw/date time transaction_id memo amount quantity total/;

# ...

my %item;
@item{@field_labels} = @fields_from_csv;

# ...
# do your processing on the values of %item
# ...

my @fields_to_output = @item{@field_labels};

The trick is to realize that you probably don't need an ordered hash for
most of the processing you want to do -- you just need to read the line
from the CSV in a specified order, to match the keys correctly, and you
need to output the line from the CSV in a specified order, to match what
the file format expects.

Charlton



-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: 09 Dec 2008 17:22:46 GMT
From: xhoster@gmail.com
Subject: Re: ordered hashes
Message-Id: <20081209122139.271$k9@newsreader.com>

Julian <julian@invalid> wrote:
> Hi,
> Is there a best practice to implement an "ordered hash" in Perl?
>
> For example I need to manipulate a csv file: each line is a record with
> a fixed number of fields.

Have you looked into a module, like Data::Table, the encapsulates the
entire table functionality?

>
> Here are some solutions but I don't find them very elegant:
>
> Solution 1:
> Two arrays: the first array holds the keys, the second array holds the
> values.
>
> my @arrkeys = ("first name", "age", "food"....)
> my @arrvalues = ("joe", 39, "corn flakes",...)

There is no efficient way to look up by field name.

>
> Solution 2:
> An array of hashes:
> my @orderedhash = (
>         { FieldName => "first name", Value => "Joe" },
>         { FieldName => "age", Value => 39 },
>         ...
> );

Again, there is no efficient way to look up by field name.

>
> Solution 3:
> An array to keep the order of the field, and then a hash.
> my @fieldnames = ( "first name", "age", "food",...);
> my %h = { "first name" => "joe", "age" => 39,...)

This is how I would do it, if for some reason I wouldn't use
a CPAN modules in the first place.  @fieldnames would probably only need
to be used during input and output, not the main processing body.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Tue, 09 Dec 2008 10:15:18 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: ordered hashes
Message-Id: <091220081015188236%jimsgibson@gmail.com>

In article <493e46e6$0$2850$ba620e4c@news.skynet.be>, Julian
<julian@invalid> wrote:

> Hi,
> Is there a best practice to implement an "ordered hash" in Perl?
> 
> For example I need to manipulate a csv file: each line is a record with 
> a fixed number of fields.
> 
> Here are some solutions but I don't find them very elegant:
> 
> Solution 1:
> Two arrays: the first array holds the keys, the second array holds the 
> values.
> 
> my @arrkeys = ("first name", "age", "food"....)
> my @arrvalues = ("joe", 39, "corn flakes",...)
> 
> 
> Solution 2:
> An array of hashes:
> my @orderedhash = (
>   { FieldName => "first name", Value => "Joe" },
>   { FieldName => "age", Value => 39 },
>   ...
> );
> 
> Solution 3:
> An array to keep the order of the field, and then a hash.
> my @fieldnames = ( "first name", "age", "food",...);
> my %h = { "first name" => "joe", "age" => 39,...)

See 'perldoc -q keep' "How can I always keep my hash sorted?"

Answer:

Use a database (e.g., DB_File) or the Tie::IxHash module.

-- 
Jim Gibson


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

Date: Tue, 9 Dec 2008 22:15:56 +1100
From: Martien Verbruggen <martien.verbruggen@invalid.see.sig>
Subject: Re: ordered hashes
Message-Id: <slrngjskrc.and.martien.verbruggen@mgjv.heliotrope.home>

On Tue, 09 Dec 2008 11:22:30 +0100,
	Julian <julian@invalid> wrote:
> Hi,
> Is there a best practice to implement an "ordered hash" in Perl?

Tie::IxHash is available from CPAN.

[snip CSV example]

I've done things like this in the past, but have always opted to use an
array with the order of the keys, rather than using an ordered hash. 

YMMV

Martien
-- 
                             | Louis Pasteur's theory of germs is
Martien Verbruggen           | ridiculous fiction --  Pierre Pachet,
first.last@heliotrope.com.au | Professor of Physiology at Toulouse,
                             | 1872


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

Date: Tue, 9 Dec 2008 15:46:47 +0000 (UTC)
From: kissg@ssg.ki.iif.hu (Kiss Gabor)
Subject: searching global variables
Message-Id: <ghm3t7$ksm$1@turmix.ikk.sztaki.hu>

I have need a code snippet those input is a text of a perl subroutine
(e.g. coming from a file) and the output of list of global variables
used by the sub.
So far I created something like this:

-------------8<-------------------8<------------------
# $code holds the source of subroutine. E.g.:
$code = q{ sub { my $aaa = $bbb + $ccc; return $aaa; } };	

my %vars;
open(PARSER,q{perl -c -e 'use strict; }.$code.q{' 2>&1 |}) or die;
while (<PARSER>) {
        next unless /Global symbol "\$(\w+)" requires explicit package name at/;
        $vars{$1}++;
}
close PARSER;

my $varlist;
foreach (keys %vars) {
        $varlist .= qq{our \$$_; };
}

# In the second pass globals do not cause error.
# Let's see if syntax is correct otherwise.
open(PARSER,q{perl -c -e 'use strict; }.$varlist.$code.q{' 2>&1 |}) or die;
while (<PARSER>) {
	# check other errors or '-e syntax OK' message
}
close PARSER;

# Global variables are keys of %vars (I.e. 'bbb' and 'ccc')
-------------8<-------------------------8<------------------

However this is not an elegant solution. I wonder if there is any way
to omit one or both fork+exec.

Any hints will be appreciated.

Gabor


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

Date: Tue, 09 Dec 2008 23:04:45 GMT
From: sln@netherlands.com
Subject: Re: searching global variables
Message-Id: <uautj41nlr7v312gh5pjh6jtg438sfs9fq@4ax.com>

On Tue, 9 Dec 2008 15:46:47 +0000 (UTC), kissg@ssg.ki.iif.hu (Kiss Gabor) wrote:

>I have need a code snippet those input is a text of a perl subroutine
>(e.g. coming from a file) and the output of list of global variables
>used by the sub.
>So far I created something like this:
>
>-------------8<-------------------8<------------------
># $code holds the source of subroutine. E.g.:
>$code = q{ sub { my $aaa = $bbb + $ccc; return $aaa; } };	
>
>my %vars;
>open(PARSER,q{perl -c -e 'use strict; }.$code.q{' 2>&1 |}) or die;
>while (<PARSER>) {
>        next unless /Global symbol "\$(\w+)" requires explicit package name at/;
>        $vars{$1}++;
>}
>close PARSER;
>
>my $varlist;
>foreach (keys %vars) {
>        $varlist .= qq{our \$$_; };
>}
>
># In the second pass globals do not cause error.
># Let's see if syntax is correct otherwise.
>open(PARSER,q{perl -c -e 'use strict; }.$varlist.$code.q{' 2>&1 |}) or die;
>while (<PARSER>) {
>	# check other errors or '-e syntax OK' message
>}
>close PARSER;
>
># Global variables are keys of %vars (I.e. 'bbb' and 'ccc')
>-------------8<-------------------------8<------------------
>
>However this is not an elegant solution. I wonder if there is any way
>to omit one or both fork+exec.
>
>Any hints will be appreciated.
>
>Gabor

If the object of an open is an expression, then sure why not?

sln

===================

 sub { my $aaa = $bbb + $ccc; return $aaa; }

open(PARSER,perl -c -e 'use strict;  sub { my $aaa = $bbb + $ccc; return $aaa; }
 ' 2>&1 |) or die;

our $VARS;

open(PARSER,perl -c -e 'use strict; VARLIST sub { my $aaa = $bbb + $ccc; return
$aaa; } ' 2>&1 |) or die;




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

Date: Tue, 09 Dec 2008 10:08:59 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Trouble with Net::Ping
Message-Id: <091220081008595502%jimsgibson@gmail.com>

In article
<26e50642-2b9f-4710-bd2b-02fef4b15a5e@41g2000yqf.googlegroups.com>, Ted
Byers <r.ted.byers@gmail.com> wrote:


> Thanks.  My scripts will be running on Windows, but the one server is
> running Linux.  I wouldn't think that would be a problem as long as
> the machine is pingable.  I have some familiarity with UDP and TCP.
> Can you tell me how ICMP fits into the mix, and its relevance for http
> exchanges?

ICMP, TCP, and UDP are separate protocols that are part of the Internet
Protocol (IP) suite. You should probably start with a good book on
networking:

<http://www.kohala.com/start/>

or Wikipedia:

<http://en.wikipedia.org/wiki/Internet_Protocol>
<http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol>
<http://en.wikipedia.org/wiki/User_Datagram_Protocol>
<http://en.wikipedia.org/wiki/Transmission_Control_Protocol>

HTTP uses TCP/IP for the transfer of static or dynamic web pages from a
web server to a browser/client.

-- 
Jim Gibson


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

Date: Tue, 9 Dec 2008 22:20:45 +1100
From: Martien Verbruggen <martien.verbruggen@invalid.see.sig>
Subject: Re: Using integers up to 0xFFFFFFFFFFFFFFFF
Message-Id: <slrngjsl4d.and.martien.verbruggen@mgjv.heliotrope.home>

On Tue, 9 Dec 2008 02:49:03 -0800 (PST),
	A. Farber <Alexander.Farber@gmail.com> wrote:
> Hello perl users,
>
> I'm programming a card game were 32 cards are used.
>
> I'd like to represent each of those cards by a bit,
> because it makes several things easier for me
> (for example I can set a mask for a user,
> restricting the cards she can play at some moment)
>
> Unfortunately constants like these:
>
> use constant ALL_CARDS  => 0xFFFFFFFFFFFFFFFF;  # line 46

That's quite a bit more than 32 bits. If you want 32 bits, 0xffffffff
should be long enough.

Your line asks for a 64 bit constant. Works on some systems, but
not on all, which is why you get the warning.

> Does anybody have an advice, how could I handle this best?

Ehm.. use 32 bits when you need 32 bits?

Martien
-- 
                             | 
Martien Verbruggen           | 
first.last@heliotrope.com.au | Curiouser and curiouser, said Alice.
                             | 


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

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


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