App-Cheats

 view release on metacpan or  search on metacpan

cheats.txt  view on Meta::CPAN

perl -Mcharnames=:full -E 'my @qr = (qr/\s/, qr/\h/, qr/\v/, qr/[[:space:]]/, qr/\p{Space}/); my $fmt = "%#06x" . ("%2s" x @qr) . " %s\n"; printf "\nVersion: $^V\n$fmt\n", qw/- s h v p u Name/; for my $ord (0..0x10ffff){ my $chr = chr $ord; next unle...
#
# s - \s
# v - \v
# p - [[:space:]] (POSIX)
# u - \p{Space}
# Version: v5.32.1
# 000000 s h v p u Name
#
# 0x0009 x x   x x CHARACTER TABULATION
# 0x000a x   x x x LINE FEED
# 0x000b x   x x x LINE TABULATION
# 0x000c x   x x x FORM FEED
# 0x000d x   x x x CARRIAGE RETURN
# 0x0020 x x   x x SPACE
# 0x0085 x   x x x NEXT LINE
# 0x00a0 x x   x x NO-BREAK SPACE
# 0x1680 x x   x x OGHAM SPACE MARK
# 0x2000 x x   x x EN QUAD
# 0x2001 x x   x x EM QUAD
# 0x2002 x x   x x EN SPACE
# 0x2003 x x   x x EM SPACE
# 0x2004 x x   x x THREE-PER-EM SPACE
# 0x2005 x x   x x FOUR-PER-EM SPACE
# 0x2006 x x   x x SIX-PER-EM SPACE
# 0x2007 x x   x x FIGURE SPACE
# 0x2008 x x   x x PUNCTUATION SPACE
# 0x2009 x x   x x THIN SPACE
# 0x200a x x   x x HAIR SPACE
# 0x2028 x   x x x LINE SEPARATOR
# 0x2029 x   x x x PARAGRAPH SEPARATOR
# 0x202f x x   x x NARROW NO-BREAK SPACE
# 0x205f x x   x x MEDIUM MATHEMATICAL SPACE
# 0x3000 x x   x x IDEOGRAPHIC SPACE

# Last unicode character
0x10FFFF


#############################################################
## Perl Modules - constant
#############################################################

# Create a constant in perl.
perl -E 'use constant ABC => 123; say ABC'  123
perl -Mconstant=ABC,123 -E 'say ABC'        123
perl -E 'sub ABC(){ 123 } say ABC'          123
perl -E 'sub ABC{ 123 } say ABC'            123


#############################################################
## Perl Modules - cpanm
#############################################################

# Install cpanm
cpan App::cpanminus

# Install dependencies using cpanm
# Create file: cpanfile
requires 'Mojolicious';
recommends 'JSON::XS';
#
# Install perl dependencies from cpanfile:
cpanm --installdeps .

# Install a perl module as root
cpanm -S Selenium::Remote::Driver
cpanm --sudo Selenium::Remote::Driver


#############################################################
## Perl Modules - cpan-outdated
#############################################################

# Update outdated perl modules
cpanm App::cpanoutdated
cpan-outdated | cpanm


#############################################################
## Perl Modules - perltidy
#############################################################

# Clean up perl script
perltidy my_file

# Perltidy configuration file
vi .perltidyrc
-mbl=2 -pt=0 -b -bext='/' -blbs=1 -bom -bbb -nbl

# Tell perltidy to ignore a line
<STDIN>;    ## no critic

# html
sudo apt-get install tidy
sudo apt-get install libhtml-tidy-perl    # Perl library

# View current options when doing perltidy
perltidy my_file -dop    # --dump-options


#############################################################
## Perl Modules - re
#############################################################

# Debug a regular expression
perl -Mre=debug -le 'print "abc:def-hij"=~/\w+/'
perl -Mre=debug -e 'print if "aaa:bbb" =~ /\w+/'
perl -Mre=Debug,PARSE -e 'print if "aaa:bbb" =~ /\w+/'

# Debug a regular expression (with some color)
perl -Mre=debugcolor -le 'print "abc:def-hij"=~/\w+/'

# Check if certain words are in order in a file
echo "line1 line2" | perl -0777nlE 'INIT{-t and die; $a=join".*?",map{/\S+/g}<STDIN>; $r=qr/$a/s} say "$ARGV - " . (/$r/?"PASS":"FAIL") ' f1 f2
echo "line1 line4" | perl -Mre=eval -0777ne 'INIT{-t and die; $a=join "",map qq[ (?{print"\\nTrying $_ - "}) (.*?(??{"$_"}) (?{print"pass"})) ],map{/\S+/g}<STDIN>; $r=qr/^$a/sx; print "\n\$r=qr$r\n\n"} print "\n# $ARGV"; print "\n".(/$r/?"PASS":"FAIL...
echo "line1 line4" | perl -Mre=eval -0777ne 'INIT{-t and die; $a=join "",map qq[ (?{print"\\nTrying $_ - "}) (.*?(??{"$_"}) (?{print"pass"})) ],map{/\S+/g}<STDIN>; $r=qr/^$a/sx} print "\n# $ARGV"; print "\n".(/$r/?"PASS":"FAIL")."\n\n"' f1 f2

# View optimizations done on a pattern.
perl -Mre=optimization -Mojo -E 'say r optimization qr/^abc/'



( run in 2.795 seconds using v1.01-cache-2.11-cpan-5c0b1e786e0 )