perl

How can I hook into Perl's use/require so I can throw an exception?

If a file is already loaded, is there anyway to hook into the use/require so I can throw an exception? In my upcoming nextgen::blacklist, I'm trying to die if certain modules are used. I'm using the object-hook method as mentioned in perldoc -f require: there are three-like hooks object, array with subref, and subref. The example in this...

How do I make a link to the previous web page in my Perl CGI program?

I have a grid which has a link to next page and I have a button to navigate back to the grid from the current page. Until now I was using this method to navigate back i.e <INPUT TYPE="BUTTON" VALUE="Back to Datagrid" onClick="history.go(-1);"> But I faced some issues navigating when I had some other constraints along with that, s...

Why does XML::LibXML keeps printing errors even when I disable them?

I'm using XML::LibXML to parse a document. The HTML file behind it, has some minor errors, and the parser reports them: http://is.gd/create.php?longurl=http://google.com:15: validity error : ID smallink already defined nal URL was <a href="http://google.com"&gt;http://google.com&lt;/a&gt;&lt;span id="smallink" ...

In Perl, how can I replace only the first character of a string?

I don't know the slightest bit of Perl and have to fix a bug in a Perl script. Given a variable $myvar which contains a string, if the first character is a dot, replace it with "foo/bar". How can I do this? (Bonus points if you can guess the bug) ...

In Perl, how can I use a string as a variable name?

Possible Duplicate: How can I use a variable as a variable name in Perl? Is this doable? I need to change a string into variable. Example: If I have a variable like this: $this_is_test = "what ever"; $default = "this"; $default = $default . "_is_test"; I want $default to take the value of $this_is_test. ...

Why did the date and number formats change when I moved my Perl program from Linux to Windows?

I am moving some scripts from a Linux box to a Windows box, but now any numbers or dates printed have lost their formatting (ie, numbers were rounded to 2 decimal places and dates as June 1 2010..). I am quite new to Perl and cannot work out where they got their formatting from in the first place as there doesn't appear to be anything ...

How to put a filter expression in the URL using Perl?

Hello every1, i have issue regarding Paging using filterexpression. here's the piece of code for filtering : if ( $q->param("Filter") ) { $Id=$q->param('User_Id'); $Name=$q->param('User_Name'); if ($Id ne "" ) { $filterexpression= $filterexpression." UserId like '" .$Id. "%' and...

How can I login and download a file with Perl's WWW::Mechanize?

I'm trying to use Perl's WWW::Mechanize to download a file. I have to login the website before and then, after having validated the form, download the file. The thing is, after hours, I didn't succeed doing what I want. At the end, the script save a file which is not a zip file but a html file with nothing interesting in it. Here is th...

How can I replace the same string several times with different random values in Perl?

I'm using this Perl one-liner (in bash) to successfully replace a string with a random one, in a given file: perl -pi -e "s/replace\ this/`</dev/urandom tr -dc A-Za-z0-9 | head -c64`/g" example.php However, I don't know how to replace several "replace this" with different random strings. ...

Multiple prepared statements disrupt a transaction using DBD::Sybase

In my Perl script, I use DBD::Sybase (via DBI module) to connect to a SQL Server 2008. The base program as below runs without problem: use DBI; # assign values to $host, $usr, $pwd my $dbh = DBI->connect("dbi:Sybase:$host", $usr, $pwd); $dbh->do("BEGIN TRAN tr1"); my $update = $dbh->prepare("UPDATE mytable SET qty = ? where name = ?");...

Netbeans fails to execute perl script when compiling C++ project

I installed Netbeans 6.9.1 with C++ support. I also installed MinGW. When I create a C++ project and run it, I get this: I checked the c++ configuration in Netbeans: (looks good) Perl is installed on my PC under c:\perl I tried reinstalling Netbeans and I tried removing Netbeans and Perl then reinstalled Netbeans. It didn't work ...

In Perl, how can I do 64bit hex/decimal arithmetic AND output full number in HEX as string?

I need to do some arithmetic with large hexadecimal numbers below, but when I try to output I'm getting overflow error messages "Hexadecimal number > 0xffffffff non-portable", messages about not portable, or the maximum 32bit hex value FFFFFFFF. All of which imply that the standard language and output routines only cope with 32 bit value...

How do I know if my Perl module is included under -M?

Is there anyway to tell from inside a module's import {} perl -MFoo -e1 apart from perl -e'use Foo;' and, likewise perl -e'package main; use Foo;' I'm trying to have two distinct behaviors for these two. In the -MFoo syntax, I want the behavoir of oose.pm, but I don't want to have import called in the main namespace. In the othe...

HTML::Treebuilder - Parse between parents

Folks, There is so much info out there on HTML::Treebuilder that I'm surprised I can't find the answer, hopefully I'm not just missing it. What I'm trying to do is simply parse between parent nodes, so given a html doc like this <html> <body> <a id="111" name="111"></a> <p>something</p> <p>something</p> <p>something</p> ...

Perl simulating Net::DBI fetchall_arrayref()

I have to simulate an array as if it was returned from Net::DBI fetchall_arrayref function. Lets say that the SQL query is something like "SELECT data1,data2,data3 from table1 " I have an XML file as <type1> <data1>a</data1> <data2>b</data2> <data3>c</data3> </type1> <type1> <data1>da</data1> <data2>db</data2> <data3>dc<...

What modules does Moose render useless, or are incompatible with modern Perl?

Given these assumptions: Your codebase is using Moose.pm Minor changes in implementations do not warrant having conflicting functionality What modules would you not want to see, by the very fact that Moose does that functionality better? This is for my recently released nextgen::blacklist I'll go first: NEXT SUPER base / parent mix...

How do I get the current date in ISO format using Perl?

What's the most efficient way to get the current date in ISO format (e.g. "2010-10-06") using Perl? ...

linux and perl script input

Alright, some of you might have noticed I've been working on this problem off and on for about 3 weeks. I cannot figure out for the life of me whats going on.. Below is the perl script that saves input from USB card reader which acts like a keyboard. The machine is an embedded system running off of a compact flash drive, using voyage lin...

How can I run a Perl script as root yet still affect user gconf settings

THE NEW QUERY: I am trying to make a unified script that initializes a new Ubuntu install to my liking, it must be run under sudo to install packages, but using gconftool-2 to affect gconf setting relies on the dbus session which is not handled properly by the method of simply changing UID in the script alone. Does someone know how to ma...

fork() and STDOUT/STDERR to the console from child processes

I'm writing a program that forks multiple child processes and I'd like for all of these child processes to be able to write lines to STDERR and STDOUT without the output being garbled. I'm not doing anything fancy, just emitting lines that end with a new line (that, at least in my understanding would be an atomic operation for Linux). F...