Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: difference between ($scalar) and $scalar

by DrZaius (Monk)
on Jul 21, 2001 at 20:23 UTC ( #98670=note: print w/replies, xml ) Need Help??


in reply to difference between ($scalar) and $scalar

This isn't really regarding the question, but have you considered doing this to get your version:
my $rcs = (qw$Revision: 1.41$)[-1];
Just a thought :)

Replies are listed 'Best First'.
Re: Re: difference between ($scalar) and $scalar
by c (Hermit) on Jul 21, 2001 at 21:40 UTC
    All of these responses have been incredible and an excellent education in perl. My final question before I say that I have sucked all I can learn from this thread...

    I toyed around with your coded to fully understand what was happening. I see that you're pulling the first element from the right using -1. However I see that it changes when I write it as:

    my $rcs = (qw($Revision: 1.46 $))[-2]

    Since I set the [ ] value to -2, I still get the correct value that I am looking for, however with my syntax and using -1 I retrieve just the $. Why is that? Since I am used to creating my arrays in the format qw(a b c); I would have thought these additional parens would not have changed the result. But they do.

    humbly -c

      Look at your spacing and what you are using for the qw delimiters.

      My code uses qw$$ while yours uses qw().

      Try these:

      perl -e 'my $rev = (qw$Revision: 1.41 $)[-1]; print $rev, "\n"' perl -e 'my $rev = (qw($Revision: 1.41 $))[-1]; print $rev, "\n"'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://98670]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2021-10-23 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?