Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Burak (3156)

  (email not shown publicly)
+ -

  Journal: reftype() lazziness on 2009.09.09 22:24

Journal by Burak on 2009.09.09 22:24
User Journal

I was doing a lot of foo() if ref($thing) eq 'ARRAY' or foo() if ref($thing) eq 'HASH' (even something idiotic like foo() if ref($thing) && "$thing" =~ m{.+?=HASH(0x.+?)}) checks inside a pet project of mine. So thought about making it in an elegant way instead. I mean ref($thing)->array or even ref($thing)->is_array seemed much better as a syntactic sugar. However ref() is clearly not the way to go fo

Read More 1 comments
Comments: 1
+ -

  Comment: I have the answer (Score 1) on 2009.09.07 14:19

by Burak on 2009.09.07 14:19 (#70512)
Attached to: Improvement Needed - Perl needs better benchmarking


Read More 10 comments
Comments: 10
+ -

  Comment: You're absolutely right (Score 1) on 2009.09.04 0:11

by Burak on 2009.09.04 0:11 (#70487)
Attached to: The People

...but I never liked IRC for the record :p I want to go to a YAPC, most likely the ::EU one. Maybe next year :)

Read More 2 comments
Comments: 2
+ -

  Journal: Parse::HTTP::UserAgent: yet another user agent string parser on 2009.09.03 23:25

Journal by Burak on 2009.09.03 23:25
User Journal

I was using HTTP::BrowserDetect for a long time. Not because it's a pice of art or accurate, but because of laziness perhaps. When I had some free time, I thought about re-inventing the wheel, like I did several times before. The main reason for re-inventing is the source code and interface of the module (try to read it, you'l

Read More 0 comments

+ -

  Comment: S is for stupid (Score 1) on 2009.08.19 17:24

by Burak on 2009.08.19 17:24 (#70185)
Attached to: REST Versus Soap

Never understood SOAP fully and didn't spend too much time on it, but .NET services gave me lots of headaches when I tried to access them via SOAP::Lite

Read More 6 comments
Comments: 6
+ -

  Comment: Re:Wait... (Score 1) on 2009.02.25 5:29

by Burak on 2009.02.25 5:29 (#67615)
Attached to: Vim: Folding POD Out Of the Way

I also prefer the it at the end. I think inline Pod is annoying and it also creates an overhead in the parser. We had mixed Pod in my previous $job. Some were inline some were after the __END__ I wish adding them after __END__ was in the coding standards :) But, anyway there are far more annoying things in the actual code of other people other than Pod...

Read More 8 comments
Comments: 8
+ -

  Comment: Re:Perl is better? (Score 1) on 2009.02.20 20:07

by Burak on 2009.02.20 20:07 (#67519)
Attached to: Known Ruby Bug?

indeed you are:

C:\Users\burak>perl -MO=Deparse -le "print (-1) ** (1/2)"
BEGIN { $/ = "\n"; $\ = "\n"; }
print(-1) ** 0.5;
-e syntax OK

try this instead:

print( (-1) ** (1/2) )

Read More 6 comments
Comments: 6
+ -

  Comment: No good with MSVC2008 on Vista Home Premium SP1 TR (Score 1) on 2009.02.20 15:05

by Burak on 2009.02.20 15:05 (#67511)
Attached to: Perl 5.005_05 RC1
Comments: 6
+ -

  Journal: Having a single version number in all modules in a distro on 2008.10.16 14:45

Journal by Burak on 2008.10.16 14:45
User Journal
I was trying to figure out a mechanism to somehow format all modules in a distro (Text::Template::Simple) automatically to have a single version number instead of varying versions among files. I'm not so sure if this is the best way, but I chose to manually modify the files to update the versions in them. First, I had to subclass Module::Build to alter the `Build dist` action. However, M::B has an awkward interface for subclassing. One needs to pass the sublass code as a string into the subclass() method. Weirdo :p But since I didn't like this interface for subclassing and I wanted to use the syntax checking/coloring of my Komodo Edit, I've decided to load the content from an external file:

my $class = Module::Build->subclass(
                                class => 'MBSubclass',
                                code => raw_subclass(),

sub raw_subclass {
        my $file = File::Spec->catfile( 'tools', '' );
        my $FH = IO::File->new;
        $FH->open( $file, 'r' ) or die "Can not open($file): $!";
        my $rv = do { local $/; <$FH> };
        close $FH;
        return $rv;

And here is the subclass (note that there is no package declaration since M::B adds this part automatically afterwards):

use strict;
use vars qw( $VERSION );
use warnings;
use File::Find;
use constant RE_VERSION_LINE => qr{
      \A \$VERSION \s+ = \s+ ["'] (.+?) ['"] ; (.+?) \z
use constant VTEMP => q{$VERSION = '%s';};

$VERSION = '0.10';

sub ACTION_dist {
      my $self = shift;
      warn sprintf(
                        "RUNNING 'dist' Action from subclass %s v%s\n",
      my @modules;
      find {
            wanted => sub {
                  my $file = $_;
                  return if $file !~ m{ \. pm \z }xms;
                  push @modules, $file;
                  warn "FOUND Module: $file\n";
            no_chdir => 1,
      }, "lib";
      $self->_change_versions( \@modules );
      $self->SUPER::ACTION_dist( @_ );

sub _change_versions {
      my $self = shift;
      my $files = shift;
      my $dver = $self->dist_version;

      warn "DISTRO Version: $dver\n";

      foreach my $mod ( @{ $files } ) {
            warn "PROCESSING $mod\n";
            my $new = $mod . '.new';
            open my $RO_FH, '<:raw', $mod or die "Can not open file($mod): $!";
            open my $W_FH , '>:raw', $new or die "Can not open file($new): $!";
            my $changed;
            while ( my $line = readline $RO_FH ) {
                  if ( ! $changed && ( $line =~ RE_VERSION_LINE ) ) {
                          my $oldv = $1;
                          my $remainder = $2;
                          warn "CHANGED Version from $oldv to $dver\n";
                          printf $W_FH VTEMP . $remainder, $dver;
                  print $W_FH $line;

            close $RO_FH or die "Can not close file($mod): $!";
            close $W_FH or die "Can not close file($new): $!";

            unlink($mod) || die "Can not remove original module($mod): $!";
            rename( $new, $mod ) || die "Can not rename( $new, $mod ): $!";
            warn "RENAME Successful!\n";


It's really straightforward. Find the *.pm and them create a modified copy that has the distro's version and replace the original with the new one and resume `dist` process :)
Read More 2 comments
Comments: 2