Solved

Use of ==> to establish value in a scalar

Posted on 2007-12-01
3
185 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
3 Comments
 
LVL 7

Accepted Solution

by:
Wod earned 75 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 50 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

828 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