I am trying to copy all files in one location to a different location and am using the File::Copy module and copy command from that, but now the issue I am facing is that I have file whose name has special character whose ascii value is ý but in unix file system it is stored as ? and so my question is that will copy or move command c...
I'm using this small snippet to determine whether or not a URL is currently being stored in an array:
if( $self->{_local} eq "true" && ! grep {m|^$new_href?$|} @m_href_array ) {
push( @m_href_array, $new_href );
push( @href_array, $new_href );
}
It seems to work but then my code throws an error saying:
Sequence (?$...) not im...
The title pretty much says it all, I am trying to get a java program (.jar file) to run from a Perl program. I read another post on Stackoverflow saying this syntax is correct:
system("java filename.jar");
However this is giving me the following error. I'm not sure if the problem is that it shows the filename as "filename/jar" inste...
Does someone have example in Perl of how I can calculate the broadcast IP from an IP address and netmask?
...
I have a file that contains parameters using this syntax
RANGE {<value> | <value>-<value>} [ , ...]
where value s are numbers.
for example, all these are valid syntax
RANGE 34
RANGE 45, 234
RANGE 2-99
RANGE 3-7, 15, 16, 2, 54
How can I parse the values to an array in Perl?
For example for the last example, I want my array to have...
I'm currently using the following which works but throws an error every time the table is created (as it is first trying to insert into a db which does not exist and returning false).
$result = $dbh->prepare("INSERT INTO `". $host ."` (URL) VALUES ('$href')");
if( ! $result->execute() ){
$result = $dbh->prepare("CREATE TABLE `" . $h...
I'm using WWW::Nechanize to read a particular webpage in a loop that runs every few seconds. Occasionally, the 'GET' times out and the script stops running. How can I recover from one such timeout such that it continues the loop and tries the 'GET' the next time around?
...
I am parsing the XML file and trying to access the values in XML file.
#!/usr/bin/perl -w
use strict;
use XML::Twig;
my $file = 'files/camelids.xml';
print "File :: $file\n";
my $twig = XML::Twig->new();
$twig->parsefile($file);
# print "twig :: $twig\n";
my $root = $twig->root;
# print "root :: $root\n";
my $num = $root->children(...
Best asked by an example:
my $var1=1;
my $var2;
my $var3=3;
# say "at least one undef" if at least one of $var1, $var2, $var3 is undef
Obviously I can explicitly loop and do that, but I always like to find one liners that achieve the same result.
...
I've been knocking up a little pet project the last two days which consists of making a crawler in Perl.
I have no real experience in Perl (only what I have learned in the past two days).
My script is as follows:
ACTC.pm:
#!/usr/bin/perl
use strict;
use URI;
use URI::http;
use File::Basename;
use DBI;
use HTML::Parser;
use LWP::Simple...
I used a Perl helper to code this. It
looks I am missing a character or something.
I need to write the new text to the top of the text file.
open (LOGFILE, ">> complete.txt") ; # writes new to the bottom
$datetime = localtime ;
print LOGFILE "\n" ;
print LOGFILE $datetime\n" ;
print LOGFILE "$name\n" ;
print LOGFILE "Has completed th...
Is there a way I can open a new cmd window and pass a variable and once completed close that window?
I have found some info but not enough that I can get it to work.
system('start "List Perl files" dir c:/dfd/dfdf.pl /B');
Opens window but does not run script.
...
I would like to crawl a website, the problem is, that its full of JavaScript things, such as buttons and such that when they are pressed, they do not change the URL, but the data on the page is changed.
Usually I use LWP / Mechanize etc to crawl sites, but neither support JavaScript.
any idea?
...
For example, to have rschit process excell.exe means Perl.
...
I have been reading some recipes in the Perl Hacks book. Recipe #24 "Query Databases Dynamically without SQL" looked interesting. The idea is to use SQL-Abstract to generate the SQL statement for you.
The syntax to generate a select statement looks something like this:
my($stmt, @bind) = $sql->select($table, \@fields, \%where, \@order...
I'm using the Perl module Mail::Box::Manager to read messages from a Maildir and move them into another directory. Once the script has finishing processing the mail messages in the Maildir it appears to also remove the cur/ and new/ Maildir directories and the Maildir files/directories need to be recreated.
I don't want the script remo...
Considering that XML::Simple is the only module which can be used, I am stuck in retrieving the values from an XML. The structure goes below:
<testxml>
<dev>
<A>
<tables>
<datatables>
<table>a1</table>
<table>a2</table>
<table>a3</table>
...
I am editing a Perl file, but I don't understand this regexp comparison. Can someone please explain it to me?
if ($lines =~ m/(.*?):(.*?)$/g) { } ..
What happens here? $lines is a line from a text file.
...
I have a file and a list of string pairs which I get from another file. I need substitute the first string of the pair with the second one, and do this for each pair.
Is there more efficient/simple way to do this (using Perl, grep, sed or other), then running a separate regexp substitution for each pair of values?
...
I usually use something like
my $dir="/path/to/dir";
opendir(DIR, $dir) or die "can't open $dir: $!";
my @files = readdir DIR;
closedir DIR;
or sometimes I use glob, but anyway, I always need to add a line or two to filter out . and .. which is quite annoying.
How do you usually go about this common task?
...