Meta Reports First Quarter 2024 Results
investor.fb.com129 pointsby jsrn162 comments
$ perldoc perlrun
(or http://perldoc.perl.org/perlrun.html) $ curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' | jq . | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'
(see my other comment about gsed vs sed) $ brew install gnu-sed
And it is then called with 'gsed' instead of 'sed'. $ cpanm JSON::PP
If you don't have cpanm, you can install it with $ curl -L https://cpanmin.us | perl - App::cpanminus
The modified command line from above then becomes: $ curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' \
| json_pp | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'
Here is a little Bash function to encapsulate this: $ function c() { curl -sS "https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=$1" | json_pp | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'; }
Which then allows you to use it like this: $ c hacker
hacker news
hacker typer
hackerrank
hackerman
hackers movie
hacker fare
hackerone
hackers cast
hacker pschorr
For spaces in your query, use a '+': $ c New+York
new york times
new york and company
new york giants
new york post
new york daily news
new york weather use Email::Valid;
print (Email::Valid->address('[email protected]') ? 'valid' : 'invalid');
as a oneliner: perl -MEmail::Valid -E"say (Email::Valid->address('[email protected]') ? 'valid' : 'invalid');"
Other than installing the Email::Valid module with a cpanm Email::Valid
it is not much longer than the example in the article. $ perl -anE 'say $F[0]'
Of course, the AWK command line is still shorter - and that's expected, because AWK is more specialized than Perl. http://perldoc.perl.org/perlrun.html
or just: $ man perlrun pi:~$ echo 'foo bar' | tr -s ' ' | cut -d ' ' -f 2
it also outputs 'bar'. The -s (for "squeeze") option of tr turns every sequence of the specified character (space in this case) into one instance of this character. $ pdfinfo FILE.pdf | grep '^Pages' | tr -s ' ' | cut -d ' ' -f 2 > And here's some constructive criticism for the aspiring Perl advocate
point taken, thanks.