python equivalent to perl’s qw()

Well, there’s definitely no way to do exactly what you can do in Perl, because Python will complain about undefined variable names and a syntax error (missing comma, perhaps). But I would write it like this (in Python 2.X): print ‘%8s %8s %8s’ % (‘date’, ‘price’, ‘ret’) If you’re really attached to Perl’s syntax, I … Read more

ListUtil.c: loadable library and perl binaries are mismatched (got handshake key 0xdb00080, needed 0xdb80080)

This may happen when perl or perl modules are installed separately along side the official packages. Environment variable can be used to switch to a different perl installation. To find out if that is the case run: env | grep PERL Having PERL5LIB or PERL_LOCAL_LIB_ROOT in the output might cause the issue. Try unsetting the … Read more

How can I use __DATA__ twice?

To use the DATA filehandle twice you need to rewind it. The tricky bit is that if you do seek(DATA, 0, 0), it’ll be positioned to the first source line, not the line after __DATA__. Therefore you need to save the position first: my $data_start = tell DATA; # save the position print while (<DATA>); … Read more

Push to array reference

It might help to think in terms of memory addresses instead of variable names. my @a = (); # Set aside memory address 123 for a list. my $a_ref = [@a]; # Square brackets set aside memory address 456. # @a COPIES the stuff from address 123 to 456. push(@$a_ref,”hello”); # Push a string into … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)