Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
to RG - Lisp lunacy and Perl psychosis
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="ccc31807, post: 4872019"] That code is hard read, but it's not obfuscated. The variable 'names' represent scalar values, in this case, an 'integer' used as a key. The convoluation comes from Perl's awkward syntax for multi-level data structures, in this particular case, a hash element that consists of an anonymous hash, thus $sec{$k}{'xlist'} in a foreach loop (which I omitted) like this foreach my $key (keys %sec) { ...$sec{$key}{'xlist'}... } and $fac{$sec{$key}{'id1'}}{'location'} simply references the $sec{$key}{'id1'} element in $fac{KEY}{'location'} This isn't harder than C pointers. And yes, I could have aliased the hash references to more readable variable names, but I wrote the code, I'm reading the code, and I'm maintaining the code ... why should I have to think of a redundant variable name when I have the hash assignments a few lines above this? my %fac; while (<SOME_DATA_SOURCE>) { chomp; my ($id, $site, $location, ... ) = split; $fac{$id} = { id => $id, site => $site, location => $location, ... }; } The script is a short one, about 40 lines of code excluding comments, use statements, etc., and wouldn't give a Perl programmer any problem. CC [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
to RG - Lisp lunacy and Perl psychosis
Top