Skip to content

Instantly share code, notes, and snippets.

View chankeypathak's full-sized avatar
Commit all day, everyday!

Chankey Pathak chankeypathak

Commit all day, everyday!
View GitHub Profile
@chankeypathak
chankeypathak / chat_client.pl
Last active August 24, 2018 14:36
Simple chat client in Perl
#!/usr/bin/perl -w
# chat_client.pl
use strict;
use IO::Socket::INET;
my $port = shift or die "No port\n";
my $server = shift or die "No server\n";
my $client_socket = IO::Socket::INET->new(
PeerPort => $port,
PeerAddr => $server,
@chankeypathak
chankeypathak / chat_server.pl
Created September 23, 2015 05:03
Simple chat server in perl
#!/usr/bin/perl -w
# chat_server.pl
use strict;
use IO::Socket::INET;
my $port = shift or die "Port required!\n";
my $socket = IO::Socket::INET->new(
LocalPort => $port,
Proto => 'tcp',
Listen => SOMAXCONN
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Time::Piece;
my $in_format = '%Y-%m-%d %H:%M:%S';
my $out_format = '%Y-%m-%dT%H:%M:%SZ';
@chankeypathak
chankeypathak / scrapyoutube.pl
Created February 23, 2015 05:45
Scrap top 10 results YouTube
#!/usr/bin/perl
#Author: Chandra Prakash Pathak
#Date: 23/02/2015 10:15 AM
#Always use strict and warnings in each Perl program
use strict;
use warnings;
use Selenium::Remote::Driver;
use Selenium::Remote::WDKeys qw(KEYS);
use Config::Simple;
use POSIX qw/strftime/;
@chankeypathak
chankeypathak / number_to_alphabet.pl
Created January 8, 2015 19:10
3=C, 5 = E. If > 26 then 27=AA, 28=AB, 29=AC
#!/usr/bin/env perl
use v5.12;
use strict;
use warnings;
use Test::More;
my %tests = (
1 => "A",
@chankeypathak
chankeypathak / image_viewer.pl
Created January 6, 2015 05:13
Image viewer in Perl GTK2
#!/usr/bin/perl
use strict;
use warnings;
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';
my $window=Gtk2::Window->new();
$window->set_title("Image Resizer");
$window->signal_connect('delete_event',sub{Gtk2::main_quit;});
@chankeypathak
chankeypathak / msort.pl
Created January 5, 2015 08:34
Merge Sort in Perl
#!/usr/bin/perl
use strict;
use warnings;
sub merge {
my($s, @b) = @_;
my(@a) = splice(@b, $s);
if (@a * @b == 0) { return @a, @b; }
my($head) = $a[0] < $b[0] ? shift(@a) : shift(@b);
@chankeypathak
chankeypathak / search_string_xpath.pl
Created January 5, 2015 07:40
HTML::TreeBuilder::XPath - Searching a string on a URL
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use HTML::TreeBuilder::XPath;
my $stringsearch = "solutions";
my $url = "http://www.matrixx.com/";
my $ua = LWP::UserAgent->new;
my $response = $ua->get($url);
@chankeypathak
chankeypathak / scrap_yt.pl
Last active August 29, 2015 14:11
Scrap YouTube's first page results
#!/usr/bin/env perl
use strict;
use warnings;
use LWP::UserAgent;
use Mojo::DOM;
my $date = localtime;
print "First page results for Google query on YouTube\nAuthor: Chankey Pathak (chankey\@cpan.org)\tDate: $date\n\n\n";
my $url = q{http://www.youtube.com/results?search_query=google};
my $ua = LWP::UserAgent->new( agent => 'Mozilla/5.0 (Windows NT 5.1; rv:10.0.1) Gecko/20100101 Firefox/10.0.1');
my $get = $ua->get($url)->content;
@chankeypathak
chankeypathak / scrap_cromaretail.pl
Last active August 29, 2015 14:07
scrapping cromaretail
#!/usr/bin/env perl
use 5.010;
use open qw(:locale);
use strict;
use utf8;
use warnings qw(all);
use Mojo::UserAgent;
my @urls = map { Mojo::URL->new($_) } qw(