[30933] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2178 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 2 14:09:50 2009

Date: Mon, 2 Feb 2009 11:09:13 -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           Mon, 2 Feb 2009     Volume: 11 Number: 2178

Today's topics:
        duplicating filehandles <pgodfrin@gmail.com>
    Re: duplicating filehandles <cartercc@gmail.com>
    Re: duplicating filehandles <cartercc@gmail.com>
    Re: duplicating filehandles <pgodfrin@gmail.com>
    Re: duplicating filehandles <rkb@i.frys.com>
    Re: duplicating filehandles <rkb@i.frys.com>
    Re: duplicating filehandles (Gary E. Ansok)
        Extracting printf(...) from  (void) printf(....) <guru.naveen@gmail.com>
    Re: Extracting printf(...) from  (void) printf(....) sln@netherlands.com
    Re: Extracting printf(...) from  (void) printf(....) sln@netherlands.com
    Re: Extracting printf(...) from  (void) printf(....) sln@netherlands.com
    Re: Extracting printf(...) from  (void) printf(....) (Jens Thoms Toerring)
    Re: Extracting printf(...) from (void) printf(....) <smallpond@juno.com>
    Re: Perl IP to Domain Name converter. (hymie!)
    Re: Perl IP to Domain Name converter. <RedGrittyBrick@spamweary.invalid>
    Re: Perl Peeves (Tim McDaniel)
    Re: Perl Peeves <jjcassidy@gmail.com>
    Re: Perl Peeves <jjcassidy@gmail.com>
    Re: Perl Peeves sln@netherlands.com
    Re: perl qt with cygwin? <zentara@highstream.net>
        pipe perl output to a bash command error <t.elganainy@gmail.com>
    Re: pipe perl output to a bash command error <josef.moellers@fujitsu-siemens.com>
    Re: pipe perl output to a bash command error (Jens Thoms Toerring)
        ~ Baby Spice Naked Photo Shoot systemofadownsyndrom2@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 2 Feb 2009 09:24:29 -0800 (PST)
From: pgodfrin <pgodfrin@gmail.com>
Subject: duplicating filehandles
Message-Id: <fa6454b0-3f3c-4957-91e5-243eb14c8d60@q30g2000prq.googlegroups.com>

Greetings,
I just cant' remember how to go bout this - I have a piece of code
which does a series of prints to an open file:

open OUTFILE,">myfile" or die;
local $\="\n";
print OUTFILE 'first line of stuff';
print OUTFILE 'second line of stuff';
print OUTFILE 'third line of stuff';

I'd like to send the output to STDOUT instead of OUTFILE, but I don't
want to have to change the print statements en masse to specify
STDOUT.

Is there a way to make the open OUTFILE statement write to STDOUT
instead of the file name specifiied in the open statement? Or is there
another way to make the filehandle OUTFILE point to STDOUT?

pg



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

Date: Mon, 2 Feb 2009 09:31:46 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: duplicating filehandles
Message-Id: <72dfbcf3-c93e-4139-b15c-91c9ee459faf@r40g2000yqj.googlegroups.com>

On Feb 2, 12:24=A0pm, pgodfrin <pgodf...@gmail.com> wrote:
> Greetings,
> I just cant' remember how to go bout this - I have a piece of code
> which does a series of prints to an open file:
>
> open OUTFILE,">myfile" or die;
> local $\=3D"\n";
> print OUTFILE 'first line of stuff';
> print OUTFILE 'second line of stuff';
> print OUTFILE 'third line of stuff';
>
> I'd like to send the output to STDOUT instead of OUTFILE, but I don't
> want to have to change the print statements en masse to specify
> STDOUT.
>
> Is there a way to make the open OUTFILE statement write to STDOUT
> instead of the file name specifiied in the open statement? Or is there
> another way to make the filehandle OUTFILE point to STDOUT?
>
> pg

open OUTFILE,">myfile" or die;
local $\=3D"\n";
print OUTFILE 'first line of stuff';
print STDOUT 'line of stuff to STDOUT'; # this is it!
print OUTFILE 'second line of stuff';
print OUTFILE 'third line of stuff';
close OUTFILE;

CC



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

Date: Mon, 2 Feb 2009 09:39:38 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: duplicating filehandles
Message-Id: <0490ec68-e757-4c0f-8c2c-07ab6eda1460@f40g2000pri.googlegroups.com>

On Feb 2, 12:31=A0pm, cartercc <carte...@gmail.com> wrote:
> > Is there a way to make the open OUTFILE statement write to STDOUT
> > instead of the file name specifiied in the open statement? Or is there
> > another way to make the filehandle OUTFILE point to STDOUT?

Ooooops, didn't read the problem carefully.

Two suggestions:

(1) Use your editor to specify STDOUT on the block of lines you want.

(2) Do this:

open $outfile, ">", "testing.txt";
print $outfile "line 1\n";
{
  local $outfile =3D STDOUT;
  print $outfile "line 2\n";
  print $outfile "line 3\n";
  print $outfile "line 4\n";
}
print $outfile "line 5\n";
close $outfile;

CC


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

Date: Mon, 2 Feb 2009 09:56:56 -0800 (PST)
From: pgodfrin <pgodfrin@gmail.com>
Subject: Re: duplicating filehandles
Message-Id: <8388a564-f978-464f-af6f-3c145e45b341@i24g2000prf.googlegroups.com>

That's interesting - I suppose that would work, but I still would have
to do a mass substitution.

Is there a way to say something like

   open OUTFILE, ">STDOUT" ;

or maybe

   open OUTFILE, ">&1" ;

and then anything written to OUTFILE would go to STDOUT ?

pg


On Feb 2, 11:39=A0am, cartercc <carte...@gmail.com> wrote:
> On Feb 2, 12:31=A0pm, cartercc <carte...@gmail.com> wrote:
>
> > > Is there a way to make the open OUTFILE statement write to STDOUT
> > > instead of the file name specifiied in the open statement? Or is ther=
e
> > > another way to make the filehandle OUTFILE point to STDOUT?
>
> Ooooops, didn't read the problem carefully.
>
> Two suggestions:
>
> (1) Use your editor to specify STDOUT on the block of lines you want.
>
> (2) Do this:
>
> open $outfile, ">", "testing.txt";
> print $outfile "line 1\n";
> {
> =A0 local $outfile =3D STDOUT;
> =A0 print $outfile "line 2\n";
> =A0 print $outfile "line 3\n";
> =A0 print $outfile "line 4\n";}
>
> print $outfile "line 5\n";
> close $outfile;
>
> CC



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

Date: Mon, 2 Feb 2009 10:09:31 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: duplicating filehandles
Message-Id: <c1ce22bc-857b-431a-a0f2-863c273f043e@z28g2000prd.googlegroups.com>

On Feb 2, 9:24=A0am, pgodfrin <pgodf...@gmail.com> wrote:
> Greetings,
> I just cant' remember how to go bout this - I have a piece of code
> which does a series of prints to an open file:
>
> open OUTFILE,">myfile" or die;

Better written as:
open my $OUTFILE, '>', 'myfile' or die "can't open 'myfile' $!";

> local $\=3D"\n";

select $OUTFILE;

> print OUTFILE 'first line of stuff';
> print OUTFILE 'second line of stuff';
> print OUTFILE 'third line of stuff';

print 'first line of stuff';
print 'second line of stuff';
print 'third line of stuff';

>
> I'd like to send the output to STDOUT instead of OUTFILE, but I don't
> want to have to change the print statements en masse to specify
> STDOUT.
>
> Is there a way to make the open OUTFILE statement write to STDOUT
> instead of the file name specifiied in the open statement? Or is there
> another way to make the filehandle OUTFILE point to STDOUT?
>

# now lets output those same lines to STDOUT

select STDOUT;
print 'first line of stuff';
print 'second line of stuff';
print 'third line of stuff';


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

Date: Mon, 2 Feb 2009 10:22:12 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: duplicating filehandles
Message-Id: <e410819b-d302-4d84-a719-78187cb951e6@f40g2000pri.googlegroups.com>

On Feb 2, 9:56=A0am, pgodfrin <pgodf...@gmail.com> wrote:
> That's interesting - I suppose that would work, but I still would have
> to do a mass substitution.
>
> Is there a way to say something like
>
> =A0 =A0open OUTFILE, ">STDOUT" ;
>
> or maybe
>
> =A0 =A0open OUTFILE, ">&1" ;
>
> and then anything written to OUTFILE would go to STDOUT ?
>
If you're wanting to send the output to both filehandles, than you may
want:

use IO::Tee;
http://search.cpan.org/~kenshan/IO-Tee-0.64/Tee.pm


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

Date: Mon, 2 Feb 2009 18:22:34 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: duplicating filehandles
Message-Id: <gm7dla$t42$1@naig.caltech.edu>

In article <8388a564-f978-464f-af6f-3c145e45b341@i24g2000prf.googlegroups.com>,
pgodfrin  <pgodfrin@gmail.com> wrote:
>That's interesting - I suppose that would work, but I still would have
>to do a mass substitution.
>
>Is there a way to say something like
>
>   open OUTFILE, ">STDOUT" ;

open OUTFILE, ">&STDOUT";

Look in perldoc perlopentut (specifically the section "Obscure Open
Tricks"), or in perldoc -f open, for more details.

Gary Ansok
-- 
Chaos reigns within. 
Reflect, repent, and reboot. 
Order shall return. 


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

Date: Mon, 2 Feb 2009 06:04:50 -0800 (PST)
From: guru <guru.naveen@gmail.com>
Subject: Extracting printf(...) from  (void) printf(....)
Message-Id: <d809ff41-0e82-454a-bd29-4f76b2c82daf@r15g2000prd.googlegroups.com>

HI all

How to search for (void) from the line.

ex: (void) printf(....)

I want to search if (void) is there at the beggining of the line.. if
exist then extract printf(....) function.

Please let me know how it can be done or tell me the reference so that
I can try.

Thanks  & Regards
Gururaja


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

Date: Mon, 02 Feb 2009 16:54:19 GMT
From: sln@netherlands.com
Subject: Re: Extracting printf(...) from  (void) printf(....)
Message-Id: <nr6eo4pspk7tlsts1da71ef5360j6p84ms@4ax.com>

On Mon, 2 Feb 2009 06:04:50 -0800 (PST), guru <guru.naveen@gmail.com> wrote:

>HI all
>
>How to search for (void) from the line.
>
>ex: (void) printf(....)
>
>I want to search if (void) is there at the beggining of the line.. if
>exist then extract printf(....) function.
>
>Please let me know how it can be done or tell me the reference so that
>I can try.
>
>Thanks  & Regards
>Gururaja

I assume this is just an example, the key phrase is 'void' and printf has
nothing to do with it.

printf() from CRT returns type 'int', the number of characters written.
To cast the return value to type (void) serves no purpose since only pointers
can be of type 'void', ie: not variables.

So these produce errors ->
int  ivar;   // ok
void var;    // invalid type
var = (void) printf(....);  // invalid rvalue cast
ivar = (void) printf(....);  // invalid rvalue cast
(void) printf(....);  // ok, does nothing
void *ptr;  // ok, its a pointer


As far as parsing a source file, functions can span lines and have 
nested functions, requiring balanced text parsing:

printf("*The floor of 0.3/0.1-2 is %f\n",
	floor(0.3/0.1-2) );

and be mixed with comments. A better solution is to get a C++ parser somewhere.

But, if this isn't real source code text and all you want to do is parse anything
in (void) "function(anything)" on a line by line basis, I guess you could adopt a quick and
dirty approach, something like this:


while (<DATA>)  # no caching of lines, raw per-line basis
{
	chomp;
	if (/(\s*void\s*)\s*([a-z][\w-]*?\s*\(.*\)\s*)/ { # greedy () in liue of balanced parenthesis
		print $1,"\n";
	}
	# Or, just grab everything past (void)
	# if (/(\s*void\s*)\s*(.+)/ {
	#	print $1,"\n";
	# }
}

sln





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

Date: Mon, 02 Feb 2009 17:12:12 GMT
From: sln@netherlands.com
Subject: Re: Extracting printf(...) from  (void) printf(....)
Message-Id: <5l9eo4lm442uki2ho7e25jaoh95o5dsno7@4ax.com>

On Mon, 02 Feb 2009 16:54:19 GMT, sln@netherlands.com wrote:

>On Mon, 2 Feb 2009 06:04:50 -0800 (PST), guru <guru.naveen@gmail.com> wrote:
>
>>HI all
>>
>>How to search for (void) from the line.
>>
[snip]
>and be mixed with comments. A better solution is to get a C++ parser somewhere.
>
>But, if this isn't real source code text and all you want to do is parse anything
>in (void) "function(anything)" on a line by line basis, I guess you could adopt a quick and
>dirty approach, something like this:
>
>
>while (<DATA>)  # no caching of lines, raw per-line basis
>{
>	chomp;
>	if (/(\s*void\s*)\s*([a-z][\w-]*?\s*\(.*\)\s*)/ { # greedy () in liue of balanced parenthesis
            ^^^
I forgot to mention this is untested. After looking at it a bit, this may be better:

	/\(\s*void\s*\)\s*([a-zA-Z][\w-]*\s*\(.*\))/

Gee, there are alot of paren's in this one..

sln



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

Date: Mon, 02 Feb 2009 17:22:16 GMT
From: sln@netherlands.com
Subject: Re: Extracting printf(...) from  (void) printf(....)
Message-Id: <5oaeo49kvgf0qou0n6lj7rn2f2hn5lmep2@4ax.com>

On Mon, 02 Feb 2009 17:12:12 GMT, sln@netherlands.com wrote:

>On Mon, 02 Feb 2009 16:54:19 GMT, sln@netherlands.com wrote:
>
>>On Mon, 2 Feb 2009 06:04:50 -0800 (PST), guru <guru.naveen@gmail.com> wrote:
>>
>>>HI all
>>>
>>>How to search for (void) from the line.
>>>
>[snip]
>>and be mixed with comments. A better solution is to get a C++ parser somewhere.
>>
>>But, if this isn't real source code text and all you want to do is parse anything
>>in (void) "function(anything)" on a line by line basis, I guess you could adopt a quick and
>>dirty approach, something like this:
>>
>>
>>while (<DATA>)  # no caching of lines, raw per-line basis
>>{
>>	chomp;
>>	if (/(\s*void\s*)\s*([a-z][\w-]*?\s*\(.*\)\s*)/ { # greedy () in liue of balanced parenthesis
>            ^^^
>I forgot to mention this is untested. After looking at it a bit, this may be better:
>
>	/\(\s*void\s*\)\s*([a-zA-Z][\w-]*\s*\(.*\))/
>
>Gee, there are alot of paren's in this one..
>
Why not add some more ..
      /\(\s*void\s*\)\s*((?:_[a-zA-Z]|[a-zA-Z])[\w-]*\s*\(.*\))/

sln



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

Date: 2 Feb 2009 18:54:43 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Extracting printf(...) from  (void) printf(....)
Message-Id: <6uotrjFgh3bdU1@mid.uni-berlin.de>

sln@netherlands.com wrote:
> On Mon, 2 Feb 2009 06:04:50 -0800 (PST), guru <guru.naveen@gmail.com> wrote:

> >How to search for (void) from the line.
> >
> >ex: (void) printf(....)
> >
> >I want to search if (void) is there at the beggining of the line.. if
> >exist then extract printf(....) function.
> >
> >Please let me know how it can be done or tell me the reference so that
> >I can try.

> I assume this is just an example, the key phrase is 'void' and printf has
> nothing to do with it.

> printf() from CRT returns type 'int', the number of characters written.
> To cast the return value to type (void) serves no purpose since only pointers
> can be of type 'void', ie: not variables.

It may not serve any purpose to the C compiler, but there are code
testing tools like lint that complain when the return value of a
function isn't used. And to keep lint etc. from doing so in cases
where disregarding the return value is exactly what you want it is
not uncommon practise to cast the such return values to '(void)'
since lint only then understands that you don't want to do anything
with it and shuts up.

To the OP: Of course you can search for such lines with something
like

/^\s*\(\s*void\*\)\s*printf\(.*?\)\s*;/

or, if it's not just about printf() but all functions,

/^\s*\(\s*void\*\)\s*[A-Za-z0-9_]+\s*\(.*?\)\s*;/

but there are more possible cases like

    if (some_condition) (void) printf(...);

or

    do_something(); (void) printf(...);

just to name a few - so just looking for the first piece of code
on a line won't catch all instances. You would have to use at least
(I probably forgot a few possibilities) something like the fol-
lowing (assuming the function call isn't split up into more than
one line):

/(^|;|\)|,|}|(*/))\s*\(\s*void\*\)\s*[A-Za-z0-9_]+\s*\(.*?\)\s*;/

But even that it still might get a few cases wrong (e.g. if you
have printf()s with weird format strings like "xyz);" etc.) or
produce false positives. To get it 100% right I guess you would
have to write a parser for C, regexps probably aren't good enough
for this since they just look at the input stream but without
"understanding" what it means. To see how hairy C code can look
like check out the winning entries of the obfuscated C contest;-)

                                  Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


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

Date: Mon, 2 Feb 2009 06:10:11 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Extracting printf(...) from (void) printf(....)
Message-Id: <679b96be-ee53-46bf-bfa1-1018c620bbe1@v18g2000pro.googlegroups.com>

On Feb 2, 9:04 am, guru <guru.nav...@gmail.com> wrote:
> HI all
>
> How to search for (void) from the line.
>
> ex: (void) printf(....)
>
> I want to search if (void) is there at the beggining of the line.. if
> exist then extract printf(....) function.
>
> Please let me know how it can be done or tell me the reference so that
> I can try.
>
> Thanks  & Regards
> Gururaja


Run the command:
perldoc perlretut



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

Date: Mon, 02 Feb 2009 14:54:00 GMT
From: hymie@lactose.homelinux.net (hymie!)
Subject: Re: Perl IP to Domain Name converter.
Message-Id: <cODhl.12580$%j5.4041@newsfe10.iad>

In our last episode, the evil Dr. Lacto had captured our hero,
  Tad J McClellan <tadmc@seesig.invalid>, who said:

>There are lots of bad "programs" on the wild interweb, you have found one
>of them.
>
>Even without the syntax errors, I can say that this was not written
>by a good Perl programmer...

It looks like what he found was not a bad program but a bad way to
download a program from the internet.

Specifically, it looks like he lost much whitespace and anything between
a less-than sign and a greater-than sign.  Somebody took the text that
comprises a perl program, put it on the web as a text/html , and
left it there to be copy-n-pasted; as opposed to something sensible like
an FTP site.

--hymie!    http://lactose.homelinux.net/~hymie    hymie@lactose.homelinux.net
------------------------ Without caffeine for 825 days ------------------------


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

Date: Mon, 02 Feb 2009 15:09:48 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Perl IP to Domain Name converter.
Message-Id: <49870cbe$0$30301$da0feed9@news.zen.co.uk>


hymie! wrote:
> In our last episode, the evil Dr. Lacto had captured our hero,
>   Tad J McClellan <tadmc@seesig.invalid>, who said:
> 
>> There are lots of bad "programs" on the wild interweb, you have found one
>> of them.
>>
>> Even without the syntax errors, I can say that this was not written
>> by a good Perl programmer...
> 
> It looks like what he found was not a bad program but a bad way to
> download a program from the internet.
> 
> Specifically, it looks like he lost much whitespace and anything between
> a less-than sign and a greater-than sign.  Somebody took the text that
> comprises a perl program, put it on the web as a text/html , and
> left it there to be copy-n-pasted; as opposed to something sensible like
> an FTP site.
> 

http://www.osix.net/modules/article/?id=194

Ick!

-- 
RGB


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

Date: Mon, 2 Feb 2009 15:46:57 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Perl Peeves
Message-Id: <gm74hh$t4g$1@reader1.panix.com>

In article <slrngo82d5.lsv.hjp-usenet2@hrunkner.hjp.at>,
Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>If you are printing this only for debugging reasons, you probably
>know about the context to tell that "nothing visible printed" means
>false.

Or I forgot to put that expression into the debug output statement.
I would think that to be unlikely in the case that I snipped, where it
was one variable being dumped, but if I were trying to dump four
variables, the mistake might be easier to overlook.  I like to
distinguish when something is deliberately missing from accidentally
missing.

-- 
Tim McDaniel, tmcd@panix.com


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

Date: Mon, 2 Feb 2009 10:17:42 -0800 (PST)
From: A Dude <jjcassidy@gmail.com>
Subject: Re: Perl Peeves
Message-Id: <7f5dacff-049c-4d90-9469-c772f28be12a@f18g2000vbf.googlegroups.com>

On Jan 31, 3:19=A0am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:

> Well, on a standard terminal, you can't distinguish '0' from '0 ',
> either, so that's rather pointless. If you are printing this only for
> debugging reasons, you probably know about the context to tell that
> "nothing visible printed" means false.

Good point. There is an inherent ambiguity in printing text without
delimiters. And your expectation would play an important role, which I
guess plays into the reason why I wouldn't blanch a


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

Date: Mon, 2 Feb 2009 10:21:16 -0800 (PST)
From: A Dude <jjcassidy@gmail.com>
Subject: Re: Perl Peeves
Message-Id: <3bc717cd-2f3a-4997-bd21-e4a4ba92efa6@e1g2000pra.googlegroups.com>

On Feb 2, 1:17=A0pm, A Dude <jjcass...@gmail.com> wrote:
> On Jan 31, 3:19=A0am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>
> > Well, on a standard terminal, you can't distinguish '0' from '0 ',
> > either, so that's rather pointless. If you are printing this only for
> > debugging reasons, you probably know about the context to tell that
> > "nothing visible printed" means false.
>
> Good point. There is an inherent ambiguity in printing text without
> delimiters. And your expectation would play an important role, which I
> guess plays into the reason why I wouldn't blanch a

 ...t the original unbalanced equals sign.

But still that there is a broader class of ambiguity (undelimited
text) does not diminish the idea that there is a distinct ambiguity in
the case mentioned.


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

Date: Mon, 02 Feb 2009 18:53:43 GMT
From: sln@netherlands.com
Subject: Re: Perl Peeves
Message-Id: <2ddeo45glu10r40topljip237gbaje6m87@4ax.com>

On Sun, 01 Feb 2009 16:24:08 GMT, Bruce Cook <bruce-usenet@noreplybicycle.synonet.comnoreply> wrote:

>Peter J. Holzer wrote:
>
>> On 2009-02-01 08:54, Bruce Cook
>> <bruce-usenet@noreplybicycle.synonet.comnoreply> wrote:
>>> Peter J. Holzer wrote:
>>>
>>>> On 2009-01-29 22:54, Bruce Cook
>>>> <bruce-usenet@noreplybicycle.synonet.comnoreply> wrote:
>>>>> Peter J. Holzer wrote:
>>>>>> On 2009-01-27 09:08, Eric Pozharski <whynot@pozharski.name> wrote:
>>>>>>> On 2009-01-27, Tim McDaniel <tmcd@panix.com> wrote:
>>>>>>>> (5) That "special false".  I was going nuts trying to figure out
>>>>>>>> what was different between
>>>>>> 
>>>>>> [ '' in string context, 0 in numeric context ]
>> [...]
>>>>> Anyone who applies a numeric operator to a logical value and expects
>>>>> consistent results is asking for trouble.
>> [...]
>>>>> In strongly-typed languages you would get a compiler or run-time
>>>>> error/warning, however perl is a scripting language and is built to be
>>>>> flexible, assumes you know what you're doing and will silently oblige
>>>>> even the most horrendous abuses.
>>>>>
>>>>> You actually have the same issue in C: false is defined as 0 and true
>>>>> is !false.
         ^^^^^
This may be an odd way to look at it since the unary and comparison operators
return 1 for true, where true can be -5 or +299, or Not Zero.
True doesen't necessarily equal 1. So "true = !false" is only a single value
in a set of values. There is only one truth, false = 0.

>>>> 
>>>> However, in C, !0 is defined as 1.
>>>
>>> This is where lots of people make mistakes in C.
>> 
>> You seem to be one of them.
>> 
>> 
>>> if(a)   is not the same as
>>> if(a == !0)
>> 
>> I didn't say that. I said !0 is the same thing as 1 which means, that
>> 
>>  if (a == !0)
>> 
>> is exactly the same as
>> 
>>   if (a == 1)
>> 
>> While
>> 
>>   if (a)
>> 
>> is the same thing as
>> 
>>   if (a != 0)
>> 
>> Obviously (a != 0) and (a == 1) are not the same thing.
               ^^^^^       ^^^^^
I know you mean this in the context stated above, but it looks funny
when put together this way.
In fact, if a is equal to 1, then (a != 0) == (a == 1) is true.

The only thing for sure is false is equal to 0, everything else is true.

>
>Yep, I missed the distinction in your original statement, I don't use the !0 
>construct as I find it rather pointless, so read it as "not zero".  
>Apologies

I'm a little confused, the !0 is not a construct, its a statement and definition
of the set of values that are true.

I think before the standards commitee got thier head around this not too long ago,
flase was anything less than or equal to zero, true was greater than zero.
I remember many old compilers where this was the case. Thus the period of confusion
updating legacy code on the sucess or failure of function calls. Still makes old
programmers cringe.

sln



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

Date: Mon, 02 Feb 2009 08:51:33 -0500
From: zentara <zentara@highstream.net>
Subject: Re: perl qt with cygwin?
Message-Id: <l6udo4dmj5ob1fq9iihjch73eiprs1u5re@4ax.com>

On Sun, 01 Feb 2009 15:11:21 -0500, rabbits77 <rabbits77@my-deja.com>
wrote:

>zentara wrote:

>> As far as I know, the Perl Qt module is very old and has not been
>> keeping up with KDE development....  so unless you have found some new
>> version of Perl/Qt, just forget about using it, it is obsolete and not
>> actively maintained.  The module on CPAN is version 0.03 and dated 1997.


>I am trying one from Sourceforge. The release is dated 10 July 2005.
>http://sourceforge.net/projects/perlqt

That is still very old, considering the way KDE is rapidly
developed/changed. This is 2009. :-)

The general concensus among Perl GUI users is Qt dosn't work,
because it is not keeping up with the KDE lib releases.
I don't know why the module author gave up on it.... maybe the
restrictive license....maybe the C++.... maybe the difficulty of
managing the xs code to access the libs. 

Try Perl Gtk2, if you want something that works and is up to date. 
It works.

zentara

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


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

Date: Mon, 2 Feb 2009 04:23:16 -0800 (PST)
From: Tarek Elganainy <t.elganainy@gmail.com>
Subject: pipe perl output to a bash command error
Message-Id: <a9acdd61-ddca-4027-a814-d050cf2f1596@f40g2000pri.googlegroups.com>

I was wondering why the first line give me output but the second
don't, any clue!!

1. while sleep 2;do printf "1\n1\n"|perl -e 'while ( <> )
{ print; }';done|perl -e 'while ( <> ) { print; }'

2. while sleep 2;do printf "1\n1\n"|perl -e 'while ( <> )
{ print; }';done|perl -e 'while ( <> ) { print; }'|cat


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

Date: Mon, 02 Feb 2009 14:00:28 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: pipe perl output to a bash command error
Message-Id: <gm6qp9$ebp$1@nntp.fujitsu-siemens.com>

Tarek Elganainy wrote:
> I was wondering why the first line give me output but the second
> don't, any clue!!
> 
> 1. while sleep 2;do printf "1\n1\n"|perl -e 'while ( <> )
> { print; }';done|perl -e 'while ( <> ) { print; }'
> 
> 2. while sleep 2;do printf "1\n1\n"|perl -e 'while ( <> )
> { print; }';done|perl -e 'while ( <> ) { print; }'|cat

Buffering?
In the first instance, the last perl is writing to the screen, so the 
output is unbuffered. In the second instance, the last perl is writing 
to a pipe, hence the output is buffered and will appear only when a 
couple of kilobytes have accumulated.

The first perl instance in each pipeline only does 2 lines, then exits 
and flushes its buffers.

Just an (un?)educated guess,

Josef
-- 
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html


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

Date: 2 Feb 2009 13:18:34 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: pipe perl output to a bash command error
Message-Id: <6uoa5aFgfecdU1@mid.uni-berlin.de>

Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote:
> Tarek Elganainy wrote:
> > I was wondering why the first line give me output but the second
> > don't, any clue!!
> > 
> > 1. while sleep 2;do printf "1\n1\n"|perl -e 'while ( <> )
> > { print; }';done|perl -e 'while ( <> ) { print; }'
> > 
> > 2. while sleep 2;do printf "1\n1\n"|perl -e 'while ( <> )
> > { print; }';done|perl -e 'while ( <> ) { print; }'|cat

> Buffering?
> In the first instance, the last perl is writing to the screen, so the 
> output is unbuffered. In the second instance, the last perl is writing 
> to a pipe, hence the output is buffered and will appear only when a 
> couple of kilobytes have accumulated.

> The first perl instance in each pipeline only does 2 lines, then exits 
> and flushes its buffers.

> Just an (un?)educated guess,

s/\(un\?\)//

You can also test that this is the case. E.g. if you replace

while sleep 2

with

while [ -n "qqq" ]

or something similar that's always true then, after a delay needed
to fill the buffer, you start getting output from 'cat'.

                               Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


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

Date: Mon, 2 Feb 2009 07:23:34 -0800 (PST)
From: systemofadownsyndrom2@gmail.com
Subject: ~ Baby Spice Naked Photo Shoot
Message-Id: <c183b55c-ef06-4d13-a619-2e3399d4f27c@x6g2000pre.googlegroups.com>

Nice http://imival.blogspot.com/ - Baby spice nude photos as well as
Britney and brooke hogan.  And one said, Be content, I pray thee, and
go with thy servants. And he answered, I will go.


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

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


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