perl

How to use perl 5.10 features inside the debugger?

Hello, I am unable to evaluate 'modern perl' code inside the perl debugger. It works OK when debugging the code in a file, but not from the prompt. minimal example: # activating 5-10 features with -E (it works) $ perl -E 'say "x"' x # calling the debugger with -E # it works for infile code but for prompt line code... $ perl -dEbu...

How do I modify a datastream on the fly?

Possible Duplicate: modify a datastream on the fly I need to hijack and modify a datastream. The stream consists of fixed-width commands. Each command is a new line, and the documentation says that each command starts and ends with an STX/ETX (start and end of text) pair. The sending system is using serial, but is attacked to...

modify a datastream on the fly

I need to hijack and modify a datastream. The stream consists of fixed-width commands. Each command is a new line, and the documentation says that each command starts and ends with an STX/ETX pair (start and end of text) The sending system is using serial, but is attacked to an iPocket device that communicates over IP to our PBX. Fro...

Compute all element in integer list

let's say you have set of integer in the list. List Declare: @lists = (22, 10, 5, 2); but if I do want all the elements to be divide in let's say 2, is there anyways to do other than manually computing in running loop? Don't want to compute like this: foreach $list (@lists) { print (list/2); } ...

Split and echo into a list

i have a sql table full of address' like this Hattie:07903 000066::Dad:07854 000095::Tom:07903 000044::Allistair:07765 000005::Home:0115 974 0000:: i would like to split each and every one so that the name and number of each contact is echoed into a seprate panel within a listbox like below <ol> <li>Hattie:07903 000066</li> <li>Dad:0...

perl + set value in parameter

With the following example script I try to print the parameter[1] content. My question is how to print also FLORIDA word (in place $VAL) so I will get FLORIDA on print output #!/usr/bin/perl my @parameter = (); my $VAL=FLORIDA; $parameter[1]='45487539 $VAL 5847366 83564566'; print $paramet...

Should a Perl module raise exceptions (die/croak)?

When writing a Perl module, is it a good practice to use croak/die inside the module? After all, if the caller doesn't use an eval block, the module might crash the program calling it. What is the best practice in these cases? ...

Convert UTF8 string into numeric values in Perl

For example, my $str = '中國c'; # Chinese language of china I want to print out the numeric values 20013,22283,99 ...

Benchmarks of scripting languages doing the same task?

This is not a X vs Y question - do not reply as same. Does anyone know where I could find reviews or reports on tasks that people did in two or more high-level scripting languages to see which one was more suited for a certain job? (note that this is different from looking for a language suited for all jobs!) I really want to know which...

Default argument values in subroutines

I have been working with perl for about two months now; it just occurred to me that I don't know how to set default arguments for subroutines. Here is what I considered: sub hello { print @_ || "Hello world"; } And that works fine for if all you needed was one argument. How would you set default values for multiple arguments? I was ...

Perl global replace touches every file - how to stop that ?

I've used this to update every file in a directory perl -pi -e 's/include\s?\(/include_once(/g' *.php It works fine but it seems to modify the access date of every *.php file in the directory - is there a way I can make it only modify the access of date of those files it's actually modified ? ...

How to import Apache access log into MySQL table?

What is the recommended approach to import Apache access log into a MySQL table? I am thinking of a ruby/perl script + a cron job. It'll be great if there is an example or reference. I am not sure how to handle the bookmarking of the last log entry in last import either. Suggestions are welcome. Thanks! ...

creating arrays dynamically in perl

Hi All, I want to create arrays dynamically based on the user input. e.x. If user gives input as 3 then 3 arrays should be created with the name @message1 @message2 @message3. How to do it in perl. Thanks Senthil kumar. ...

Perl max execution time on webserver

How can I set the execution time of a perl skript on a webserver. Is this analog to php in the php.ini "max_execution_time" or is there another way? ...

Solaris /dev/poll support in Perl

Has anyone any experience using /dev/poll (the Solaris equivalent of the Linux epoll method) with Perl, either via a module or directly in their application? There's not much about this subject I can find through Google. ...

Print raw data when using the Curses development kit (Cdk)

My perl program needs to jump between ncurses and a raw console as it executes a system call in a loop, like this (simplified for problem emphasis): init Cdk present menu deinit Cdk run system call Unfortunately Cdk appears to initialize ncurses at the use Cdk import and not instantiation (Cdk::init()) and so I don't know how to di...

Higher level libraries for Sybase::DBLib?

Has anyone written something similar to SQL::Abstract for Sybase::DBLib? in particular, I'm interested in being able to insert a hash of values into a table without manually forming the sql query myself. A big issue in working with sybperl is that SQL::Abstract returns bind values and placeholder SQL, not concrete SQL. The way to creat...

How can I exclude some characters from a class?

Say I want to match a "word" character (\w), but exclude "_", or match a whitespace character (\s), but exclude "\t". How can I do this? ...

Printing and concatenation with Parse::RecDescent

I am testing the grammar from P::RD tutorial in order to develop my own grammar. I haven't figured out how to print a string declaration and append '$' to the front of it. For example "STRING sDir" should print out "$sDir". It is simple enough to just do a $string =~ s/STRING /\$/, but what about the case where there is assignment? eg. "...

Determine user/group ownership for a directory

I have a perl script that will perform some operations on directories, and I only wait it to run on directories for which the current user(e.g. the user executing the script) has ownership. I've tried the following: ... my $user = getlogin(); opendir(HANDLE, $path) or die ("No such directory: $path"); foreach my $directory (readdir HAN...