perl

Why does Perl complain about barewords in my Win32::OLE script?

#___ FIND LAST ROW/COLUMN WITH DATA my $row = $Sheet1 -> UsedRange -> Find( { What => "*", SearchDirection => xlPrevious, SearchOrder => xlByRows })-> {Row}; Error: Bareword "xlByRows" not allowed while "strict subs" in use. ...

How can I enhance the look of the Perl/TK GUI under Perl 5.004?

I have an application that is built to work on Windows, Linux, and Solaris that uses the Perl/TK GUI. Due to constraints, we are limited to Perl/TK only. Moreover, we are limited to an old Perl/Tk version, 5.00404. I'd like to work within these limitations to make the GUI look as nice and modern as possible. Are there any web-resource...

How do you use sed from Perl?

Hi, I know how to use sed with grep, but within Perl the below fails. How can one get sed to work within a Perl program? chomp (my @lineNumbers=`grep -n "textToFind" $fileToProcess | sed -n 's/^\([0-9]*\)[:].*/\1/p'`) ...

How can I impress people with Perl's capabilities?

I would like to give a presentation for my co-workers that will show off some amazing things that Perl can do, things that would make programmers and non-programmers alike say to themselves, "WHOA you can do that?!" I really want to turn heads, since many are of the mindset that Perl is a dying language, but also be fun and entertaining...

How can I pass data from Perl to Java?

I'm working on some Java <-> Perl interaction. I would like to know what the best way is to pass information from Perl to Java. (Great answers about Perl and Java here and here btw). There's a lot of text and XML(XML::Twig) I'm parsing in Perl, in a script I'm supposed to call from a Java Web App. So I have all this gathered data, and I...

What's the best way to get the last N elements of a Perl array?

What's the best way to get the last N elements of a Perl array? If the array has less than N, I don't want a bunch of undefs in the return value. ...

How can I record changes made during in-place editing in Perl?

I've scripted up a simple ksh that calls a Perl program to find and replace in files. The passed-in arg is the home directory: perl -pi -e 's/find/replace/g' $1/*.html It works great. However, I'd like to output all the changes to a log file. I've tried piping and redirecting and haven't been able to get it work. Any ideas? Thank...

Why do I get wrong results for hmac in Python but not Perl?

I'm trying to compute hmac using sha-512. The Perl code: use Digest::SHA qw(hmac_sha512_hex); $key = "\x0b"x20; $data = "Hi There"; $hash = hmac_sha512_hex($data, $key); print "$hash\n"; and gives the correct hash of 87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cde daa833b7d6b8a702038b274eaea3f4e4be9d914eeb6...

Is there a need for a "use strict" Python compiler?

There exist static analysis tools for Python, but compile time checks tend to be diametrically opposed to the run-time binding philosophy that Python embraces. It's possible to wrap the standard Python interpreter with a static analysis tool to enforce some "use strict"-like constraints, but we don't see any widespread adoption of such a...

How do I raise an event in a PerlNet module?

I’m using PDK 7.3 as a development tool for developing an application using both .NET and Perl. I want to build Perl into an .NET compatible dll and this module can raise an event that a .NET GUI application can handle. I can't find any documentation about it. As far as I know PDK 7.3 does not support implementing delegates. Is this t...

Why does Programming Perl use local (not my) for filehandles?

When I read through Programming Perl, 2nd Edition, Page 51, something confuses me : sub newopen { my $path = shift; local *FH; #not my! open (FH, $path) || return undef; return *FH; } $fh = newopen('/etc/passwd'); My I know, why we are not recommenced to use my? So far, I cannot see anything will go wrong if we use...

What is the best way to deal with time math in Perl?

I am running through two large log files and I want to compare timestamps. I already wrote a Perl script to find the matching log statements, but I need to find the difference in the timestamps. For example, 15:31:19.430888 minus 15:31:19.427763 Are there any good constructs for dealing with time in Perl? I don't want to deal with...

Using Perl, how do I show the context around a search term in the search results?

I am writing a Perl script that is searching for a term in large portions of text. What I would like to display back to the user is a small subset of the text around the search term, so the user can have context of where this search term is used. Google search results are a good example of what I am trying to accomplish, where the cont...

How can I install Perl module without using CPAN.pm?

Is it possible? ...

Why doesn't my variable interpolate correctly when I build up a Mysql query?

I am trying to write a regex expresstion in mysql from a Perl program. I want to have query such as this: WHERE a.keywords REGEXP '[[:<:]]something[[:>:]]' However, in Perl when I make this query I am getting error when concatenating: for($i=0;$i<$count;$i++){ $where = $where . "'[[:<:]]$andkeywords[$i][[:>:]]' "; #errors Wher...

How do I call a Perl script from Excel?

I want to call a Perl script from Excel using VBA. I have used a shell command. I have also used the code below: Function Chk() Dim RetVal RetVal = Shell("C:\Perl\bin\Hello.pl", 1) End Function But the above function doesnt run the file. Is there any error? Is there any other way to call a Perl script or external program using Excel?...

How can I redirect the output from one filehandle into another?

I want to set up a pipeline of processes from within Perl (running on Linux), consisting of two parts run at separate times. Eg: Start the consumer process: open( OUT, "| tar xvf - " ) || die "Failed: tar: $!"; then much later start the producer process: open( IN, "gpg -d $file |" ) || die "Failed: gpg: $!"; but then somehow redi...

How do I write text in aligned columns in Perl?

I am trying to write to a file from Perl. I just want to write the data in tab delimited format. However, the data that I am writing has varying lengths and is not lining up. For example I am trying to write something like this: Name Education Fav_Car MoneyInBank josh High School Porche 500 SomeOtherName PHD Hyundai 50000 ...

Is there a Perl implementation in Java?

Hi, I am looking for Perl implementation in Java. Something like Jython is for Python. I found PLJava but it needs both JVM and Perl compiler installed. I need something which does not need a Perl compiler. I need to run some Perl code in a Java class. UPDATE: I figured out that PLJAVA is what I need. Does anybody know some tutorial?...

Should I escape shell arguments in Perl?

When using system() calls in Perl, do you have to escape the shell args, or is that done automatically? The arguments will be user input, so I want to make sure this isn't exploitable. ...