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.
I'm having a hard time with what seems like a really simple issue: comparing a string to a variable. I've pored over the Camel book and the docs for a disturbing amount of time and I'm stumped by something that hasn't been an issue for me for 15 years. For some reason when I run the code below I keep get warnings about uninitialized values in the pattern match.
while ($allChanges->[$k]) {
$logger->info("Change $k was to the ", $allChanges->[$k]->getField(
+), " field of testCase ", $allChanges->[$k]->getKey(), " on createdDa
+te ", $allChanges->[$k]->printCreatedDate(), " Old String = (", $allC
+hanges->[$k]->getOldString(), ") New String = ", $allChanges->[$k]->g
+etNewString());
local $oldString = $allChanges->[$k]->getOldString();
local $newString = $allChanges->[$k]->getNewString();
$logger->debug("oldString = (", $oldString, ")");
$logger->debug("newString = (", $newString, ")");
print Dumper($oldString);
if ($oldString eq "Automated") { # Line 103, the one that gives all
+ the trouble.
$logger->debug("old string = Automated: ", $oldString);
$logger->debug("new string: ", $newString);
}
}
package ChangeItem;
sub new {
my $class = shift;
my $logger = get_logger("ChangeItem");
my $self = { } ;
if (@_) {
$self->{line} = shift @_;
}
$self->{key} = 0;
$self->{field} = 0;
$self->{oldString} = 0;
$self->{newString} = 0;
$self->{createdDate} = 0;
$self->{version} = 0;
bless ($self, $class);
return $self;
}
sub setOldString {
my $self = shift;
$self->{oldString} = shift;
}
sub getOldString {
my $self = shift;
return $self->{oldString};
}
When I run the code I keep getting warnings about uninitialized values in the pattern match
INFO main:::80: Change 0 was to the Automated field of testCase HIREX-
+16861 on createdDate 2013-05-13 10:16:05 Old String = (To Be Automate
+d) New String = Ready For Integration
DEBUG main:::84: oldString = (To Be Automated)
DEBUG main:::85: newString = (Ready For Integration)
$VAR1 = 'To Be Automated';
Use of uninitialized value in pattern match (m//) at weeklyAutomationC
+hanges.pl line 103.
Use of uninitialized value in pattern match (m//) at weeklyAutomationC
+hanges.pl line 103.
The value of $oldString is populated by a call to ChangeItem::getOldString(). I can see that it has a value because it's being printed. I've checked that the value is a simple scalar by sending it to Data::Dumper ($VAR1 = 'To Be Automated';). I feel like I'm missing something incredibly basic but at this point I'm baffled.
-Logan "What do I want? I'm an American. I want more."
Previous function calls using the outTaskHandle are working fine, I'm pretty sure the problem is in the $writearray parameter (which I need to set to some hex value like 0xF7), the $sampsPerChanWritten which is modified by the C function, or the $reserved pointer which is supposed to be NULL. I've tried many different assignments to $writearray and $sampsPerChanWritten with no luck.
I'm new to Perl, Win32::API and perlmonks so I apologize for formatting issues.
This goes back to a previous post, which I've somewhat resolved myself, but still have one outstanding issue:
I am looking to grab and store the value of each overall json line value first. Example: from the below code, I want to actually read and store in a variable through a while loop and store 1, 2, 3, etc.
(etc...)
I currently already can store subject1's value as well as the array of subject2 and grab its subject3 value.
my $jsonfeed = (above json format!)
my $json = new JSON;
my $data = $json->decode($jsonfeed);
my $value = "$data->{1}->{subject1}";
foreach my $array(@{$data->{1}->{subject2}}){
my %hash = ();
$hash{subject3} = $array->{subject3};
}
So this is all nice, but I need to store the first value of each {} sequence which is listed here as 1{}, 2{}, 3, etc as well in a variable, and then loop the whole thing in one giant while or foreach loop. I can't seem to grab every value, however, of $data->{$_}. Anyone have a good idea?
I have tried and tried to unpack this into 4 perl variables in a single unpack() call and failed.
I had to resort to two unpack()'s, the first to extract the lengths followed by something like
It currently produces a "readline() on closed filehandle FILE" if there is a space in the path. I've done a lot of research and the answer is quoting the path. I think I've done that. I'm running perl5.10.0 on MacOS 10.6.8.
Hi monks, I just registered. Thanks in advance!
I want to use WWW::Mechanize::get in an inherited class's "get" subroutine, but it does not export any error (like "GETting...") even while the Internet access is out. See my code:
package MyMech;
use base qw(WWW::Mechanize);
sub new {
my $class = shift or die $!;
my $self = $class->SUPER::new;
return bless $self, $class;
}
sub get {
my $self = shift;
$self->SUPER::get(@_);
}
I think the get routine should work just like the base class' one, but it never die when it fails GETting.
When I call the class and use the get subroutine while the Internet access is out, it just pass through the GETting error without saying anything and $mech->title produces "Uninitialized..." error.
It works perfectly when the access is not out.
Does anybody know why it happens? Thank you so much!
Return code = 65280
Error = No such file or directory
I have ensured that C:/zip.exe files exists and is executable. I tried executing other system binaries like cmd.exe but ran into the same issue.
My question is what could be causing this issue like
i. some environment setting is wrong and interfering with the system api and hence it is not able to load the binary.
ii. The $PATH variable in this environment is greater than 1024 characters. Is the length of this variable a concern or some paths set in this variable is causing this issue
Im curious if someone would be so kind as to share their experiences setting up a minimal perl container in lxc, openvz, bsd jails, linux-vserver or even chroots.
App::Staticperl (http://software.schmorp.de/pkg/App-Staticperl.html) looks like it might be a good starting point - if i wanted to avoid a stripped down installed of <favourite distro or bsd>
The ideal outcome would provide a container with mcpan and a given version of perl. Possibly some fusion of perlbrew and some dark magic to cook up the perl version then drop it in the container.
Use case is to wrap up apps and put resource limits on them. PAAS like really. I know uwsgi can use namespaces and what not, if someone has used that - please share!