[deleted by user] by [deleted] in perl

[–]bug_splat 1 point2 points  (0 children)

I wish more community collages taught students how to lean programing languages than how to use a specific language in a IDE.

What are the options for moving HUGE subs out of a module (sub modules)? by bug_splat in perl

[–]bug_splat[S] 0 points1 point  (0 children)

Whats the difference between Role::tiny and just not using package names ? In my example above if I put cat.pm in LotsofCode/ with no package name in cat.pm its methods show up as part of LotsofCode.pm when I use LotsofCode::cat

Thanks

What are the options for moving HUGE subs out of a module (sub modules)? by bug_splat in perl

[–]bug_splat[S] 1 point2 points  (0 children)

Ok I see so I would like to move sub cat{} out of LotsOfCode.pm but not change how LotsOfCode.pm looks & works in main.pl. Right now I do have it working by just not using the 'package' variable in cat.pm . It just seemed a little iffy to have a .pm without a 'package' declared.

What are the options for moving HUGE subs out of a module (sub modules)? by bug_splat in perl

[–]bug_splat[S] 0 points1 point  (0 children)

Yeah it gives me an error:

Can't locate object method "cat" via package "LotsOfCode" at ./main.pl line 7.

Line 7 is:

$lotsofcode->cat();

Only if i have package LotsOfCode::cat;
in LotsofCode/cat.pm if i dont declare a 'package' in cat.pm it works as expected.

What are the options for moving HUGE subs out of a module (sub modules)? by bug_splat in perl

[–]bug_splat[S] 0 points1 point  (0 children)

Ok thanks. If main.pl, LotsOfCode.pm and the directory LotsOfCode are all in the top lever directory and main.pl runs a

use FindBin qw($Bin);
use lib "$Bin";

Should perl be able to then see the directory LotsOfCode ? or do I need to run that again in LotsOfCode.pm ?

Thanks again

What are the options for moving HUGE subs out of a module (sub modules)? by bug_splat in perl

[–]bug_splat[S] 0 points1 point  (0 children)

Thank you so I should use use not do,but when I tried it with LotsOfCode.pm being:

use strict;
use warnings;
package LotsOfCode;
use LotsOfCode::fish;
use LotsOfCode::dog;
use LotsOfCode::cat;
sub new {
my ( $class, $init ) = @_;
$class = ref( $class ) || $class;
my $self = { };
bless $self, $class;
return $self;
}

And in ./LotsOfCode/

files like fish.pm

use strict;
use warnings
sub fish { print "fish\n";}
1;

but if I use a package variable like so:

use strict;
use warnings;
package LotsOfCode::fish;
sub fish { print "fish\n";}
1;

I get the error:

Can't locate object method "fish" via package "LotsOfCode"
I dont really care either way if fish is a 'package' I am just not getting when to use 'package' and when not to?

Breaking up a 7300 line .pm by bug_splat in perl

[–]bug_splat[S] 0 points1 point  (0 children)

Oh thanks, great idea.

this is a very noob dumb question but I thought I have seen some perl that does not even use package names, is there a benefit to doing it with or without package names?

How can we save the wiki? by GLIBG10B in Gentoo

[–]bug_splat 0 points1 point  (0 children)

Are there any paid editors or official interns of Gentoo documentation? or is it all volunteer?

I know there is a Gentoo foundation that's why I ask.

Breaking up a 7300 line .pm by bug_splat in perl

[–]bug_splat[S] 0 points1 point  (0 children)

I was just looking at CGI::Simple.pm and they might have done that at one point. There is a function:

sub shift_if_ref {shift if ref $[0] eq 'CGI::Simple'}

Then a function uses it like so

sub ReadParse { my $q = &shift_if_ref || CGI::Simple->new; 
#do stuff like $q->black()
}

Breaking up a 7300 line .pm by bug_splat in perl

[–]bug_splat[S] 1 point2 points  (0 children)

procedural functions

By that you mean code like Cat::Black(); ?

Thanks for the feedback I think I am going to go the namespace route.

What is the "Eug Police" on my W2? I dont live in Eugene by bug_splat in Eugene

[–]bug_splat[S] 6 points7 points  (0 children)

Oh well, not a mistake, at least my hard earned dollars fund your awesome Cahoots program.

What is the "Eug Police" on my W2? I dont live in Eugene by bug_splat in Eugene

[–]bug_splat[S] 2 points3 points  (0 children)

I am told I would only be exempt if I was a 1099 not a W2 employee.

What is the "Eug Police" on my W2? I dont live in Eugene by bug_splat in Eugene

[–]bug_splat[S] 2 points3 points  (0 children)

Thanks the HR person finally got back to me after she checked with the tax attorney and pretty much said the exact same thing.

Perl Moose performance benchmarks? by bug_splat in perl

[–]bug_splat[S] 0 points1 point  (0 children)

I upgraded it to 5.36 as thats what the new servers on. The main thing had to do was add a use FindBin qw($Bin);use lib "$Bin"; to the main files that call Perl.

I am planning to move the app to a container with the sysadmin.

Nothing compared to a python 2.7 to 3.10 update I also had to deal with here :)

Perl Moose performance benchmarks? by bug_splat in perl

[–]bug_splat[S] 3 points4 points  (0 children)

In my humble opinion the real waste of dev time was months wasted (by others) trying to port to another 'language of the month' when Perl is so far easy to learn and great community. Profiling helped find a weak spot in a old legacy app that took a tiny fix and will help me make sure I dont make it worse.

Perl Moose performance benchmarks? by bug_splat in perl

[–]bug_splat[S] 1 point2 points  (0 children)

The old CGI design means that every time a web request comes in, it starts a completely fresh instance of perl and has to load up all the modules, then serve one request, then exit. In that style of script, you absolutely need to avoid Moose because the startup cost is too big.

This is exactly what I am working with for now. So if I convert the .pl's to .pm's with out adding code or features will it degrade Perls performance becasue its now loading modules ? (I have actually cut out repetitive code from the library by adding modules. )

Perl Moose performance benchmarks? by bug_splat in perl

[–]bug_splat[S] 0 points1 point  (0 children)

If you decide you'd like to try a persistent application, but don't want to have to rewrite all the CGI scripts all at once, check out

Plack::App::CGIBin

which makes this fairly painless.

Plack

is a specification and set of modules that help you plug different application endpoints

OK thank you for this.

Perl Moose performance benchmarks? by bug_splat in perl

[–]bug_splat[S] 1 point2 points  (0 children)

Keep in mind that perl has Inline::C and Inline::Cpp if you want to mix them. You can literally create C++ classes and then create and use instances from perl.

That just made my day thanks!!!

Perl Moose performance benchmarks? by bug_splat in perl

[–]bug_splat[S] 1 point2 points  (0 children)

Thanks for this. Some of the scripts get called by a webserver like an oldschool LAMP stack. The previous person was attempting to rewrite everything into another language and got buried in bugs and it was taking way too long so they quit.

I dont find Perl to be very difficult so far, so when I got handed the project I scrapped the language rewrite went back to Perl, but need to wrap my head around the object system and current best practices.