in reply to Re^2: Learning classes in Perl
in thread Learning classes in Perl

perlobj should explain this for you.

#!/usr/bin/perl use strict; use warnings; package MyFile; sub new { my ($class,%args) = @_; my $self = { %args }; bless $self,$class; return $self; } sub print_args { my $self = shift; for (sort keys %$self){ print "$_ = $self->{$_}\n"; } } package main; # create new object my $hostname = MyFile->new( path => '/etc/hostname', content => "foo\n", last_mod_time => 1304974868, ); # call method on object $hostname->print_args();
poj