When to use ( and when to use ((?

I'm just not getting it.

When do you use ( in a statement, when do you need to use ((, and is
the space after either or both mandatory?

For example, I coded this statement:

if (( $_ eq $bad_guys_ip )) { more_stuff_here };

Why the two (( in an if?  And why does it seem to not work when I miss
the space after the ((?

Thanx!

Mark me as...
/Corn-fused|Dense/



-1
mweber
3/14/2003 11:18:28 PM
perl.beginners 29284 articles. 3 followers. Follow

3 Replies
1747 Views

Similar Articles

[PageSpeed] 44

> I'm just not getting it.
>=20
> When do you use ( in a statement, when do you need to use ((, and is
> the space after either or both mandatory?
>=20
> For example, I coded this statement:
>=20
> if (( $_ eq $bad_guys_ip )) { more_stuff_here };

(( )) is ksh integer test syntax, and has nothing to do with perl. Just =
use ( ).
-2
Luke
3/14/2003 11:24:04 PM
Michael Weber wrote:
> I'm just not getting it.
>
> When do you use ( in a statement, when do you need to use ((, and is
> the space after either or both mandatory?
>
> For example, I coded this statement:
>
> if (( $_ eq $bad_guys_ip )) { more_stuff_here };
>
> Why the two (( in an if?  And why does it seem to not work when I miss
> the space after the ((?

If this is pure Perl then it doesn't make any difference.

    if         (
                                ($_
    eq $bad_guys_ip)                  )
{more_stuff_here         };


is fine (although the second pair of parentheses won't make any
difference either) as long as you also have a

    sub more_stuff_here;

somewhere!

Can you give us a
bit more context, and say what error you're getting?

Cheers,

Rob



0
rob
3/15/2003 12:01:29 AM
Michael Weber wrote:
> 
> I'm just not getting it.
> 
> When do you use ( in a statement, when do you need to use ((, and is
> the space after either or both mandatory?
> 
> For example, I coded this statement:
> 
> if (( $_ eq $bad_guys_ip )) { more_stuff_here };
> 
> Why the two (( in an if?  And why does it seem to not work when I miss
> the space after the ((?

You don't need two parenthesis pairs in that context, if fact, you don't
need any whitespace at all.

if(${_}eq$bad_guys_ip){more_stuff_here}


John
-- 
use Perl;
program
fulfillment
0
krahnj
3/15/2003 1:04:32 AM
Reply:

Similar Artilces:

Using Using
I have just completed reading a chapter in my book on performance. The books says to speed up performance on your web site you should use the using statement when opening connections. My question is how do you catch errors if you are using this as apposed to a try catch block.thanksBryan  Why would you use it as an alternative to a try/catch statement. Couldn't you just do something like  public void UsingSomeMethod() { try { SomeMethod(); } catch(SomeException e) { /// do something useful }}public void SomeMethod() { using (Something) { ...

How to use the arguments to use() in the package being used
Howdy,=20 The subject says it all believe it or not :) What I'm trying to figure out is how to pass an argument=20 (pragma I believe is the proper term) to use() and do=20 sonethign in the package based on it. I've looked at CGI.pm source but can't seem to track it down.=20 (Similar idea as to CGIs -oldstyle_urls -newstyel_urls) http://search.cpan.org/~lds/CGI.pm-3.04/CGI.pm#PRAGMAS What I'd like to do is something like this: # for old time's sake we'll just use our favorite module use Foo::Monkey qw(:Foo :Bar -doamazingthings); #then in Foo::Monkey...

why to use 1)use CGI,2)use Strict ,3)use Carp in script
hi why we r using 1)use CGI, 2)use Strict, 3)use Carp in the begining of script sometimes. What is the use of it.Is the files CGI.pm,Strict.pm,Carp.pm default with PERL. Thnx __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com On Thu, 2004-11-04 at 09:31, supriya devburman wrote: > hi Hi > why we r using > 1)use CGI, We only use CGI when we want to use methods from that module (usually on web pages); see `perldoc CGI` for more information on what you...

CodeSmith
Of course it is a matter of preference, but personally I prefer to code our own template and dislike tools like this, like to do a quick poll here to know if many uses it, like to get your feedback on: (1) Do you use CodeSmith? (2) Why yes and why not? Thanks       No, prefer learning on my own.Rod H  >(1) Do you use CodeSmith?No >(2) Why yes and why not?Never had the opportunity!I incidentally use ReSharper from Jetbrains, that helps tremendously - it is like intellisence on steroids. Don't forget to click "...

DSRepair
Any good information on when to use Dsrepair which settings to use ? Is this something that should be run on a monthly /weekly basis and which of the million settings should be turned on:o) Use DSREPAIR to fix a broken database - that is what it is intended to be used for. It is not intended to be used as a "regular maintenance" tool. Using it in this way can in fact hide more serious issues by removing symptoms that indicate a more serious problem. Use it as a last resort for trying to identify problems with the database. Run health checks weekly or monthly (...

Why using use strict;
Hi all, I know why I should use "use strict;" but what happen if I use "use strict;" then if the code is OK, I delete this line? Shouldn't it work the same without this line if the code has no problems? Thanks. Teddy, orasnita@home.ro why would you want to do that Octavian? "use strict" is a sanity safety net. What your saying is like "I know why I should use safety belt whilst driving my car but what if I took it off?" - of course you can do it but beware of the consequences. joel -----Original Message----- From: ...

I used to use Firefox until...
Name: Dan Product: Firefox Summary: I used to use Firefox until... Comments: Firefox takes forever to load now, even the absolute newest version. It has become clunky and everyone I know has moved on to another browser. I prefer Chrome. I suggest adding some sort of configuration optimization tool as well as toolbar/add-on install/hijack prevention. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.53 Safari/525.19 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a re...

How to use net use?
Please can any one tell me how to use the dos command net use properly? I have read the help but can't seem to get it to work. Keep getting sytax error message. Thanks in advance. "Beowulf" <who-knows@no-one.com> wrote in message news:9krutk$puu$1@news.grc.com... > Please can any one tell me how to use the dos command net use properly? > > I have read the help but can't seem to get it to work. Keep getting sytax > error message. what are you trying to do? There are about 50 options to "net use" that do a ton of different thin...

FreeAndNil to use or not to use
After reading these debates about FreeAndNil I separated the people into two categories: The first one says: "You should have a perfect design which prohibits errors from happening. So, if you have a perfect design then FreeAndNil is not necessary so you should not use it. If we see FreeAndNil in your code then it means that your design is not perfect." The second one says: "Yes, we agree that we should have a perfect design which prohibits errors from happening and we do our best in order to create a perfect design. However our practice says that it is better ...

To use signatures or not to use?
--001a11c3871a8a8fe2051b7b8b18 Content-Type: text/plain; charset=UTF-8 Dear all, Perl now has subroutine signatures. However, they are marked as experimental feature. As I really like it, I'm always tempted to use it. On the other hand, I don't want to wast efforts to something I have to roll back. So, does anyone know the tendency if signatures are going to stay? I'm not looking for the standard "do if you want to do it because TIMTOWTDI" answer, it will not help me. I'm looking for rumors, or eventually an assessment from the people who did the fe...

To use DNN or not to use?
Hello,I am developing a community web based appication for non-profits and social service agencies in our county, that will be used to provide and track client services in a single datastore.Some built in features that dnn has is what I need, but I need custom tree navigation, list views, edit on the fly, several customized layers for data access, etc.I am familiar with asp.net, but not very familiar with dnn.  I installed  dnn on a friends website but never had time to configure and learn more about it.What are the general rules when deciding when to use dnn and when not...

this keyword- to use or not to use???
While reading some articles I came across this sample code which uses the "this" keyword. Is this best practice?         this.sqldsCustomerDetails.SelectParameters.Clear();        this.sqldsCustomerDetails.SelectParameters.Add("customerid", Convert.ToString(this.gvCustomers.DataKeys[row.RowIndex].Value));        this.dvCustomerDetail.DataSource = this.sqldsCustomerDetails;        this.dvCustomerDetail.DataBind(); In my code I usual...

When to use/not use ViewState
I'm creating a client app and I'm wondering is it neccessary to enable viewstate for "All" the fields. When should you use viewstate and when should you "NOT" use viewstate. Thanks.Daniel It depends on your requirements. if you dont need to preserve the contents of inputboxes past the initial post then dont turn on viewstate for them. you could take the approach of turning off viewstate for everything, and then turn it back on item by item as you find you need it. It shouldnt just be enabled for everything as it does make the page heavier - especially with ...

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there ...