in reply to What is Perl way to simultaneously assign to three separate arrays?
None, any golfing here would be awkward for just 3 arrays and too hard to maintain.
Truth is - like you already realized - that it doesn't make sense to have three different arrays.
This
my ($url, $id, $title) = ($_ =~ m|<h6 class="project-title"><a hre +f="(/proje +cts/(\d+)/.+?\?ref=discovery)" target="">(.+?)</a></h6>|o ); push @project, [$url, $id, $title];
already does the trick.
( IMHO even better $project{$id} = [$url,$title] )
Please note that I didn't try to replace ($url, $id, $title) with @matches cause you'd loose self-documenting names.
But if you really want to condense it further try
push @project, [ m|<h6 class="project-title"> ... yadda ... </h6>| +o ];
HTH!
PS: As a side note, better dump references
dump \@urls, \@ids, \@titles;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What is Perl way to simultaneously assign to three separate arrays?
by CoVAX (Beadle) on Feb 15, 2015 at 04:41 UTC | |
by LanX (Saint) on Feb 15, 2015 at 10:42 UTC | |
by CoVAX (Beadle) on Feb 15, 2015 at 20:40 UTC | |
by CoVAX (Beadle) on Feb 15, 2015 at 08:42 UTC |