I need to generate a list of IP-addresses (IPv4) in Perl. I have start and end addresses, for example 1.1.1.1 and 1.10.20.30. How can I print all the addresses inbetween?
I'm doing some web scraping using perl's LWP. I need to process a set of URLs, some of which may redirect (1 or more times).
How can I get ultimate url with all redirects resolved, using HEAD method ?
I have this warning every time I run my CGI-script (output is rendered by Template::Toolkit):
Wide character in print at /usr/local/lib/perl5/site_perl/5.8.9/mach/Template.pm line 163.
What's the right way to eliminate it?
I create the tt object using this config:
my %config = (
ENCODING => 'utf8',
INCLUDE_PATH => $ENV{TEMPLATES_DIR},
EVAL_PERL => 1,
}
my $tt = Template->new(\%config);
I have a web scraping application, written in OO perl. There's single WWW::Mechanize object used in the app. How can I make it to not fetch the same url twice, i.e. make the second get() with the same url nop:
my $mech = WWW::Mechanize->new();
my $url = 'http:://google.com';
$mech->get( $url ); # first time, fetch
$mech->get( $url ); # same url, do nothing
I'm coming from perl, and reading Python module and program documentation causes me frustration. Perl modules usually have flowing and descriptive documentation. While python docs seem to have no flow at all. Could you give some advices for using python docs?
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"?
I have a config file which has sorted lines. After I add new lines somewhere in the file, I usually type ggvG :sort. Is it possible to make vim do this automatically when I close the file?
I have a shell script like this:
cat file | while read line
do
# run some commands using $line
done
Now I need to check if the line contains any non-whitespace character ([\n\t ]), and if not, skip it.
How can I do this?
After moving my mod_perl site from Linux hosting to FreeBSD, I have this error in the logfile:
Your vendor has not defined POSIX macro SIGRTMIN, used at ../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/SigRt/_init.al) line 993\n
The script just imports POSIX and utilizes some functions (ceil, etc)
How can I solve this issue ?
I have a test script like this:
package Test;
sub new { bless {} }
sub DESTROY { print "in DESTROY\n" }
package main;
my $t = new Test;
sleep 10;
The destructor is called after sleep returns (and before the program terminates). But it's not called if the script is terminated with Ctrl-C. Is it possible to have the destructor called in this case also?
I want to put custom scripts/programs in ~/bin on few machines under version control (repository is on a remote server). In the bin/ folders I have many perl/sh/bash scripts, as well as small .c programs. What layout would you use for such repo?
I need to compare two strings, containing HTML text. The test should return true if the html strings are equivalent, i.e. differ only in whitespace and comments.
Is there any module that can be used for this task?