perl

How can I download link targets from a web site using Perl?

I just made a script to grab links from a website, and in turn saves them into a text file. Now I'm working on my regexes so it will grab links which contains php?dl= in the url from the text file: E.g.: www.example.com/site/admin/a_files.php?dl=33931 Its pretty much the address you get when you hover over the dl button on the site...

In Perl, what is the difference between if (%hash) and if (defined %hash)?

What is difference between if (%hash) and if (defined %hash)? my %hash ; if ( %hash) { print "defined "; } if (defined %hash) { print "defined "; } ...

how can i compare two text files which has multiple fields in unix

i have two text files file 1 number,name,account id,vv,sfee,dac acc,TDID 7000,john,2,0,0,1,6 7001,elen,2,0,0,1,7 7002,sami,2,0,0,1,6 7003,mike,1,0,0,2,1 8001,nike,1,2,4,1,8 8002,paul,2,0,0,2,7 file 2 number,account id,dac acc,TDID 7000,2,1,6 7001,2,1,7 7002,2,1,6 7003,1,2,1 i want to compare those two text files. if the four col...

using sed in perl

Hi , I have a file with the following entries --INFO----- Command processing: Name='shayam' Age='19' Project='Alwa' --ERROR---- Failed to process --INFO----- Command processing: Name='ram' Age='23' Project='Alwa' --INFO----- Command processing: Name='raja' Age='24' Project='Alwa' --INFO----- Command processing: Name='shyla' Ag...

How to wait for a certain period of time in Perl on Linux

I want a Perl script to check a certain PID every couple of minutes and then kill the process. How do I wait those couple of minutes? Thanks. ...

Why am I being warned about the use of an uninitialized value in the following Perl script?

I am trying to cut down the number of ports printed in this list: A.B.C.D 80,280,443,515,631,7627,9100,14000 to the ones that are most interesting for me: A.B.C.D 80,515,9100 To do this, I am using this bit of code: foreach (@ips_sorted) { print "$_\t"; my $hostz = $np->get_host($_); my $port = 0; my $output = ...

Convert number to base26 column string for excel. lang perl

Possible Duplicate: How to convert a column number (eg. 127) into an excel column (eg. AA) How convert number to base26 column string for excel. lang perl ...

How do I call a Python/Perl script in bin folder from a Bash script?

I previously used to copy Python/Perl scripts to access from my bash script. Duplication is not a good idea I know! Is there a way to call them from bin or libs folder that we have set up? For instance : My python script resides in /home/ThinkCode/libs/python/script.py My bash script resides in /home/ThinkCode/NewProcess/ProjectA/run...

What module can I use to parse RSS feeds in a Perl CGI script?

I am trying to find a RSS parser that can be used with a Perl CGI script. I found simplepie and that's really easy parser to use in PHP scripting. Unfortunately that doesn't work with a Perl CGI script. Please let me know if there is anything that's easy to use like simplepie. I came across this one RssDisplay but I am not sure about th...

extracting text from HTML (Perl)

I'm doing a script that enters a page and extract and extract information from it. The script I'm doing it in Perl. Problem: Not how to start running the script because when I start it picks up the url like this and this is not what I want <a href="http://valeptr.com/scripts/runner.php?BA=6672&amp;amp;hash=08c5c66839a468a11b7574e6ce02e...

How can I specify StrictHostKeyChecking=no while creating a Net::SSH:Expect object?

Something like: my %options = ( debug => 1, options => ["ConnectTimeout 3","StrictHostKeyChecking no",], ); # Making an ssh connection with user-password authentication # 1) construct the object my $ssh = Net::SSH::Expect->new ( host => $address, password=> 'password', user => 'admin', raw_pty => 1, log...

perl if-then-else logic and how to handle no data if regex doesn't match

So far, I have some working code that goes into a list of servers and does some regex to grab data from a log file. What I want to do is to pring out a status of "NOTHING TO REPORT FOR THIS SERVER" if there is NO data to capture from the regex on a particular server. Right now, it goes through each server and if data matches the regex,...

What is the Perl equivalent of the 'mv' system command?

I have the below "system command" for moving the file. Is it good to use File::Move command or the use the below one. In case if File::Move is better, how can I use it? system("mv $LOGPATH/test/work/LOGFILE $LOGPATH/test/done/$LOGFILE") == 0 or WriteLog(ERROR, "mv command Failed $LOGPATH/test/work/$LOGFILE status was $?"); ...

Download files with Perl

I have updated my code to look like this. When i run it though it says it cannot find the specified link. Also what is a good way to test that it is indeed connecting to the page? #!/usr/bin/perl -w use strict; use LWP; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $browser = LWP::UserAgent->new; $browser->credentials( ...

How can I remove leading and trailing whitespaces from array elements?

I have a array that contains string which may contain whitespaces appended to the end. I need to remove those spaces using perl script. my array will look like this @array = ("shayam "," Ram "," 24.0 "); I need the output as @array = ("shayam","Ram","24.0"); I tried with chomp (@array). It is not working with the s...

How do I edit a previously setup webpage with Template Toolkit

I am trying to edit a bugzilla page and was going to use template toolkit (on windows) for this as I am making quite a few changes. I am new to perl and template toolkit. I have looked at the manuals and tutorials for template toolkit but I seem to be missing the initial step. i.e. how to open an existing file for example "create.html.tm...

Showing progress whilst running a system() command in Perl

I have a Perl script which performs some tasks, one of which is to call a system command to "tar -cvf file.tar.....". This can often take some time so I'd like the command line to echo back a progress indicator, something like a # echoing back to screen whilst the system call is in progress. I've been doing some digging around and stum...

string.find using directory path in Lua

Hello, I need to translate this piece of code from Perl to Lua open(FILE, '/proc/meminfo'); while(<FILE>) { if (m/MemTotal/) { $mem = $_; $mem =~ s/.*:(.*)/$1/; } elseif (m/MemFree/) { $memfree = $_; $memfree =~ s/.*:(.*)/$1/; } } close(FILE); So far I've written ...

How can I specify a transparent background using Perl and Curses?

I am trying to get the background the standard terminal color instead of black but I can't seem to figure it out. When I use use_default_colors() the standards is just like not using colors but I would like to change the foreground color and not the background color. I use init_color_pair(1, COLOR_RED, COLOR_BLACK); but that gives me a b...

.htaccess headache with perl script?

Trying to get a simple test perl script working. Have the following files/folder structure on a shared hosting service: ~/public_html/ .htaccess ~/public_html/lookup Permissions: "drwxrwxrwx 2 myusername myusername" .htaccess lookup.pl* Permissions: "-rwxr-xr-x myusername myusername" The first .h...