This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Improving Dev
Assistant
Decreasing the amount of
PERLin the world
Dev Assistanthttp://www.devassistant.org/
Let's lookat the code
package myClass;
use strict;use warnings;
sub new { my $class = shift; my $self = { _hotelName => shift, _street => shift, _name => shift, _date => undef }; bless $self, $class; return $self;}
sub enterBookedDate { my ($self) = shift; my $date = shift; $self->{_date} = $date;}
sub getHotelName { my $self = shift; return $self->{_hotelName};}
# etc ...
#!/usr/bin/perl
#use strict;use warnings;
use POSIX qw(strftime);
use myClass;
my $myClass = new myClass( "Holiday", "Baker Street", "Sherlock Holmes");my $tm = strftime "%m/%d/%Y", localtime;$myClass->enterBookedDate($tm);
print ("The hotel name is ". $myClass->getHotelName() . "\n");print ("The hotel street is ". $myClass->getStreet() . "\n");print ("The hotel is booked on the name ". $myClass->getGuestName() . "\n");print ("Accomodation starts at " . $myClass->getBookedDate() . "\n");
I don't usetools like this
You probably don't use
tools like this
But a lot of people DO use toolslike this
These people are gettinga bad first impressionof Perl