Skip to content

shakibamoshiri/illustrated_Perl_one-liners

Repository files navigation

This is my idea to put Perl one-liners in more attractive style. So that you can see the output of each one-liners and understand it convenience.
I am a new typist in C++ and Perl, may be you see some mistakes.
Also I am beginner in writing English and may be you will find
some mistakes here or on the pictures, so I apologize about that.

I hope this style of Perl one-liner would be fun and useful for you.

Screenshot:
illustrate Perl one-liners

Last shot:
illustrate Perl one-liners

License

I got allowed from Peteris Krumins who have written a book about Perl one-liners and I have read that book and 99% of the one-liners come from this book. But a few of them not in the book, like: generate full password
or ...

How to use:

First
- git clone https://github.com/k-five/illustrated_Perl_one-liners
- cd illustrated_Perl_one-liners

Then:

  1. using animate

    • animate *.png it will show you all png in animation style
    • animate -delay 100 *.png it will show you with delay of 1 second
  2. using gnome-open

    • gnome-open file.gif or gnome-open file.png
  3. using mpv

    • mpv file.mp4
    • may be you do like download the file and only want to watch in so:
      • mpv https://github.com/k-five/illustrated_Perl_one-liners/1_numbering/mp4/numbering_slideshow.mp4 it is played for you

#WARNING ⚠️ The two below handy-code are JUST for fun and show how to use one-liners in use. Of course everything that you dump, STILL, belongs to the two dictionaries.

handy-quick-dump with one-liners

dumps definitions, examples, and sounds file , from Oxford Dictionary Online

Unfortunately I could not set device in Ubuntu to record a video along audio file, so I had to use picture again :). We do it in three item:

item one:

The address of the site : http://www.oxfordlearnersdictionaries.com/

If you search for a word like see, you will see this: (in address bar)
http://www.oxfordlearnersdictionaries.com/definition/english/see_1?q=see

Put that in a bash file like this:

#!/bin/bash
lynx -dump -source http://www.oxfordlearnersdictionaries.com/definition/english/$1\_1?q=$1

Then do this:
chmod u+x dump_page.sh

Just we need to get a word form user and pass it to the . dump_page.sh like this:

clear; read -p "Enter a word:" word && . dump_page.sh $word

which it will dump the source page of each word that you want. If you enter a word such as gloomy it will dump source for the gloomy word.

Lastly we need Perl one-liners, which it will be:

item two:

dumping examples:

perl -lne 'push @M,"$1" while /class="x".+?"> ?([A-Z].+?)<(?!class)/g; END{ foreach $file (@M) { print ++$n," : ",$file =~ /.+[.!?]$/g ? "\e[0;32m$file\e[m" : "\e[1;31mmissed example\e[m" } }'

dumping definition:

perl -lne 'push @M,"$1" while /class="def".+?"> ?([a-z].+?)<(?!class)/g; END{ foreach $file (@M) { print ++$n," : ",$file =~ / +/g ? "\e[0;32m$file\e[m" : "\e[1;31mmissed example\e[m" } }'

hears pronunciation: (us/uk need to use mpv)

perl -lne 'push @M,"$1" while /data-src-mp3="(.+?\.mp3)/g; END{ print "\e[0;32mUS pronunciation:\e[m"; foreach $file (@M) { $file =~ /us/i && `mpv $file` } }'

downloads pronunciation:(us/uk need to use wget)

perl -lne 'push @M,"$1" while /data-src-mp3="(.+?\.mp3)/g; END{ print "\e[0;32mUS pronunciation:\e[m"; foreach $file (@M) { $file =~ /us/i && `wget -c -q --show-progress $file` } }'

Summary you will have something like this: (finding examples)

read -p "Enter a word: " word && . dump_page.sh $word | perl -lne 'push @M,"$1" while /class="x".+?"> ?([A-Z].+?)<(?!class)/g; END{ foreach $file (@M) { print ++$n," : ",$file =~ /.+[.!?]$/g ? "\e[0;32m$file\e[m" : "\e[1;31mmissed example\e[m" } }'

Animation of how them work:

dumps from oxford dictionary online

item three

Just enjoy :) -- that's it.


slideshow in youtube:


handy-quick-dump with one-liners

dumps definitions, examples, and sounds file, from longman Dictionary Online

You can do it by yourself.

About

some Perl one-liners which have been illustrated :)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages