Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

satest3 posted:

I'm not sure if that is true

Gotcha. :ese:

I was hoping the "fastest, aka best" would give me away.

Adbot
ADBOT LOVES YOU

Puck42
Oct 7, 2005

Thanks to this thread I've started fooling around with Moose. So far I like it. But I'm not too up to date on OO programming.

I've run into one issue I'm not sure how to tackle.

I have an object named Conf that is extended by another object named Admin.
I pull data from a database query and dump that into the Conf object. The admin row of the query returns an index number for another table.

How would I setup the Admin object to take the index number it gets from the query and load it's self from another query? I initially replaced the new function, but I get an Type Constraint error. Which makes sense.

I hope I'm explaining this well enough.

code:
package Conf;
use Moose;

has 'idx' => (is => 'ro', isa => 'Int');
has 'admin' => (is => 'rw', isa => 'Admin');

sub new {
  my ($class, $conf_num) = @_; 
  
  my $sth = $dbh->prepare("SELECT * FROM table WHERE idx = ?;");
  $sth->execute($conf_num);
  my $row = $sth->fetchrow_hashref;
  my $self = $class->SUPER::new(%$row);
  return $self;
}

package Admin;                 
use Moose;
                            
extends 'Conf';

has 'idx' => (is => 'ro', isa => 'Int');
has 'first_name' => (is => 'rw', isa => 'Str');
has 'last_name' => (is => 'rw', isa => 'Str');

package main;

my $conf = Conf->new(21);

Puck42 fucked around with this message at 19:00 on Aug 23, 2009

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Puck42 posted:

How would I setup the Admin object to take the index number it gets from the query and load it's self from another query?

I'm not quite sure what you mean here. Since this is the heart of your question, I don't know how to help you with this without more information.

Puck42 posted:

I initially replaced the new function, but I get an Type Constraint error. Which makes sense.

With Moose, replacing new is usually a last resort. We have plenty of hooks and functionality to let you avoid replacing new. In your case, BUILDARGS is what you want.

code:
sub new {
  my ($class, $conf_num) = @_; 
  
  my $sth = $dbh->prepare("SELECT * FROM table WHERE idx = ?;");
  $sth->execute($conf_num);
  my $row = $sth->fetchrow_hashref;
  my $self = $class->SUPER::new(%$row);
  return $self;
}
becomes

code:
sub BUILDARGS {
  my ($class, $conf_num) = @_; 
  
  my $sth = $dbh->prepare("SELECT * FROM table WHERE idx = ?;");
  $sth->execute($conf_num);
  return $sth->fetchrow_hashref;
}
Basically, you can accept whatever arguments you want to new. It is up to BUILDARGS to transform it into a hashref.

Puck42
Oct 7, 2005

Filburt Shellbach posted:

I'm not quite sure what you mean here. Since this is the heart of your question, I don't know how to help you with this without more information.


Sorry, it's a horrible way to phrase it.

I have the BUILDARGS run a query and it returns a number for admin, like 4. I then want that number to run through the Admin object as a DB query and setup the Admin object inside of Conf using the hash returned from the Admin query.

Basically the same way I have Conf setup to run the number it receives as a query and create the object.

Speaking of BUILDARGS...

code:
sub BUILDARGS {
  my ($class, $conf_num) = @_; 
  
  my $sth = $dbh->prepare("SELECT * FROM table WHERE idx = ?;");
  $sth->execute($conf_num);
  return $sth->fetchrow_hashref;
}
I can not get BUILDARGS to work, I've tried it a few different ways based off examples, but I always get an error.

code:
Single parameters to new() must be a HASH ref at /usr/share/perl5/Moose/Object.pm line 18
	Moose::Object::new('Conf', 21) called at ./m_test.pl line 64
Any ideas?

Thanks

Edit: Never mind, I should of check the version of Moose installed, 0.17 is not up to date...

Puck42 fucked around with this message at 01:48 on Aug 24, 2009

Roseo
Jun 1, 2000
Forum Veteran
Speaking of has-a relationships, is there a better way to refer to a parent object in Moose than just like this?

code:
sub _build_childobj {
    my $self = shift;
    return Child::Obj->new(parent=> $self);  
}

S133460
Mar 17, 2008
hello
I hate this redesign of perldoc.org. Why would someone think that shoehorning perlguts into a 600px wide box was a good idea? And that aggravating header bar that sticks at the top of the page... what's up with that? There's a preference to turn it off but it only works in IE for me.

ok I'm done. :coffee:

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Yeah they're wasting a ton of space on either side, idg why they did that

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
The usual blogs have been pretty serious about reshaping Perl's image to be more modern. Apparently any change is better than no change.

tef
May 30, 2004

-> some l-system crap ->
shorter columns are easier to read :eng101:

(especially when everyone's got a big screen now, with content sprawling over it)

that said I don't think the redesign is somehow 'modern' or nice either :argh:

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Wow, you guys know nothing. That facelift is yards better than the design before it. And yes, that gluey top bar is executed oddly.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

Otto Skorzeny posted:

Yeah they're wasting a ton of space on either side, idg why they did that

http://www.maxdesign.com.au/presentation/em/

Studies have shown that columns of roughly 30-35em width aid the user by providing optimal reading speed. (Something that personal experience has confirmed.)

As such their overall page design is not bad. The real WTF is why the hell they enforce it in pixels and not in em.

tef
May 30, 2004

-> some l-system crap ->

Triple Tech posted:

Wow, you guys know nothing. That facelift is yards better than the design before it. And yes, that gluey top bar is executed oddly.

I can't recall what it looked like before, but it now looks like 'if slashdot did man pages'



p.s. a little bit more whitespace would be nice too :3:

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Mithaldu posted:

http://www.maxdesign.com.au/presentation/em/

Studies have shown that columns of roughly 30-35em width aid the user by providing optimal reading speed. (Something that personal experience has confirmed.)

As such their overall page design is not bad. The real WTF is why the hell they enforce it in pixels and not in em.

I don't know if I'm some weirdo or whatever but I find the cpan.org style of presenting perldoc (which I believe is nearly identical to what perdoc.perl.org used to use) to be more usable, as there's more info on the screen, it looks nicer and there aren't dark blobs flanking the information on either side and providing a visual distraction.

I guess this is pretty much bikeshedding though, i can always type perldoc at a command prompt and see poo poo rendered Correctly

e: (i should mention i'm on a 1400x1050 laptop screen so there's way more empty space when i load the page than in tef's screenshot (im too lazy to take a screenshot of my own (i'm not sure i have a screenshot program installed atm and i forget the hotkey (nil ))))

Blotto Skorzany fucked around with this message at 16:25 on Aug 26, 2009

tef
May 30, 2004

-> some l-system crap ->

Otto Skorzeny posted:

e: (i should mention i'm on a 1400x1050 laptop screen so there's way more empty space when i load the page than in tef's screenshot (im too lazy to take a screenshot of my own (i'm not sure i have a screenshot program installed atm and i forget the hotkey (nil ))))

I cropped it, I'm on a 1920x1200 display.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:
I agree that the graphical style of the remake is totally balls. My comment was only on the column width. For anyone doubting i seriously urge to simply try reading an actual book-like full-text at screen-spanning width to see how annoying that is in practice. Also, if you have such a huge screen, make use of it properly and throw a sidebar on there. ;)

S133460
Mar 17, 2008
hello

Otto Skorzeny posted:

I don't know if I'm some weirdo or whatever but I find the cpan.org style of presenting perldoc (which I believe is nearly identical to what perdoc.perl.org used to use) to be more usable, as there's more info on the screen, it looks nicer and there aren't dark blobs flanking the information on either side and providing a visual distraction.

I feel the same way. After I posted this morning, I wrote this stylesheet to get that cpan.org feel back. It's a quick 10-minute rush job and could be improved, but you know...

code:
@-moz-document domain("perldoc.perl.org") {

body { font-family:Arial,Verdana,sans-serif !important; font-size:16px !important; }
div#page { width:auto !important; margin:16px 0 16px 32px !important; margin-right:20ex !important; }
div#page div#header { width:auto !important; background-image:none !important; height:60px !important; background-color:#0a0a0a !important; }
div#search_form { font-family:sans-serif !important; text-align:right !important; right:10px !important; top:16px !important; left:inherit !important; position:absolute !important; width:90% !important; }
div#search_form input { width:200px !important; float:right !important; }
div#homepage_link a { display:block !important; height:60px !important; width:100% !important; z-index:900 !important; }
label.overTxtLabel {
    top:0 !important; color:#d9d9d9 !important; font-style:italic !important;
    left:inherit !important; position:relative !important; font-weight:bold !important; float:right !important;
    margin-right:8px !important; font-size:16px !important;
}
div#homepage_link {
    height:inherit !important; position:static !important; border-right:2px #666 solid !important;
    background-image:url('http://perldoc.perl.org/static/combined-20090722.png') !important;
    background-repeat:no-repeat !important; background-position:-95px -25px !important;
}
div#page div#body { background-image:none !important; }
div#left_column { display:none !important; }
div#left_column{ padding:0 !important; }
div#left_column .side_group { display:none !important; }
div#left_column > div:first-child { display:block !important; }
div.side_panel { background:#ddd !important; }
div.side_panel p { font-weight:bold !important; color:#666 !important; padding:2px 8px !important; width:auto !important; background:none !important; height:auto !important; }
div.side_panel li { text-align:inherit !important; list-style-type:square !important; color:#777 !important; margin-left:12px !important; }
div.side_panel li a { color:#888 !important; }
div.side_panel ul { padding:8px !important; padding-top:0 !important; margin:0 !important; }
div#content_header, div#content_body { background-image:none !important; }
div#content_header { height:auto !important; margin-bottom:12px !important; position:static !important; }
div#content_body, div#breadcrumbs  { font-size:inherit !important; width:94% !important; margin:0 auto !important; }
div#content_body h1 { margin-left:-8px !important; font-size:18px !important; border:0 !important; background:#ccc !important; padding-left:12px !important; border:1px #999 solid !important; }
div#content_body ul { padding-left:16px !important; }
div#content_body ul li > p { margin-bottom:1em !important; }
div#content_body a:link, div#content_body a:active { color:#069 !important; }
div#breadcrumbs { font-size:14px !important; padding:12px 0 !important; }
div.mod_az_list { display:none !important; }
div#title_bar { display:none !important; }
div#centre_column { width:100% !important; padding:0 !important; margin:0 !important; }
div#right_column { display:none !important; }
pre.verbatim { background:#eee !important; margin:14px 14px 14px 0 !important; padding:0 !important; border:1px solid #999 !important; padding:12px !important; white-space:pre !important; }
pre.verbatim ol { font-size:12px !important; background:none !important; }
pre.verbatim ol li { list-style:none !important; padding:0 !important; margin:0 !important; background:none !important; margin-left:-36px !important; }
code.inline { background:none !important; border:none !important; font-size:14px !important; font-family:monospace !important; font-weight:400 !important; }
div#footer { background-image:none !important; border-top:2px #333 solid !important; height:24px !important; background-color:#666 !important; }
pre.verbatim a, pre.verbatim a:link, pre.verbatim a:active { text-decoration:none !important; color:#444 !important; }
.q, .n, .i, .m { color:#111 !important; }
.c { color:#107010 !important; }

}

baquerd
Jul 2, 2007

by FactsAreUseless
That's one narcissistic stylesheet you have there.

Roseo
Jun 1, 2000
Forum Veteran
Regarding error handling,

How is everyone here handling error handling in a OO perl situation? I've been using Moose pretty heavily in a very OO-oriented situation, and started using Exception::Class to handle fatal errors. However, I've run into gotchas with the two ways I found to use an eval{} block to provide error handling.

Method 1:
code:
eval {
  ### Do poo poo
}
if ($@) {
  ### Handle errors
}
I skipped this right from the get-go, as the reccommendations I'd seen were to avoid this as $@ is too unreliable since any bit of code anywhere can overwrite it. Instead, I went with...

Method 2:
code:
eval {
  ### Do poo poo
} or do {
  ### Handle errors
}
Unfortunately, this has a couple issues as well. As with the first method, you can lose your error when $@ is overwritten. In my case, this was triggered by a Moose object's ->new() failing due to an attribute failing type validation, and the DEMOLISH method I had logging the object's destruction via Log::Dispatch overwriting $@. Of course, this is easily fixed with a local $@ in the DEMOLISH subroutine. However, these sort of issues still need to be tracked down on a case-by-case basis. Error handling still executing means I know something goes wrong, but not what, due to the error being cleared.

More subtle was some debugging code causing the error handling code to always trigger, making a false positive:

code:
eval {
  print "Doing poo poo... " if $debug;
  ### Do poo poo
  print "poo poo's done\n" if $debug;
} or do {
  ### Handle errors
}
In this case, as if $debug is the last operation does, the eval{} happily returns the false result, causing or do{} to always execute. So, I'm left with:

Method 3
code:
eval {
  ### Do poo poo
  return 1;
} or do {
  ### Handle errors
}
Is this bulletproof? Are there subtle issues that happen with this that I'm missing? Is there a better way to perform this construct?

Alternately, I've been staying away from the various try-catch routines on CPAN due to them saying that they're in alpha, reccommendations to stay away from source filter ones, etc. Is there a stable, bulletproof CPAN module that will do what I want? I'm not a java/C coder, so I'm comfortable enough with eval{} to not be thinking that I -HAVE- to try or catch exceptions.

How does everyone here code this sort of thing?

Roseo fucked around with this message at 23:45 on Aug 27, 2009

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?
There's no problem with using $@ as long the first thing you do is assign it to a lexical and then only refer to that lexical from then on. If you keep referring to $@ in your post-eval if() you run the risk of your exception handling code over-writing your exception. Also don't forget that if you're dealing with an hierarchy of exception classes you may need to test for the most specific subclass first, to ensure your handlers operate as expected:
code:
use Scalar::Util qw/blessed/;

eval {
 # Do poo poo
};

my $e = $@;

if (not blessed $e) {
  die "non-OO exception:\n" . Dumper($e);
}
elsif ( $e->isa('My::Exception::Foo::Bar') ) {
  handle_foo_bar_exception($e);
}
elsif ( $e->isa('My::Exception::Foo') ) {
  handle_foo_exception($e);
}
elsif ( $e->isa('My::Exception') ) {
   handle_exception($e);
}
Of course since you're using Moose you can use its role/metaclass methods instead of relying upon UNIVERSAL::isa;

Adolfo Castro
Aug 6, 2002
"I think rape is fucking hilarious."
I've finished a few chapters on perl, enough that I'm comfortable writing a couple of little scripts, understand scalars, hashes etc.

I'm guessing I can automate an annoying online task with perl. Once a week, I have to fill out a webform (timesheet). Are there any tutorials for doing this with a perl script ran on client side? So I want a script that will access website, populate selected fields and hit the submit button. Anybody got links to examples where something like this is done?

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
This is the bread and buffer of WWW::Mechanize. If its own documentation isn't enough, I'm sure you could easily find a dozen blog posts explaining how to automate form submission with it.

Fenderbender
Oct 10, 2003

You have the right to remain silent.
I'm getting into Moose and I am looking to make a simple object for a User, but I'm not sure the best way to go about implementing Rose::DB::Object into it. Would anyone be willing to throw me a few pointers on where to start?

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?
Where are you going to be using this user class? If I were doing it in Catalyst, for example, I'd create a new model which consumes the RDBO schemas and loads the row from the database on your behalf, before packing it into the attribute of a Moose object and returning that. Then you call high level methods on the Moose object and it operates on your RDBO row under the hood.

Fenderbender
Oct 10, 2003

You have the right to remain silent.

atomicstack posted:

Where are you going to be using this user class? If I were doing it in Catalyst, for example, I'd create a new model which consumes the RDBO schemas and loads the row from the database on your behalf, before packing it into the attribute of a Moose object and returning that. Then you call high level methods on the Moose object and it operates on your RDBO row under the hood.

I'm writing it for use within my own framework. The current method I've gone about it is as such, though I plan on expanding the fields that 'rose' handles out to include all of the row's fields. Possibly I'll be doing that through more logic in BUILD? I'm not too familiar and if this seems like an obtuse way of getting what I need, please let me know.

code:
use ESP::DB::Object::Users;

has 'username' => (
    'isa' => 'Str',
    'is'  => 'rw',
);

has 'rose' => (
    'isa' => 'ESP::DB::Object::Users',
    'is'  => 'rw',
    'handles' => [ 'password' ],
);

sub BUILD {
    my $self = shift;

    my $user = ESP::DB::Object::Users->retrieve( user => $self->username );

    $self->rose($user);
}

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?
You can add delegates at run-time, but you'll have to pay the toll of mutability, and to be honest database schemas don't really change all that frequently. Unless you need to do it that way, you might be best off hacking some meta-code into your toolchain so that when you update your schema files, a complete Moose role will pop out that contains a correct has 'rose' declaration, with the table's column names listed as delegates under handles. Then you can replace your existing has 'rose' declaration with, err, with.

Fenderbender
Oct 10, 2003

You have the right to remain silent.

atomicstack posted:

You can add delegates at run-time, but you'll have to pay the toll of mutability, and to be honest database schemas don't really change all that frequently. Unless you need to do it that way, you might be best off hacking some meta-code into your toolchain so that when you update your schema files, a complete Moose role will pop out that contains a correct has 'rose' declaration, with the table's column names listed as delegates under handles. Then you can replace your existing has 'rose' declaration with, err, with.

Did just what you described, took all of 5 minutes to do. Clarifies and compartmentalizes the objects properly with little effort. Moose rules. :)

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?
It does. I'm considering making a Moose-ified branch of Net::DRI, we use it pretty heavily at work and there's a lot of cruft related to validation and introspection that would be better off dead, and roles would be perfect for handling the bizarro EPP extensions that pop up at the registry and TLD levels.

(Which doesn't help at all when someone like Nominet comes along and decides to adopt the protocol for the .uk registry and then go on to ignore RFC and implement 90% of their system in the protocol's extension space, resulting in some sort of weird quantum state of simultaneously being both EPP and not-EPP and making my class hierarchy all wonky at the bottom.)

Fenderbender
Oct 10, 2003

You have the right to remain silent.
Say, I'm building an object like so:

code:
    my $events = new ESP::Objects::Events(
        lat   => $lat,
        lng   => $lng,
        range => $range,
    );
and for example, $range is not defined in this context.

Now in the ESP::Objects::Events I have:

code:
has 'range' => ( is => 'rw', default => 10 );
has 'lat' => ( is => 'rw', default => 36.170103 );
has 'lng' => ( is => 'rw', default => -86.770315 );
What would be the proper way to predicate or what-have-you to make it so that if the value passed to these is undef it goes to the default value?

Puck42
Oct 7, 2005

Another small Moose question.

Is it possible to extend an object and have the extension replace one attribute with another.

For example:
code:
package User;
use Moose;

has 'name'=>(is => 'ro', isa => 'Str');

package UserManip
extends User;
use Moose;

has 'name'=>(is => 'rw', isa => 'Str', trigger => \&change_name);
I'd like to be able to add administration functions to an object without having to create a whole new package.

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?

Fenderbender posted:

What would be the proper way to predicate or what-have-you to make it so that if the value passed to these is undef it goes to the default value?
lazy_build kinda meets your needs, although you'd need to have a custom BUILDARGS that stopped any undef attributes from reaching the constructor, otherwise either a) the undef will violate the type constraints for that attribute or b) the constraints will be too loose, allow the undef through, and the predicate will always return true, so the builder won't get called. If exists-but-undef is a valid value then you'll need to modify the attribute's operation itself...

Puck42 posted:

Is it possible to extend an object and have the extension replace one attribute with another.
code:
package User;
use Moose;

has 'name'=>(is => 'ro', isa => 'Str');

package UserManip;
extends User;
use Moose;

has '+name'=>(is => 'rw', trigger => \&change_name);

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
How come in a for loop over a tied array, FETCH gets called twice for each index? Seems kind of... redundant.

I would look for the reason why in the source myself but I don't know how to navigate it.

S133460
Mar 17, 2008
hello

Triple Tech posted:

How come in a for loop over a tied array, FETCH gets called twice for each index? Seems kind of... redundant.

I would look for the reason why in the source myself but I don't know how to navigate it.

That doesn't sound right. Are you sure the array element is really only being accessed once? You may have something like this going on...

code:
for (0) {
  next unless $tied[$_];
  ...
  printf "val:%s\n", $tied[$_];
}
That's two fetches. You can avoid a FETCH on the second line by using exists. Something like B::Concise may be more helpful than digging thru source. The tie interface is implemented as perl magic, so its basically a giant pile of hacks scattered all over the perl source.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
You know what, nevermind. It was probably something gay in my implementation of the tied class. v:)v

Triple Tech fucked around with this message at 19:04 on Sep 14, 2009

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Let's say I have an idea for a framework. Should I publish immediately to CPAN so people can start toying with it or should I hold back until it's "complete"? I know what you're thinking. Triple Tech, you always have ideas! I know. But this time I actually made some proof of concept code, so I know this works somewhat.

The idea is to have LINQ for Perl. If you don't know LINQ, it's a query language for C#. It's like having SQL for lists/arrays or really any collection (trees, graphs, other data providers). Here's what I would think it would look like in Perl:
code:
my $local_collection =
  descend by 'n',
  where { $_->n =~ /Triple/    }
  let     n => 'g_name',
  where { $_->b_id != $_->g_id }
  from    b => $banned_goons,
  from    g => $goons;

my $l = new Lambda;

my $remote_collection =
  descend by 'n',
  where $l->StartsWith(n => 'Triple'),
  let   n => 'g_name',
  where $l->Ne($_->b_id, $_->g_id),
  from  b => $banned_goons,
  from  g => $goons;

my $sexier_collection =
  descend by 'n',
  where $looks_like_me,
  let   n => 'g_name',
  where $is_not_banned,
  from  b => $banned_goons,
  from  g => $goons;

Mithaldu
Sep 25, 2007

Let's cuddle. :3:
I think I'd write an RFC on Perlmonks first.

Tim Berners-Lee
Apr 12, 2007
Inventor of the Internet

Triple Tech posted:

Let's say I have an idea for a framework. Should I publish immediately to CPAN so people can start toying with it or should I hold back until it's "complete"? I know what you're thinking. Triple Tech, you always have ideas! I know. But this time I actually made some proof of concept code, so I know this works somewhat.

The idea is to have LINQ for Perl. If you don't know LINQ, it's a query language for C#. It's like having SQL for lists/arrays or really any collection (trees, graphs, other data providers). Here's what I would think it would look like in Perl:

I don't know LINQ, but most of it looks to be redundant in perl. Perl already has map, grep, and sort. All you'd be doing is changing the syntax.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Tim Berners-Lee posted:

I don't know LINQ, but most of it looks to be redundant in perl. Perl already has map, grep, and sort. All you'd be doing is changing the syntax.

That's like saying LINQ is redundant because SQL exists. Which is only partially true.

The point of making a language-integrated query ... language. is so that other people can implement data providers. So of course LINQ for local collections looks like it could be done better with map, grep, and sort. But you can use the remote collections version for both remote and local collections. Then, you could mix and match local and remote collections.

It's like doing a join at runtime between an array and an XML document, without writing a lick of SQL or XPath.

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?
Any mod_perl gurus around, how hard is it to dynamically configure an Apache+FastCGI vhost? I'd like to completely decouple Catalyst from our front end web servers so we can run different revisions simultaneously on the same boxes, for staging/QA, and so that we can promote a new version into production with no down-time. Mostly I'd like to be able to update the FastCGI endpoints (we're currently using TCP/IP for the back-end channel) on the fly without having to resort to writing out a new config file to disk and then reloading it.

x1o
Aug 5, 2005

My focus is UNPARALLELED!
I've been given the task to write the new perl DB Backup management script at work, as clients now want database backups every half hour or 15 minutes instead of the 1 hour we had beforehand. Now, there are about 30 websites on the server, each with a db size of about 300mb.

If I accomplish this using good 'ol fork and exec where the parent management script forks 30 times and calls the script that does the actual backing up, what issues would I run into?

Adbot
ADBOT LOVES YOU

Ninja Rope
Oct 22, 2005

Wee.

TheHeadSage posted:

what issues would I run into?

Locking all tables from writes every 15 minutes to insure consistency? Are you using innodb with transactions?

Edit: Er, sorry, I'm assuming you're using mysql, is that correct?

Ninja Rope fucked around with this message at 07:02 on Sep 21, 2009

  • Locked thread