I can't wrap my brain around Class::DBI. I don't think I understand what exactly a has_a is or something. Or maybe it's Friday and it's been a loooooong week.
I'm writing this little code repository script ( that is quite weak) just to get some practice with cdbi.
Here is my module
package Repository::DBI;
use base 'Class::DBI';
Repository::DBI->set_db('Main','dbi:mysql:repository','root','mysql');
packag e Repository::Users;
use base 'Repository::DBI';
Repository::Users->table('repository_users');
Repository::Users->columns(All => qw`users_id users_name users_email users_since users_password`);
Repository::Users->has_many('entries', "Repository::Entry" => 'entry_user_id');
package Repository::Category;
use base 'Repository::DBI';
Repository::Category->table('repository_cat');
Repository::Category->columns(All => qw`cat_id cat_name cat_description`);
Repository::Category->has_many('entries', 'Repository::Entry' => 'entry_cat_id');
package Repository::Entry;
use base 'Repository::DBI';
Repository::Entry->table('repository_entry');
Repository::Entry->columns(All => qw`entry_id entry_user_id entry_cat_id entry_code entry_description entry_mod_date entry_create_date`);
#Repository::Entry->has_a(user => 'Repository::Users');
#Repository::Entry->has_a(category => 'Repository::Category');
The commented lines are the ones giving me trouble.
And my database:
# category table
CREATE TABLE `repository_cat` (
`cat_id` int(11) NOT NULL auto_increment,
`cat_name` varchar(50) default NULL,
`cat_description` text,
PRIMARY KEY (`cat_id`)
) ENGINE=MyISAM;
# entry table
CREATE TABLE `repository_entry` (
`entry_id` int(11) NOT NULL auto_increment,
`entry_user_id` int(11) NOT NULL default '0',
`entry_cat_id` int(11) default NULL,
`entry_code` longtext,
`entry_description` text,
`entry_mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`entry_create_date` date default NULL,
PRIMARY KEY (`entry_id`)
) ENGINE=MyISAM;
# users table
CREATE TABLE `repository_users` (
`users_id` int(11) NOT NULL auto_increment,
`users_name` varchar(50) default NULL,
`users_email` varchar(225) default NULL,
`users_since` date default NULL,
`users_password` varchar(25) default NULL,
PRIMARY KEY (`users_id`)
) ENGINE=MyISAM;
My script (below) only works with the last 2 lines in my
1 #!/usr/bin/perl
2
3 use strict;
4 use lib '/home/will/lib/';
5 use Repository::DBI;
6
7
8 my $iterator = Repository::Users->retrieve_all;
9 print join("\t",qw/id name email/) , "$/";
10 while (my $user = $iterator->next){
11 print join("\t",($user->users_id, $user->users_name, $user->users_email, $/));
12 }
~
~
~
CPANPLUS is already the easy way, but comon! There are like 40+ Net::Amazon modules and a ton for Template::* etc...
I tried CPAN Terminal> install Net::Amazon::* but that didn't work. After looking in the docs I noticed that CPANPLUS accepts install MODULE | NUMBER. Which installs modules by name or by search number.
Still, knowing the search number wouldn't save me time. Then I thought , wouldn't it be cool if I could do something like install Net::Amazon 1..LAST_IN_SEARCH
Well I searched on Net::Amazon, found that 41 modules existed, and issued a i Net::Amazon 1..41 and do you know it WORKED!
This will save me soo much time, especially with the Template::* modules.
The only problem is that it wouldn't follow dependencies, which I do have CPANPLUS set up to do.
I know a just a little of Java and VB, as for the others I know even less.
What I'd really like to know is which language will best
I'd love to hear your thoughts on this from some of you experienced programmers out there. Also, I may not get around to taking this class for a few semesters. In the event that VB is replaced with C# would your choice change?
Thanks
$schools = {
'University of Houston' = ['Entrepreneurship', 'MIS', 'Finance'],
'University of Houston Downtown' = ['Finance', 'Computer Information Systems'],
'Sam Houston State University' = ['General Business']
};
I've decided to go with Computer Information Systems at UHD.#!/usr/bin/perl
use strict;
use LWP::Simple;
use HTML::TokeParser;
# usage Links("URL","File Extension","Save Files to");
# This will download the Book of Mormon in MP3 format.
Links("http://lds.org/mp3/display/0,18692,5297-41,00.html", "mp3" , "./BofM/");
sub Links
{
my $count = 0;
my $url = shift;
my $type = shift;
my $dir = shift;
if ( defined $dir )
{
# mkdir $dir || die $!;
print "$dir directory was created\n";
}
print "URL : $url \n TYPE: $type \n\n";
unless ( defined $url )
{
return("No URL Provided\n");
die $!;
}
unless ( defined $type )
{
return("No Link Type Provided\n");
die $!;
}
my $html = get( $url );
my $page = HTML::TokeParser->new(\$html);
while ( my $token = $page->get_tag("a"))
{
my $url = $token->[1]{href} || "-";
my $file = $url;
$file =~ s/^.+\///;
if ($url =~/$type$/i)
{
print "Getting $url as $file \n\n";
sleep 3;
getstore( $url , $dir . '/' . $file ) || die $!;
$count ++;
}
}
}
use LWP::Simple 'getstore';
for (1..140){
getstore('http://www.squidfingers.com/patterns/patterns/img_'.$_.'.gi f',$_.'.gif');
print qq~
<table background="$_.gif" height="400" width="100%">
<tr>
<td align="center" valign="middle"><h1>$_</h1></td>
</tr>
</table>~
}
usage:
perl squid.pl > out.html
What do I do?
It wouldn't be that bad if I wasn't married, and if I had a degree, however, I am, and I don't. Currently I have the flexabality to work full tiem while going to school part time. The last 3 years hear have really been a blessing, a blessing that is drawing to an end. It makes me regret that I wasn't so ambitious towards school while I had it easy over the last little while. The way things are looking now I'm gonna be out of a job with no degree and *some* skills.
Going back to school full time would be FUN in my opinion, however It's not just me anymore. Being married is so interesting like that. Don't get me wrong, I wouldn't change a thing in my life, especially being married! It's just that we can both have the same aspirations and goals, with 2 different roads leading to the goal.
I'd rather get this school/degree thing out of the way ASAP and if I do find myself unemployed this would be the perfect time to do it. We are used to a certain standard of living tho, and I'd hate to yank that comfortable carpet out from underneath my wife with one big tug.
In my mind the only way to do both (education/income) would be to land some perfect job (even more perfect than the one I have now) where I could attend school during the day and work making serious bank at night.
I have faith that things will work out for us, it's just no fun waiting for the future sometimes.