This file contains hidden or 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
| #!/usr/bin/env perl | |
| use Mojolicious::Lite; | |
| use utf8; | |
| use Encode qw/encode_utf8 decode_utf8/; | |
| post '/' => sub { | |
| my $self = shift; | |
| my $param = $self->req->body; |
This file contains hidden or 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
| perl -E 'open my $x, "<", "test.tmp" or die; seek $x, 10, 0; if (my $child = fork) { waitpid $child, 0; say "Parent: child exited, pos: " . tell($x) } else { ; say "Child: after read from file, pos: " . tell($x) }' |
This file contains hidden or 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
| #!/usr/bin/env perl | |
| use common::sense; | |
| use AnyEvent; | |
| use AnyEvent::Util qw/fork_call/; | |
| my $cond = AnyEvent->condvar; | |
| my $timer = AnyEvent->timer( | |
| interval => 3, |
This file contains hidden or 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
| svn co http://svn.perlide.org/padre/trunk/ padre_trunk | |
| svn co http://svn.perlide.org/padre/trunk/Padre padre_trunk |
This file contains hidden or 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
| #Newbie programmer | |
| def factorial(x): | |
| if x == 0: | |
| return 1 | |
| else: | |
| return x * factorial(x - 1) | |
| print factorial(6) | |
| #First year programmer, studied Pascal |
This file contains hidden or 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
| #!/usr/bin/env perl | |
| use Mojolicious::Lite; | |
| # create file for testing | |
| my $file = "yet_another_file"; | |
| qx(touch $file; echo "hello" > $file); | |
| any '/' => sub { | |
| my $self = shift; |
This file contains hidden or 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
| [sugar@comp mojoxrun]$ PERL5LIB="lib" prove | |
| t/00-load.t ................. 1/1 # Testing MojoX::Run 0.15, Perl 5.012004, /usr/bin/perl5.12.4 | |
| t/00-load.t ................. ok | |
| t/boilerplate.t ............. ok | |
| t/manifest.t ................ skipped: Author tests not required for installation | |
| t/mojox-run-complexsub.t .... [Wed Oct 5 00:17:45 2011] [debug] Not installig any signal handler, because IOWatcher implementation Mojo::IOWatcher::EV implements better CHLD signal handling. | |
| t/mojox-run-complexsub.t .... 1/5 Write failed: Can't call method "_connecting" on an undefined value at /usr/local/share/perl/5.12/Mojo/IOLoop/Client.pm line 129. | |
| t/mojox-run-complexsub.t .... 2/5 Write failed: Can't call method "_connecting" on an undefined value at /usr/local/share/perl/5.12/Mojo/IOLoop/Client.pm line 129. | |
| t/mojox-run-complexsub.t .... ok | |
| t/mojox-run-long-running.t .. [Wed Oct 5 00:17:46 2011] [debug] Not installig any signal handler, because IOWatcher implementation Mojo::IOWatcher::EV implements better CHLD |
This file contains hidden or 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
| #!/usr/bin/env perl | |
| use common::sense; | |
| use lib qw(./lib); | |
| use MojoX::Run; | |
| use Data::Dumper; | |
| my $run = MojoX::Run->new; | |
| my $all = { sda => 11, sdb => 22, sdc => 11, sdd => 22, sde => 11, sdf => 22, sdg => 33 }; |
This file contains hidden or 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
| my $count = scalar keys %$all; | |
| my (@shas, $i); | |
| for my $disk (keys %$all) { | |
| my $part = $all->{$disk}->{partition}; | |
| my $pid = $run->spawn( | |
| cmd => sub { | |
| # my @shas = | |
| # map {/^([0-9a-f]+)/} | |
| # qx(find $dest/$part -type f | grep -Fv "lost+found" | sort | xargs shasum) | |
| # ; |
This file contains hidden or 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
| #!/usr/bin/env perl | |
| use common::sense; | |
| use Data::Dumper; | |
| use MojoX::Run; | |
| use Mojolicious; | |
| say $Mojolicious::VERSION; | |
| my $sub = sub { | |
| return "hello", "world"; |