How can I parse JSON in Perl?
I want to use Perl script that gets the JSON data and converts it into XML file. How can I do that in Perl? ...
I want to use Perl script that gets the JSON data and converts it into XML file. How can I do that in Perl? ...
Hi! I cannot make my Perl script run stable on the server. Here is the problem. When the script is accessed more than 5 times a second, the server freezes. And some time later the server hangs forever. SSH does not respond and I have to restart the server. I'm using Apache with mod_perl. The script is hosted on Virtual Dedicated Serv...
I'm trying to compare the checksum value of a file. One variable $a has the checksum (output of md5sum command, only the hexadecimal part) and the same value is in variable $b. If I do ($a == $b), I am getting an error, but if I do ($a eq $b) it gives not equal. Thanks for your answers, it worked in string comparison after trimming th...
Does anyone have a solution to the task of processing a multi-line string one line at a time, other than the string-as-a-filehandle solution shown below? my $multiline_string = "line one\nline two\nline three\nline four"; my $filehandle; open( $filehandle, '<', \$multiline_string ) or croak("Can't open multi-line string as a filehan...
I'm using a Perl script to modify some files inside a .tar, and the directory structure inside the resulting .tar disappears. Eliminating more and more code I've come as far as all that's required to reproduce this is my $data_tar = Archive::Tar->new('data.tar'); $data_tar->write('modified_data.tar'); Both .tar-files have all the file...
The documentation for the /m option in perlre says this: Treat string as multiple lines. That is, change "^" and "$" from matching the start or end of the string to matching the start or end of any line anywhere within the string. But this example seems to indicate that /^/ and /^/m behave the same way. What am I misunderst...
I'd like to install a Perl module (in this case, FindBin), but since it is included in the perl5.10.1 distribution, cpan wants to install perl5.10 for me. Is there any way of installing just the module via cpan? The only option that I can see is installing directly from source, which seems a bit crude as there is no separate package (e...
Before I start coding this myself and reinventing the wheel, how do you copy a hash of hashes without duplicating the hashrefs? I'm reading a hash of hash of hashes via Config::General. i.e., the data structure is: my %config = ( group => { item1 => { foo => 'value', bar => 'value', ...
I've racked my brain trying to come with a solution but in vain. Any guidance would be appreciated. _data_ mascot friend ocean \n parsimon **QUERY** apple \n jujube \n apricot maple **QUERY** rose mahonia \n ....Given the search keyword is QUERY, it would output: parsimon **QUERY** apple apricot maple **QUERY** rose mahonia I wro...
I need to achieve the following in perl printmsg(@val1, $msg1) if @val1; printmsg(@val2, $msg2) if @val2; printmsg(@val3, $msg3) if @val3; printmsg(@val4, $msg4) if @val4; printmsg(@val5, $msg5) if @val5; printmsg(@val6, $msg6) if @val6; So i wrote the following snippet for(my $i=1; $i < 6; $i++ ) { printmsg(@val$i, $msg$i) if @v...
I have a situation where I'd like to cache some calculations for use later. Let's say I have a list of allowed values. Since I'm going to be checking to see if anything is in that list I'm going to want it as a hash for efficiency and convenience. Otherwise I'd have to grep. If I'm using Moose it would be nice if the cache was recalc...
I'm using svnnotify. It works (sends email and all that) but it always outputs some error messages, such as Use of uninitialized value in substr at /usr/lib/perl5/site_perl/5.8.8/SVN/Notify.pm line 1313. substr outside of string at /usr/lib/perl5/site\_perl/5.8.8/SVN/Notify.pm line 1313. Use of uninitialized value in index at /usr/lib/...
I have a question relating to Perl and scoping. I have a common file with lots of various variables. I require the common file in my main script, but I cannot access the variables; they seem to be outside of its scope. I assumed that an our declaration would overcome that problem, but it doesn't seem to work. Script 1: common.pl #!/usr...
I am trying to invoke a bat file from a perl script as follows: system("call D:/SIP/run_$file_idx.bat"); However I observe that the environment variables in the bat fail to get resolved. If I run the bat file separately from the command prompt it works. Does system() create a new environment and execute bat file in that? What is th...
I'm currently somewhat stuck getting a regular expression in Perl (taken from an earlier question of mine) to match word characters from a non-ASCII locale (i.e., German umlauts). I already tried various things such as setting the correct locale (using setlocale), converting data that I receive from MySQL to UTF8 (using decode_utf8), an...
I extracted year, month, day, hour, minute, second, and millisecond data from human readable text (it wasn't in a timestamp format, but rather something like "X started at HH:MM:SS.SSS on DD MMM YYYY and ended at HH:MM:SS.SSSS on DD MMM YYYY"), so for each recorded event, I have each of the values. However, I need to turn those into som...
We have a sizable code base in Perl. For the forseeable future, our codebase will remain in Perl. However, we're looking into adding a GUI-based dashboard utility. We are considering writing the dashboard in Python (using tkinter or wx). The problem, however, is that we would like to leverage our existing Perl codebase in the Python GUI....
Hello. I'm trying to write my first Perl program. If you think that Perl is a bad language for the task at hand tell me what language would solve it better. The program tests connectivity between given machine and remote Apache server. At first program requests the directory listing from the Apache server, than it parses the list and do...
Hi there, I've been trying to get SVN to connect to Atlassian Crowd for authentication but have been running into issues with OS X Leopard Server (10.5.8) and Perl's Digest::SHA1. I've installed it from the source (http://search.cpan.org/~gaas/Digest-SHA1-2.12/SHA1.pm) and if I call it directly from a Perl script it works fine, but in ...
Well, I know this is another newbie question but I'm very frustrated and I'm looking to be enlightened again. With the guidance of you guys, I've already learnt how to use the glob function to read the contents of each file in a directory. Now I'm trying the readdir-foreach combination to do the same thing but I keep receiving "Cannot op...