#!/usr/bin/perl use strict; use Data::Dumper; use Text::CSV; my $csv = Text::CSV->new(); my %hash_temp; while (my $line = ) { next if ( $line =~ /^\"create_stamp\"/ ); $csv->parse( $line ); my @cols = $csv->fields(); $hash_temp{"dn: uid="} = lc( $cols[1] ); $hash_temp{"givenName: "} = $cols[2]; $hash_temp{"sn: "} = $cols[3]; $hash_temp{"telephoneNumber: "} = $cols[8] . "-" . $cols[6] if ( $cols[7] == 0 ); $hash_temp{"faxNumber: "} = $cols[8] . "-" . $cols[6] if ( $cols[7] == 1 ); } print Dumper( \%hash_temp ); __DATA__ "create_stamp","username","first_name","last_name","name","name","extension","fax_flag","exchange","position","username" "2009-03-02 15:31:52","SimpsonH","Homer","Simpson","Nuclear Control Center","Radioctive Hall","6798","1","218 555","Nuclear Control Operator","BurnsM" "2009-03-02 15:31:52","SimpsonH","Homer","Simpson","Nuclear Control Center","Radioctive Hall","6793","0","218 555","Nuclear Control Operator","BurnsM"