The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
! operator in variable mmunir Shell Programming and Scripting 1 05-30-2008 04:29 AM
perl scalar variable in backquoted string mehdi9 Shell Programming and Scripting 6 10-09-2007 03:33 PM
what is diff b/w copy constructor and overloaded assignment operator amitpansuria High Level Programming 3 08-06-2007 04:45 PM
Can't modify not in scalar assignment compilation error new2ss Shell Programming and Scripting 2 05-18-2006 06:03 AM
@ in a variable assignment rkap UNIX for Dummies Questions & Answers 1 05-23-2005 11:53 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-17-2008
JamesGoh JamesGoh is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 89
scalar variable assignment in perl + { operator

When reading over some perl code in a software document, I came across an assignment statement like this

$PATH = ${PROJECT}/......./....

In this particular form of scalar variable assignment, what does the curly braces operators do ? Also, what is the benefit in doing scalar assignment this way ?

many thanks
  #2 (permalink)  
Old 01-17-2008
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
Surrounding the identifier with curly braces is more frequently seen in double-quoted strings to separate it from neighbouring text. For example,

"The time now is ${time}A.M."

This syntax also works outside strings, as you cited, but that is rarely needed and being most of the time redundant. It is there to support identifiers that start with a ^ sign, which is normally not allowed. However, I cannot think of any case that really needs to refer this kind of variables.

For more information, refer to

perlvar - perldoc.perl.org
  #3 (permalink)  
Old 01-18-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086

Code:
#!/usr/bin/perl
my $cap = 53;
print "${cap}rd cap! \n";

output:
Code:
53rd cap!

  #4 (permalink)  
Old 01-20-2008
JamesGoh JamesGoh is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 89
thanks guys.
Closed Thread

Bookmarks

Tags
perlvar

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0