perl

How do I replace an arbitrary number of backreferences in sed or Perl? (for obfuscating mailto)

I'm looking for a way to obfuscate mailtos in the source code of a web site. I'd like to go from this: href="mailto:[email protected]" To this: href="" onmouseover="this.href='mai'+'lto:'+'pre'+'sid'+'ent'+'@wh'+'ite'+'hou'+'se.'+'gov'"</code> I'm probably going to go with a PHP solution instead, like this (that way I only h...

When were non-capturing parentheses added to Perl's regular expressions?

I am having a hard time figuring out the earliest version of perl where non-capturing parentheses are supported in regex patterns? Can I take this feature for granted for all versions of Perl5? ...

How do I change the UI language on Padre?

I've installed the current version of Padre with Strawberry Perl for 64-bit Windows. My OS is in Portuguese, and the UI language of the Padre IDE is now Portuguese. How do I override the default and change it to English? ...

Extract a line of C code using perl based on filename + line number

Hi, I'm looking to extract a statement of C code given the filename and linenumber where it begins. I can't, of course, just take the line, as I could have something like: foo(i, j, "this is ); \ ", k); as the example indicates, I also can't look for the next ); either, which would make it fairly simple. Is there anything out...

How can I get Perl's Getopt::Long to tell if arguments are missing?

I'm using Perl's Getopt::Long module to parse command line arguments. However, it seems that it returns a true value even if some of the arguments are missing. Is there a way to tell if this is the case? ...

What's the difference between return; and return undef; in Perl

Is there a difference between a subroutine that does return; and one that does return undef; ? ...

How can i count the respective lines for each sub in my perl code?

I am refactoring a rather large body of code and a sort of esoteric question came to me while pondering where to go on with this. What this code needs in large parts is shortening of subs. As such it would be very advantageous to point some sort of statistics collector at the directory, which would go through all the .pm, .cgi and .pl f...

perl cgi | Definition List syntax

Having trouble finding the correct syntax for creating a Definition List via Perl to create output as follows: <dt>One</dt> <dd><p>Testing 1</p></dd> <dt>Two</dt> <dd><p>Testing 2</p></dd> <dt>Three</dt> <dd><p>Testing 3</p></dd> </dl> I can't seem to find any documentation on the usage. I tried $cgi->d...

Matching unknown # of occurrences on a page using perl?

i am parsing an html page, let's say this page lists all players in a football team and those who are seniors will be bolded. I can't parse the file line by line and look for the strong tag because in my real example the pattern is much more complex and span multiple lines. Something like this: <strong>Senior:</strong> John Smith Junio...

Convert ASN.1 to human-readable format

I have ASN.1 format files. I have to convert into CSV(comma separated) format also readable one. Tell me the shortest way... Like Decoders etc. ...

List Operator Precedence in Perl

Hey guys, I'm reading the "Beginning Perl" book, and it gives these two statements: print "Test one: ", 6 > 3 && 3 > 4, "\n"; print "Test two: ", 6 > 3 and 3 > 4, "\n"; The first line prints nothing with a new line, the second line prints a 1 with no new line. I'm confused about the output. According to the author, the second stateme...

Calling Perl script from PHP and passing in variables, while also using variablized perl script name

I normally call perl scripts from PHP as below and pass in variables this way, and it works fine, however now I am building a component for re-use where I want to also variablize the perl script name that I am passing in and this is giving me some headaches, so I am wondering if anyone can point out a better way to do this as my way isn'...

Shell Script to update the contents of a folder.

Hello Everyone, I'm a beginner in Unix Shell Scripting and Perl Scripting. I would like to have an example program that teaches me how to update a file contents on a directory. The scenario is, there is a directory which has some n number of files. Among those n number of files, m number of files have been modified. I need to update t...

Makefile.PL: Installing multiple scripts and binaries

Given a Makefile.PL, how can I install two binaries and two scripts in four different locations? To be more precise, the directory structure is as follows: lib/my_package/main.pl bin/daemon/daemon.pl (*) bin/plugin/plugin.pl (*) scripts/conf/conf.sh (*) scripts/init/initd.sh (*) Makefile.PL The files marked with (*) should be instal...

How can I match everything that is after the last occurence of some char in a perl regular expression?

For example, return the part of the string that is after the last x in axxxghdfx445 (should return 445). ...

Perl: Use s/ (replace) and return new string

In Perl, the operator s/ is used to replace parts of a string. Now s/ will alter its parameter (the string) in place. I would however like to replace parts of a string befor printing it, as in print "bla: ", replace("a","b",$myvar),"\n"; Is there such replace function in Perl, or some other way to do it? s/ will not work directly in t...

Interrupted server-side perl CGI script when client-side browser closes

Hi everyone, I've been trying to solve a little problem for quite a while now but it seems I'm not able to. I wrote an HTML page which calls a perl CGI script upon submitting a form. This CGI executes a certain number of tasks server-side and I made the script print the steps of these tasks into an iframe on the HTML page. The thing i...

Calling a Python module from Perl

Hello: I created a module in Python which provides about a dozen functionalities. While it will be mostly used from within Python, there is a good fraction of legacy users which will be calling it from Perl. What is the best way to make a plug in to this module? My thoughts are: Provide the functionalities as command line utilities a...

How to switch between versions of Perl 5.8 and 5.10 on Mac OS X 10.6 Server and using Apache2

The new Mac Mini Server comes with OS X 10.6 and natively supports (comes with) two versions of Perl and Apple has included these by default for good reason. These can be found under the following directories: /Library/Perl/5.8.9 and /Library/Perl/5.10.0 I also found under /Library/Perl/Updates/5.8.9 and /Library/Perl/Updates/5.10.0. I...

Perl regex syntax generation

This is a follow up to the question posted here: http://stackoverflow.com/questions/3358361/perl-regex-syntax The results from that discussion yielded this script: #!/usr/bin/env perl use strict; use warnings; my @lines = <DATA>; my $current_label = ''; my @ordered_labels; my %data; for my $line (@lines) { if ( $line =~ /^\/(.*)$...