perl

Why do I get 'use: command not found' when I run my Perl script?

I'm new to Perl. And I have used following code from one forum to connect to one of the server. but throwing error messages [root@Cus]# cat tt.pl #!/usr/bin/perl use Net::Telnet; $telnet = new Net::Telnet ( Timeout=>2, Errmode=>'die'); $telnet->open('10.0.0.28'); $telnet->waitfor('/login:/'); $telnet->print('administrator'); $telnet->wa...

How can I print N array elements with delimiters per line?

I have an array in Perl I want to print with space delimiters between each element, except every 10th element which should be newline delimited. There aren't any spaces in the elements if that matters. I've written a function to do it with for and a counter, but I wondered if there's a better/shorter/canonical Perl way, perhaps a specia...

How can I add a directory to the Perl library path at the system level?

On a standard linux set up, where can I add a directory to the @INC variable? In the /etc/profile file, I added: export PERLLIB=$PERLLIB:/foo/bar export PERL5LIB=$PERL5LIB:/foo/bar Thanks ...

Is there a Perl wrapper for the Human interface device (HID)?

Does anyone know if there a wrapper library over Human interface device library on Perl? ...

Why can't I pipe the output of uuencode to mailx in a single Perl open statement?

Here's my code that is not working: print "To: "; my $to=<>; chomp $to; print "From: "; my $from=<>; chomp $from; print "Attach: "; my $attach=<>; chomp $attach; print "Subject: "; my $subject=<>; chomp $subject; print "Message: "; my $message=<>; chomp $message; my $mail_fh = \*MAIL; open $mail_fh, "uuencode $attach $attach |mailx...

How can I modify complex command-line argument strings in Perl?

I have a command line that I'm trying to modify to remove some of the arguments. What makes this complex is that I can have nested arguments. Say that I have this: $cmdline = "-a -xyz -a- -b -xyz -b- -a -xyz -a-" I have three different -xyz flags that are to be interpreted in two different contexts. One is the -a context and the othe...

Perl DBI execute not maintaining MySQL stored procedure results

I'm having a problem with executing a stored procedure from Perl (using the DBI Module). If I execute a simple SELECT * FROM table there are no problems. The SQL code is: DROP FUNCTION IF EXISTS update_current_stock_price; DELIMITER | CREATE FUNCTION update_current_stock_price (symbolIN VARCHAR(20), nameIN VARCHAR(150), currentP...

Help with Perl persistent data storage using Data::Dumper

I have been trying to figure this out for way to long tonight. I have googled it to death and none of the examples or my hacks of the examples are getting it done. It seems like this should be pretty easy but I just cannot get it. Here is the code: #!/usr/bin/perl -w use strict; use Data::Dumper; my $complex_variable = {}; my $MEMORY =...

How can I use macros in Perl?

How do I use macros in Perl, like I do in C? Example: #define value 100 print value; I want to get the output as 100. ...

Why does my Perl/Tk button widget size vary with different xterm clients?

I have a Perl/Tk script in which I am creating a button widget of height 1. Now when I execute script through Citrix xterm client I get button displayed. Again when I execute script now through xterm client in my PC size of button widget differs. Can someone explain why is this happening, and what should I do so that size of button widg...

Can my Perl program execute code stored in a database?

Is it possible to save some Perl code in a database then retrieve it using a select statement and then execute that Perl code? I have tried using eval, but that doesn't seem to work. Here is what I'm trying right now and it doesn't seem to work: my $temp = $qryResults[0]; print $temp."\n"; eval{"$temp"}; the output is $con->Disconne...

How can I extract all links from the page excluding one using Perl's WWW::Mechanize?

I'm trying to use WWW::Mechanize to extract some links from the HTML page using find_all_links() method. It supports matching on these criterias: text text_regex url url_regex url_abs url_abs_regex ... How can I extract all links except one that has text "xyz"? ...

How can I integrate advanced computations into a database field?

My biological research involves the measurement of a cellular structure as it changes length throughout the course of observation (capturing images every minute for several hours). As my data sets have become larger I am trying to store them in an Access database, from which I would like to perform various queries about their changes in...

How should I redirect users in a formmail script?

So I'm using a basic formmail script. Within the script I'm using a redirect variable. The value of the redirect is something like: http://www.mysite.com/NewOLS_GCUK_EN/bling.aspx?BC=GCUK&amp;IBC=CSEE&amp;SIBC=CSEE When the redirect action happens however, the URL appears in the browser as: http://www.mysite.com/NewOLS_GCUK_EN/bli...

WebService client libraries for Python and Perl

I want to access web service in Python or/and Perl scripts. What are the most popular and reliable libraries today? I read this question, and I know about SOAPpy and ZSI. Can anybody say something about this libraries? Are they reliable enough for use in production? ...

How can I get the file extensions from relative links in HTML text using Perl?

For example, scanning the contents of an HTML page with a Perl regular expression, I want to match all file extensions but not TLD's in domain names. To do this I am making the assumption that all file extensions must be within double quotes. I came up with the following, and it is working, however, I am failing to figure out a way to e...

How can I sort an array so that certain file extensions sort to the top?

I have an array containing a list of files. I want to sort it in a way that it will let me have .txt files in the beginning of the array and the rest of files after that. This is what I'm doing now, which works fine. @files = (grep(/\.txt$/,@files),grep(!/\.txt$/,@files)); Is there a better way to do it though? ...

How can I implement the Gale-Shapley stable marriage algorithm in Perl?

Problem statement: We have equal number of men and women. Each man has a preference score toward each woman. So do the woman for each man. Each of the men and women have certain interests. Based on the interest, we calculate the preference scores. So initially, we have an input in a file having x columns. The first column is the person...

What is Perl's equivalent to awk's /text/,/END/ ?

I am looking to replace a nasty shell script that uses awk to trim down some HTML. The problem is I cannot find anything in Perl that does the aforementioned function awk '/<TABLE\ WIDTH\=\"100\%\" BORDER\=1\ CELLSPACING\=0><TR\ class\=\"tabhead\"><TH>State<\/TH>/,/END/' How can I do this in Perl? the expected output would be <TABLE...

Is there an SDL module for Perl?

Is there an SDL module for Perl? ...