comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
October 2006
motuwethfrsasuw
      1 39
2345678 40
9101112131415 41
16171819202122 42
23242526272829 43
3031      44
2006
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.perl.misc Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Regular Expression Question Why Doesn't this Match?         


Author: jm
Date: Oct 31, 2006 19:51

/([\w\s\.\'\-]*)

does not match this:

My Fictional Co.

But it does match

Product by abc company

I don't understand why it matches the second one, but not the first.
Doesn't my expresionsay match anything that has a word, space, dot,
apostrophe, or a hyphen, one or more times? Thefirst one has a . in it
and it should work. It does work on others like:

Dr. Smith's

Thank you for any help.
7 Comments
  FAQ 4.45 How do I find the first array element for which a condition is true?         


Author: PerlFAQ Server
Date: Oct 31, 2006 18:03

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.45: How do I find the first array element for which a condition is true?

To find the first array element which satisfies a condition, you can use
the "first()" function in the "List::Util" module, which comes with Perl
5.8. This example finds the first element that contains "Perl".

use List::Util qw(first);

my $element = first { /Perl/ } @array;

If you cannot use "List::Util", you can make your own loop to do the
same thing. Once you find the element, you stop the loop with last.

my $found;
foreach ( @array ) {
if( /Perl/ ) { $found = $_; last }
}
Show full article (2.21Kb)
no comments
  Abysmal performance of Net::SFTP (and I have GMP & Pari)         


Author: usenet
Date: Oct 31, 2006 17:30

Greetings.

I am having terrible problems with very poor performance when using
Net::SFTP. Specifically, it takes about 10 seconds for a machine to
transfer a 1 MB file to itself (localhost), and this is a brand new,
very FAST, lightly loaded server (and I can replicate this problem on
other machines as well). Using ordinary FTP takes 0.4 seconds, and
doing the same thing with commandline sftp completes the task in the
blink of an eye.

I ***DO*** have Math::GMP::BigInt installed (as well as
Math::Pari::BigInt), and a diagnostic dump of %%INC indicates these are
being called (see below). Enabling SFTP debug mode shows that I am not
experiencing any long pauses (ie, I get a handle in 0.8 seconds, and
transfers occur at a steady - though slow - pace without any pauses).

It is doubtful that I have the option to use Net::SSH2 (because the
servers do not have libssh2 and I probably won't be able to do anything
about that). I really need to figure out why Net::SFTP is behaving so
poorly. I really appreciate any insight anyone can offer.

Here is my test script:
Show full article (5.61Kb)
9 Comments
  Mailbox-style directory hashing         


Author: s1037989
Date: Oct 31, 2006 15:40

I whipped up this quick and ugly script and I wanted to post it for
code review and others' benefit.

With an array such as:
qw(aaaa aaab aaac bbbb bccc bcdd bcee bcff cccc dddd)

The program returns:
# perl list2fs.pl 2
/a/aa/aaa/aaaa/aaaa
/a/aa/aaa/aaab/aaab
/a/aa/aaa/aaac/aaac
/b/bb/bbbb
/b/bc/bcc/bccc
/b/bc/bcd/bcdd
/b/bc/bce/bcee
/b/bc/bcf/bcff
/c/cccc
/d/dddd
Show full article (2.45Kb)
7 Comments
  Use of uninitialized variable with print << HTMLEND (and $ENV)         


Author: kevinwhite
Date: Oct 31, 2006 14:28

I am trying to fix some code I inherited, and there are many warnings I
would like to clean up. The biggest offenders are as follows:

print <<"HTMLEND"; #<= this causes an uninitialized variable warning...


HTMLEND

The second example is:
my $htmlfile = "";
my $hide = "";

$htmlfile = param('filename');
$hide = param('hide') || "no"; #<= what does this do?

if ($htmlfile eq "default.html") #<= this causes an uninitialized
variable warning...
{ #do some stuff
}

The third problem I have is printing environment variables when I have
"use strict" enabled. What is the legal way to do this?
Show full article (0.87Kb)
6 Comments
  FAQ 4.26 How do I reformat a paragraph?         


Author: PerlFAQ Server
Date: Oct 31, 2006 12:03

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.26: How do I reformat a paragraph?

Use "Text::Wrap" (part of the standard Perl distribution):

use Text::Wrap;
print wrap("\t", ' ', @paragraphs);

The paragraphs you give to "Text::Wrap" should not contain embedded
newlines. "Text::Wrap" doesn't justify the lines (flush-right).

Or use the CPAN module "Text::Autoformat". Formatting files can be
easily done by making a shell alias, like so:

alias fmt="perl -i -MText::Autoformat -n0777 \
-e 'print autoformat $_, {all=>1}' $*"

See the documentation for "Text::Autoformat" to appreciate its many
capabilities.

--------------------------------------------------------------------
Show full article (1.70Kb)
no comments
  max # of threads         


Author: gmlvsk2
Date: Oct 31, 2006 12:01

i use ver 5.8.8 on linux.
2 gig of memory
Running this example perl dies after 295 threads.
JVM lets me create tens of thousands.
Is perl so limited when it comes to threads?

test script---------------------------
use strict;
use threads;

for(my $i=0; ; $i++){
threads->new(\&f1);
print "$i\n";
}

sub f1{
sleep 100;
}
Show full article (0.81Kb)
4 Comments
  Homemade youtube style (Flash??) videos?         


Author: Ignoramus18920
Date: Oct 31, 2006 10:55

Like many people, I make pictures and videos and place them on my own
website (self hosted). I wrote a perl script that makes HTML index
files for directory structures, along with such nice features as image
thumbnails, RSS feed for updates, and even "video thumbnails" (small
animated GIFs that represent first several seconds of a video at the
rate of one frame per second).

That's all nice. What I would like, though, is to also add
functionality to generate whatever Youtube is doing to make videos
that you can see embedded in a page, with the pause and resume buttons
etc. I assume that it is a Flash presentation. Is there some transcode
module or perl module that would let me convert a DivX file into a
video like youtube?

thanks

i
13 Comments
  killing processes using perl (artsd)         


Author:
Date: Oct 31, 2006 10:37

Hello all,

I'm using an unstable debian distribution (Debian 2.6.18-3) and at some
day I found several artsd processes running in the process list. Normally
there should be only one sound server.

Now I started thinking about how to reduce the artsd process count using a
perl script and wrote something which works and can possibly be used to
remove any processes (cron etc.)

#!/usr/bin/perl -w
# file: killartsd.pl
# kill additional artsd processes - only one is required!
# (c)2006 Andreas Mueller andreas%%at%%poipoi.de
#####################################

# get artsd process ids from ps piped into a sed script
$plist=qx'ps h -C artsd | sed "s/\(\([ 0-9]*\|[0-9]*\).*\)/\2/g"';

# remove space+newline to form a list of pids
$plist =~ s/ \n/,/g;

# remove the ugly last comma in that list $plength=length($plist);
$plist=substr($plist,0,$plength-1) unless $plength < 1 ;
Show full article (1.25Kb)
11 Comments
  Problem using Spreadsheet::Excel         


Author: dave
Date: Oct 31, 2006 09:49

Hello all,

I have been searching the archives for a while and can't seem to find a
solution to my problem. The quick and dirty of it is I am pulling data
from an Oracle database via DBI. I am using the following code to pull
data and write it into an excel spreadsheet:

59 while ( my @row = $sth->fetchrow_array() ) {
60 my $array_ref = \@row;
61 $worksheet1->keep_leading_zeros();
62 $worksheet1->write_row( $row_num, 0, $array_ref );
63 $row_num = $row_num + 1;
64
65 my $line = join("|", map{defined($_) ? $_ : ""} @row);
66 print $line, "\n";
67 push(@DOCIDS, "$row[2]");
68 push(@DATA, $line);
69 }

After executing this I fill up the array @DATA and @DOCIDS and I print
each row (ie line 66) so I know I am fetching the data correctly. But
my Excel doc is not being written. If I were to put a die...
Show full article (6.04Kb)
4 Comments
 
1 2 3 4 5 6 7 8 9