perl

Is there a Perl equivalent to the null coalescing operator (??) in C#?

I started to really like C#'s ?? operator. And I am quite used to the fact, that where there is something handy in some language, it's most probably in Perl too. However, I cannot find ?? equivalent in Perl. Is there any? ...

Binding values to functions in Perl

I am using a hash table similar to the following to store the letters that can be entered at a prompt along with that option's description and the function that will be called. my %main_menu = ( "l" => ["list locks", \ menu_prompt(\%main_menu) produces the following menu: ________________________ | l - list locks | | n ...

How do I stop Eclipse (EPIC Perl) from adding DOS CR/LF to my Perl scripts?

I use Eclipse on Windows to edit files on a remotely mounted Linux SMB share. Coupled with Samba's stubborn opposition to on-the-fly mapping, Eclipse's insistence on CR/LF creates a real headache with Perl scripts. Any workarounds? ...

How can I match "/*" in a regular expression?

Hello all. $stuff = "d:/learning/perl/tmp.txt"; open STUFF, $stuff or die "Cannot open $stuff for read :$!"; while (<STUFF>) { my($line) = $_; # Good practice to always strip the trailing chomp($line); my @values = split(' ', $line); foreach my $val (@values) { if ($val == 1){ print "1 found"; ...

How can I automate and share sessions between Firefox and Perl?

Is it possible to do part of a web flow in Perl and then transfer the rest of the session to Firefox? I need to retry(with Perl) logging in to a website which returns 500 every now and then on a successful login, transfer the authenticated session to Firefox, from where I can continue my normal browsing. Is this possible? If this is poss...

How can I break apart fixed-width columns in Perl?

Programming is so new to me that I apologize for not knowing how to phrase the question. I have a Perl script that gets a variable from an internal tool. This isn't always what it looks like, but it will always follow this pattern: darren.local 1987 A Sentence1 darren.local 1996 C Sentence2 darren.lo...

What's a free Perl IDE for Windows?

I am looking for a Windows Perl IDE with debugger like Komodo but free. I have seen Eclipse+EPIC but I don't want to install Eclipse here . Padre doesn't have debugger built in. ...

How do I check if a user is authenticated with NickServ using POE::Component::IRC::State in Perl?

I'm trying to test whether a user is registered on FreeNode. nick_info() doesn't seem to return information about this, so I want to use $irc->yield(whois => $nick); and then grab the irc_whois event's reply. The problem is that I want to wait until this event is fired, so I created a global variable $whois_result and wrote a sub like th...

How can I generate non-repetitive random 4 bytes hex values in Perl?

I want to generate random hex values and those values should not be repetitive and it should be of 4 bytes (ie: 0x00000000 to 0xffffffff) and the display output should contain leading zeros. For example: if I get the value 1 it should not represented as 0x1 but 0x00000001. I want a minimum of 100 random values. Please tell me: how ...

Splitting a String into Tokens and Storing the Delimiters in Perl

I have a string like this: a b c d I process my string like this: chomp $line; my @tokens = split /\s+/, $line; my @new_tokens; foreach my $token (@tokens) { push @new_tokens, some_complex_function( $token ); } my $new_str = join ' ', @tokens; I'd like to re-join the string with the origi...

How can I get started with Perl 6?

Could someone provide a link of material where to start with Perl 6? Also could someone point to real application already developed with Perl 6? ...

Why can't Perl launch telnet under Windows?

I had enabled telnet client feature on Windows 2008, and tried to launch it from a Perl script: perl -e "system('c:\windows\system32\telnet localhost')" Then I got an error like this: 'c:\windows\system32\telnet' is not recognized as an internal or external command, operable program or batch file. I could run it from 'cmd' terminal...

How can I uninstall an application in Windows using Perl?

Is it possible to uninstall an application in windows using a Perl script? ...

How can I use Perl to start a Win32 program and redirect its output to stdout?

I have a cross-platform Perl program that starts a win32 windows program on win, and a macosx appliaction on the mac. I use system(), which on the mac makes the stdout of the invoked program, be written in the stdout of the Perl program, which is what i want. On Windows, it seems like there is no way to get the stdout a Windows program...

How can I read the URL-Data send with POST in Perl?

I'm trying to read out the POST-Data that was sent from a form in a page to my Perl Script. I googled and found out that: read(STDIN, $param_string, $ENV{'CONTENT_LENGTH'}) reads out the whole Data-String with and writes the whole string to $param_string in the form of Param1=Value1&Param2=Value2&Param3=Value3 by spliting it at the...

Where should I put the ack configuration file on Windows?

I'm using ack (the grep replacement) on Windows XP under Strawberry Perl. Where should the .ackrc config file be placed, since ~/.ackrc is not reasonable on Windows? ...

What is an easy way to read a sql server table into a hash in Perl?

I'd like a simple perl script / sub to read a sql server table into a hash, does anyone have a good script or snippet (with 'use's) that can do this given a connection string and table name? Here's a template: sub sqltable { my ($connStr,$table) = @_; my ($user, $password, $host) = ($connectstr =~ m|^(.*)/(.*)@(.*)$|); ...

How do I write an HTTP server in Perl?

Is there a webserver or HTTP server module in the Perl standard library or in CPAN or elsewhere? I guess I'm looking for the equivalent of Python 3's http.server module. Thanks! ...

What characters are valid in hash keys?

As per subject: what are the characters that can be used in hash keys or, if it's shorter, which ones can't be used? Also, are there any problems in using long hash keys (like full path names)? ...

How can I fetch the last row I inserted using DBI?

How can I fetch the last row that was inserted using DBI (DBD::mysql)? Code sample: my $sth = $dbh->prepare('INSERT INTO a ( x, y, z ) VALUES ( ?, ?, ? )'); $sth->execute( $x, $y, $z ); How can I get access to the data that was inserted by the above prepare statement? I need to get the primary ID (AUTOINCREMENT) value. UPDATE: From...