Re: Is this correct? print syntax

2002-10-13 Thread Jeff 'japhy' Pinyan

On Oct 11, Michael Fowler said:

>> if (condition) {
>>  print FILEHANDLE list, of, stuff;
>>  next;
>> }
>
>I agree.  It's much more readable.

I rarely do that.  Unless the body of the block is going to be enormous, I
do it without the block.  However, I think print(FOO @list) looks really
odd, so I'd probably do

  (print FOO @list), next if $condition;

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-13 Thread Peter Scott

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Michael Fowler) writes:
>On Fri, Oct 11, 2002 at 01:50:53PM -0500, James Edward Gray II wrote:
>> It's the indirect method call syntax, as far as I understand.
>
>It looks like it, but it isn't.  See
>http:[EMAIL PROTECTED]/msg33969.html for a recent
>discussion on that.

It's an indirect filehandle syntax, which is close.  There's some interesting
stuff here:

$ perldoc -q indirect
Found in /usr/lib/perl5/5.6.1/pod/perlfaq5.pod
   How can I use a filehandle indirectly?
[...]

-- 
Peter Scott
http://www.perldebugged.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-13 Thread Peter Scott

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jeff 'Japhy' Pinyan) writes:
>
>>> if (condition) {
>>> print FILEHANDLE list, of, stuff;
>>> next;
>>> }
>>
>I rarely do that.  Unless the body of the block is going to be enormous, I
>do it without the block.  However, I think print(FOO @list) looks really
>odd, so I'd probably do
>
>  (print FOO @list), next if $condition;

The parens feel funny to me.  I usually write this as

print FOO @list and next if $condition;

-- 
Peter Scott
http://www.perldebugged.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-12 Thread Michael Fowler

On Fri, Oct 11, 2002 at 01:50:53PM -0500, James Edward Gray II wrote:
> It's the indirect method call syntax, as far as I understand.

It looks like it, but it isn't.  See
http:[EMAIL PROTECTED]/msg33969.html for a recent
discussion on that.


> Personally though, I wouldprefer to see your example as:
> 
> if (condition) {
>   print FILEHANDLE list, of, stuff;
>   next;
> }

I agree.  It's much more readable.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-12 Thread James Edward Gray II

On Friday, October 11, 2002, at 05:01  PM, Michael Fowler wrote:

> On Fri, Oct 11, 2002 at 01:50:53PM -0500, James Edward Gray II wrote:
>> It's the indirect method call syntax, as far as I understand.
>
> It looks like it, but it isn't.  See
> http:[EMAIL PROTECTED]/msg33969.html for a 
> recent
> discussion on that.

Thanks for the correction.  Sorry, about the misinformation.

James


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Is this correct? print syntax

2002-10-11 Thread david

Nikola Janceski wrote:

> I need them.. for
> 
> 
> print FILEHANDLE (list, of, stuff), next if (condition);
> 

you probably just want:

print FILEHANDLE qw(list of stuff) and next if(condition);

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-11 Thread Larry Coffin

At 3:05 PM -0400 10/11/02, James Edward Gray II wrote:
>>> print FILEHANDLE (list, of, stuff), next if (condition);
>>
>> print FILEHANDLE (list, of, stuff);
>> next if (condition);

>But these two examples don't behave the same.  The first one prints
>and calls next, only on the condition.  The second one always prints
>and then calls next, if the condition is true.

You're right James. I saw that from your earlier letter that I
received after I sent mine -- the 'if' has a higher precedence than the
comma and both statements are executed conditionally. And I agree with your
earlier letter that it is better to break those into two statements and
enclose them within an 'if' block -- much cleaner that way.

Thanks for clearing that up!

---Larry


++
| Larry Coffin, G.P.H. Watertown, MA |
| http://www.PointInfinity.com/lcoffin/[EMAIL PROTECTED] |
++

Today is the tomorrow you worried about yesterday


-



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-11 Thread Paul Johnson

On Fri, Oct 11, 2002 at 02:57:21PM -0400, Larry Coffin wrote:

> >print FILEHANDLE (list, of, stuff), next if (condition);
> 
>   Why are you using a comma operator here and not just a semi-colon
> to terminate the print statement? I.e. why not:
> 
> print FILEHANDLE (list, of, stuff);
> next if (condition);
> 
>   In both cases, the return value of print() is getting tossed and
> the 'next if (...)' is not dependent on the print statement.

Because print is generally called for its side effects rather than for
its return value.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-11 Thread Steve Grazzini

Nikola Janceski <[EMAIL PROTECTED]> wrote:
> Is this correct placement of the parenthesis?
> 
> print FILEHANDLE (list_of_print_stuff);
> 

Not really.  It will usually work, but the FILEHANDLE
is the first argument, so it ought to be:

  print(FH "foo", "bar");


-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-11 Thread James Edward Gray II


On Friday, October 11, 2002, at 01:57  PM, Larry Coffin wrote:

>> print FILEHANDLE (list, of, stuff), next if (condition);
>
> print FILEHANDLE (list, of, stuff);
> next if (condition);
>
>   In both cases, the return value of print() is getting tossed and
> the 'next if (...)' is not dependent on the print statement.

But these two examples don't behave the same.  The first one prints 
and calls next, only on the condition.  The second one always prints 
and then calls next, if the condition is true.

James


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Is this correct? print syntax

2002-10-11 Thread Jeff 'japhy' Pinyan

On Oct 11, Nikola Janceski said:

>print(FILEHANDLE list, of, stuff, to, print), next if (condition);
>
>which I haven't tested. and do I need another comma in that?... ;) just
>fueling the fire I guess.

That is what you need.

  print (FH @args), next if condition;

And no, do NOT put a comma after the filehandle.

  print FH (@args), next if condition;

is the same as

  print FH @args, next if condition;

which is NOT what you want.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-11 Thread Tim Musson

Hey Nikola, 

My MUA believes you used Internet Mail Service (5.5.2650.21)
to write the following on Friday, October 11, 2002 at 2:40:28 PM.

NJ> I need them.. for

NJ> print FILEHANDLE (list, of, stuff), next if (condition);

This type of thing is common in my code when I am messing around.

my $debug=0; # !=0 makes info print
print "\n\n\tThis is in the test\n\n" if $debug;

-- 
[EMAIL PROTECTED]
Flying with The Bat! eMail v1.61
Windows 2000 5.0.2195 (Service Pack 2)
Does the noise in my head bother you?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-11 Thread James Edward Gray II

On Friday, October 11, 2002, at 01:45  PM, Tim Musson wrote:

> use strict;
> use warnings;
> print (list_of_print_stuff); # This gives an error

I don't get any error with this, assuming I either make it a proper 
declared variable or quote it, in Perl 5.6.0.  It's never wrong to use 
parenthesis, even if they aren't required.

James


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Is this correct? print syntax

2002-10-11 Thread Larry Coffin

>print FILEHANDLE (list, of, stuff), next if (condition);

Why are you using a comma operator here and not just a semi-colon
to terminate the print statement? I.e. why not:

print FILEHANDLE (list, of, stuff);
next if (condition);

In both cases, the return value of print() is getting tossed and
the 'next if (...)' is not dependent on the print statement.

---Larry


++
| Larry Coffin, G.P.H. Watertown, MA |
| http://www.PointInfinity.com/lcoffin/[EMAIL PROTECTED] |
++

Today is the tomorrow you worried about yesterday


-



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Is this correct? print syntax

2002-10-11 Thread Nikola Janceski

from the doc I was a little confused and wanted clarification:
 
  Also be careful not to
 follow the print keyword with a left parenthesis
 unless you want the corresponding right parenthesis
 to terminate the arguments to the print--interpose a
 "+" or put parentheses around all the arguments.

this makes me think I can do this:

print(FILEHANDLE list, of, stuff, to, print), next if (condition);

which I haven't tested. and do I need another comma in that?... ;) just
fueling the fire I guess.

> -Original Message-
> From: Tim Musson [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 11, 2002 2:46 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Is this correct? print syntax
> 
> 
> Hey Nikola, 
> 
> My MUA believes you used Internet Mail Service (5.5.2650.21)
> to write the following on Friday, October 11, 2002 at 2:28:27 PM.
> 
> NJ> Is this correct placement of the parenthesis?
> 
> NJ> print FILEHANDLE (list_of_print_stuff);
> 
> The best thing to do is look at perldoc, and try it yourself.
> 
> use strict;
> use warnings;
> print (list_of_print_stuff); # This gives an error
> print "\nThis is how I usually do it\n";
> 
> tryperldoc -q printat a command prompt.
> 
> -- 
> [EMAIL PROTECTED]
> Flying with The Bat! eMail v1.61
> Windows 2000 5.0.2195 (Service Pack 2)
> What else can you do at 3:00 am?
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-11 Thread Tim Musson

Hey Nikola, 

My MUA believes you used Internet Mail Service (5.5.2650.21)
to write the following on Friday, October 11, 2002 at 2:28:27 PM.

NJ> Is this correct placement of the parenthesis?

NJ> print FILEHANDLE (list_of_print_stuff);

The best thing to do is look at perldoc, and try it yourself.

use strict;
use warnings;
print (list_of_print_stuff); # This gives an error
print "\nThis is how I usually do it\n";

tryperldoc -q printat a command prompt.

-- 
[EMAIL PROTECTED]
Flying with The Bat! eMail v1.61
Windows 2000 5.0.2195 (Service Pack 2)
What else can you do at 3:00 am?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-11 Thread James Edward Gray II

In that case yes, I believe you have it right.  It's the indirect  
method call syntax, as far as I understand.  Personally though, I would  
prefer to see your example as:

if (condition) {
print FILEHANDLE list, of, stuff;
next;
}

TMTOWTDI though, of course.

James

On Friday, October 11, 2002, at 01:40  PM, Nikola Janceski wrote:

> I need them.. for
>
>
> print FILEHANDLE (list, of, stuff), next if (condition);
>
>> -Original Message-
>> From: James Edward Gray II [mailto:[EMAIL PROTECTED]]
>> Sent: Friday, October 11, 2002 2:39 PM
>> To: Nikola Janceski
>> Cc: Beginners (E-mail)
>> Subject: Re: Is this correct? print syntax
>>
>>
>> Parenthesis are optional for pre-defined subroutines, like Perl's
>> built-in, so most users just leave them off when they're not needed:
>>
>> print FILEHANDLE list, of stuff, to print;
>>
>> On Friday, October 11, 2002, at 01:28  PM, Nikola Janceski wrote:
>>
>>> Is this correct placement of the parenthesis?
>>>
>>> print FILEHANDLE (list_of_print_stuff);
>>>
>>>
>>> Nikola Janceski
>>>
>>> The straightest path is not the path of experience.
>>> -- Nicky J. from da' Bronx
>>>
>>>
>>>
>> --
>> -
>>> -
>>> 
>>> The views and opinions expressed in this email message are
>> the sender's
>>> own, and do not necessarily represent the views and
>> opinions of Summit
>>> Systems Inc.
>>>
>>>
>>> --  
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>
>
> --- 
> -
> 
> The views and opinions expressed in this email message are the sender's
> own, and do not necessarily represent the views and opinions of Summit
> Systems Inc.
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Is this correct? print syntax

2002-10-11 Thread Nikola Janceski

I need them.. for


print FILEHANDLE (list, of, stuff), next if (condition);

> -Original Message-
> From: James Edward Gray II [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 11, 2002 2:39 PM
> To: Nikola Janceski
> Cc: Beginners (E-mail)
> Subject: Re: Is this correct? print syntax
> 
> 
> Parenthesis are optional for pre-defined subroutines, like Perl's  
> built-in, so most users just leave them off when they're not needed:
> 
> print FILEHANDLE list, of stuff, to print;
> 
> On Friday, October 11, 2002, at 01:28  PM, Nikola Janceski wrote:
> 
> > Is this correct placement of the parenthesis?
> >
> > print FILEHANDLE (list_of_print_stuff);
> >
> >
> > Nikola Janceski
> >
> > The straightest path is not the path of experience.
> > -- Nicky J. from da' Bronx
> >
> >
> > 
> --
> - 
> > -
> > 
> > The views and opinions expressed in this email message are 
> the sender's
> > own, and do not necessarily represent the views and 
> opinions of Summit
> > Systems Inc.
> >
> >
> > -- 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is this correct? print syntax

2002-10-11 Thread James Edward Gray II

Parenthesis are optional for pre-defined subroutines, like Perl's  
built-in, so most users just leave them off when they're not needed:

print FILEHANDLE list, of stuff, to print;

On Friday, October 11, 2002, at 01:28  PM, Nikola Janceski wrote:

> Is this correct placement of the parenthesis?
>
> print FILEHANDLE (list_of_print_stuff);
>
>
> Nikola Janceski
>
> The straightest path is not the path of experience.
> -- Nicky J. from da' Bronx
>
>
> --- 
> -
> 
> The views and opinions expressed in this email message are the sender's
> own, and do not necessarily represent the views and opinions of Summit
> Systems Inc.
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]