Skip to content

Instantly share code, notes, and snippets.

@dbb
Created June 30, 2011 00:11
Show Gist options
  • Save dbb/1055330 to your computer and use it in GitHub Desktop.
Save dbb/1055330 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
open (my $in, '<', '/etc/passwd');
my %passwd;
while (<$in>) {
if ( /^(\w+):([\w:\/]+)$/ ) {
my $key = $1;
my $val = $2;
$val =~ s/:+/\ /g;
$passwd{ $key } = $val;
}
}
while ( my ($key, $val) = each(%passwd)){
say "'$key' => '$val'";
}
@dbb
Copy link
Author

dbb commented Jun 30, 2011

while (<$in>) {
s/[\w/:]//g;
say unless /^\s+$/;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment