package.pl to HTML.

index -|- end

Generated: Tue Feb 2 17:54:52 2010 from package.pl 2010/01/29 714.

#!/usr/bin/perl -W
# NAME: package.pl
# AIM: Simple use of 'package' declaration
use strict;
use warnings;
####################################
package Hexer;
####################################
sub new {
    my($class) = @_;
    my $str = "";
    bless \$str, $class;
}
sub toHex {
   my ($self,$str) = @_;
   my $len = length($str);
   my @a = unpack ("C$len", $str);
   my $s = "";
   for (@a) {
       $s .= sprintf ("%02x ", $_);
   }
   $s;
}
######################################
package main;
######################################
my $cc = "ABC \n";
my $a = new Hexer;
my $hx = $a->toHex($cc);
print "hex $hx\n";
######################################
# eof - package.pl

index -|- top

checked by tidy  Valid HTML 4.01 Transitional