Some tasks can be conveniently achieved with Perl one-liners. Perl is a scripting language originating in the environment of another operating system. Since many Windows computing environments have Perl installed, Perl one-liners are a natural and compact extension of Windows batch scripting.
Examples:
echo "abcbbc"| perl -pe "s/a.*?c/ac/"
echo a b| perl -lane "print $F[1]"
$F[2]
to display 3rd field; indexing starts at zero. Native solution: [FOR](<https://www.notion.so/kjkpublic/FOR-bad676c158e747ff96145309fead1b63>) /f
.perl -ne "print if /\\x22hello\\x22/" file.txt
perl -ne "$. <= 10 and print" MyFile.txt
perl -e "sleep 5"
for /f %i in ('perl -MPOSIX -le "print strftime '%Y-%m-%d', localtime"') do @set isodate=%i
isodate
variable.perl -MWin32::Clipboard -e "print Win32::Clipboard->Get()"
perl -MText::Diff -e "print diff 'File1.txt', 'File2.txt'"
On the web, Perl one-liners are often posted in the command-line conventions of another operating system, including the use of apostrophe ('
) to surround the arguments instead of Windows quotation marks. These need to be tweaked for Windows.
Links: