[24400] in Perl-Users-Digest
Perl-Users Digest, Issue: 6588 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 20 14:06:01 2004
Date: Thu, 20 May 2004 11:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 20 May 2004 Volume: 10 Number: 6588
Today's topics:
ANNOUNCE: Tk::DirSelect 1.06 (Michael Carman)
Binary dump in browser (Bike Rider)
Re: Binary dump in browser <1usa@llenroc.ude>
Converting file-input argument as string <ewijaya@singnet.com.sg>
Re: Converting file-input argument as string <jurgenex@hotmail.com>
Re: Converting file-input argument as string <ewijaya@singnet.com.sg>
Re: Converting file-input argument as string <1usa@llenroc.ude>
Re: Converting file-input argument as string <ittyspam@yahoo.com>
create tables in pdf using perl (Mohamed Parvez)
Re: create tables in pdf using perl <glex_nospam@qwest.invalid>
Re: Favorite Editor for Perl programming <734562323@yahoo.de>
how can I send messages from both sides through socket? <mysympatico001@sympatico.ca>
Re: how can I send messages from both sides through soc <1usa@llenroc.ude>
Re: how can I send messages from both sides through soc <ebohlman@earthlink.net>
Re: How to find the target of a Unix symlink? (Peter Scott)
Re: How to find the target of a Unix symlink? <usenet@morrow.me.uk>
Re: iterating over arrays with map - problem <pinyaj@rpi.edu>
openwebmail and speed (Jasper)
Re: openwebmail and speed <glex_nospam@qwest.invalid>
Re: Password scheme/Persistent session... <jwkenne@attglobal.net>
Pattern matching against a "use constant" character <bernie@rev.net>
Re: Pattern matching against a "use constant" character <usenet@morrow.me.uk>
Re: perl tcp server script works, but no data. (Eli Sidwell)
Re: Perl vs PHP <kirk@strauser.com>
Re: Perl vs PHP <wappler@gmx.net>
regexp to match time string <bmetcalf@nortelnetworks.com>
Re: regexp to match time string <jwillmore@remove.adelphia.net>
Re: regexp to match time string <usenet@morrow.me.uk>
Re: Test post from Nortel - pls ignore <734562323@yahoo.de>
Re: Testing whether given file is open? <uri@stemsystems.com>
Re: Testing whether given file is open? <vladimir@NoSpamPLZ.net>
Re: Testing whether given file is open? (Bill)
Re: Using DBI to retrieve exit code of stored procedure <jboes@qtm.net>
Re: using modules <usenet@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 May 2004 16:12:30 GMT
From: mjcarman@mchsi.com (Michael Carman)
Subject: ANNOUNCE: Tk::DirSelect 1.06
Message-Id: <Hy0tIL.5yD@zorch.sf-bay.org>
Tk::DirSelect is a module that seems to get recommended from time to
time, but the original author stopped development. I have taken over
as the maintainer. I've made a number of updates and have published it
on CPAN. It should be available from your local CPAN mirror soon.
http://www.cpan.org/authors/id/M/MJ/MJCARMAN/
CHANGES
1.06 (2004-05-20)
* Add Tk as dependancy in Makefile.PL. Should be beyond obvious to
end users, but automated test sites aren't as smart. :)
1.05 (2004-05-20)
* First CPAN release.
* Added a patch for HList behavior changes around Tk 804.025.
Corrects the problem where Show() returned an ARRAY ref instead of
a string.
1.04 (2004-05-19)
* Cleaned up guts (no longer recreates a DirTree for each drive
change)
* Generate drive list upon display, not creation.
* Initial directory now an argument to Show() (not creation)
* Better display of initial directory.
* Changed title from default, allow user to set (at creation)
1.03 (2004-05-19)
* Maintenance taken over by Michael Carman.
* Use a BrowseEntry instead of buttons for Win32 drives
* Restores cwd after finished.
* Better passthrough of args to DirTree.
* Lots of miscellaneous tweaks.
------------------------------
Date: 20 May 2004 10:44:54 -0700
From: google@webticker.com (Bike Rider)
Subject: Binary dump in browser
Message-Id: <870ce12a.0405200944.61b3668c@posting.google.com>
Hey folks!
I am having a problem with a perl script that is printing binary into
the browser... Credit being due where credit is being due first...
<PLUG ALT="suckup">
I bought Martien Verbuggen's book "Graphics Programming with Perl" and
it is GREAT! I know Martien is in here from time to time and first off
MANY thanks for a great piece of work (Buy it now!)
</PLUG>
Here's the code in question....
$im = Image::Magick->new();
$im->Read($uploadedfile);
binmode STDOUT;
print $cgi->header('image/jpeg');
$im->Write('jpg:-');
Instead of actualy showing the image it does a binary dump in the
browser.
I have NO experience in pushing out binary this way and thought I'd
see if anyone has seen this before. Yes yes I know it is probably
something extraordinarily simple but I have RTFM'd and RTFGSR (Read
The ..ahem Fine Google Search Results) extensively and no luck.
Many thanks in advance!
Julian
------------------------------
Date: 20 May 2004 17:58:52 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Binary dump in browser
Message-Id: <Xns94EF8E3A4488Easu1cornelledu@132.236.56.8>
google@webticker.com (Bike Rider) wrote in
news:870ce12a.0405200944.61b3668c@posting.google.com:
> Hey folks!
> I am having a problem with a perl script that is printing binary into
> the browser... Credit being due where credit is being due first...
> <PLUG ALT="suckup">
> I bought Martien Verbuggen's book "Graphics Programming with Perl" and
> it is GREAT! I know Martien is in here from time to time and first off
> MANY thanks for a great piece of work (Buy it now!)
> </PLUG>
>
> Here's the code in question....
>
> $im = Image::Magick->new();
> $im->Read($uploadedfile);
> binmode STDOUT;
> print $cgi->header('image/jpeg');
> $im->Write('jpg:-');
You should probably print the header _before_ switching STDOUT to
binmode.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Thu, 20 May 2004 22:49:30 -0000
From: "Edward Wijaya" <ewijaya@singnet.com.sg>
Subject: Converting file-input argument as string
Message-Id: <opr8blossspncm2o@news.singnet.com.sg>
Hi,
Suppose I have this snippet
which take files as input argument.
$file = $ARGV[0];
open(FILE,"<$file");
@array = <FILE>;
close(FILE);
Is there anyway we can convert $file
into strings (of file name)?
Because we need this later as string value
for other operation.
Regards
Edward WIJAYA
SINGAPORE
------------------------------
Date: Thu, 20 May 2004 15:20:22 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Converting file-input argument as string
Message-Id: <W04rc.7193$r6.4098@nwrddc03.gnilink.net>
Edward Wijaya wrote:
> Suppose I have this snippet
> which take files as input argument.
I guess you mean the arguments are file names, not files?
> $file = $ARGV[0];
> open(FILE,"<$file");
> @array = <FILE>;
> close(FILE);
> Is there anyway we can convert $file
> into strings (of file name)?
There is no variable type "string" in Perl. $file is a scalar. And any
scalar has a text representation.
So, for all practical purposes $file _is_ a string already and can be
treated just like a string (it's also a number, but that is irrelevant
here).
In so far you question doesn't make sense. What are you trying to do?
jue
------------------------------
Date: Fri, 21 May 2004 00:59:32 -0000
From: "Edward Wijaya" <ewijaya@singnet.com.sg>
Subject: Re: Converting file-input argument as string
Message-Id: <opr8brpiqkpncm2o@news.singnet.com.sg>
> In so far you question doesn't make sense. What are you trying to do?
>
I would like to use that string as a name of
output files (with some added string as index).
Edward WIJAYA
SINGAPORE
------------------------------
Date: 20 May 2004 17:07:38 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Converting file-input argument as string
Message-Id: <Xns94EF858A115F3asu1cornelledu@132.236.56.8>
"Edward Wijaya" <ewijaya@singnet.com.sg> wrote in
news:opr8blossspncm2o@news.singnet.com.sg:
> Suppose I have this snippet
> which take files as input argument.
use strict;
use warnings;
> $file = $ARGV[0];
my $file = $ARGV[0];
> open(FILE,"<$file");
Always check whether open succeeded. I prefer lexical filehandles and the
three argument form of open:
open my $in, '<', $file or die "Error opening $file: $!";
> @array = <FILE>;
Why are you slurping the file?
> close(FILE);
>
> Is there anyway we can convert $file into strings (of file name)?
Jurgen already asked what you mean by that. In your response to him, you
stated:
"Edward Wijaya" <ewijaya@singnet.com.sg> wrote in
news:opr8brpiqkpncm2o@news.singnet.com.sg:
> I would like to use that string as a name of output files
> (with some added string as index).
open my $out, '>', $file.'.ext' or die "Error opening $file.ext: $!";
I will ask again: What are you trying to do?
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Thu, 20 May 2004 13:09:01 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Converting file-input argument as string
Message-Id: <20040520130403.J382@dishwasher.cs.rpi.edu>
On Fri, 21 May 2004, Edward Wijaya wrote:
> Suppose I have this snippet which take files as input argument.
> $file = $ARGV[0];
> open(FILE,"<$file");
> @array = <FILE>;
> close(FILE);
> Is there anyway we can convert $file into strings (of file name)?
$file *is* a string. What kind of conversion do you think you need? (And
why do you think that?)
print "The file is: $file\n";
> > In so far you question doesn't make sense. What are you trying to do?
>
> I would like to use that string as a name of
> output files (with some added string as index).
So what's stopping you? The variable IS a string. Just go ahead and use
it. What have you tried that doesn't work the way you think it should?
my $outfile = $file . '.o'; # add '.o' to end of original filename
open OFILE, '>', $outfile or die "Cannot open $outfile for writing: $!";
Paul Lalli
------------------------------
Date: 20 May 2004 08:48:08 -0700
From: parvez@gmail.com (Mohamed Parvez)
Subject: create tables in pdf using perl
Message-Id: <f86738db.0405200748.7f6d5630@posting.google.com>
Hello All,
Is there any perl module that will let me create tables inside pdf document?
I need to create reports in table format in a pdf file
If some examples can be provided it will be great
Thanks/Regards,
Parvez
------------------------------
Date: Thu, 20 May 2004 11:30:52 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: create tables in pdf using perl
Message-Id: <035rc.66$QZ6.20350@news.uswest.net>
Mohamed Parvez wrote:
> Hello All,
>
> Is there any perl module that will let me create tables inside pdf document?
>
> I need to create reports in table format in a pdf file
>
> If some examples can be provided it will be great
Whenever you have a. "Is there any perl module that will...", question,
always start by searching CPAN:
http://search.cpan.org/
Examples are typically included with the module's documentation.
------------------------------
Date: Thu, 20 May 2004 13:34:17 -0400
From: L D Jones <734562323@yahoo.de>
Subject: Re: Favorite Editor for Perl programming
Message-Id: <40ACEC19.EFAC136@yahoo.de>
Chris Mattern wrote:
>
> John Bokma wrote:
>
> > knowsitall wrote:
> >
> >> No. But vi will be close second after vim. Then come (in this order):
> >> emacs
> >> xemacs
> >> editor
> >
> > copy con: script
> >
> >> notepad
> >> ms word.
> >
> No, notepad is better than copy con:. copy con: IS better than MS Word,
> though. Using MS Word to write anything that needs to be plain ASCII
> text is like trying to pound in a nail with a screwdriver.
Or a fish
------------------------------
Date: Thu, 20 May 2004 09:06:28 -0400
From: "B. W." <mysympatico001@sympatico.ca>
Subject: how can I send messages from both sides through socket?
Message-Id: <x32rc.69143$325.1485289@news20.bellglobal.com>
I want to send a request from A to B through socket, then B returns the
process result back to A for display. I run B script first then start A
script, but I got error message at B side "can't use an undefined value as a
symbol reference at line 'print $sock_send "$result";'. How can I have both
sides to support sending messages?
the script I created is as:
A side script:
use IO::Socket;
my $sock_recv = new IO::Socket::INET(Localhost
=>'localhost';
LocalPort =>'7071',
Proto =>'tcp',
Listen =>1,
Reuse =>1,
Timeout =>20,
);
die "error create receive socket" unless $sock_recv;
$sock_send = new IO::Socket::INET( PeerAddr
=>'localhost',
PeerPort =>'7070',
Proto =>'tcp',
);
die "error create send socket" unless $sock_send;
print $sock_send "$request";
$new_sock = $sock_recv->accept();
while (defined ($buf = <$new_sock>)) {
print $buf;
}
close ($sock_send);
close ($sock_recv);
B side script:
use IO::Socket;
my $sock_recv = new IO::Socket::INET(Localhost
=>'localhost';
LocalPort =>'7070',
Proto =>'tcp',
Listen =>1,
Reuse =>1,
Timeout =>20,
);
die "error create receive socket" unless $sock_recv;
$new_sock = $sock_recv->accept();
while (defined ($buf = <$new_sock>)) {
$sock_send = new IO::Socket::INET( PeerAddr
=>'localhost',
PeerPort =>'7070',
Proto =>'tcp',
);
die "error create send socket" unless $sock_send;
$result = <some lines to get result from received
$buf>;
print $sock_send "$buf";
close ($sock_send);
}
close ($sock_recv);
thanks,
B.W.
------------------------------
Date: 20 May 2004 16:46:30 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: how can I send messages from both sides through socket?
Message-Id: <Xns94EF81F4FEFC8asu1cornelledu@132.236.56.8>
"B. W." <mysympatico001@sympatico.ca> wrote in
news:x32rc.69143$325.1485289@news20.bellglobal.com:
> I want to send a request from A to B through socket, then B returns
> the process result back to A for display. I run B script first then
> start A script, but I got error message at B side "can't use an
> undefined value as a symbol reference at line 'print $sock_send
> "$result";'. How can I have both sides to support sending messages?
>
> the script I created is as:
>
> A side script:
> use IO::Socket;
> my $sock_recv = new IO::Socket::INET(Localhost
> =>'localhost';
>
> LocalPort =>'7071',
>
> Proto =>'tcp',
>
> Listen =>1,
You might want to spend some time properly formatting your code for
others to want to read it.
When one side is done sending, it should tell the other side it is done
sending:
perldoc -f shutdown.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: 20 May 2004 16:52:01 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: how can I send messages from both sides through socket?
Message-Id: <Xns94EF796448AD9ebohlmanomsdevcom@130.133.1.4>
"B. W." <mysympatico001@sympatico.ca> wrote in
news:x32rc.69143$325.1485289@news20.bellglobal.com:
> I want to send a request from A to B through socket, then B returns
> the process result back to A for display. I run B script first then
> start A script, but I got error message at B side "can't use an
> undefined value as a symbol reference at line 'print $sock_send
> "$result";'. How can I have both sides to support sending messages?
>
> the script I created is as:
>
> A side script:
> use IO::Socket;
No 'use strict'.
No 'use warnings'.
Let perl find as many of your problems as it can.
> my $sock_recv = new IO::Socket::INET(Localhost
> =>'localhost';
That semicolon should be a comma. Given that I see this in two different
places in your code, and that nowhere does your code contain the
actual statement that you claim gives the error message, I can only
conclude that the code you posted resembles, but is not identical to, the
code you're actually trying to run. Posting mutant code is a Bad Thing;
all it accomplishes is wasting everyone's time. None of us here, AFAIK,
have the psychic powers they'd need in order to determine what your actual
code is from what you've posted.
Try again (*after* enabling warnings and strictures and correcting anything
that perl complains about when you do), but this time *copy and paste* the
*exact* code that's giving you the problem. Not something "like" it, but
the Real Thing. Post something that any of us can copy from our
newsreaders and run without having to alter it. Otherwise the people who
know what they're talking about will refuse to engage in futile guesswork,
and any responses you'll get will be likely to come from people who may not
really know what they're talking about.
------------------------------
Date: Thu, 20 May 2004 16:42:07 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: How to find the target of a Unix symlink?
Message-Id: <zd5rc.545549$Ig.200663@pd7tw2no>
In article <c8gh1g$re5$1@reader2.panix.com>,
kj <socyl@987jk.com> writes:
>
>How does one find the target(s) of a Unix symlink?
[...]
>Is there a more civilized way to do this?
File::Spec::Link
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
------------------------------
Date: Thu, 20 May 2004 17:32:14 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: How to find the target of a Unix symlink?
Message-Id: <c8iq2u$li9$1@wisteria.csv.warwick.ac.uk>
Quoth kj <socyl@987jk.com>:
> In <c8gus3$hf8$3@wisteria.csv.warwick.ac.uk> Ben Morrow <usenet@morrow.me.uk> writes:
>
> >Quoth kj <socyl@987jk.com>:
> >> In <c8gh1g$re5$1@reader2.panix.com> kj <socyl@987jk.com> writes:
> >>
> >> >How does one find the target(s) of a Unix symlink?
> >>
> >> I found readlink, but my gripe with it is that it doesn't follow
> >> links beyond the first hop. (I.e. if "first" points to "second",
> >> and "second" points to "third", readlink "first" returns "second"
> >> not "third.)
>
> >This is the only way to get all the information. A simple way to follow
> >all links:
>
> >sub readalllinks {
> > my $file = shift;
> > while (-l $file) {
> > $file = readlink $file;
> > }
> >}
> >
>
> Hmm. I think this fails if $file's target is outside $file's
> directory and is specified using a relative path.
Yes, of course it does. Whoops :)
> I think this
> does "the right thing":
>
> ...but it is eggly.
Having seen your use of Cwd, I remembered that this will do just fine:
use Cwd qw/realpath/;
my $file = realpath($file);
:)
But a cleaner rewrite would be
use Cwd qw/cwd/;
use File::Spec::Functions qw/rel2abs catpath splitpath/;
sub readalllinks {
my $rel = shift;
my $dir = cwd;
my $abs;
while ( -l ($abs = rel2abs $rel, $dir) ){
$dir = catpath +(splitpath $abs)[0,1];
$rel = readlink $abs;
}
return $abs;
}
--
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/' # ben@morrow.me.uk
------------------------------
Date: Thu, 20 May 2004 11:54:20 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Mothra <mothra@mothra.com>
Subject: Re: iterating over arrays with map - problem
Message-Id: <Pine.SGI.3.96.1040520115318.47977A-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On Wed, 19 May 2004, Mothra wrote:
> push @dict, map { s/[aA]/4/g;$_ } @dict;
> push @dict, map { s/[bB]/8/g;$_ } @dict;
> push @dict, map { s/[eE]/3/g;$_ } @dict;
> push @dict, map { s/[gG]/6/g;$_ } @dict;
> push @dict, map { s/[iI]/1/g;$_ } @dict;
> push @dict, map { s/[lL]/1/g;$_ } @dict;
> push @dict, map { s/[oO]/0/g;$_ } @dict;
> push @dict, map { s/[sS]/5/g;$_ } @dict;
> push @dict, map { s/[tT]/7/g;$_ } @dict;
> push @dict, map { s/[zZ]/2/g;$_ } @dict;
Sounds like a job for tr///
$str =~ tr/AaBbEeGgIiLlOoSsTtZz/44883366111100557722/;
--
Jeff Pinyan RPI Acacia Brother #734 RPI Acacia Corp Secretary
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: 20 May 2004 08:41:02 -0700
From: jasper@mccrea.demon.co.uk (Jasper)
Subject: openwebmail and speed
Message-Id: <b6891527.0405200741.42dae094@posting.google.com>
Hello, all,
We're using openwebmail in work, and we're experiencing some speed
issues when it comes to mailboxes which are quite full.
Is there any way to speed this up?
For instance, the dbmopen() call presumably has to create the
databases in the first instance to get a fresh look at a mailbox. Can
this be moved to an external script, called when new mail is added to
the box?
That's about all I can think of.
Anyone worked with this? Anyone just moved to another web mail? From
the info I've looked at people (and ow themselves) seem to think that
openwebmail isn't slow compared to other systems.
Help appreciated,
Jasper
------------------------------
Date: Thu, 20 May 2004 11:35:57 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: openwebmail and speed
Message-Id: <N75rc.67$QZ6.20668@news.uswest.net>
Jasper wrote:
> Hello, all,
>
> We're using openwebmail in work, and we're experiencing some speed
> issues when it comes to mailboxes which are quite full.
>
> Is there any way to speed this up?
>
> For instance, the dbmopen() call presumably has to create the
> databases in the first instance to get a fresh look at a mailbox. Can
> this be moved to an external script, called when new mail is added to
> the box?
>
> That's about all I can think of.
>
> Anyone worked with this? Anyone just moved to another web mail? From
> the info I've looked at people (and ow themselves) seem to think that
> openwebmail isn't slow compared to other systems.
Simply reading through their web site shows:
CONTACT
If you encountered any problem with Open Webmail, please check
changes.txt to see if the problem is fixed in the latest current
version. If not, try the readme.txt and faq.txt.
If you want to seek help, please post your problem in the
openwebmail-users discussion forum.
The forum is: http://sourceforge.net/forum/forum.php?forum_id=108433
------------------------------
Date: Thu, 20 May 2004 16:34:02 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Password scheme/Persistent session...
Message-Id: <_55rc.106204$MH.21799388@news4.srv.hcvlny.cv.net>
krakle wrote:
> The question IS ontopic to this group.
No, it is not. You are asking a question about how the web works, not
how Perl works. You are in the position of someone who goes to a group
concerned with English grammar to ask "What is the quadratic formula?",
and, when told the question is off-topic, complains, "What's wrong? I
asked the question in English, didn't I?"
--
John W. Kennedy
"Compact is becoming contract,
Man only earns and pays."
-- Charles Williams. "Bors to Elayne: On the King's Coins"
------------------------------
Date: Thu, 20 May 2004 12:56:58 -0400
From: Bernard Cosell <bernie@rev.net>
Subject: Pattern matching against a "use constant" character
Message-Id: <89opa0pco37jr79ge6odf4sto6qufuig70@4ax.com>
I have a bunch of constants [field separators] and I need to remove
them from various strings before format them up. I'm clearly not
_quite_ understanding how \Q and \E work -- I tried something like:
perl -we 'use constant a => "*"; $b = "\Q".a."\E"; $c = qr($b);
warn "xxx" =~ /$c/'
Quantifier follows nothing before HERE mark in regex m/* << HERE / at
-e line 1.
Is there some way to do this other than the rather clunky one of
assigning the constant to a variable and interpolating that variable
into the pattern? Tnx...
/Bernie\
------------------------------
Date: Thu, 20 May 2004 17:45:16 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Pattern matching against a "use constant" character
Message-Id: <c8iqrc$li9$3@wisteria.csv.warwick.ac.uk>
Quoth Bernard Cosell <bernie@rev.net>:
> I have a bunch of constants [field separators] and I need to remove
> them from various strings before format them up. I'm clearly not
> _quite_ understanding how \Q and \E work -- I tried something like:
>
> perl -we 'use constant a => "*"; $b = "\Q".a."\E"; $c = qr($b);
> warn "xxx" =~ /$c/'
> Quantifier follows nothing before HERE mark in regex m/* << HERE / at
> -e line 1.
\Q etc. only quote things that follow them inside a literal string: so
this works
$c = qr(\Q*\E);
but what you have doesn't. You are looking for quotemeta:
perl -Mconstant='a,*' -we'$b = quotemeta a; $c = qr/$b/;
warn "xxx" =~ $c'
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
- Heraclitus
ben@morrow.me.uk
------------------------------
Date: 20 May 2004 08:24:15 -0700
From: sidwelle@alexian.net (Eli Sidwell)
Subject: Re: perl tcp server script works, but no data.
Message-Id: <ef9a95b0.0405200724.2b8f1e58@posting.google.com>
Still nothing, the $nread even comes up 0.
As far as the client, I tried to telnet a small file to that port and
then I wrote an app using the VB winsock to move text to that port.
Both times it opens the port and accepts the data (I think), I can get
the port and IP from perl but, I don't see any data.
Are there any good reference books on the perl socket with examples.
I have the orilly cookbook, but its a lot of theory.
Thanks
Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in message news:<190520041320228983%jgibson@mail.arc.nasa.gov>...
> In article <ef9a95b0.0405191046.6ef2960e@posting.google.com>, Eli
> Sidwell <sidwelle@alexian.net> wrote:
>
> > I am trying to get the following script to accept data, but I never see any.
> > Is this a flushing issue ?
> >
> > Any help is appreciated.
> >
> >
> > #!/usr/bin/perl -w
> >
> > $server_port = "5001";
> >
> > use IO::Socket;
> >
> > # make the socket
> > $server = IO::Socket::INET->new(LocalPort => $server_port,
> > Type => SOCK_STREAM,
> > Proto => 'tcp',
> > Reuse => 1,
> > Listen => 10 ) # or SOMAXCONN
> > or die "Couldn't be a tcp server on port $server_port : $@\n";
> >
> > $server->autoflush();
> >
> > while ($client = $server->accept()) {
> > # $client is the new connection
> >
> > $client->recv($str, 1024)
> > or die "Can't recv: $!\n";
>
> recv() is for UDP messages. You have specified a TCP connection. Try
>
> my $nread = $client->read($str,1024);
> die "Can't read from socket: $!" unless defined $nread;
>
> instead.
>
> >
> > $client_ip = $client->peerhost;
> > $client_port = $client->peerport;
> >
> > print "Data is: $str \n";
> > print "Client IP: $client_ip\n";
> > print "Client port: $client_port\n";
> > }
> >
> > close($server);
>
> You have not shown the client program, so there could be a problem
> there as well.
------------------------------
Date: Thu, 20 May 2004 14:45:06 GMT
From: Kirk Strauser <kirk@strauser.com>
Subject: Re: Perl vs PHP
Message-Id: <87vfir17m2.fsf@strauser.com>
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 2004-05-20T03:08:39Z, John Bokma <postmaster@castleamber.com> writes:
> swiss army knife v.s. a screwdriver would be a better comparison :-D.
Only if you concede that PHP is the Swiss Army Knife, and that writing a
large web app is like changing the head gasket on a Chevy 350. It does a
lot of things, but none of them as well as purpose-built tools. :)
=2D --=20
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFArMQ15sRg+Y0CpvERAhQxAKCabJfNCXcQkENJsmhBDO9eUbvC6wCfWFGE
QehLjPBbo2pUGsDKrEEPEss=3D
=3DvlnU
=2D----END PGP SIGNATURE-----
------------------------------
Date: Thu, 20 May 2004 19:40:01 +0200
From: "Wappler" <wappler@gmx.net>
Subject: Re: Perl vs PHP
Message-Id: <40acecba$0$31052$91cee783@newsreader02.highway.telekom.at>
Perhaps it is not possible to get a decent answer in a perl newsgroup.
Maybe you should try a google search with "advantages of PHP versus Perl".
There are people - not only PHP freaks - who see advantages here.
------------------------------
Date: Thu, 20 May 2004 14:54:20 +0000 (UTC)
From: Brandon Metcalf <bmetcalf@nortelnetworks.com>
Subject: regexp to match time string
Message-Id: <slrncapho7.cum.bmetcalf@cash.rhiamet.com>
I'm trying to come up with a regexp to match a string containing the
date and time in the format:
yyyy-mm-dd hh:mm:ss
with either the date or time part being optional but not both and the
":ss" part always being optional. I have the following which falls short
in a number of ways:
/^(\d{4}(-\d{1,2}){1,2}\s+)?(\d{1,2}(:\d{2}){1,2})?$/
Is there a way to do this with one regexp?
Thanks.
--
Brandon
------------------------------
Date: Thu, 20 May 2004 13:21:27 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: regexp to match time string
Message-Id: <pan.2004.05.20.17.21.24.784299@remove.adelphia.net>
On Thu, 20 May 2004 14:54:20 +0000, Brandon Metcalf wrote:
> I'm trying to come up with a regexp to match a string containing the
> date and time in the format:
>
> yyyy-mm-dd hh:mm:ss
>
> with either the date or time part being optional but not both and the
> ":ss" part always being optional. I have the following which falls short
> in a number of ways:
>
> /^(\d{4}(-\d{1,2}){1,2}\s+)?(\d{1,2}(:\d{2}){1,2})?$/
>
> Is there a way to do this with one regexp?
>
> Thanks.
Not sure (and could be very wrong)
my @datetime = split /[-:]/, $the_string_to_parse;
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
If mathematically you end up with the wrong answer, try
multiplying by the page number.
------------------------------
Date: Thu, 20 May 2004 17:39:05 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: regexp to match time string
Message-Id: <c8iqfp$li9$2@wisteria.csv.warwick.ac.uk>
Quoth Brandon Metcalf <bmetcalf@nortelnetworks.com>:
> I'm trying to come up with a regexp to match a string containing the
> date and time in the format:
>
> yyyy-mm-dd hh:mm:ss
>
> with either the date or time part being optional but not both and the
> ":ss" part always being optional. I have the following which falls short
> in a number of ways:
>
> /^(\d{4}(-\d{1,2}){1,2}\s+)?(\d{1,2}(:\d{2}){1,2})?$/
>
> Is there a way to do this with one regexp?
Ummm...
my $date = qr/\d{4}-\d{2}-\d{2}/;
my $time = qr/\d{2}:\d{2} (?: :\d{2} )?/x;
my $re = qr/^ (?: $date | $time | $date \s+ $time ) $/x;
Ben
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
------------------------------
Date: Thu, 20 May 2004 12:52:21 -0400
From: L D Jones <734562323@yahoo.de>
Subject: Re: Test post from Nortel - pls ignore
Message-Id: <40ACE245.3FC91041@yahoo.de>
Chris wrote:
>
> Testing outbound posts, please ignore.
>
> News Admin @ Nortel
wouldn't a news admin know to post to a test group?
------------------------------
Date: Thu, 20 May 2004 13:33:00 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Testing whether given file is open?
Message-Id: <x7vfirmdf7.fsf@mail.sysarch.com>
>>>>> "l" == lostriver <vladimir@NoSpamPLZ.net> writes:
l> On Thu, 20 May 2004 03:04:41 GMT, Uri Guttman wrote:
>>
>> that is a very poor solution. what if the transfer dies before it
>> completes?
l> If transfer dies (by dies I assume you mean termination of TCP
l> session) it is complete. Esp. if sending process does not
l> automaticaly resend the file and does not check for success of the
l> transfer.
huh? i mean dying in the middle of the transfer. and the whole point is
to detect a proper transfer of the file so your point about not checking
is moot.
>> what if there is a long delay for some reason? how long do
>> you sleep for?
l> It depends how often transfer takes place.
>> what if you need to know quickly and can't afford the
>> time to sleep?
l> Than you cannot use this.
right.
>>
>> polling for file transfer completions is not a good idea in
>> general. there are other ways that work.
>>
l> It is not great solution but it will work just fine in some situations.
l> The OP never defined the frequency and quantity of those transfers.
it is a poor design in general. polling is poor in general. it can have
race conditions unless you do atomic stuff like a rename after
transfer. it means the remote system has to be in a polling loop which
is wasteful when no files are transfered.
l> How would you go about it, Uri?
that is for to know and you to find out. :)
actually i would use a framework where file transfers were integrated in
and remote notification is possible. then the remote side is just told
when files have been transfered and it can process them at will. no
races, no wasted polling. of course stem (on cpan) is such a beast.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Thu, 20 May 2004 15:43:37 GMT
From: lostriver <vladimir@NoSpamPLZ.net>
Subject: Re: Testing whether given file is open?
Message-Id: <Jm4rc.21208$Q6.76402@weber.videotron.net>
On Thu, 20 May 2004 13:33:00 GMT, Uri Guttman wrote:
>
> actually i would use a framework where file transfers were integrated in
> and remote notification is possible. then the remote side is just told
> when files have been transfered and it can process them at will. no
> races, no wasted polling. of course stem (on cpan) is such a beast.
>
You are trying to give me a solution for a perfect world :)
I am dealing with reality - external entity pushes some
files over FTP or (better) SSH onto my server. This external entity is run
by a bunch of clueless morons who can't/does't want to make any changes.
Since i am on the receiving end, I can use fuser, sleep and check sizes
or (if IP address is known) netstat. There is not much else I can do....
--
.signature: No such file or directory
------------------------------
Date: 20 May 2004 09:43:31 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Testing whether given file is open?
Message-Id: <239ce42f.0405200843.1c004ef9@posting.google.com>
chris-usenet@roaima.co.uk wrote in message news:<tk9un1-vg.ln1@moldev.cmagroup.co.uk>...
> lostriver <vladimir@nospamplz.net> wrote:
> > You can also check the size of the file, go sleep()
> > for a while and check the size again. If sleep()
> > was long enough and size hasn't increased, you can assume
> > that the transfer is complete....
>
> No you can't. The transfer could have been interrupted (temporarily
> or permanently).
Back before the internet was big, telephone based networks (Fidonet
and others) were used for file transfer, and modem/telephone based
file mailers had an elaborate system of flag files for this. The flag
file code in these could be adapted for an FTP system. For a remaining
example, see eg.
http://btxe.sourceforge.net/
Such a setup may be overkill for OP's needs, of course.
------------------------------
Date: Thu, 20 May 2004 14:23:41 GMT
From: Jeff Boes <jboes@qtm.net>
Subject: Re: Using DBI to retrieve exit code of stored procedure
Message-Id: <959acd8b82d51ffcff7f934bedbd0b14@news.teranews.com>
Domenico Discepola wrote:
> Hello all. I'm using DBI to connect via ODBC to Microsoft SQL Server 2000.
> I wish to execute a stored procedure and return the exit code of the stored
> procedure. The stored procedure only returns 1 numerical value. In this
> stored proc, I'm calling gzip with a non-existent file in order to produce
> an error. I do not get any results back. Any thoughts?
Hmm ... well, I'm far more familiar with the DBD::Pg world than SQL
Server, but in *my* world you would retrieve it using something like --
SELECT sp_test();
I don't know if that's SQL-standard, so you may have to do --
SELECT sp_test() FROM dual;
(That's old Oracle background creeping in.)
--
(Posted from an account used as a SPAM dump. If you really want to get
in touch with me, dump the 'jboes' and substitute 'mur'.)
________
Jeffery Boes <>< jboes@qtm.net
------------------------------
Date: Thu, 20 May 2004 17:48:53 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: using modules
Message-Id: <c8ir25$li9$4@wisteria.csv.warwick.ac.uk>
Quoth ihatespam@hotmail.com:
> Hi all,
>
> Quick question. I've got a Perl program that runs fine from my account at
> work, but when someone else copies it and tries to run it from their
> account, or when I telnet to another machine and try to run it, it doesn't
> work. The error is something to the effect..."Can't find loadable object
> in Term::Readkey".
>
> At the top of my script I have
>
> use lib "/acct/mjo1234/perllib";
Do other people have search access to this directory?
Is this directory the same on the other machine you telnet to?
Ben
--
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based
on the strictest morality. [Samuel Butler, paraphrased] ben@morrow.me.uk
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6588
***************************************