perl

How do I add Perl scripting support to a Delphi application?

PLDelphi is a Perl project hosted on CPAN. I am currently working on a Delphi application and I am investigating the possibility of adding Perl scripting support and read about PLDelphi. Ideally, I'd like my application to not require Perl to be installed. PLDelphi claims to support this: To use PLDelphi from your Delphi applicati...

What happens when you have a conditional operator and a postfix conditional in the same Perl statement?

Can anybody explain how this line works? return $y < 0 ? - pip2 : pip2 if $x == 0; if $y <0 it returns -pip2, but what it returns when $y >= 0 and $x != 0 ? This line is from this function: sub _atan { my( $y, $x ) = @_; return $y < 0 ? - pip2 : pip2 if $x == 0; return atan( $y / $x ); } ...

How can I get list of mirrors in newest CPAN.pm?

In old CPANs, when you run it first time, it asked you for the continent/country your're in, and then gave you a way to choose mirror. Now it doesn't ask this question! I can of course find mirror manually, and put it in urllist, but the geographical browsing in CPAN was really handy, but I can't seem to be able to get it any longer. W...

Can I skip a whole file with the <> operator?

The following Perl code has an obvious inefficiency; while (<>) { if ($ARGV =~ /\d+\.\d+\.\d+/) {next;} ... or do something useful } The code will step through every line of the file we don't want. On the size of files this particular script is running on this is unlikely to make a noticeable difference, but for the sake of learnin...

How does AMF communication work?

How does Flash communicate with services / scripts on servers via AMF? Regarding the AMF libraries for Python / Perl / PHP which are easier to develop than .NET / Java: do they execute script files, whenever Flash sends an Remote Procedure Call? or do they communicate via sockets, to script classes that are running as services? Rega...

Is there something equivalent to Sonar for Perl?

Is there something equivalent to Sonar for Perl ? ...

Is a string comparison or a hash lookup faster in Perl?

I have some code that at one part will get executed a lot, and I'm wondernig which way is a more efficient implementation. I will use a for loop to simulate the part the gets executed alot: option A: my %sections = ( 'somestring1' => 1, 'somestring2' => 1, 'somestring3' => 1, 'somestring4' => 1 ); for (0..10000) { ...

How can I install specialized environments for different Perl applications?

Is there anything equivalent or close in terms of functionality to Python's virtualenv, but for Perl? I've done some development in Python and a possibility of having non-system versions of modules installed in a separate environment without creating any mess is a huge advantage. Now I have to work on a new project in Perl, and I'm loo...

How can I tell if my Perl script is running under Windows?

What is the best way to programatically determine if a Perl script is executing on a Windows based system (Win9x, WinXP, Vista, Win7, etc.)? Fill in the blanks here: my $running_under_windows = ... ? 1 : 0; ...

Can PAR Packer generate stand-alone scripts?

I'm currently using the PAR Packer (pp) to package a couple of pl scripts such that they can be copied to a machine and "just work" without my client having to muck with CPAN. Unfortunately, the PAR Packer doesn't work for deep dependencies. For example, a script imports CHI::Driver::File but does not explicitly import Log::Any::Adapte...

How can I disable scientific notation when working with very large numbers in Perl?

Consider the following: print 3 ** 333; #Yields 7.6098802313206e+158 My question is simple: How can I disable scientific notation when working with very large numbers? Basically, I'd like to see all the digits dumped to stdout verbatim. Is this possible? ...

How do scripting languages use sockets?

Python, Perl and PHP, all support TCP stream sockets. But exactly how do I use sockets in a script file that is run by a webserver (eg Apache), assuming I only have FTP access and not root access to the machine? When a client connects to a specific port, how does the script file get invoked? Does the script stay "running" for the durat...

How can I preserve whitespace when I match and replace several words in Perl?

Let's say I have some original text: here is some text that has a substring that I'm interested in embedded in it. I need the text to match a part of it, say: "has a substring". However, the original text and the matching string may have whitespace differences. For example the match text might be: has a substring or has a s...

How do I read a file which is constantly updating?

Hi there, I am getting a stream of data (text format) from an external server and like to pass it on to a script line-by-line. The file is getting appended in a continuous manner. Which is the ideal method to perform this operation. Is IO:Socket method using Perl will do? Eventually this data has to pass through a PHP program (reusable)...

How can I use Solaris::Kstat on Solaris 5.10?

Hi, I am looking to find the SunOS system details using Kstat. I have found Solaris::Kstat module in CPAN but this only supports Solaris 2.5.1, 2.6 & 2.7. The Sun developer's site mentions a Sun::Solaris::Kstat which I have not found in CPAN. Can anyone please help me with the Perl scripting to find details from kstat on Solaris 5.10. ...

How can I combine overlapping path segments to get the full path in Perl?

I'm really not loving Perl but I've got to use it for my current task. Here is my problem... I have three strings, that make up elements of a full directory path (windows, but needs to work on *nix too). For example... $root = "c:\\checkout\\omega"; $client = "abc\\mainline"; $build = "omega\\abc\\mainline\\host\\make"; I want to co...

How do I handle exceptions in a procedural language?

How do I do exception handling in a procedural language like C or Perl? (I know Perl also does OO.) What’s the best way to handle exception in procedural code in Perl? ...

How can I access a variable outside a loop when I set in it inside the loop?

I wrote a quick Perl script to query the local DNS servers for an IP address, and I have a variable that needs to be declared within the scope of the loop, but it doesn't seem to be in scope outside of the loop. The compiler is returning the errors Global Symbol "$ipAddr" requires explicit package name Here's the code my $resolver ...

How can I copy and paste a range of tables in Word?

EDIT: If you have an example in VBA, I'll take it. I'm just trying to understand how to use the Range object with the Tables collection to copy and paste multiple tables without looping. Put another way, how can I specify a range of 1..lastTable using the Tables collection? If I can see a working VBA example of this, I'll work on the VBA...

How can I call a Perl class with a shorter name?

I am writing a Perl module Galaxy::SGE::MakeJobSH with OO. I want to use MakeJobSH->new() instead of Galaxy::SGE::MakeJobSH->new(), or some other shortnames. How can I do that? ...