Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Use of ==> to establish value in a scalar

Posted on 2007-12-01
3
Medium Priority
?
204 Views
Last Modified: 2010-04-21
A book example has the line:

Readonly my $ACTIVE_LOG => '>temp.log<';

I thought => was used for hash list? Why was the => used instead of =  ?
0
Comment
Question by:lqwest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Accepted Solution

by:
Wod earned 300 total points
ID: 20389518
The => digraph is mostly just a synonym for the comma operator:

Comma Operator

Binary ``,'' is the comma operator. In scalar context it evaluates its left argument, throws that value away, then evaluates its right argument and returns that value. This is just like C's comma operator.

In list context, it's just the list argument separator, and inserts both its arguments into the list.

The => digraph is mostly just a synonym for the comma operator. It's useful for documenting arguments that come in pairs. As of release 5.001, it also forces any word to the left of it to be interpreted as a string.
0
 
LVL 17

Assisted Solution

by:mjcoyne
mjcoyne earned 200 total points
ID: 20389573
Likewise, a hash can be contructed from a comma-separated list:

#!/usr/bin/perl -w
use strict;

my %hash = ('apples', 'red', 'bananna', 'yellow');

foreach my $fruits (sort keys %hash) {
    print "$fruits are $hash{$fruits}\n"
}

0
 

Author Closing Comment

by:lqwest
ID: 31412145
I found some help also in the Perl's Best Practices book - basically has guideline that can be used when trying to decide if a => (aka fat comma) should be use: use it when you can say the symbol becomes blah-blah. Or as in my example ACTIVE_LOG becomes temp.log.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question