 |
User since: |
Jun 18, 2018 at 02:17 UTC
(5 years ago) |
Last here: |
Jul 12, 2018 at 21:49 UTC
(5 years ago) |
Experience: |
208
|
Level: | Beadle (5) |
Writeups: |
53
|
Location: | #!/usr/bin/perl |
User's localtime: |
Sep 28, 2023 at 14:52 PDT
|
Scratchpad: |
View
|
For this user: | Search nodes |
|
Mostly just make sure you connect with some people.
We can have modules out there in the DarkPAN but we don't want to have, you know, dark perl programmers. In the sense, you know, of ones off in the closet, that don't interact with others. The real strength, are parts of our community that CAN welcome, and there are. For every place of darkness, that you want to point out, there are also places of brightness. There are people who are serving, who are just loving other people, and my advice is: FIND THOSE PEOPLE.
Stay away from the old curmudgeons who are, you know: GET OFF MY LAWN! and find the people who will encourage you and make you a better person.
—Larry Wall
perl -e'$_=`perl -v`;while(/\d\,(\s\x4c[^\n]+)/){print$1}'
perl -e'$_=`perl -v`;while(/\d\,(\s\x4c[^\n]+)/){print"\r".$1;print"\r
+"," "x10;print"\r".reverse$1}'
#!/usr/bin/perl -lw #!/Once/upon/a/time
$_=qq~http://wall.org/\~larry/natural.html~;
require(HTTP::Tiny);$_=HTTP::Tiny->new->get(
$_);$_=$_->{content};$a=0;for(/<H3/g){push@_
,++$a}use List::Util qw/shuffle/;@_=shuffle(
@_);$a=pop@_;@_=split/<H3>/;($_=$_[$a])=~s/<
[^>]+>//xgx;system('clear');$_=~s/^([^\n]+)/
\033\[1m$1\033\[0m/x;$a=$a**$a/$a**$a;print;
__END__
And they lived happily ever after.
perl -lw -Xe'{"#!/Once/upon/a/time"}
$L=qq~http://wall.org/\~larry/natural.html~;
require(HTTP::Tiny);$_=HTTP::Tiny->new->get(
$L);$_=$_->{content};$a=0;for(/<H3/g){push@_
,++$a} @_=sort{rand($a)<=>rand($b)}@_;$a=pop
@_;@_=split/<H3>/;($_=$_[$a])=~s/<[^>]+>//g;
system("clear");$_=~s/^([^\n]+)/\0\033\[1m$1
\033\[0m/x;print;;print$L;$A=$R**$R**$Y;WALL
#__END__ And they lived happily ever after.'
perl -v|perl -pe's\(?<=r)[l]\x\g;s\(?<=pe)r\\gi;s\p(e)\S$1\gi'
perl -MO=Deparse -e 'E S I X G S O O D'
Type perlpdf instead of perldoc!
This bash function uses pod2pdf to produce a very nice san-serif font PDF with title and footer and opens it with the "open" command (for OSX, adjust as needed). The tempfile is necessary for the PDF reader (Preview) to have a filename should one choose to save the file as, for example: "perldoc -q array.pdf". pod2pdf seems to call PDF::API2 about 10,000 times per page so it's slow on large documents:
function perlpdf() {
P=perldoc;
X="$P $@";
$P -uT "$@" |
pod2pdf --title="$X" --footer-text="$X" > "/tmp/$X.pdf";
open "/tmp/$X.pdf";
}
Type perlpdx instead of perlpdf!
This one uses ghostscript ps2pdf via man via pod2man to produce a plainer looking serif font PDF with a more generic title and footer (perl version/date/etc) and a filename. It seems more complicated but the process is extremely fast.
function perlpdx(){
P=perldoc;
$P -uT "$@" |
pod2man > "/tmp/$P $*.1";
man -t "/tmp/$P $*.1" |
ps2pdf - "/tmp/$P $*.pdf";
open "/tmp/$P $*.pdf";
}
perl -Mautodie -we 'die"not apple mac"unless${^O}eq"darwin";open$f,"|-
+","osacompile -o CPAN.app";print$f qq~set CPAN to text returned of (d
+isplay dialog "Search CPAN for" with title "Perl CPAN Search" default
+ answer "")\nif CPAN is equal to "" then return\ndo shell script("ope
+n \\"https://metacpan.org/search?q=" & CPAN & "\\"")~;close$f;system(
+"open CPAN.app")'
echo 'display alert (do shell script "perl -e \"print q/Just Another P
+erl Hacker/\"")' | osacompile -o japh.app; open japh.app
perl -Mautodie -we '$app="ApplePerlQuine\@perlmonks.org.app";die"not a
+pple mac"unless${^O}eq"darwin";open$f,"|-","osacompile -o $app";print
+$f qq~set myPATH to path to me as string\nset myPATH to myPATH & "Con
+tents:Resources:Scripts:main.scpt"\nset myPATH to do shell script"ech
+o " & myPATH & " | tr : / | sed -E \x27s/Macintosh HD//\x27"\ndisplay
+ dialog (do shell script ("osadecompile " & myPATH)) with title "$app
+" buttons {"Use Perl!"} default button 1\n~;close$f;system("open $app
+")'
#!/usr/bin/perl
use strict;
use warnings;
use autodie;
die "not apple mac" unless $^O eq "darwin";
my $app = "ApplePerlQuine\@perlmonks.org.app";
open my $f, "|-", "osacompile -o $app";
print $f qq~set myPATH to path to me as string
set myPATH to myPATH & "Contents:Resources:Scripts:main.scpt"
set myPATH to do shell script "echo " & myPATH & " | tr : / | sed -E \
+x27s/Macintosh HD//\x27"
display dialog (do shell script ("osadecompile " & myPATH)) with title
+ "$app" buttons {"Use Perl!"} default button 1\n~;
close $f;
system("open $app");
perl -Mautodie -we '$app=qq(ApplePerlQuine\@perlmonks.org.app);die"not
+ apple mac"unless${^O}eq"darwin";open$f,qq(|-),qq(osacompile -o $app)
+;print$f qq(set myPATH to path to me as string\nset myPATH to myPATH
+& "Contents:Resources:Scripts:main.scpt"\nset myPATH to do shell scri
+pt"echo " & myPATH & " | tr : / | sed -E \x27s/Macintosh HD//\x27"\nd
+isplay dialog (\"perl -Mautodie -we \x27\x24app=qq(ApplePerlQuine\134
+\134\100perlmonks.org.app);\nopen\x24f,qq(|-),qq(osacompile -o \x24ap
+p);\nprint\x24f qq\(\" & do shell script ("osadecompile " & myPATH))
+& "\);close\x24;system\(\x27\x27open \x24app\x27\x27\)" with title "$
+app" buttons {"Use Perl!"} default button 1\n\(* This is an ASCII rep
+resentation of the Perl source used to make this app. It will not cut
+ and paste because of hex and octal tricks. See perlmonks.org/?node=1
+216984 for details. *\));close$f;system("open $app")'
#!/usr/bin/perl -l
use strict;
use warnings;
# List EXE_FILES installed by CPAN
$_ = join '', `perldoc -uT perllocal`;
@_ = (/EXE_FILES:\s([^>]+)/sg);
my @z = ();
for (@_) {
my @x = split /\s+/;
s/^\S+\/// for @x;
push @z, @x;
}
%_ = map { $_ => 1 } @z;
print $_ for sort keys %_;
#print scalar keys %_;
#!/usr/bin/perl -l
use strict;
use warnings;
# List EXE_FILES installed by CPAN, by module
$_ = join '', `perldoc -uT perllocal`;
my @m = (/=head2.*?\|([^>]+)/g);
my @e = (/EXE_FILES:\s([^>]*)/sg);
for (my $c = 0; $c < scalar @m; $c++) {
$_{$m[$c]} = $e[$c]
}
my @z = ();
my $n = 0;
for (sort { lc($a) cmp lc($b) } keys %_) {
if (my @x = split /\s+/, $_{$_}) {
print;
$n += scalar @x;
s/^\S+\/// for @x;
print " $_" for @x;
print "";
}
}
#print $n;
#!/usr/bin/perl -l
# Use a CPAN module that is *not* installed! Is this a good idea?
# Posted to perlmonks.org by an Anonymous Monk on Sun Jun 17 2018
#
# In this example, if the Astro::MoonPhase module is not installed,
# the use_cpan sub will parse the error, download the module page
# from metacpan, parse that for the source code uri, download the
# raw module source, eval that string, and proceed normally as if
# the module was installed! It does not work with all modules and
# the concept is presented to the Monastery for contemplation.
#__QKB__
# Hacked by usemodperl: use Carp. Added module cache.
use strict;
use warnings;
use Carp 'croak';
eval { require Astro::MoonPhase };
use_CPAN($@) if $@;
my @phases = Astro::MoonPhase::phasehunt();
print q~LOCALTIME = ~, scalar localtime time;
print q~New Moon = ~, scalar localtime $phases[0];
print q~First quarter = ~, scalar localtime $phases[1];
print q~Full moon = ~, scalar localtime $phases[2];
print q~Last quarter = ~, scalar localtime $phases[3];
print q~New Moon = ~, scalar localtime $phases[4];
sub use_CPAN
{
local ($_) = @_;
if (/install the (\S+) module/) {
my $module = $1;
my $moddir = '.perlmod';
(my $modloc = $module) =~ s/::/__/g;
$modloc = "$moddir/$modloc";
if (-d $moddir and -e $modloc) {
open my $fh, '<', $modloc or croak "$!";
@_ = <$fh>; close $fh;
$_ = join "\n", @_;
eval $_ or croak;
}
else {
require HTTP::Tiny;
$_ = HTTP::Tiny->new->get("https://metacpan.org/pod/$modul
+e")->{content} || croak;
for (/Source<\/a>\s*\(<a href="([^"]+)">raw/) {
$_ = HTTP::Tiny->new->get($1)->{content} || croak;
eval $_ or croak;
eval mkdir $moddir; croak $@ if $@;
if (open my $fh, '>', $modloc or croak "$!") {
print $fh $_; close $fh;
}
last
}
}
}
}
perl -e'$_="Larry";while(++$_){print"\rPerl is $_";goto(MAGIC)if/Magic
+/}MAGIC:print"\n"';perl -v|perl -pe's\Perl\Magic\magic';perl -e'print
+"[Perl$^V] ";<STDIN>;exit';
perliaq - infrequently asked questions about Perl
The programmer is fighting against the two most destructive forces
in the universe: entropy and human stupidity.—Damian Conway
STOP REINVENTING WHEELS, START BUILDING SPACE ROCKETS!—CPAN 🐪
|