Interesting, I was also thinking of yesterday's "splice/mesh" discussion. (I wouldn't really do it this way.)
But do notice in your RE, I changed delimiter and did not escape forward slashes, commas or hyphens.
use strict; use warnings; use List::MoreUtils qw(mesh); use Data::Dumper; my @users; my @fields = qw(login uid gid name home shell); while (<DATA>) { m#^\s*([\w-]+):x:(\d+):(\d+):([\w\s\(\),-]*):([\w/]+):([\w/]*)$# or die "Malformed input [$_]"; push @users, { mesh @fields, @{[//]} }; } print Dumper \@users; __DATA__ root:x:0:0::/:/usr/bin/ksh paul:x:201:1::/home/paul:/usr/bin/ksh jdoe:x:202:1:John Doe:/home/jdoe:/usr/bin/ksh
Update: The parens don't need to be escaped either:
m#^\s*([\w-]+):x:(\d+):(\d+):([\w\s(),-]*):([\w/]+):([\w/]*)$#
In reply to Re: Getting rid of a temporary variable in AoH
by hbm
in thread Getting rid of a temporary variable in AoH
by reisinge
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |