Pull specific information from a long list with Perl
- by melignus
The file that I've got to work with here is the result of an LDAP extraction but I need to ultimately get the information formatted over to something that a spreadsheet can use.
So, the data is as follows:
DataDataDataDataDataDataDataDataDataDataDataDataDataDataDataData
DataDataDataDataDataDataDataDataDataDataDataDataDataDataDataData
displayName: John Doe
name: ##userName
DataDataDataDataDataDataDataDataDataDataDataDataDataDataDataData
DataDataDataDataDataDataDataDataDataDataDataDataDataDataDataData
displayName: Jane Doe
name: ##userName
DataDataDataDataDataDataDataDataDataDataDataDataDataDataDataData
DataDataDataDataDataDataDataDataDataDataDataDataDataDataDataData
displayName: Ted Doe
name: ##userName
The format that I need to export to is:
firstName lastName userName
firstName lastName userName
firstName lastName userName
Where the spaces are tabs so I can then impor that file into a database. I have experience doing this in VBScript but I'm trying to switch over to using Perl for as much server administration as possible.
I'm not sure on the syntax for what I want which is basically
while not endoffile{
detect "displayName: " & $firstName & " " & $lastName
detect "name: ##" & $userName
write $firstName tab $lastName tab $userName to file
}
Also if someone could point me to a resource specifically on the text parsing syntax that Perl uses, I'd be very grateful. Most of the resources that I've come across haven't been very helpful.