perl

net::rawip and net::packet cpan modules

which cpan module is more sutiable for packet crafting and injection (net::rawip and net::packet) could someone provide what the cons and pros for everyone one of those modules and when it suitable to use every module ? ...

Perl - How to get the number of elements in an anonymous array, for concisely trimming pathnames

Hi Everyone, I'm trying to get a block of code down to one line. I need a way to get the number of items in a list. My code currently looks like this: # Include the lib directory several levels up from this directory my @ary = split('/', $Bin); my @ary = @ary[0 .. $#ary-4]; my $res = join '/',@ary; lib->import($res.'/lib'); That's ...

XML::LibXML Line Ending (whitespace) Problem.

HI, I am parsing an XML file using LibXML in Perl. The problem that I have is the ending characters (whitespace) is treated as a text node. For instance, given an input like the following <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE books [ <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT year (#PCDATA...

Converting a file to UTF8 format using Perl

How do I convert a file to its utf-8 format using Perl? and how do I check whether the converted file is in utf-8 format? ...

How to transfer binary data through multiple http server?

Well, the question is not intended to be that big. Let me explain the scenario: I have two http servers. server A is accessible to end user by web browser, while server B is internal server which can only be accessed by server A. If server B generate some big jpeg image in local disk, and server A has no way to access server B's filesyst...

Perl equivalent of PHP's preg_callback

Do we have a preg_callback equivalent in Perl ? Lets say I want to match something and replace it with the return value of the function that is called with the matched thing. ...

How can I convert a shell script into a Perl script?

How can I convert a shell script into a Perl script? I have a 10k line shell script and want to convert it into Perl. Is there any tool is doing that, or is there any way to do that? ...

How can I tell if a filehandle is empty in Perl?

For example: open (PS , " tail -n 1 $file | grep win " ); I want to find whether the file handle is empty or not. ...

[PERL Tk] printing Line number in Text widget

I use the following code for printing the line number in a Text widget: my $c = 0; my $r = 0; $txt = $mw->Text( -background => 'white', -width => 400, -height => 300, -selectbackground => 'skyblue', -insertwidth => 5, -borderwidth => 3, -highlightcolor ...

Search and replace

Hi, I have a really large SQL dump around 400MB. It's in the following format, "INSERT INTO user VALUES('USERID', 'USERNAME', 'PASSWORD', '0', '0', 'EMAIL', 'GENDER', 'BIRTHDAY', '182', '13', '640', 'Married', 'Straight', '', 'Yes', 'Yes', '1146411153', '1216452123', '1149440844', '0', picture', '1', '0', '0', 'zip', '0', '', '0', '',...

Perl -check for uninitialized value

I am doing the below in a perl script: my @pm1_CS_missing_months = `sqlplus -s $connstr \@DLmissing_months.sql`; it takes the output of an sql query. if i have to check for no rows selected,how could i do it? i want to do like this: if(no rows selected) { do this; } ...

How can I return a value from a Perl program to a Korn-shell script?

I want to do this in a shell script: #!/usr/bin/ksh PERL_PATH=/usr/local/bin/perl RET1=$(${PERL_PATH} missing_months_wrap.pl) echo $RET1 How do i do it? calling the perl script as above is giving me an error: > shell.sh Can't return outside a subroutine at missing_months_wrap.pl line 269. EDIT: inside the perl script the state...

DBD::CSV: How can I generate different behavior with the two f_ext-options ".csv" and ".csv/r"?

This is from the DBD::File-documentation: f_ext This attribute is used for setting the file extension where (CSV) files are opened. There are several possibilities. DBI:CSV:f_dir=data;f_ext=.csv In this case, DBD::File will open only table.csv if both table.csv and table exist in the datadir. The table will still b...

How do I find out which version of Java I am using Perl?

How do I find out which version of Java I am using Perl programming and using that execute some jar file based on that? ...

How do I use an index in an array reference as a method reference in Perl?

Similar to this question about iterating over subroutine references, and as a result of answering this question about a OO dispatch table, I was wondering how to call a method reference inside a reference, without removing it first, or if it was even possible. For example: package Class::Foo; use 5.012; #Yay autostrict! use warnings;...

How do I retrieve program output in Python?

I'm not a Perl user, but from this question deduced that it's exceedingly easy to retrieve the standard output of a program executed through a Perl script using something akin to: $version = `java -version`; How would I go about getting the same end result in Python? Does the above line retrieve standard error (equivalent to C++ s...

How can I identify the "tokens" (wrong word) of a regular expression

I'm working on a fairly specialized search engine implementation in Perl, it searches (by regex) documents for specifically delimited (a subset of :punct:) strings from a text file. I'm doing the usual search engine indexing tricks, but there's a problem. Some of the search regex patterns include, by necessity, delimiters used in the fi...

How do i make a multi-threaded server in perl?

I have looked online at making a multi-threaded server in perl, but i cannot find any good ones that clearly explain how to create one. I have created a server and client in perl but i do not seem to be able to make it multi-threaded. Can someone help me? ...

Why does my perl server stop working when i press 'enter'?

I have created a server in perl that sends messages or commands to the client. I can send commands just fine, but when i am being prompted for the command on my server i have created, if i press 'enter', the server messes up. Why is this happening? Here is part of my code: print "\nConnection recieved from IP address $peer_address on p...

Keeping track of the Facebook session when navigating pages in iframe-based Facebook applications

I'm working on an iframe-based canvas application and have run into a major roadblock in finding a good way to keep track of the Facebook session when navigating between pages within the iframe. On the first page load, the Facebook page passes all the necessary fb_sig parameters to your callback URL via the query string. On subsequent pa...