Log4perl is a great tool for logging.
The warnings pragma is also an essential tool.
However, when Perl scripts are running as daemons, the Perl warnings, are printed into STDERR where nobody can see them, and not into the Log4perl log file of the relevant program.
Is there a way to catch Perl warnings into the Log4perl log?
For exa...
I have an XML file like this:
<wave waveID="1">
<well wellID="1" wellName="A1">
<oneDataSet>
<rawData>0.1123975676</rawData>
</oneDataSet>
<well>
I am trying to print out the wellName attribute with the following code:
my @n1 = $xc->findnodes('//ns:wave[@waveID="1"]');
# so @n1...
Hi,
I tried the following code snippet from Robert's Perl tutorial (link text):
> $_='My email address is
> <[email protected]>.';
>
> print "Found it ! :$1:" if /(<*>)/i;
When I ran it, the output was:
Found it ! :>:
However, shouldn't the output be,
Found it ! :m>:
since 'm' matches "0 or more '<' i.e the '<*' p...
I'm trying to access an element called raw data, inside some <rawData>data is here</rawData> tags. However this XPath query with Perl's XML::LibXML is not working:
foreach my $m ($xc->findnodes(q<//ns:wave[@waveID='1']/ns:well/oneDataSet/rawData>)) {
print $m->textContent, "\n";
}
but a similar query to get an attribute @wellName...
I would like to create 1000+ text files with some text to test a script, how to create this much if text files at a go using shell script or Perl. Please could anyone help me.
...
How can I tell what modules were originally provided with the specific Perl installation on a machine?
(This is not a duplicate of:
http://stackoverflow.com/questions/2049735
( "How can I tell if a Perl module is core or part of the standard install?" )
- it is in fact a spin-off question from it )
I am looking for what came with the i...
I have a script that is using DBI to interface with Oracle, but I keep getting the following error:
install_driver(Oracle) failed: Can't
load
'/usr/opt/perl5/lib/site_perl/5.005/aix/auto/DBD/Oracle/Oracle.s
o' for module DBD::Oracle: dlopen:
/usr/opt/perl5/lib/site_perl/5.005/aix/auto/DBD/Oracle/Oracle.so:
can't load libra...
Hello!
I need to make 3 arrays from the contents of $directory.
The first one I can use:
$var = qx{ls $directory};
print $var;
However the second and third I want to grep for "Primary *" and "Secondary *"
I've used the commands:
my @primary = 0;
my @secondary = 0;
@primary = system("ls test_77 > test | grep Primary* test");
print...
I was just looking at Can someone tell me how to create an array of directory contents?. Unsurprisingly, file globs were offered as an answer. What surprised me was that the post recommended using glob() rather than <*>.
I use use <*> because that is what I learned a long time ago and have never thought about it. Which is not a good ...
I have a list that contains arguments I want to pass to a function. How do I call that function?
For example, imagine I had this function:
sub foo {
my ($arg0, $arg1, $arg2) = @_;
print "$arg0 $arg1 $arg2\n";
}
And let's say I have:
my $args = [ "la", "di", "da" ];
How do I call foo without writing foo($$args[0], $$args[1], $$...
I'm using Getopt::Lucid to process CLO and I've run into an interesting and unexpected problem. The following code:
push @clo_spec, map { Switch($_) } qw(-c -m -s -p),
map { Switch($_) } qw(--help --man --usage --version),
map { Switch($_) } qw(--debug --verbose),
map { Param($_) } keys ...
Hello! Why doesn't the line "$rc = $dbh->func( 'dropdb', $dbname, 'admin' );" remove the database db_test_2?
#!/usr/bin/perl
use warnings;
use strict;
use 5.010;
use DBI;
my $host = 'localhost';
my $user = 'user';
my $password = 'password';
my( $rc, $dbname, @databases );
my $drh = DBI->install_driver( 'mysql' );
$dbname = 'db_test_...
Code would be nice but a point in the right direction is good as well.
CPAN? RegEx?
I've seen both ways
"yyyy-MM-dd'T'HH:mm:ssZ";
"yyyy-MM-ddTHH:mm:ssZ";
...
Lately I've been thinking a lot about functional programming. Perl offers quite a few tools to go that way, however there's something I haven't been able to find yet.
Prototype has the function detect for enumerators, the descriptions is simply this:
Enumerator.detect(iterator[, context]) -> firstElement | undefined
Finds the first ele...
How can I find which object type I am dealing with in Perl? I tried using perl -d to enter the debugger, but I'm not sure what to do then. Likewise I'd like a way to easily see which methods are available for each object, how can that be done?
...
I am working on a file downloader in Perl (UNIX/Mac OS X on terminal). I am actually searching for libraries that would work with handling checksum verification, progress bars and actually such things that the CPAN library itself uses. Which libraries and places to look can you recommend? Are there maybe some finished things like that ar...
I am trying to automate telnet to a Linux box which doesn't require any authentication through Net::Telnet Perl module. Here is a test script:
use strict;
use Net::Telnet;
my $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die',
host=> '10.104.20.200', port => 2004,
);
$tel...
I am trying to use Win32::GuiTest and with Windows XP and perl version 5.8.6.
I am getting the following error:
Can't locate loadable object for module Win32::GuiTest in @INC (@INC contains:
C:/Perl/lib C:/Perl/site/lib .) at E:\a\simply.pl line 259
Compilation failed in require at E:\a\simply.pl line 259.
BEGIN failed--compilati...
I want to create Perl scripts that run on older OS X machines as well as on current versions. Is there a list or a resource where I can find out which Perl versions were distributed with older Mac OS X Versions (10.0 to 10.6)?
...
I'm an experienced developer, but not in Perl. I usually learn Perl to hack a script, then I forget it again until the next time. Hence I'm looking for advice from the pros.
This time around I'm building a series of data analysis scripts. Grossly simplified, the program structure is like this:
01 my $config_var = 999;
03 my $result_va...