Are both of the examples below OK, or is the second one bad style?
Case 1: Stay in top directory and use catdir to access subdirectories
#!/usr/bin/env perl
use warnings; use strict;
my $dir = 'my_dir_with_subdir';
my ( $count, $dh );
use File::Spec::Functions;
$count = 0;
opendir $dh, $dir or die $!;
while ( defined( my $file = re...
Hi my test.pl as below
#!C:\Perl\bin\perl.exe
use strict;
use warnings;
my $numArgs = $#ARGV + 1;
print "thanks, you gave me $numArgs command-line arguments.\n";
while (my $line = <DATA> ) {
foreach my $argnum (0 .. $#ARGV) {
if ($line =~ /$ARGV[$argnum]/)
{
print $line;
}
}
...
This is related to the question: SCTP with Multihoming as a Drop In Replacement for TCP
I have a simple echo client / concurrent server app that ran perfectly fine using TCP. I could pipe a file to stdin on the client and the client would receive all the data back, call select which would return 1 indicating the socket was readable, t...
I based my code on the answer to the question Access get all tables, but am getting the following error:
DBD::ODBC::st execute failed:
[Microsoft][ODBC Microsoft Access
Driver] Record(s) cannot be read; no
read permission on 'MSysObjects'.
(SQL-42000) at direct.pl line 22.
[Microsoft][ODBC Microsoft Access
Driver] Reco...
I am using Params::Validate for validation, but at the callbacks section instead of defining the direct anonymous function, if I try giving the reference to that anonymous function it is directly jumping to the error logging area without printing the message inside the block (in case of passing correct value).
use Params::Validate qw(...
I've been working with Perl for years and recently started learning how to do GUI via Gtk2. All examples and tutorials I've found illustrate simple one-window type applications. Anything with a second window is limited to a simple text entry or yes/no type dialogue. I want to learn how to build something with that next-step more compl...
Are RDBOC objects cached through different processes? I'm thining of running it in mod-perl, and it would factor into things, even though it would mostly be used on things that don't change (much).
Also, do relationships referencing RDBOCs use the cache when it should intuitively?
...
Here is my javascript code:
var xmlhttp;
var result;
function load()
{
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=state_Change;
xml...
I'm maintaining a perl script which runs an automated install of our base server software. One of the new requirements is to install the Inline::Java module.
Our usual strategy of installing using Yum seems to fall down as there's no Inline::Java available in yum. I can't find an RPM release for it so can't install as an RPM. The only...
I have cookies set when the user log in to the application. Yet I need to modify that when the user updates his profile. Can anyone tell me how to update an existing cookies?
Thanks in advance.(I'm using perl).
...
If I do the following, it works fine:
print $ref->{element}->[0]->{data};
I would like to see how many references are in the array so that I can loop through them, but I am having a hard time doing that.
Here is the code I have tried, but it doesn't work:
my @array = @$ref->{element};
foreach(@array) {
print $_->{data};
}
I ...
UPD: I updated the question with more details.
In this example:
my $x = 1;
for $x (2..3) { }
print $x; # 1
$x is localized to the loop.
man perlsyn says that
"... If the variable was previously declared with "my", it uses that variable instead of the global one, but it's still localized to the loop."
But the variables are not th...
I have a script that performs BLAST queries (bl2seq)
The script works like this:
Get sequence a, sequence b
write sequence a to filea
write sequence b to fileb
run command 'bl2seq -i filea -j fileb -n blastn'
get output from STDOUT, parse
repeat 20 million times
The program bl2seq does not support piping.
Is there ...
Hi,
I am trying to connect to a mysql server which is running at port 3307. How do I connect to the server? I do not see any other way to specify port. I am using like this:
#!/usr/bin/perl
use Mysql;
$host = "localhost";
$database = "abc";
$tablename = "def";
$user = "uuu";
$pw = "ppp";
$connect = Mysql->connect($host, $database, $...
I'm wondering how I would download all _*.xml_ files from a folder I have set up on an FTP server using Net::FTP. I have seen that glob() would be the best way, but I cannot quite wrap my head around the logic.
Basically, I need to check if there are XML files in the folder. If not, wait 5 seconds, and check again. Once the files show u...
Here is what I am trying to do:
I want to read a text file into an array of strings. I want the string to terminate when the file reads in a certain character (mainly ; or |).
For example, the following text
Would you; please
hand me| my coat?
would be put away like this:
$string[0] = 'Would you;';
$string[1] = ' please hand me...
[% IF OrgType.id == Organization.org_type_id %]selected="selected"[% END %]
Does not work even when they both evaluate to the same number.
[% IF OrgType.id == 3 %]selected="selected"[% END %]
(i.e. hard-coding in a number for testing purposes) does work.
[% OrgType.id %] and [% Organization.org_type_id %]
both print "3" on t...
Sorry. I am not trying to start any flame. My scripting experience is from Perl, and I am pretty new in Python.
I just want to check whether I can have the same degree of flexibility as in Python.
In Python :
page = form.getvalue("page")
str = 'This is string : ' + str(int(page) + 1)
In Perl :
$str = 'This is string : ' . ($page + ...
I've written a Perl script, below which generates a warning and I can't work out why.
#!/usr/local/bin/perl -w
$status = $ENV{ 'STATUS' };
if ( $status eq "" )
{
$status = 0;
}
else
{
$status = 1;
}
It says "Use of uninitialized value in string eq at ./x.pl line 4."
Line 4 is the "if ( $status eq "" )" line but the variable...
Hello! My OS-Distribution provides the rpm-package "perl-obexftp", which installs the Modul "OBEXFTP".
These are the files:
/usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi/OBEXFTP.pm
/usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi/auto/OBEXFTP
/usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi/au...