in reply to Re: Loading a Hash directly from a Regex
in thread Loading a Hash directly from a Regex

$_=~ /^(\d+)\W\d+\W\d+\W(\d+)\W\w+/;
which is more readable
That's debateable. If someone puts =~ and $_, I am forced to wonder if something is going on that requires them to not merely accept the default. It's misleading. I don't see how that makes it "more readable".

Regex matches against $_ are the common form. =~ is an exception. To use an exeception to still perform the common operation is a bit like using the emergency handbrake at every stop light.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Re: Loading a Hash directly from a Regex
by hakkr (Chaplain) on Feb 14, 2002 at 17:18 UTC
    But the complete novice or maintainer may not know the footbrake exists.
    It's fair point around here but for novice or unperlish programmer using a = sign in the statement indicates there is an assignment going on. One of the problems/benefits of Perl is the number of unique programming concepts it has and defaults you need to learn. In my opinion Perl code is not of a high standard unless it's unreadable to a non Perl programmer. Anyway it's an old argument, I think even $_ is unreadable but I realise it has it's benefits. Especially for for the experts:)
      It's fair point around here but for novice or unperlish programmer using a = sign in the statement indicates there is an assignment going on.
      ... which is exactly why you shouldn't use it, because in =~, there is no assignment going on!

      -- Randal L. Schwartz, Perl hacker

        Shot foot there then, maybe I meant comparison instead of assignment. I suppose there is an assignment to the special vars. Maybe we need a ==~ operator or an eq~ or maybe my confusion has defeated me.