Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Seekers of Perl Wisdom

( #479=superdoc: print w/replies, xml ) Need Help??

If you have a question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working... then this section is the place to ask. Post a new question!

However, you might consider asking in the chatterbox first (if you're a registered user). The response time tends to be quicker, and if it turns out that the problem/solutions are too much for the cb to handle, the kind monks will be sure to direct you here.

User Questions
Converting Uniprot File to a Fasta File in Perl
3 direct replies — Read more / Contribute
by pearllearner315
on Feb 27, 2017 at 11:09
    Hello monks, I have an uniprot file that I need to run through and parse certain lines. Those certain lines have values that I need to construct a fasta format file. Here is an example uniprot file:
    ID ARF1_PLAFA Reviewed; 181 AA. AC Q94650; O02502; O02593; DT 15-JUL-1998, integrated into UniProtKB/Swiss-Prot. DT 23-JAN-2007, sequence version 3. DT 25-NOV-2008, entry version 52. DE RecName: Full=ADP-ribosylation factor 1; GN Name=ARF1; Synonyms=ARF, PLARF; OS Plasmodium falciparum. OC Eukaryota; Alveolata; Apicomplexa; Aconoidasida; Haemosporida; OC Plasmodium; Plasmodium (Laverania). OX NCBI_TaxID=5833; RN [1] RP NUCLEOTIDE SEQUENCE [GENOMIC DNA]. RC STRAIN=T9/96; TISSUE=Blood; RX MEDLINE=97112480; PubMed=8954160; RX DOI=10.1111/j.1432-1033.1996.0104r.x; RA Stafford W.H., Stockley R.W., Ludbrook S.B., Holder A.A.; RT "Isolation, expression and characterization of the gene for an AD +P- RT ribosylation factor from the human malaria parasite, Plasmodium RT falciparum."; RL Eur. J. Biochem. 242:104-113(1996). RN [2] RP NUCLEOTIDE SEQUENCE [MRNA]. RX MEDLINE=97237566; PubMed=9084044; DOI=10.1016/S0166-6851(96)02803 +-4; RA Truong R.M., Francis S.E., Chakrabarti D., Goldberg D.E.; RT "Cloning and characterization of Plasmodium falciparum ADP- RT ribosylation factor and factor-like genes."; RL Mol. Biochem. Parasitol. 84:247-253(1997). CC -!- FUNCTION: GTP-binding protein that functions as an allosteric CC activator of the cholera toxin catalytic subunit, an ADP- CC ribosyltransferase. Involved in protein trafficking; may modu +late CC vesicle budding and uncoating within the Golgi apparatus (By CC similarity). CC -!- SUBCELLULAR LOCATION: Golgi apparatus (By similarity). CC -!- SIMILARITY: Belongs to the small GTPase superfamily. Arf fami +ly. CC ----------------------------------------------------------------- +------ CC Copyrighted by the UniProt Consortium, see +/terms CC Distributed under the Creative Commons Attribution-NoDerivs Licen +se CC ----------------------------------------------------------------- +------ DR EMBL; Z80359; CAB02498.1; -; Genomic_DNA. DR EMBL; U57370; AAB63304.1; -; mRNA. DR HSSP; P32889; 1RRF. DR SMR; Q94650; 6-179. DR GO; GO:0005794; C:Golgi apparatus; IEA:UniProtKB-KW. DR GO; GO:0005525; F:GTP binding; IEA:InterPro. DR GO; GO:0015031; P:protein transport; IEA:UniProtKB-KW. DR GO; GO:0007264; P:small GTPase mediated signal transduction; IEA: +InterPro. DR GO; GO:0016192; P:vesicle-mediated transport; IEA:UniProtKB-KW. DR InterPro; IPR006688; ARF. DR InterPro; IPR006689; ARF/SAR. DR InterPro; IPR001806; Ras_trnsfrmng. DR InterPro; IPR005225; Small_GTP_bd. DR PANTHER; PTHR11711; ARF/SAR; 1. DR Pfam; PF00025; Arf; 1. DR PRINTS; PR00449; RASTRNSFRMNG. DR PRINTS; PR00328; SAR1GTPBP. DR SMART; SM00177; ARF; 1. DR TIGRFAMs; TIGR00231; small_GTP; 1. DR PROSITE; PS01019; ARF; 1. PE 2: Evidence at transcript level; KW ER-Golgi transport; Golgi apparatus; GTP-binding; Lipoprotein; KW Myristate; Nucleotide-binding; Protein transport; Transport. FT INIT_MET 1 1 Removed (Potential). FT CHAIN 2 181 ADP-ribosylation factor 1. FT /FTId=PRO_0000207447. FT NP_BIND 24 31 GTP (By similarity). FT NP_BIND 67 71 GTP (By similarity). FT NP_BIND 126 129 GTP (By similarity). FT LIPID 2 2 N-myristoyl glycine (Potential). SQ SEQUENCE 181 AA; 20912 MW; 18013B069BEA2413 CRC64; MGLYVSRLFN RLFQKKDVRI LMVGLDAAGK TTILYKVKLG EVVTTIPTIG FNVETVEFRN ISFTVWDVGG QDKIRPLWRH YYSNTDGLIF VVDSNDRERI DDAREELHRM INEEELKDAI ILVFANKQDL PNAMSAAEVT EKLHLNTIRE RNWFIQSTCA TRGDGLYEGF DWLTTHLNNA K
    I need to use regex and select the values of the "AC" line, "OS" line, "OX" line, "ID" line, "GN" line, "SQ" line and construct the fasta format which should look like this. The first line of the fasta format consists of the values from the line headings parsed from the uniprot file and are separated by "|". Here is an example of a fasta file:
    some code I have so far:
    #!/usr/bin/perl use warnings; use strict; unless (open(UNIPROT, "<", "uniprotfile")) { die "Unable to open uniprot file", $!; } while (<UNIPROT>) { my $lines = $_; if ($lines =~ /^AC\s+(.*)\;|^OS\s+(.*)|^OX\s+(.*)|^ID\s+(.*)|^GN\s+(. +*)/) print $1, $2, $3, $4, $5, "\n"; }
    I just printed $1, $2, $3, $4, and $5 just to see if i was able to capture the values that the regex matched. However I keep getting this output when I try printing:
    Use of uninitialized value $1 in print at ./ line 11, <UNIPROT> + line 1. Use of uninitialized value $2 in print at ./ line 11, <UNIPROT> + line 1. Use of uninitialized value $3 in print at ./ line 11, <UNIPROT> + line 1. Use of uninitialized value $5 in print at ./ line 11, <UNIPROT> + line 1. CERU_HUMAN STANDARD; PRT; 1065 AA. Use of uninitialized value $2 in print at ./ line 11, <UNIPROT> + line 2. Use of uninitialized value $3 in print at ./ line 11, <UNIPROT> + line 2. Use of uninitialized value $4 in print at ./ line 11, <UNIPROT> + line 2. Use of uninitialized value $5 in print at ./ line 11, <UNIPROT> + line 2. P00450; Q14063 Use of uninitialized value $1 in print at ./ line 11, <UNIPROT> + line 7. Use of uninitialized value $2 in print at ./ line 11, <UNIPROT> + line 7. Use of uninitialized value $3 in print at ./ line 11, <UNIPROT> + line 7. Use of uninitialized value $4 in print at ./ line 11, <UNIPROT> + line 7. CP. Use of uninitialized value $1 in print at ./ line 11, <UNIPROT> + line 8. Use of uninitialized value $3 in print at ./ line 11, <UNIPROT> + line 8. Use of uninitialized value $4 in print at ./ line 11, <UNIPROT> + line 8. Use of uninitialized value $5 in print at ./ line 11, <UNIPROT> + line 8. Homo sapiens (Human). Use of uninitialized value $1 in print at ./ line 11, <UNIPROT> + line 11. Use of uninitialized value $2 in print at ./ line 11, <UNIPROT> + line 11. Use of uninitialized value $4 in print at ./ line 11, <UNIPROT> + line 11. Use of uninitialized value $5 in print at ./ line 11, <UNIPROT> + line 11. NCBI_TaxID=9606;
    I'm not exactly sure where i'm making the mistake..does the "or |" part mess up the loop? Thank you for your help!
Integrating codebases: namespace pollution, passing objects, and more
2 direct replies — Read more / Contribute
by Anonymous Monk
on Feb 27, 2017 at 11:06

    Hello Monks!

    I'm integrating two sets of code, one written for a Dancer web app, the other for There's core code in the Dancer app that runs, and then the request parameters are parsed, the appropriate modules loaded, and the route-specific code is run, returning either a data structure (Dancer app) or printing to STDOUT ( code). The content is then rendered in a template that also has page header, footer, navigation, etc., generated by the Dancer app.

    I'm running into various problems because of the way that the code is written, e.g. some of the modules auto-export all their functions into the global namespace, most of the modules initialise a load of request-specific variables on load, there are function name clashes between modules, and most were written without warnings (and some without strict mode) turned on. From my understanding of the way Dancer is operating, the Dancer app stays alive between requests, so the modules really need to be reloaded to reinitialise these request-specific variables. Additionally, some of the functionality in the modules takes a long time to execute (it was written before the days of AJAX) and might be better dealt with by presenting a 'loading' page in the UI and retrieving the data via javascript when it is ready.

    Is there a way to temporarily / safely execute the code within the Dancer framework without running into the issues above? Some kind of sandbox around the code, like a big eval but which also prevents namespace pollution (and ideally "unloads" the modules after use)? To recap, I'd like to:

    • load old modules without namespace pollution in the Dancer app (???)
    • override various functions, e.g. using Sub::Override (OK)
    • capture STDOUT into a variable (OK)
    • pass in objects (session, environment, etc.) from Dancer app, some of which (e.g. the session) will get modified by the app (mostly OK)
    • fork a new process or deal with long-running processes asynchronously (not yet)

    Apologies if this is not clearly enough described. I can provide more detail if helpful. Thank you in advance for any suggestions!

Is there a free IDE for Strawberry Perl, running in Windows, that is interactive?
8 direct replies — Read more / Contribute
by Amphiaraus
on Feb 27, 2017 at 10:25

    Is there a free IDE for Strawberry Perl, running in Windows, that is both visual and interactive?

    Some of our build servers have a 32-bit Windows OS, others have a 64-bit Windows OS. Is there a free IDE for Strawberry Perl that is compatible with both 32-bit and 64-bit Windows operating systems?

    Currently we debug our Perl scripts by using the "-d" debug option on the command line, to go through the Perl code line-by-line. However the command line option "perl -d", is text oriented, not visual, and is very cumbersome to use.

    Is there a Perl IDE that can be downloaded free, and would provide a visual interactive mode that is less cumbersome than the "perl -d" command line mode?

    I have studied the Perl IDEs "Padre" and "Perl Express". I found a webpage saying the "Padre" interactive mode has quit working. I found another webpage saying that "Perl Express" contains some bugs and has not been updated since December 2005.

    Currently I am studying the "Netbeans" IDE, which is freeware, and which has a plugin making it compatible with Perl. For Netbeans see, for the Netbeans Perl plugin see Has anyone tried Netbeans + the Netbeans Perl plugin to debug Perl programs in a visual, interactive manner? Did it work successfully?

    Our requirements are having a Perl IDE: a) That is visually oriented (instead of text-oriented like "perl -d"). b) Allows a Perl program to be run and debugged line-by-line, in an easy to understand visual display. c) Is Freeware. d) Is compatible with Windows OS 32-bit and Windows OS 64-bit

    Is there an existing Perl IDE that can be downloaded free, that meets the requirements listed above? I need to download and test Perl IDE's on my home computer, not my work computer, so I can't do such testing at the moment

Critique of my "WebServerRemote" module
2 direct replies — Read more / Contribute
by nysus
on Feb 27, 2017 at 07:37

    If you are bored and looking for someone to beat some sense into, read on. Note: this post is somewhat of a followup to my question yesterday.

    First, a little background to put this in context. I started learning Perl in the late 90s. I'm a very on again/off again programmer. I don't code for a living and I write some hellacious spaghetti code. But every year or two I get the programming bug but usually end up biting off more than I can chew and/or get sidetracked with other stuff. But the last couple of weeks I've decided to pour my heart into getting as good as I can get at programming with perl so I can take on some larger projects I'd like to work on. First, to sharpen my chops, I decided to work on a smaller project, a family of modules and roles to manipulate my webserver from my local machine. The primary purpose of this project is not to write the best possible mechanism for issuing commands to a remote server. While I want this program to be useful, its primary purpose is to help me cut my teeth more with Moose, seeing what it can do, and getting more adept with it and other tools (like testing, vim, etc.).

    So anyway, what I'm looking for is a critique of what I have to see if I'm way out to lunch. I'm particularly concerned with how I'm using roles, which seems very convoluted. I'll explain in more detail as I show the code below. I have more to code but I'm far enough along to have enough shape to it. What I have written so far works and has been tested. Feel free to bash me. I can take it.

    So first I have my WebServerRemote class. It is intended to be the kind of glue that holds my family of my modules together and does odd tasks and delegates other tasks out to other modules and subclasses:
    package WebServerRemote 0.000001; use Carp; use Moose; use Data::Dumper; use Modern::Perl; use Params::Validate; use MyWebsite; use namespace::autoclean; with 'MyOpenSSH'; with 'Apache2Info'; sub get_file { validate_pos(@_, 1, 1); my $self = shift; my $file_path = shift; return $self->capture("cat $file_path"); } # get website objects based on domain name sub get_websites { validate_pos(@_, 1, 1); my ($self, $domain) = @_; my @websites = (); # website o +bjects my $config_files = $self->lookup_config_files($domain); # list of c +onfig files croak 'No config files found with ' . $domain if !@$config_files; foreach my $file (@$config_files) { my $config = $self->get_file($file); #my @cmds = qw( servername, suexecusergroup, customlog, serveralia +s ); foreach my $docroot (@{$self->get_docroots_from_string($config)}) +{ my $vh = $self->get_vh_context($config, 'documentroot' +, $docroot); my @aliases = (); my $aliases = ''; while (my $alias = $vh->cmd_config('serveralias')) { push @aliases, $alias; } $aliases = join ', ', @aliases; my $suexec = $vh->cmd_config('suexecusergroup') || ''; my $servername = $vh->cmd_config('servername') || ''; my $errorlog = $vh->cmd_config('errorlog') || ''; push @websites, MyWebsite->new ( docroot => $docroot, apache_config_path => $file, domain => $servername, suexecgroup => $suexec, aliases => $aliases, error_log => $errorlog, ssh => $self->ssh->get_user . '@' . $self +->ssh->get_host, ); } } return \@websites; } sub check_dir_for_files { validate_pos(@_, 1, 1, 1); my $self = shift; my $dir = shift; my $files = shift; my $listing = $self->capture('ls -1 ' . $dir); my %files = map { $_ => 1 } split /\n/, $listing; my @fail = (); # $files can be a scalar or an array if (ref $files) { push @fail, grep { !exists $files{$_} } @$files; return !@fail; } else { return $files{$files}; } } ##########################################

    The module above consumes two roles. First, there is MyOpenSSH which is just a wrapper for Net::OpenSSH:

    package MyOpenSSH 0.000001; use Carp; use Data::Dumper; use Moose::Role; use Modern::Perl; use Net::OpenSSH; use Params::Validate; has 'ssh' => (is => 'rw', isa => 'Net::OpenSSH', required => 1, lazy = +> 0, handles => qr/[^(capture)]/, ); around BUILDARGS => sub { my $orig = shift; my $class = shift; my %args = ref $_[0] ? %{$_[0]} : @_; croak 'a host must be supplied for ssh: ssh => (\'<user>@<host>\', % +opts)' if !%args; my ($host, %opts) = $args{ssh}; return $class->$orig( %args) if ref $host eq 'Net::OpenSSH'; delete $args{ssh}; my $ssh = Net::OpenSSH->new($host, %opts); $ssh->error and croak "could not connect to host: $ssh->error"; return $class->$orig( ssh => $ssh, %args ); }; # wrapper for system method sub exec { validate_pos(@_, 1, 1); my $self = shift; my $cmd = shift; $self->ssh->system($cmd) || carp 'Command failed: ' . $self->ssh->er +ror; } # wrapper for capture method sub capture { validate_pos(@_, 1, 1); my $self = shift; my $cmd = shift; $self->ssh->capture($cmd) || carp 'Command failed: ' . $self->ssh->e +rror; } ###########################################

    Now, I'm sure the first question will be, "Why is he using Net::OpenSSH and not just doing it directly on the machine?" Well, mostly because I wanted to get familiar with it and also because I want to be able to develop everything on my local machine to see if it can be done. I'm sure the other question will be "Why a wrapper for Net::OpenSSH?" The answer to that is twofold: I wanted to see how it might be done and two, I don't want to have to remember how to construct a Net::OpenSSH object. I can now create a WebServerRemote object with something as simple as $wsr = WebServerRemote(ssh => me@host). Yeah, I'm that lazy.

    I found some nice side benefits to wrapping Net::OpenSSH. For example, I can automatically check for errors every time I run a command on the remote server.

    Now, the BUILDARGS is the most interesting (convoluted?) feature of the Net::OpenSSH role. It was hacked together with trial and error until I got it to work. I will get back to this later. It's a doozy.

    So, the other role I have is called Apache2Info. Its job is to do boring things related to retrieving information from Apache config files. So far, it mostly has methods I will use for reporting. I've left out a lot of the code of this role because it's not very interesting or pertinent to this post:

    package Apache2Info 0.000001; use Carp; use Try::Tiny; use File::Spec; use File::Util; use Moose::Role; use Data::Dumper; use Modern::Perl; use File::Listing; use File::Basename; use Params::Validate; use Apache::ConfigFile; requires 'ssh'; # get document roots of a config file sub get_docroots_from_string { --snip-- } # searches a config file string for a command and returns virtual host + config # if a match is found sub get_vh_context { --snip-- } # Apache::ConfigParser requires a path to a file as an argument # so we save contents to a file first and then read it sub _read { --snip-- } # get list of absolute, non-canonical paths to all apache configuratio +n file sub get_enabled_apache_config_filenames { --snip-- } # get a listing of all directories where config files reside sub get_config_file_dirs { --snip-- } # get all docroots sub get_all_docroots { --snip-- } # find the config files for a given domain name sub lookup_config_files { --snip-- ###############################################

    The only really interesting thing here is the requires 'ssh' bit because this role needs a Net::OpenSSH functionality to get stuff from the server. I satisfy that in my consumers by having an ssh attribute. You'll notice the ssh attribute is supplied by the MyOpenSSH role. This is also where stuff gets kind of convoluted.

    The last piece of the puzzle is the MyWebsite class which extends WebServerRemote. I'm not sure if this is a good idea or not but in the interest of experimenting I decided to try it and see what happens. My thinking on this was that since I want my website objects to use the MyOpenSSH role and Apache2Info, that I could just extend WebServerRemote and have those features automatically included. Also, there are methods in WebServerRemote that will be used by my MyWebsite. So, anyway, here is the code:

    package MyWebsite 0.000001; use Carp; use Moose; use Modern::Perl; use Drupal; use WordPress; extends 'WebServerRemote'; with 'MyOpenSSH'; use namespace::autoclean; has 'db' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'ver' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'type' => (is => 'ro', isa => 'Str', required => 0, +lazy => 1, builder => '_set_type'); has 'domain' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'aliases' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'docroot' => (is => 'rw', isa => 'Str', required => 1, +lazy => 0 ); has 'db_user' => (is => 'ro', isa => 'Str', required => 0, +lazy => 1, default => '', writer => '_set_dbuser', ); has 'db_pass' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'root_dir' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'error_log' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'site_config' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'suexecgroup' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'apache_config' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'site_config_path' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); has 'apache_config_path' => (is => 'rw', isa => 'Str', required => 0, +lazy => 1, default => '', ); sub _set_type { my $self = shift; # check for drupal multi site if ($self->check_dir_for_files($self->docroot, ['sites', 'includes', + 'modules'])) { $self = Drupal->meta->rebless_instance($self); return 'drupal'; } if ($self->check_dir_for_files($self->docroot, 'wp-config.php')) { $self = WordPress->meta->rebless_instance($self); return 'wordpress'; } if ($self->check_dir_for_files($self->docroot, 'settings.php')) { $self = Drupal->meta->rebless_instance($self); return 'drupal'; } } ##############################################

    So, I have to have the with 'MyOpenSSH'; bit in there. I thought by extending MyWebsite I wouldn't need that. However, when I remove that line, things break when the _set_type method gets run. I get an error saying there is no capture method which is found in MyOpenSSH. But putting this line wreaked all other kinds of havoc. I think the ssh attribute was trying to get set twice. I'm not sure. Anyway, after fiddling with the BUILDARGS method of MyOpenSSH and playing with the order of the with statements, I was able to get it to work somehow. I feel in my bones this is a horrible hack but I don't know how to fix it properly.

    The other thing I do is apparently what's called an "object factory" where the MyWebsite object detects what kind of website it is and then subclasses itself when the _set_type method is called. Perhaps this is a bad idea. I'm not sure if there's a real good reason to do it except to see if it can be done. But I'm thinking it may come in handy because different kinds of websites will have different methods.

    Alright, that's it. Feel free to beat on me if this is a ridiculous mess. :)

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

Recursive Module Dependencies
1 direct reply — Read more / Contribute
by 13gurpreetsingh
on Feb 27, 2017 at 06:03
    Hi Monks,

    Tried searching many a times, but couldn't find. I believe there isn't a real solution to my problem, but might be !!

    So, I am working on Company Servers where I deploy modules in separate directory due to root permission issues and use them via PERL5LIB or 'use lib'.

    But problem comes when installing each module goes up and up with recursive dependencies. I have proxy restrictions due to which I can't connect to internet on shell and directly install via cpan. Each module, and thereafter its parent module, I have to download, unzip and install manually.

    Is there a way I can view all the dependencies of a module I am going to install on browser itself and view the order of installation?

    If it is possible, I will go and download them one by one and install it in that manner instead of opening multiple sessions to a server, multiple browser windows, doing scp from my local windows machine, unzip and blah blah. Although this is also a manual work, but atleast a bit better.

    Thanks for your help in advance.

Design question for berrybrew update
1 direct reply — Read more / Contribute
by stevieb
on Feb 26, 2017 at 17:36

    Hey all,

    So thankfully, Strawberry Perl is in the beginning stages of providing a JSON document with all of their releases. Here is their first example/mockup.

    Currently, in berrybrew, I hand pick releases, add them into an existing JSON file within the install, and allow others to manually edit this file as they see fit.

    The entire list is quite long, even using just the portable editions. For instance, each version has a 32-bit and a 64-bit cut, and each 32-bit cut has both a "with USE_64_BIT_INT" and "without USE_64_BIT_INT". I like the entire default list to show up in one cmd window without scrolling.

    My question is essentially looking for assistance on how I should decide which versions to include. First, the list file will be included in each distribution as it currently was when that release is done. The user will have to manually run a command line command to fetch any updates.

    I'm thinking about including only all 32 and 64 bit portable editions in the berrybrew available command, with some options to include others:

    berrybrew update_perls # only look for new default includes berrybrew update_perls include PDL berrybrew update_perls include 64_BIT_INT berrybrew update_perls all

    etc. After the new JSON data is fetched, we'll run a routine that will reformat everything to how it is used internally.

    What are your thoughts on this? If you use Perlbrew, is there anything you wish was/wasn't being done?

    All suggestions welcome, as I'm in the extremely early stages of drumming up a design on how this will be approached (and hopefully, make decent decisions early on, as to minimize work after if it needs to be modified).

    berrybrew is developed in C#. It is currently being reviewed for porting to C++ because I desire to get rid of the .Net requirement, if possible. However, that doesn't affect the outcome of this particular question. That said, any and all suggestions to how the software operates or acts is welcome, as I'm a *nix person by default, and would love feedback of all sorts from my fellow Monks who use Windows.

UP-TO-DATE Comparison of CGI Alternatives
6 direct replies — Read more / Contribute
by iaw4
on Feb 26, 2017 at 17:18

    A comparison of tradeoffs using various web technologies should probably be a FAQ and updated once a year. The web is important, and unlike ruby and rails (or python and django?), there is really not one recommended dominating web framework in perl to start with.

    I am going to start this post with what I understand.

    • was a simple low- or mid-level framework. It has been deprecated. It is still supported for existing projects, but no one should start a new web project with it.
    • PSGI/Plack is expressly middleware. While powerful and stable, it really is not designed for writing websites, but designed for use in higher-level frameworks. The authors are not too happy with (or equipped to) handle large number of noobie requests on how to use it, and the examples in the documentation are modest.
    • The two primary choices for new modest-size websites are Dancer2 and Mojolicious. They have good documentation and are suitable for newbies. (Both frameworks are or can be users of PSGI/Plack, but this is transparent to the user programmer.) They are good high-level, but not stable. In particular, I know that Mojolicious is evolving---projects can break upon M updates. I don't know about Dancer2.
    • For large projects, Catalyst becomes a third alternative.

    So, for someone new who wants to learn how to code a website, there seem to be two primary perl choices. If my reading of the landscape is not correct, then please correct it. And if someone could please post the pros and cons of Dancer2 and Mojolicious---so that one does not have to learn both first to start with one---it would be helpful.

    Personal Observation: What I liked about and Plack/PSGI over the frameworks was that lower-level code makes it easier to determine what perl code was responsible for displaying a given web page. With the frameworks, by the time all routes, templates, injections, etc., are considered, it becomes hard to trace how the given web page has been built. Where web programs are one's primary responsibility and used every day for years, the linkage within the frameworks is not a problem. One remembers instantly what was where. Where web programs are occasional tasks, separated by long periods of neglect, this becomes more difficult.

    thanks in advance to the experts for illuminating the issues.

Converting Moose object to a subclass of itself
3 direct replies — Read more / Contribute
by nysus
on Feb 26, 2017 at 14:42

    I have a Moose class which represents websites on a server, call it the Website class. This is a parent class of two subclasses: Website::Drupal and Website::WordPress. Website objects start out as a generic. Once the object "learns" which type of object it is, I'd like it to subclass itself as Website::WordPress or Website::Drupal. I believe that "coercion" is what I need to do. I read this but I couldn't really make heads or tails of it and so I'm not sure if I'm on the right track. If someone could give me some hints to steer me in the right direction, I'd appreciate it.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks Failure ( CGI::Switch? )
1 direct reply — Read more / Contribute
by tultalk
on Feb 26, 2017 at 10:59
    Never mind. Ignore this post. I am having difficulty keeping track of what I am doing. I have a duplicate of website on local machine. I was using hosts to keep from accessing files on line but what a horror having to change hosts when I want to go to the live site. Got screwed up as to what file I was using. Sorry. This is wrong thread. Could not find link to start a new one. Went from compile error to software error. Problem with sendmail. Trying to block out section of code for testing Ttried the = for comments and =cut Didn't work Tried # on every line. Didn't work?? Error before comment out # Same after all the # Global symbol "$mailprog" requires explicit package name at /home/jalamior/www/cgi-bin/lib/perl/ line 777.
    #my $mailprog = '/usr/lib/sendmail -oi'; #my $mailprog = '/usr/lib/sendmail -oi -t'; #my $mailprog = '/usr/sbin/sendmail -oi -q -t'; # FUNCTION: open_sendmail_pipe($fh, $mailprog) # my ($fh, $mailprog) = @_; # $result = open $fh, "| $mailprog" #$result = open $fh, "| $mailprog"; #die "Can't open $mailprog\n" unless $result; # open_sendmail_pipe(\*MAIL, $mailprog); #close (MAIL) || die "close mailprog: \$?=$?,\$!=$!";
    Suggestion from monks =for comment die "testing"; =cut All the code between =for comment and =cut dimmed out. Same with all the # but still error message: Global symbol "$mailprog" requires explicit package name at /home/jalamior/www/cgi-bin/lib/perl/ line 777. No instances of "$mailprog" exist which are not commented out. Help!!!!!
Open an application from windows registry
2 direct replies — Read more / Contribute
by ElAlx
on Feb 26, 2017 at 09:36
    Hello Monks, I'm writing a script which could automatically open a specific version of programm by using the path in windows registry using Win32::TieRegistry. How can i place a variable into the string so that will work?
    use Win32::TieRegistry (Delimiter => '/'); my $version=2.1; my $mykey = $Registry->{'HKEY_LOCAL_MACHINE/Software/SPS/$version'}; my $mykeyval = $mykey->{'/AppsDir'}; $mykeyval2="$mykeyval"."\\start.exe"; system("$mykeyval2");
    I tried to find something for my problem but with no luck. I would appreciate your help! Thank you!

Add your question
Your question:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (8)
    As of 2017-02-28 08:09 GMT
    Find Nodes?
      Voting Booth?
      Before electricity was invented, what was the Electric Eel called?

      Results (398 votes). Check out past polls.