Posted by pc486 Tue 27th Feb 2007 20:30 - Syntax is Perl - 40 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
-
#!/usr/bin/env perl
-
-
use strict;
-
use warnings;
-
-
BlogEntry;
-
-
sub new {
-
; # first arg is the package name, dump it
-
my $self = {};
-
($self->{title}, $self->{author}, $self->{content}, $self->{datetime}) =
-
(@_, ());
-
$self;
-
$self;
-
}
-
-
sub title { $_[0]->{title} }
-
sub author { $_[0]->{author} }
-
sub content { $_[0]->{content} }
-
sub datetime { $_[0]->{datetime} }
-
-
main;
-
-
my @blog;
-
@blog, new BlogEntry("Post 1", "ParadoxHeart", "The first post in the Ruby blog.");
-
@blog, new BlogEntry("Post 2", "ParadoxHeart", "The second post in the Ruby blog.");
-
-
foreach my $entry (@blog){
-
$entry->title() . "\n";
-
"By: " . $entry->author() . "\n";
-
"=" x 20 . "\n";
-
$entry->content() . "\n";
-
}
-
PermaLink to this entry https://pastebin.co.uk/11087
Posted by pc486 Tue 27th Feb 2007 20:30 - Syntax is Perl - 40 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
Comments: 0