#! /usr/local/bin/perl # use DBI; use DBD::CSV; my($dh, $sh); my($row); $dh = DBI->connect("DBI:CSV:") || die "Cannot connect: ". $DBI::errstr; $dh->{'csv_tables'}->{'passwd'} = { 'eol' => '\n', 'sep_char' => ':', 'quote_char' => undef, 'escape_char' => undef, 'file' => '/etc/passwd', 'col_names' => ["login", "password", "uid", "gid", "gecos", "dir", "shell"] }; $sh = $dh->prepare("SELECT * FROM passwd") || die "Cannot prepare: ". $dh->errstr(); $sh->execute() || die "Cannot execute: ". $sh->errstr(); while ($row = $sh->fetch) { printf "%s\n", $row; } #### user:*:[0-9]+:[0-9]+:Real Name:/dir:/path/to/shell