perl

How can I separate a full path into directory and filename?

$a = '/etc/init/tree/errrocodr/a.txt' I want to extract /etc/init/tree/errrocodr/ to $dir and a.txt to $file. How can I do that? (Editor's note: the original question presumed that you needed a regular expression for that.) ...

XML facebook feed

Can I get an XML feed of my personal facebook news? Is there any existing Perl CPAN modules for parsing the XML feed? ...

Local cpan builds

Hi, I'd like to use a home directory specific, non-root directory for stuff I install from cpan. How can I configure it? Normal CPAN configuration tries to install packages into /usr. After adding 'makepl_arg' => q[PREFIX=~/cpan_local], simple packages seem to build, but I cannot build a package that pulls its dependencies - the depende...

regular expression is not working

my $pat = '^x.*d$'; my $dir = '/etc/inet.d'; if ( $dir =~ /$pat/xmsg ) { print "found "; } how to make it sucess ...

How can I find which jobs in a dependency tree can be run in parallel?

Currently, I am using a graph to store the dependencies and then running all of the vertices the don't have any dependencies. This works, but it feels kludgy. Is there a better algorithm or data structure I should be using? #!/usr/bin/perl use strict; use warnings; use Graph; #FIXME: naive implementation, there may be a much better...

How to clean up a string to use as a filename in PERL?

I have a job application form where people fill in their name and contact info and attach a resume. The the contact info gets emailed and the resume attached. I would like to change the name of the file to that it is a combination of the competition number and their name. How can I clean up my generated filename so that I can guarante...

How to print program usage in Perl?

What's the easiest to maintain way of printing a Perl program's usage to stdout? I am looking for heredoc tricks or anything similarly useful. Forget individual successive prints. ...

Using capture buffers in a Perl regular expression stored in a variable.

I am receiving the left and right sides of a regular expression replacement as the arguments to a function. I want my users to be able to use capture buffers, but it doesn't work the way I'm trying to do it. my $string = "This is my string"; $string = regex_replace($string,'is (my) string','$1'); print "$string\n"; sub regex_replace...

Perl paragraph n-gram

Let's say I have a sentence of text: $body = 'the quick brown fox jumps over the lazy dog'; and I want to get that sentence into a hash of 'keywords', but I want to allow multi-word keywords; I have the following to get single word keywords: $words{$_}++ for $body =~ m/(\w+)/g; After this is complete, I have a hash that looks like...

Problem with Curl fetching Ajax Data

I'm trying to get the "Added contacts" on this page: The data is injected with an Ajax call, and I used Wireshark to capture the call which I think gets the data: POST /dwr/call/plaincall/UserActionAPI.getRecentlyTitleChangedContacts.dwr HTTP/1.1 This posts a bunch of variables and a cookie, and so I made a curl call with the followin...

How do I detect if stdout is connected to a tty in Perl?

I'm looking for the Perl equivalent to this Python code: from sys import stdout if stdout.isatty(): print "yes" else: print "no" ...

RegExp get string inside string

Let presume we have something like this: <div1> <h1>text1</h1> <h1>text2</h1> </div1> <div2> <h1>text3</h1> </div2> Using RegExp we need to get text1 and text2 but not text3. How to do this? Thanks in advance. EDIT: This is just an example. The text I'm parsing could be just plain text. The main thing I want to accompli...

How to tell, using Perl, if a windows service is stalled, but still running

I have a problem that probably is not unique, but certainly does not seem to be widely reported. I need a method to ping a windows service that will tell me if it has stalled out, even if windows is reporting that it is running. I would prefer to use have a Perl solution but would accept any solution that someone can come up with. Tha...

Perl Net::FTPSSL, won't connect, timeout or throw errors.

I am trying to use perl's Net::FTPSSL to connect to a host. When I run the script, it hangs and eventually times out on my error logs, but not to the browser. The problem seems to be when creating the new connection. If I use Filezilla to connect, there is a pause/response warning that the host key is unknown. When I 'ok' it in Filez...

Not Able to Set Class' Attributes in Role

Hello all, First off, I'm not really sure how much information is necessary to include because I'm having a really hard time tracing the origin of this problem. I have a Moose role with a subroutine that (along with a few other things) tries to set the attributes for a class like this: $genre = Movie::Genre->new({ genreName => 'Dr...

Perl: simple foreach on hash hands mixed results?

Possible Duplicate: What decides the order of keys when I print a Perl hash? Say I got a simple script to list the contents of a hash from a book: my %hash = ("a" => 1, "b" => 2, "c" => 3, "d" => 4); for my $i (%hash) { print $i . "\n"; } On one computer it lists: c 3 a 1 b 2 d 4 But on another it has it proper (in or...

Why following XPath statement returns all "a" elements?

print $tree->findvalue('//a[1]'); I am using HTML::TreeBuilder::XPath in perl. Now i expect the above statment to return the value of second "a" element but instead it returns the value of all "a" elements in the page. I cant understand Why? ...

How to get dimesions of Excel worksheet in perl?

I need to find how many rows in worksheet have been defined. How can I do this? ...

1 javascript/css issue 2 perl cgi issues

Javascript CSS issue: I am using a textarea box to write to a div. I get the textarea box to do this by using the following javascript: <script type="text/javascript"> function process_input(){ document.getElementById("description").innerHTML = document.getElementById("message").value; return true; } </script> I style...

Where does CPAN install Perl modules in OS X?

Just curious where CPAN installs all the Perl modules by default in OS X. ...