This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use JSON; | |
use MIME::Base64; | |
use REST::Client; | |
use constant API_KEY => "KEY TEXT"; | |
use constant URL => "https://vision.googleapis.com/v1/images:annotate?key="; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Challenge #1 | |
# Write a script to replace the character 'e' with 'E' in the string 'Perl Weekly Challenge'. | |
# Also print the number of times the character 'e' is found in the string. | |
## | |
my $challenge_string="Perl Weekly Challenge"; | |
my $number=do{ | |
$challenge_string=~tr/e/E/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script or one-liner to remove leading zeros from positive numbers. | |
## | |
use constant EXAMPLE => "000123"; | |
print sprintf("%d", EXAMPLE)."\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Create a script to generate 5-smooth numbers, whose prime divisors are less or equal to 5. | |
# They are also called Hamming/Regular/Ugly numbers. | |
## | |
use boolean; | |
sub is_divisible{ | |
my($divisor) = @_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script to output the same number of PI digits as the size of your script. | |
# Say, if your script size is 10, it should print 3.141592653. | |
## | |
use bignum; | |
sub pi{ | |
my($max) = @_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a program which prints out all anagrams for a given word. | |
## | |
use constant DICTIONARY => "/usr/share/dict/words"; | |
my %word_product; | |
my %letter_factor = ( | |
e => 2, | |
t => 3, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the initial clone of the repo we want to "fork" | |
git clone https://github.com/original | |
# clone from folder we just got from github to a new location (which will be | |
# created by this command) | |
git clone original my-fork | |
## | |
# [create new repo for my-fork on githubcom] | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Create a script which takes a list of numbers from command line and print | |
# the same in the compact form. For example, if you pass "1,2,3,4,9,10,14,15,16" then | |
# it should print the compact form like “1-4,9,10,14-16”. | |
## | |
use Data::Dump q/pp/; | |
my @a = split(/\,/, $ARGV[0]); | |
my $a = pp @a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Print all the niven numbers from 0 to 50 inclusive, each on their own line. | |
# A niven number is a non-negative number that is divisible by the sum of its digits. | |
## | |
use constant NIVEN_COUNT => 50; | |
my $i = 1; | |
my $count = 0; | |
do{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script that computes the first five perfect numbers. | |
# A perfect number is an integer that is the sum of its positive | |
# proper divisors (all divisors except itself). | |
## | |
use constant PERFECT_COUNT => 5; | |
sub factor{ |
OlderNewer