perl

PHP passing variables to Perl, having issues with using spaces between variables method, is there another, better way?

I find myself needing to use Perl more and more since PHP's regular expressions leave me wondering what is going on half the time as they simply don't respond as they should (as they do when I use Perl, for example)... i had been using this method to call perl (before i started trying to do this with regular expressions).. passing in a r...

What exactly "W" do in unpack function in Perl?

I couldn't understand what exactly "W" do. my $x = "this is my string"; print unpack("W",substr($x,0,1)); Prints: 116 my $x = "this is my string"; print unpack("W",$x); Still Prints: 116 ...

Loop a part of PHP code every 15 seconds

Hi everyone, i'm trying to make a logging function with php for a tool that captures computer information on Windows. Every 15 seconds the a txt file will be produced with information inside. i want to make it run in the background while the user access other pages and not be interrupted. Here's the code i'm now using <?php $tr...

How to count the number of queries with DBIx::Class ?

I'm using DBIx::Class in a web context and I'd like to display the number of SQL queries performed and the time they took for the rendering of a page. Any idea about how to implement that? ...

capture arguments passed to a subroutine inside the package outside the subroutine

I try to log all soap calls, with subrutine called and arguments passed to the subroutine, my solution was this: #!/usr/bin/perl -w use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI -> dispatch_to('SoapStatus') -> handle; package SoapStatus; use POSIX qw(strftime); # Can I capture arguments and called sub from here ? ...

What do I use to read from STDIN/write to STDOUT of a child process?

I have an executable which reads from STDIN and output goes to STDOUT. I need a Perl script which will fork this executable as a child and write to STDIN of that child process and read from the STDOUT. This is required for Windows. Any ideas or suggestions? ...

Queries to get all ancestors/descendents of a tree in a db?

I have a table (id, parent_id, data) where parent_id points to another row in same table (or is null). Is there a standard way to query (1) all the ancestors of a certain id and (2) all the descendants of a certain id? I'm also doing this in DBIx::Class, so if there's a most convenient way to do it with that module (or some other), I'd...

How do I evaluate shell variables in a string?

In my Perl script I get strings of file paths that may contain environment variables, e.g. $FONTS/test.ttf or $TMP/file.txt. I now want to open those files like this: open my $handle, "<$filename" or die $!; How can I now expand the environment variables prior to the open call, as e.g. the bash shell would do? ...

run perl -e from inside perl script in windows

I need to run the following command from inside a Perl script in Windows. The code can't be simpler than this: #! C:\Perl\bin\perl perl -e "print qq(Hello)"; I save this file as test.pl. I open a command prompt in Windows and run the following from the c:\Per\bin directory. When I run it as perl test.pl, I get the following result: ...

How to iterate through range of Dates ?

Hi, In my script I need to iterate through range of dates given the start date and end date. Please provide me guidance to achieve this using perl. Thank You ...

Parse negative numbers from string in perl

How do I parse a negative number from a string in perl? I have this piece of code: print 3 - int("-2"); It gives me 5, but I need to have 3. How do I do it? ...

Regex.split, how to read left of the matched pattern

I am trying to convert a Perl script to a C# 3.5 routine. The perl code I have is: if($work =~ /\<[0-9][0-9][0-9]\>/){ $left = $`; $match = $&; $work = $'; } In C# I wrote the following code: string[] sSplit = Regex.Split(work, @"\<[0-9][0-9][0-9]\>"); if sSplit.length is > 2 { left = sSplit[0]; ...

TFMail : How to keep original name of attachments.

TFMail was a popular CGI Form Mail script at one time. Unfortunately, my client insists on continuing to use it. I hope that there are people who still use it and are experts in using it. The best documentation I can find is someone's home made reference sheet. In my HTML form, I have an input named attachment1 : <input type="file"...

What can I use instead of TFMail for a form-mail script?

TFMail was a popular PERL CGI Form Mail script at one time. So far it has served our purposes. It is very easy to set up and configure. Unfortunately, it only has basic functionality. It works well when you want users to fill in a form and have the result emailed to a specified email address. Can someone recommend a script ( maybe...

How do I perform a function using DateTime objects?

I want my .pl to execute a function at the end of every day, week and month. What the function will do is grab an integer from an html at the end of the day and store it in a .txt to be used to create a graph. I already know how to implement CGI and JS with a perl script, so that is no issue. I'm just not clear on whether or not DateTi...

Is there a way to have Test::Class's "Tests" subs always act like Test::More's subtests?

Right now when i do something like this: use strict; use warnings; package My::Test; use parent 'Test::Class'; use Test::More; sub overrides_basic : Tests { ok( 1, "works" ); ok( 1, "works" ); } sub overrides_no_profile : Tests { ok( 2, "works" ); ok( 2, "works" ); } __PACKAGE__->runtests; 1; The output is this: ok 1 - work...

How to dump ops for all functions using B::Concise

Right now I can name the subroutine printargs as follows to get the dump. perl -MO=Concise,printargs,-main,-terse Hello.pl Assuming I have several subroutines, how can I build a generic module to dump details for all subroutines? ...

What is the regular Expression to uncomment a block of Perl code in Eclipse?

I need a regular expression to uncomment a block of Perl code, commented with # in each line. As of now, my find expression in the Eclipse IDE is (^#(.*$\R)+) which matches the commented block, but if I give $2 as the replace expression, it only prints the last matched line. How do I remove the # while replacing? For example, I need to...

How do I execute a Perl program on a remote machine?

I wrote a Perl program to capture a live data stream from a tail command on a Linux machine using the following command in the console: tail -f xyz.log | myperl.pl It works fine. But now I have to execute this Perl program on a different machine because the log file is on that different machine. Can anyone tell me how I can do it? ...

Listing variables in current and higher frames

Hi, I'm trying to debug a script with perl -d .... After I break where I want, I'd like to print out the current environment and the environment from higher frames. I see the stack via T. Now, if I try V, I get a list of everything, which is pretty much useless, since it includes stuff like SO_BROADCAST constants, etc. How can I filter ...