Keep It Simple, Stupid | |
PerlMonks |
Re: What one-liners do people actually use?by strat (Canon) |
on Dec 09, 2005 at 08:37 UTC ( [id://515484]=note: print w/replies, xml ) | Need Help?? |
My most important one liner: if I set up some coffee and continue working, I often forget to fetch it, and it gets cold... so: perl -le 'sleep(300); print qq~\a~ x 10' reminds me that I must not forget to fetch the fresh coffee; this is the oneliner I use most oftenother cases, for filtering or replacing data in files, e.g. printing objects in LDIF files which have the auxiliary object class dxmADsUser: perl -e 'BEGIN { $/="\n\n" }' -ne 'print if /^objectClass: dxmADsUser/si' file1 > file2or replacing domain components on-the-fly: perl -i.bak -pe 's/dc=domain1,dc=tld$/dc=domain2,dc=tld/' fileor counting something, e.g. how often each attribute is existing in an ldif file: perl -MData::Dumper -ane '$count_of{$F[0]}++' -e 'END { print Dumper(\%count_of) }' file
Best regards,
In Section
Seekers of Perl Wisdom
|
|