Perl question:
I want to replace one string with the other; both are of the same length. I want to replace all occurrences of the string (case insensitive), but I want that the case of the letter will be preserved. So if the first letter was upper case, the first letter after the replacement will be upper case also.
For example, if I w...
Can I use a session variable that I have created with php in perl?
...
I installed ActivePerl 5.10.1.1007 on my Ubuntu 10.04 machine.
I have a very simple Perl script with the following lines:
use lib "/opt/ActivePerl-5.10/lib";
use Tcl;
my $Interpreter = new Tcl;
$Interpreter->Eval('puts "Hello world"');
$Interpreter->Eval('set ::env(TESTVAR) 55')
The output is the following:
$ /opt/ActivePerl-5.10/...
Actually I am in great agony recoverying a corrupt gzip file, possibly due to interrupted ftp transfer and then resume. After googling I found Recovering a damaged .gz file and am trying as it reads.
What I'm doing now is merging a gzip header file with some last part of the damaged file varying the size of the last part. Then I test th...
I know that caller will give me the file name and line number where a function was called, but how can I get the character or byte offset? It is okay if I must drop down to XS for it (the function will probably wind up being XS anyway).
What I am trying to do is uniquely identify all of the calls to a function, so, if there is a better...
I'm using this code to process my folders and files with two subs:
"sub folders" for folder names only
"sub files" for file names with extensions only
But I realized that "sub folders" messes with my files with extensions during the rename process.
How to distinguish the processes from one another or what is the intelligent way to te...
I have the following script to update one of my FTP passwords every 15 days through a cronjob and e-mail the appropriate people after the attempt has been made. It randomly will fail and so I will run it again manually and it will work. I can't seem to find where it's going wrong.
The script is connecting to a local mysql database grabb...
Hi
I have been trying to authenticate my CGI application through 2 drivers, one that uses username/password stored in the database and other using ldap active directory.
following is the code
$self->authen->config(
DRIVER => [ 'DBI',
DBH => $self->dbh,
TABLE => 'user',
CONSTRAINTS => {
'user.username' => '...
I want to get a .java file, recognize the first class in the file and getting information about annotations, methods and attributes from this class.
Is there any module in both languages that already does that?
I could build up a simple regexp to do it also, but I don't known how to recognize in the regexp the braces indicating the end ...
I know there's an easy way of doing this, but my recursion abilities are out of practice. Given a database table that has three fields:
id
label
child_id
I should be able to put together a recursive function that will give output like this:
child (input of program)
parent1
parent2
grandparent1
great-grandparent1
gr...
I want to pass a lexical file handle to a subroutine using a named argument, but the following does not compile:
#!/usr/bin/perl -w
use strict;
my $log_fh;
my $logname = "my.log";
sub primitive {
my ($fh, $m) = @_;
print $fh $m;
}
sub sophisticated {
my ($args) = @_;
print $args->{m};
print $args->{fh} $args->{m} ;
}
...
I am attempting to write a Perl script that parses a log where on each line the second value is the date. The script takes in three arguments: the input log file, the start time, and the end time. The start and end time are used to parse out a certain value on each line that that falls between those two times. But to properly run this...
can you convert this python code to perl code (i search about it but dont find a good result)
for i in xrange(20):
try:
instructions
except :
pass
Thanks
...
Below is my code (don't worry there's a USUW at the top of the module)
I'm testing if an array ref is readonly, and if that is the case then I'm copying it into another array ref. The tests show that the array is not read-only, yet when it runs, it fails with that error. ( For those of you not familiar with me or Smart::Comments--those ...
I'm trying to use getpos in Perl. I am using a FileHandle object in the code below, and it doesn't seem to be working. Can anyone tell me what I'm doing wrong?
use strict;
use warnings;
use FileHandle;
my $fh = new FileHandle;
$fh->open("<test.txt") or die "$!";
my $pos = $fh->getpos;
print "pos: \"$pos\"\n";
The output is:
pos: ""
...
I would like to optimise this Perl sub:
push_csv($string,$addthis,$position);
for placing strings inside a CSV string.
e.g. if $string="one,two,,four"; $addthis="three"; $position=2;
then push_csv($string,$addthis,$position) will change the value of $string = "one,two,three,four";
sub push_csv {
my @fields = split /,/, $_[0]; # ...
I'm making progress but I've run into a new problem.
This is the new code:
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
use HTML::TreeBuilder;
my $url = 'http://oreilly.com/store/complete.html';
my $page = get( $url ) or die $!;
my $p = HTML::TreeBuilder->new_from_content( $page );
my($book);
my($edition);
my @links = $p->look_dow...
Hi
I'm new to Catalyst, I found server.pl built-in in catalyst module can not parse jqGrid correctly.
Below is error messages:
Error: syntax error
Source File: http: //xxx:3000/site/static/js/i18n/grid.locale-en.js
Line: 2
Source Code:
Error: syntax error
Source File: http ://localhost:3000/site/static/js/jquery.jqGrid.min.js
Line...
Hi all,
I'm learning Perl and noticed a rather peculiar quirk -- attempting to match one of multiple regex conditions in a while loop results in that loop going on for infinity:
#!/usr/bin/perl
my $hivar = "this or that";
while ($hivar =~ m/this/ig || $hivar =~ m/that/ig) {
print "$&\n";
}
The output of this program is:
th...
I'm writing a perl script that mimics gcc. This my script needs to process some stdout from gcc. The part for processing is done, but I can't get the simple part working: how can I forward all the command line parameters as is to the next process (gcc in my case). Command lines sent to gcc tend to be very long and can potentially contai...