perl

How can I strip escape codes from a string in Perl?

The original string is passed as: FileSystems\/\1K-blocks=5036316, FileSystems\/\Available=3295944, FileSystems\/\Filesystem=/dev/cciss/c0d0p2, FileSystems\/\Use%=32% What I need as an output is: / 1K-blocks=5036316, / Available=3295944, / Filesystem=/dev/cciss/c0d0p2, / Use%=32% but trying to delete the '\' with a regex is giving ...

perl plotting for multiple datasets in .csv file

Hi, I have a .csv file with the following data.(I open CSV file as comma separated file) file1 date1 1 76.09 date10 10 87.09 date11 11 89.89 date2 2 66.5 date3 3 78.89 date4 4 87.98 date5 5 57 date6 6 57.98 date7 7 34.32 date8 8 45.76 date9 9 34.99 file2 date...

Perl: using variable in substitution

Possible Duplicate: How to use a variable in the replacement side of the Perl substitution operator? I would like to do something like $sub = "\\1"; $match = "hi(.*)"; $str = "hi1234" $res = $str; $res =~ s/$match/$sub/g I would like this to return 1234 but in this case it returns \1. I.e. I want it to be equivalent to s/$m...

Catalyst create schema can't connect but I can

So I can connect with (obviously I replaced all the real values) mysql -u username -p -h db.dbhostname.com dbname But when I run Catalyt's create script I get ./script/dasgift_create.pl model DB DBIC::Schema MyApp::Schema create=static components=TimeStamp dbi:mysql:dbname:db.dbhostname.com username p@55w0rd DBIx::Class::Schema::Load...

Good compilers for compiling perl/python/php scripts into linux executables?

I am working on a project that requires reading text files, extracting data from them, and then generating reports (text files). Since there are a lot of string parsing, I decided to do it in Perl or Python or PHP (preference in that order). But I don't want to expose the source code to my client. Is there any good compiler for compiling...

What are examples how to use Email::Stuff?

I have read about Email::Stuff and came across some of the example on the net. All the examples then haven't created the object. They straight go away like this: Email::Stuff->to('Simon Cozens<[email protected]>') ->from('[email protected]') ->text_body("You've been a good boy this year. No coal for you.") ...

Parallel computing in Perl

I want to parse through a 8 GB file to find some information. This is taking me more than 4 hours to finish. I gone through perl Parallel::ForkManager module for this. But it doesn't make much difference. What is the better way to implement this? The following is the part of the code used to parse this Jumbo file. I actually have list ...

Perl splitting text string (from HTML page, text document, etc.) by line into array?

This is kind of a weird question, at least for me, as I don't exactly understand what is fully involved in this. Basically, I have been doing this process where I save a scraped document (such as a web page) to a .txt file. Then I can easily use Perl to read this file and put each line into an array. However, it is not doing this base...

Assigning multiple values in perl, trouble with undef

I want to return several values from a perl subroutine and assign them in bulk. This works some of the time, but not when one of the values is undef: sub return_many { my $val = 'hmm'; my $otherval = 'zap'; #$otherval = undef; my @arr = ( 'a1', 'a2' ); return ( $val, $otherval, @arr ); } my ($val, $otherval, @arr) ...

Emacs CPerl mode: bug in indent-region

I edit my Perl scripts in Emacs, using CPerl mode. But the Emacs function indent-region is broken in that mode. If I have a variable: my $num_elements; it becomes my $num_ elements; It's very annoying, especially since I am used to using underscores in variable names, and I press the keyboard shortcut for indent-region all the tim...

Code that finds missing files in a series

Hello, I'm looking for a line of code that identifies missing files in a series of files and exports that list to a txt file. For example: a directory called 1to100000 contains pdfs named 1,2...99999,100000 but is missing some from the series. I would like the script to report those missing files to a txt file. Ideally this would be an ...

Socket programming in Perl

What is the best way to receive data from a socket in Perl, when the data length is unknown? Right now, I read one character at a time in a loop, until I reach the '\0' character. Is there a better way to do this? ...

How to extract email address from a string using perl?

How to extract emails address from a string using perl and to put the email addres into a variable? My strings looks like Ben Tailor <[email protected]> [email protected], [email protected], Ben Tailor <[email protected]> I tryed this $string ="Ben Tailor <[email protected]>"; $string =~ /\b([^\s]+@[^\s]+)\b/g ; print $string;...

Which one is good practice, a lexical filehandle or a typeglob?

Some say we should use a lexical filehandle instead of a typeglob, like this: open $fh, $filename; But most Perl books, including The Llama Book, use a typeglob, like this: open LOGFILE, $filename; So what are the differences? Which one is considered a better practice? ...

How to see progress when parsing large XML file with XML::Parser?

I'm using following code to parse rather large xml file (> 50GB): use XML::Parser; my $p = new XML::Parser( 'Handlers' => { 'Start' => \&handle_start, 'End' => \&handle_end, 'Char' => \&handle_char, } ); $p->parsefile( 'source.xml' ); ... sub handle_start { ... } The problem is tha...

what is the best programming language for selenium?

I am planning to learn selenium, what would be the best language to learn along with selenium? Perl or Ruby or others? ...

Compiling a perl script to a .exe

Possible Duplicates: How can I compile my Perl script so it can be executed on systems without perl installed? How can I package my Perl script to run on a machine without Perl? what is the best way to accomplish this. I have been using the activestate add on for the komodo IDE, but my license expired and now I am trying to ...

web automation from perl

Hi, I am looking for a web page automation tool in Perl. I want to be able to drive different browsers like IE, firefox etc from my test script. I have to automate a product web page with lots of input fields and loads of javascript. I do not want a custom browser like mechanize does. I used to work with Ruby before and there I used W...

perl regexp replace string with a substring of the regular expression

Hello I have a question concerning perl. Assume I have the following line in my file: DoMatchLong ( "ThisIsMyVariable", lThisIsMyVariable); I want to replace "ThisIsMyVariable" by cp_const_ThisIsMyVariable So my aim is: DoMatchLong ( cp_const_ThisIsMyVariable, lThisIsMyVariable); $count = s/(?<=")\w+(?=")/const_cmd_cp_$&/gx; lea...

sort perl numeric array

Hi, I have an array which looks like this: array[0]: 6 8 array[1]: 12 9 6 array[2]: 33 32 5 array[3]: 8 6 What I want to do is to sort this array that it looks like this: array[0]: 6 8 array[1]: 6 9 12 array[2]: 5 32 33 array[3]: 6 8 I know I can sort the array with @newarray = sort {$a cmp $b} @array;, but I need to sort the eleme...