Pumpkin Perl logo
Tuesday, February 19, 2013 4:52:55 PM
<rant>
Tuesday, February 19, 2013 4:52:55 PM
Thursday, October 25, 2012 11:43:06 PM
# Example 1
sub get_first_person_name {
my ($self) = @_:
my $persons = $self->persons() || [];
if (scalar @{ $persons }) {
my $first_person = $persons->[0];
if (ref $first_person) {
return $first_person->{name};
}
}
return;
}
vs.
# Example 2
sub get_first_person_name {
my ($self) = @_;
my ($first_person_name) = map { ref $_ && $_->{name} } @{ $self->persons() || [] };
return $first_person_name;
}
# Example 1b
sub get_first_person_name {
my ($self) = @_:
my $persons = $self->persons() || [];
return unless (ref $persons && scalar @{ $persons } && ref $persons->[0]);
return $persons->[0]->{name};
}
Sunday, December 11, 2011 9:29:38 PM
#!/usr/bin/perl -wl
use strict;
use warnings;
use PadWalker qw/var_name/;
use Data::Dumper;
{
no strict 'refs';
*{'main:::'} = sub {
my $ret;
my @params;
foreach (@_) {
my $var_name = var_name(1,\$_);
do { $ret->{substr $var_name, 1} = $_; next } if $var_name;
push @params, $_;
}
return $ret, @params;
};
}
sub foo {
print Dumper(\@_);
}
my $a = 123;
my $b = 'abc';
my $c = { foo => 'bar' };
foo(&:($a, $b, $c, '456', '567'));
$ perl perl/autoparams.pl
$VAR1 = [
{
'c' => {
'foo' => 'bar'
},
'a' => 123,
'b' => 'abc'
},
'456',
'567'
];
Wednesday, April 6, 2011 10:35:02 AM
svnsync: REPORT of 'http://repo/svn%27: 200 OK (http://repo).
[global]
http-proxy-host=localhost
http-proxy-port=8080
#!/usr/bin/perl
use HTTP::Proxy;
use HTTP::Proxy::BodyFilter::simple;
use Data::Dumper;
use Encode;
my $proxy = HTTP::Proxy->new( port => 8080 );
$proxy->push_filter(
method => 'OPTIONS, PROPFIND, GET, REPORT, MKACTIVITY, PROPPATCH, PUT, CHECKOUT, MKCOL, MOVE, COPY, DELETE, LOCK, UNLOCK, MERGE',
mime => '*/*',
response => HTTP::Proxy::BodyFilter::simple->new(
sub { warn Dumper($_[1]); ${ $_[1] } = Encode::encode_utf8( ${ $_[1] } ); }
)
);
$proxy->start;
Tuesday, December 7, 2010 12:52:35 AM
nicolasm@akiko:~$ perl -wle 'my $a = { };'
Unrecognized character \xC2 in column 10 at -e line 1.
nicolasm@akiko:~$ echo "perl -wle 'my $a = { };'" | hd
00000000 70 65 72 6c 20 2d 77 6c 65 20 27 6d 79 20 20 3d |perl -wle 'my =|
00000010 20 7b c2 a0 7d 3b 27 0a | {..};'.|
00000018
setxkbmap -option "nbsp:none"in a shell
Saturday, May 15, 2010 2:42:32 PM
$server->command("whois $nick");
to:
$server->command(qq{whois "$nick"});
in the bitlbee_rename.pl script.
If anyone could notify the original author of the script, that would be awesome.Monday, February 1, 2010 9:50:54 AM
Encode, decode_utf8 for reading and encode_utf8 for outputting. But that's strictly for handling I/O.
utf8::_utf8_on) on your string, use utf8::upgrade or use utf8;.
perl -wle 'sub u { utf8::upgrade(shift); }; print encode_utf(u"æøå");'
What do you think? Wednesday, January 27, 2010 7:00:00 PM
dh-make-perl --install --cpan HTML::Tidy would normally have built and installed a Debian package in seconds.
t/perfect............dubious
Test returned status 0 (wstat 11, 0xb)
DIED. FAILED test 3
Failed 1/3 tests, 66.67% okay
t/pod-coverage.......ok
t/pod................ok
t/roundtrip..........ok
t/segfault-form......ok
t/simple.............ok 1/4Unknown error type: line 2 column 5 - Info: <body> previously mentioned at t/simple.t line 17
Unknown error type: line 2 column 5 - Info: <body> previously mentioned at t/simple.t line 17
Unknown error type: line 2 column 5 - Info: <body> previously mentioned at t/simple.t line 17
t/simple.............ok
t/too-many-titles....ok 1/3Unknown error type: line 4 column 9 - Info: <head> previously mentioned at t/too-many-titles.t line 22
t/too-many-titles....ok
t/unicode............dubious
Test returned status 0 (wstat 11, 0xb)
DIED. FAILED test 7
Failed 1/7 tests, 85.71% okay
t/venus..............ok 1/3Unknown error type: line 8 column 2 - Info: <h1> previously mentioned at t/venus.t line 21
Unknown error type: line 10 column 2 - Info: <h1> previously mentioned at t/venus.t line 21
Unknown error type: line 11 column 2 - Info: <h1> previously mentioned at t/venus.t line 21
Unknown error type: line 12 column 2 - Info: <h1> previously mentioned at t/venus.t line 21
Unknown error type: line 15 column 2 - Info: <h2> previously mentioned at t/venus.t line 21
Unknown error type: line 17 column 2 - Info: <h4> previously mentioned at t/venus.t line 21
Unknown error type: line 18 column 2 - Info: <h4> previously mentioned at t/venus.t line 21
Unknown error type: line 20 column 2 - Info: <h4> previously mentioned at t/venus.t line 21
Unknown error type: line 25 column 3 - Info: <h4> previously mentioned at t/venus.t line 21
dh-make-perl --cpan HTML::Tidy
cd HTML::Tidy # possibly having to tab your way to something like HTML::Tidy.37534
wget -O - http://rt.cpan.org/Ticket/Attachment/365180/165489/tidy.patch | patch -p0
cat | patch lib/HTML/Tidy.pm
267a268,271
> elsif ( $line =~ m/^line [\d]+ column [\d]+ - Info:/ ) {
> # Info line we don't want
>
> }
Ctrl+D
dh-make-perl --build
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
|
| ||||||
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
Nordic news about Amiga, Mac, Linux, Scene, Mobile, C64
Your guide to Amiga development
Amiga related news
Amiga software repository
Game development portal
Chat logs from the #webapps channel
A planet consisting of Opera employees and related people