How can I compare a number against a range in bash or Perl?
How to script a comparison of a number against a range? 1 is not within 2-5 or 3 is within 2-5 ...
How to script a comparison of a number against a range? 1 is not within 2-5 or 3 is within 2-5 ...
I want to host a mod_perl application on a shared RHEL server where I do not have access to a root account. mod_perl is available on the server as are all Perl modules required (my app runs fine with CGI). Here are two problems I anticipate: Apache restarts would be required whenever I update my code the first time and subsequently on ...
Hi everyone, I've used PerlNet for a data extraction project. Perl is a powerful language for extracting data and text manipulation with a huge CPAN module. However, my program need some kind of UI, thread... which I decided to use .NET C#. With Perl Dev Kit, we have an option to wrap an Perl module to a .NET DLL and use this DLL direct...
There are some errors in my Perl script, I looked though the source code but couldn't find the problem. #Tool: decoding shell codes/making shell codes use strict; use Getopt::Std; my %opts=(); getopts("f:xa", \%opts); my($infile, $hex); my($gen_hex, $gen_ascii); sub usage() { print "$0 -f <file> [-x | -a] \n\t"; print '-p <path to ...
Given these inputs: my $init_seq = "AAAAAAAAAA" #length 10 bp my $sub_rate = 0.003; my $nof_tags = 1000; my @dna = qw( A C G T ); I want to generate: One thousand length-10 tags Substitution rate for each position in a tag is 0.003 Yielding output like: AAAAAAAAAA AATAACAAAA ..... AAGGAAAAGA # 1000th tags Is there a compact ...
I've come across the following line of code. It has issues: it is intended to do the same as push it ought to have used push it's hard to read, understand I've since changed it to use push it does something I thought was illegal, but clearly isn't here it is: $array [++$#array] = 'data'; My question is: what does it mean to pre-i...
I have this web application which needs to do several heavy text processing tasks: removing certain characters, parsing XML files, among others. Some of them involve regular expressions. The web application has some implementations in Java and others in PHP. Is it worth using Perl or other specific text processing language for such task...
I am a Perl developer and have gravitated towards a specific suite of modules that I use for almost everything. I primarily build GIS and database oriented web applications for reporting and data entry and the like. I'm curious what groups of modules other Perl devs have settled on using regularly. Mine: CGI DBI Spreadsheet::WriteE...
I read Runtime.getRuntime().exec("perl script.pl") is an option, but is this the best way to do it? I'll need an answer from that script, so I'll have to read the script's return in some cases, although I might read it from a text file on other cases. Anyway, is exec() a good way of calling a Perl Script from Java? I should note, I'm w...
In Perl, localtime takes a Unix timestamp and gives back year/month/day/hour/min/sec etc. I'm looking for the opposite of localtime: I have the parts, and I'd like to build a unix timestamp from them. ...
How can I parse this date format that my web service is receiving in JSON format in Perl? I'd like to convert it to a DateTime object: Date(1216647000000-0400) I assumed it was milliseconds since the epoch along with a time zone offset but the dates are way off. ...
In Perl 5.10, I can say: sub foo () { state $x = 1; say $x++; } foo(); foo(); foo(); ...and it will print out: 1 2 3 Does Python have something like this? ...
I am working on Perl script that uses Expect to login via telnet to remote machines (don't ask, gotta use telnet). I also do perforce p4 login operations as necessary and use expect to pipe in the correct passwords. For now I just read passwords from clear text environment variable, i.e. export PASSWORD=password, which I know is no good ...
I've got a Perl function which takes a timestamp and returns either the unchanged timestamp (if it's never seen it before) or otherwise, it appends some letters to make it unique: sub uniqify($) { my $timestamp = shift; state $last_ts = -1; state $next_letter = 'A'; if ($timestamp == $last_ts) { $timestamp .= $next_letter+...
I would like to generate Perl Expect code automatically, does something like autoexpect exist for Perl's Expect?? ...
Hi, I wrote a simple program that using Class::ArrayObjects but It did not work as I expected. The program is: TestArrayObject.pm: package TestArrayObject; use Class::ArrayObjects define => { fields => [qw(name id address)], }; sub new { my ($class) = @_; my $self = []; bless $...
What's the best way to programatically discover all of the subroutines a perl module has? This could be a module, a class (no @EXPORT), or anything in-between. Edit: All of the methods below look like they will work. I'd probably use the Class::Sniff or Class::Inspector in production. However, Leon's answer is marked as 'accepted' ...
I would like to use MooseX::ClassAttribute in a role. I.e., do something like package Cachable; use Moose::Role; use MooseX::ClassAttribute; class_has Cache => ( is => 'rw' ); 1; Unfortunately, the code above doesn't work as the deep magic of MooseX::ClassAttribute expects to be called from within a Moose object, and not a Moos...
I don't know what I could be doing wrong with this simple transaction, but it's not working: print "OK? (y or n)\n"; $ans = <>; print "\n"; if($ans eq "y"){print $ans;} I basically want to know how to test the user input. This little bit of code won't work for me. I'm just trying to print $ans if y is entered by the user. Any sugge...
In a Perl script I'm working on, I need to build a matrix out of several other matrices. I've looked at a couple of modules in CPAN (Math::Matrix, PDL::Matrix, Math::Cephes::Matrix), but none of these seem to support this. In Octave, this is very easy. Here's an example of something similar to what I'm trying to do: octave:1> A = [ 1, ...