Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Palindrome array

by LanX (Chancellor)
on Dec 29, 2012 at 17:47 UTC ( #1010832=note: print w/replies, xml ) Need Help??


in reply to Re: Palindrome array
in thread Palindrome array

> if (@array eq (reverse scalar @array)){..

Sorry I can't let this stand uncorrected!

DB<108> @array=1..9 => (1, 2, 3, 4, 5, 6, 7, 8, 9) DB<109> @array eq (reverse scalar @array) => 1 DB<110> @array=0..9 => (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) DB<111> @array eq (reverse scalar @array) => "" DB<112> scalar (reverse scalar @array) => "01" DB<113> scalar @array => 10

Cheers Rolf

Replies are listed 'Best First'.
Re^3: Palindrome array
by 2teez (Priest) on Dec 29, 2012 at 18:33 UTC

    Hi LanX,

    > if (@array eq (reverse scalar @array)){..
    "..Sorry I can't let this stand uncorrected!.."
    There is really no need to be sorry, because your assertions and "tests" are so correct and right I.

    However, I believe Athanasius first caught the message I was trying to pass to the OP, in this line
    ..The string comparison operator eq puts its operands into scalar context..

    ++ LanX

    I -> Updated.

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me

      I must say I agree with the sentiment expressed by LanX: tossing a beginner a lit firecracker and saying "Does this help?" doesn't really help. I sympathize with your desire to show a pathway to an answer rather than just saying the answer, but that one was just a bit too obscure!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010832]
help
Chatterbox?
[TCLion]: Good Morning Monks, I am parsing logs and some date time formats are inconsistent. I am trying to make output all same format. What is the best way to convert a month(word) to month(number)?
[Corion]: TCLion: I'm not aware of a better way than manually building the hash, as all strptime incarnations I know have nasty edge cases

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (15)
As of 2017-03-23 14:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (287 votes). Check out past polls.