I have list of catalog paths and need to filter out some of them. My match pattern is in a non-Unicode encoding.
I tried the following:
require 5.004;
use POSIX qw(locale_h);
my $old_locale = setlocale(LC_ALL);
setlocale(LC_ALL, "ru_RU.cp1251");
@{$data -> {doc_folder_rights}} =
grep {
# catalog path pattern in $...
I get this error from my CGI script:
my_circle.pl: [FormBuilder] Warning: metro: No options specified for 'select' field at /home/ecoopr/ecoopr.com/CPAN/CGI/FormBuilder.pm line 1407, referer: http://kkarnam.ecoopr.dyndns.org:880/home.pl
Can you suggest me what might be the problem?
...
How can I tar multiple directories and also append files with some pattern like '.txt' and exclude some directories and exclude some patterns like '.exe' all into a single tar file. The main point is the number of directories are unknown(dynamic), so I need to loop through I guess?
...
I was performing a code review for a colleague and he had a regular expression that looked like this:
if ($value =~ /^\d\d\d\d$/) {
#do stuff
}
I told him he should change it to:
if ($value =~ /^\d{4}$/) {
#do stuff
}
To which he replied that he preferred the first for readability (I find the second more readable, but that'...
I'm writing a Perl script that reads data from the infamous /dev/input/event* and I didn't find a way to translate the key codes generated by the kernel into ASCII.
I'm talking about the linux key codes in this table here and I can't seem to find something that would help me translate them without hardcoding an array into the script. ...
I just saw some code in our code base (and it's OLD code, as in Perl 3 or Perl 4 days) that looks like this (I'm simplifying greatly):
@array;
push( array, $some_scalar );
Notice that the array in the push() doesn't have an @. I would assume that the code behind push knows that the first argument is supposed to be array so grabs th...
Write a function that returns the first non-repeating character in a string. Example: “Thanks for visiting" returns "h".
...
Your task, should you choose to accept it, is to write a Perl regular expression that for a given string, will return the first occurence of a character that is not consecutively duplicated. In other words, both preceded AND succeeded by characters different from itself (or start/end of string respectively).
Example:
IN: aabbcdecc
OUT:...
HI, I'm completely new to Bash and StackOverflow.
I need to move a set of files (all contained in the same folder) to a target folder where files with the same name could already exist.
In case a specific file exists, I need to rename the file before moving it, by appending for example an incremental integer to the file name.
The exte...
How can I write a Perl script that would scrape out sentences that mention 'Calvein Klein' in articles in a file named by $file? (Sentences can cross zero or more CR/LF characters.) I want to create an array of sentences scraped and print it at the end.
...
Why to use factory to wrap a constructor in Perl? An example would help.
...
So I'm familiar with the fields pragma in Perl that can be used to restrict the fields that are stored in a class:
package Fruit;
use fields qw( color shape taste );
sub new {
my ( $class, $params ) = @_;
my $self = fields::new( $class ) unless ref $class;
foreach my $name ( keys %$params ) {
$self->{ $name } = $params->{ $na...
I have a hosts file that looks like this:
10.10.10.1 myserver1 myserver1alias
10.10.10.2 myserver2 myserver2alias
I'm looking for a way using perl to pass in an argument of myserver1 and have it return myserver1alias, likewise if I pass in myserver2 it should return myserver2alias. Any suggestions?
...
I have an interesting problem. I wrote the following perl script to recursively loop through a directory and in all html files for img/script/a tags do the following:
Convert the entire url to lowercase
Replace spaces and %20 with underscores
The script works great except when an image tag in wrapped with an anchor tag. Is there a wa...
I have a problem when I use Apache::DBI in child processes. The problem is that Apache::DBI provides a single handle for all processes which use it, so I get
DBD::mysql::db selectall_arrayref
failed: Commands out of sync; you
can't run this command now at
/usr/local/www/apache22/data/test-fork.cgi
line 20.
Reconnection does...
I have two Perl files: action.pl and the other is test.pl
action.pl has a form:
print $cgi->header, <<html;
<form action="test.pl" method="post">
html
while (my @row = $sth->fetchrow)
{
print $cgi->header, <<html;
ID:<input name="pid" value="@row[0]" readonly="true"/><br/>
Name: <input name="pname" value="@row[1]"/><br/>
Description : ...
Is it possible to extract the nth match in a string of single-quoted words?
use strict;
use warnings;
my $string1 = "'I want to' 'extract the word' 'Perl','from this string'";
my $string2 = "'What about','getting','Perl','from','here','?'";
sub extract_quoted {
my ($string, $index) = @_;
my ($wanted) = $string =~ /some_regex...
Hi,
I want to use the SVN::Client cpan module to check out code from a repository.
But how to install and use this module? The documentation is kind of no existing.
I have tried install the Alien::SVN module both through cpan and build it myself.
And it seems to install okay. No error messages, and when i go into cpan again and do the...
Data is put into a MYSQL DB in the following format:
| 2010-03-18 | 1.580 | 1.590 | 1.560 | 1.580 | 164500 | 1.580 |
| 2010-03-19 | 1.570 | 1.570 | 1.560 | 1.570 | 178300 | 1.570 |
| 2010-03-22 | 1.550 | 1.560 | 1.540 | 1.560 | 309000 | 1.560 |
| 2010-03-23 | 1.560 | 1.560 | 1.550 | 1.550 | 284900 | 1.550 |
I need to se...
Possible duplicate:
http://stackoverflow.com/questions/2548835/renaming-and-moving-files-in-bash-or-perl/2548919#2548919
I'm kinda newbie to perl and looking for a script that will handle file moving.
#!/usr/bin/perl -w
$filename = 'DUMBFILE';
$destination = '/some/location/';
if (-e $destination + $filename) {
print "File Ex...