#perl - Sat 5 May 2007 between 00:45 and 00:50



linux3revdiablo: well i am trying to include the code to connect to my database
f00li5hlinux3: you want to make a module full of stateless functions and then C< use > it
revdiablo: meow
revdiablolinux3: Okay, and what problem is that causing you?
linux3so i made a seperate file called dbconnect.pl
and then in my index.pl file i did require "dbconnect.pl"
f00li5hlinux3: so you're changing from php... good for you
linux3and now perl throws out Global symbol "$dbconnect" requires explicit package name at ./index.pl line 17.
Execution of ./index.pl aborted due to compilation errors
f00li5h: never used PHP. perl is my first language
f00li5hlinux3: here's the thing, it's far far easier to use an ORM like dbix::class or Class::db
revdiablolinux3: Each file has its own set of lexical variables
f00li5hlinux3: odd, including ramdom scripts is something i've only ever seen in php..
revdiablolinux3: You have to declare '$dbconnect' in the lexical scope you use it
linux3f00li5h: well i read one chapter on it. lol
f00li5hoh, i see
linux3revdiablo: so i should declare it and then in the section where it is included it will have its value changed?
revdiablolinux3: Nope
f00li5hlinux3: check out http://search.cpan.org/author/BLBLACK/DBIx-Class-0.07006/lib/DBIx/Class.pm
revdiablolinux3: Make your connect function return the new connection, then from the caller you can put it in any variable you want
f00li5hlinux3: if you just require bits and pieces, you'll get namespaces keeping things private
linux3f00li5h: yeah thats pretty much what im doing but its causing problems
just cause the variables aren't in the same scope
f00li5hlinux3: my $database = DbConnect::get_connection();
linux3and programming confuses me
gotta get better at it
revdiablolinux3: Learn or hire. =)
f00li5hright
linux3thats why im making this pointless website
f00li5hrevdiablo: the dude is trying to learn
revdiablof00li5h: I can see that. Just wanted to put that out there.
f00li5hlinux3: i have a pointless website on which i do silly perl things too
linux3lol
f00li5h: yeah mine is going to be the modradio if i ever get it done
revdiablolinux3: Files having separate scopes is a very good thing
linux3i just get discouraged easily cause i never seem to get any farther
f00li5hlinux3: i'm not sure what a "modradio" is
linux3: further
linux3ahh its complicated. you can check it out kinda at http://rpmmaker.net/modradio/
of course what im working on is in the http://rpmmaker.net/modradio-dev/ directory

Page: 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 

IrcArchive