Filed under: PERL, Work — Jawaad @ 7:30 am
January 16, 2008

This is one of those strange things that sounds a lot easier to do than it is.

I originally handled this by exploding the character through this:

$array = preg_split('//u', $a);

This worked fine and the string was split into an array of unicode characters. The next part was converting it into a useful hexidecimal value.

$character = $array[0];
$value = hexdec(bin2hex($character));

I originally thought this was the way to do so - I was wrong, don’t do it. It turns out there is no real simple way to convert from UTF-8 to hex values. Instead, try the UTF8ToUnicode function here: http://hsivonen.iki.fi/php-utf8/

Include this function and use the author’s utf8ToUnicode function. It becomes simple then:

$value = utf8ToUnicode($character);
$value = $value[0];

I am only posting this because of the sheer amount of time it took for me to find this information. I hope it helps you out.


Filed under: PERL, Work — Jawaad @ 9:40 am
May 16, 2007

Unfortunately, I have been stuck in a brutal losing battle against Blogger’s API. I have managed to get the authentication function working, but it stops when I try actually posting -_-

Functional Authentification Function

require_once "HTTP/Client.php";
require_once 'HTTP/Client/CookieManager.php';

$email = "blahblah";
$password = "blahblah";
$blog_id = "http://blahblah.blogspot.com/";
$source = "superman-bloggingbro-0.1";
$service = "blogger";

$login_url = "https://www.google.com/accounts/ClientLogin";
$login_params = array( "Email"=> "$email", "Passwd" => "$password", "source" => $source, "service" => $service);

$client =& new HTTP_Client();
$client->setDefaultHeader($headers2);
$client->post($login_url, $login_params);


Filed under: PERL, Work — Jawaad @ 2:02 am
February 1, 2007

First is my Nintendo DS site. Basically, a social web / meeting site that is mobile-enabled, it is the first time I’ve done an entire site on my own. Using the security experience I gained working for PCSafe, and the programming knowledge from Searching.com and a whole bunch of other people, I think I’ve put together something interesting/useful. Yeah, there is a lot of work yet to do, but who is to say?


Filed under: PERL — Jawaad @ 10:45 pm
November 10, 2006

There is only ONE source for decent Perl-DBI documentation online. Thank you Tony Bowden.

The important commands which seem to be available nowhere are..

  • $obj = Class->retrieve( $id );
  • $obj = Class->retrieve( %key_values );
  • my @objs = Class->retrieve_all;
  • my $iterator = Class->retrieve_all;
  • my @cds = Music::CD->retrieve_from_sql(qq{
    artist = ‘Ozzy Osbourne’ AND
    title like “%Crazy” AND
    year < = 1986
    ORDER BY year
    LIMIT 2,3
    });

  • Filed under: PERL — Jawaad @ 9:15 pm
    November 8, 2006

    If you are having problems with hashes not initializing in perl, check to make sure you are using the “{}” brackets instead of regular “()” brackets. Knowing that would have saved me 60 minutes today


    Filed under: PERL — Jawaad @ 7:39 pm
    January 3, 2006

    The XML Parser is great - but dammit it hurts when it breaks down.

    Ever get messages like this?

    no element found at line 1, column 0, byte -1 at /~~~~~~/XML/Parser.pm line 187

    These are the result of poorly formed feeds that screw up the XML feed. The solution is pretty simple however - use the Eval method.

    eval{
    (The line that calls the parser)
    }
    if($@){
    print $feed->name, ” failed to load\n”; (depending on what your rss feed name is)
    next;
    }
    else{
    (the rest)
    }

    Eval catches any errors and passes them to $@. You can use this to prevent a long .pl file from crashing halfway through running.

    Powered by WordPress

    Archives 
    August 2008 July 2008 June 2008 May 2008 April 2008 March 2008 February 2008 January 2008 December 2007 November 2007 October 2007 July 2007 June 2007 May 2007 April 2007 March 2007 February 2007 January 2007 December 2006 November 2006 October 2006 September 2006 August 2006 July 2006 June 2006 May 2006 April 2006 March 2006 February 2006 January 2006 December 2005 November 2005 February 2005 December 2004 November 2004 October 2004 September 2004

    Creative Commons License
    All text and images under 1024 x 768 pixels on this site are licensed under a Creative Commons Attribution 3.0 Unported License.
    I require a link back to the original page of the article/image. If the image/article is not public (IE: It is not present in an article on the blog), you may not reproduce it without permission.