[29829] in Perl-Users-Digest
Perl-Users Digest, Issue: 1072 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 27 18:09:43 2007
Date: Tue, 27 Nov 2007 15:09:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 27 Nov 2007 Volume: 11 Number: 1072
Today's topics:
Re: Applications Help! <simon.chao@fmr.com>
Re: Applications Help! <cwilbur@chromatico.net>
Re: Applications Help! <jurgenex@hotmail.com>
Re: Applications Help! <uri@stemsystems.com>
Re: Applications Help! <leonard_plummer@hotmail.co.uk>
Re: Applications Help! <ben@morrow.me.uk>
Re: Applications Help! <glex_no-spam@qwest-spam-no.invalid>
Re: Calling a SQL Server Stored Procedure from within P <glex_no-spam@qwest-spam-no.invalid>
Close function blocks forever when reading from piped o <google@markginsburg.com>
Re: Close function blocks forever when reading from pip <ben@morrow.me.uk>
Re: Failed with exit code 65280. <shareef.jalloq@lightblueoptics.com>
Re: Failed with exit code 65280. <glex_no-spam@qwest-spam-no.invalid>
Re: Failed with exit code 65280. <shareef.jalloq@lightblueoptics.com>
Re: Failed with exit code 65280. <spamtrap@dot-app.org>
Re: Failed with exit code 65280. <glex_no-spam@qwest-spam-no.invalid>
How much validation when using Mail::Sendmail? <abc@def.com>
Re: How much validation when using Mail::Sendmail? <noreply@gunnar.cc>
Re: How much validation when using Mail::Sendmail? <abc@def.com>
Re: interesting case of data corruption, and its cause <jl_post@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 Nov 2007 11:11:52 -0800 (PST)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: Applications Help!
Message-Id: <9ce17676-743b-4b04-a683-3e91966ea87b@g30g2000hsb.googlegroups.com>
On Nov 27, 1:50 pm, Frieza <leonard_plum...@hotmail.co.uk> wrote:
> Hi can anyone think up of at least five applications that could
> benefit from the use of arrays in Perl?
That is an utterly ridiculous question.
------------------------------
Date: 27 Nov 2007 14:18:38 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Applications Help!
Message-Id: <87ve7nxzsh.fsf@mithril.chromatico.net>
>>>>> "F" == Frieza <leonard_plummer@hotmail.co.uk> writes:
F> Hi can anyone think up of at least five applications that could
F> benefit from the use of arrays in Perl?
Yes. Oddly enough, they're also the same sort of applications that
could benefit from the use of variables, or subroutines.
Good luck with your homework.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Tue, 27 Nov 2007 19:40:10 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Applications Help!
Message-Id: <uo_2j.11485$7T.8967@trndny09>
Frieza wrote:
> Hi can anyone think up of at least five applications that could
> benefit from the use of arrays in Perl?
Can anyone think up of at least five cars that could benefit from the use of
gasoline in the tank? (*)
jue
*: Yes, there are some cars that don't run on gasoline, just as there are a
very few trivial applications where arrays would not be useful.
------------------------------
Date: Tue, 27 Nov 2007 20:37:21 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Applications Help!
Message-Id: <x763zn4e7y.fsf@mail.sysarch.com>
>>>>> "F" == Frieza <leonard_plummer@hotmail.co.uk> writes:
F> Hi can anyone think up of at least five applications that could
F> benefit from the use of arrays in Perl?
my @apps = ( 1 .. 5 ) ;
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: Tue, 27 Nov 2007 13:21:05 -0800 (PST)
From: Frieza <leonard_plummer@hotmail.co.uk>
Subject: Re: Applications Help!
Message-Id: <64984252-e8e1-47ae-941e-c2322af593c4@p69g2000hsa.googlegroups.com>
On 27 Nov, 20:37, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "F" == Frieza <leonard_plum...@hotmail.co.uk> writes:
>
> F> Hi can anyone think up of at least five applications that could
> F> benefit from the use of arrays in Perl?
>
> my @apps = ( 1 .. 5 ) ;
>
> uri
>
> --
> Uri Guttman ------ u...@stemsystems.com --------http://www.stemsystems.com
> --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
> Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
thanks uri that helped alot, the other's that answered my question
they were ridicolous answers! thanks anyway.
------------------------------
Date: Tue, 27 Nov 2007 19:52:21 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Applications Help!
Message-Id: <l49u15-o9e.ln1@osiris.mauzo.dyndns.org>
Quoth Frieza <leonard_plummer@hotmail.co.uk>:
> Hi can anyone think up of at least five applications that could
> benefit from the use of arrays in Perl?
Do your own homework.
Ben
------------------------------
Date: Tue, 27 Nov 2007 16:26:54 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Applications Help!
Message-Id: <474c99ae$0$495$815e3792@news.qwest.net>
Frieza wrote:
> On 27 Nov, 20:37, Uri Guttman <u...@stemsystems.com> wrote:
>>>>>>> "F" == Frieza <leonard_plum...@hotmail.co.uk> writes:
>> F> Hi can anyone think up of at least five applications that could
>> F> benefit from the use of arrays in Perl?
>>
>> my @apps = ( 1 .. 5 ) ;
>>
>> uri
>>
> thanks uri that helped alot, the other's that answered my question
> they were ridicolous answers! thanks anyway.
Garbage in, garbage out.
------------------------------
Date: Tue, 27 Nov 2007 13:49:35 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Calling a SQL Server Stored Procedure from within Perl
Message-Id: <474c74d0$0$10303$815e3792@news.qwest.net>
ab wrote:
> Thanks for those discussions about warnings and errors. It didn't help
> me at all. I was merely asking for a Perl script that could execute a
> stored procedure. In the meanwhile I have found a solution that works.
>
> use Win32::ODBC;
> if (!($MyDB = new Win32::ODBC("DSN=MyDSN;UID=MyLoginID;PWD=MyPwd;")))
> {
> print "Error: Unable to connect to the database\n";
> exit;
How useful is that? Why not possibly add the reason why it failed?
Taking 1 minute to scan the documentation, looks like Error is a method
that might prove useful. Also, using die is more appropriate.
perldoc -f die
> }
> $MyDB -> Run("exec usp_test'");
use Win32::ODBC;
my $MyDB = Win32::ODBC->new( ... );
die "blah..." unless $MyDB;
$MyDB->Run('exec usp_test');
much cleaner. IMHO.
------------------------------
Date: Tue, 27 Nov 2007 13:16:11 -0800 (PST)
From: Mark <google@markginsburg.com>
Subject: Close function blocks forever when reading from piped output
Message-Id: <eaac9bf1-90bd-4aa8-bf17-614097ac137a@a35g2000prf.googlegroups.com>
I am reading piped output from a command that produces a lot of
output. I would like to terminate reading the data before the end of
the output is reached.
The following sample program illustrates the issue. The program will
get stuck on the close(). Any help in dealing with this situation
will be appreciated.
I am having this issue on Windows XP.
use strict ;
use warnings ;
$| = 1 ;
# The following one line perl program produces the lines, "one",
"end", "two",
# continuously, forever.
# Note: You may need to change the quote characters for your command
shell.
my $GenTxtCmd = 'perl -le "while () {foreach (qw(one end two))
{print};}" ' ;
open my $FH, '-|', "$GenTxtCmd" or die "open failed: $!" ;
while (<$FH>) {
print "got $_" ;
last if /end/ ;
}
print "performing close()\n" ;
my $result = close($FH) ;
print "completed close(), result=$result\n" ;
--------
I get the following output:
got one
got end
performing close()
------------------------------
Date: Tue, 27 Nov 2007 22:19:06 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Close function blocks forever when reading from piped output
Message-Id: <qnhu15-pve.ln1@osiris.mauzo.dyndns.org>
Quoth Mark <google@markginsburg.com>:
> I am reading piped output from a command that produces a lot of
> output. I would like to terminate reading the data before the end of
> the output is reached.
>
> The following sample program illustrates the issue. The program will
> get stuck on the close(). Any help in dealing with this situation
> will be appreciated.
>
> I am having this issue on Windows XP.
This is probably your problem :). Try killing the process before closing
the pipe: open '-|' returns a pid, and kill TERM => $pid should do
something reasonable on Win32.
Otherwise try IPC::Run, or do it all by hand with Win32::Process.
Ben
------------------------------
Date: Tue, 27 Nov 2007 12:41:04 -0800 (PST)
From: lbo_user <shareef.jalloq@lightblueoptics.com>
Subject: Re: Failed with exit code 65280.
Message-Id: <12f6c17b-b2d9-4216-b917-e4de9f65a82a@f3g2000hsg.googlegroups.com>
OK, thanks for the help so far. Here's some more detail and the code
itself.
I'm running a script that transcodes FLAC to MP3 hence it calls both
the flac and lame executables with the relevant options and file
paths. The script tries to create a mirrored directory structure of
the source flac tree. You can get the code here: http://robinbowes.com/projects/flac2mp3
I've been in touch with the author but he doesn't have an OS X machine
to test on. It seems to work fine on Windows and possibly Linux. If
you look at the script, the parts to search for are $convert_command
which is a concatenation of tools, arguments and paths, and the
variable $tmpfilename which is the temp destination filename that it
fails to write.
Having added Sherman's code to get the actual error, running the
script returns the following:
[macbaddy:~] sjalloq% flac2mp3.pl /Volumes/FreeNAS/MEDIA/FLAC /Volumes/
FreeNAS/MEDIA/MP3_new
Using flac from: /usr/local/bin/flac
Using lame from: /usr/local/bin/lame
Processing directory: /Volumes/FreeNAS/MEDIA/FLAC
1546 flac files found. Sorting...
Sort complete.
Here is the source file info:
src_base: 01-Young Black Male
src_dir: ./
src_ext: .flac
Transcoding "2Pac/2Pacalypse Now/01-Young Black Male.flac"
flac 1.1.4, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007
Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are
welcome to redistribute it under certain conditions. Type `flac' for
details.
Can't init outfile '/Volumes/FreeNAS/MEDIA/MP3_new/2Pac/2Pacalypse Now/
OwbFwjqwWP.tmp'
child exited with value 255
"flac" --decode --stdout "2Pac/2Pacalypse Now/01-Young Black
Male.flac"| lame --noreplaygain --preset standard - "/Volumes/FreeNAS/
MEDIA/MP3_new/2Pac/2Pacalypse Now/OwbFwjqwWP.tmp" failed with exit
code 65280
[macbaddy:~] sjalloq%
------------------------------
Date: Tue, 27 Nov 2007 15:06:14 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Failed with exit code 65280.
Message-Id: <474c86c7$0$3572$815e3792@news.qwest.net>
052lbo_user wrote:
> Can't init outfile '/Volumes/FreeNAS/MEDIA/MP3_new/2Pac/2Pacalypse Now/
> OwbFwjqwWP.tmp'
> child exited with value 255
Hu.. permission problem? Does the file exist?
> "flac" --decode --stdout "2Pac/2Pacalypse Now/01-Young Black
> Male.flac"| lame --noreplaygain --preset standard - "/Volumes/FreeNAS/
> MEDIA/MP3_new/2Pac/2Pacalypse Now/OwbFwjqwWP.tmp"
That's the exact command that's executed?
"flac" --decode ...
^ ^ ?????
And it works perfectly when you run it from the command line?
Run the flac command, redirect output to a file, maybe there's
something in there? If that works, then redirect that file
to the lame command. If there's a verbose option to those,
then try that.
It's not a perl problem, so focus on something else.
> failed with exit code 65280
------------------------------
Date: Tue, 27 Nov 2007 13:11:43 -0800 (PST)
From: lbo_user <shareef.jalloq@lightblueoptics.com>
Subject: Re: Failed with exit code 65280.
Message-Id: <aedbc708-a9cb-4b14-b851-76744d813346@p69g2000hsa.googlegroups.com>
On 27 Nov, 21:06, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
wrote:
> Hu.. permission problem? Does the file exist?
>
Not a permissions problem. The destination directory is readable and
writable by all. I can touch a file without any problems.
> > "flac" --decode --stdout "2Pac/2Pacalypse Now/01-Young Black
> > Male.flac"| lame --noreplaygain --preset standard - "/Volumes/FreeNAS/
> > MEDIA/MP3_new/2Pac/2Pacalypse Now/OwbFwjqwWP.tmp"
>
> That's the exact command that's executed?
>
> "flac" --decode ...
> ^ ^ ?????
>
> And it works perfectly when you run it from the command line?
>
Yes, that's the exact command. The script changes directory to the
source directory, so when I run it directly on the command line I just
need to add the source path as follows:
[macbaddy:~] sjalloq% "flac" --decode --stdout "/Volumes/FreeNAS/MEDIA/
FLAC/2Pac/2Pacalypse Now/01-Young Black Male.flac"| lame --
noreplaygain --preset standard - "/Volumes/FreeNAS/MEDIA/MP3_new/2Pac/
2Pacalypse Now/1jvGmLGt0G.tmp"
flac 1.1.4, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007
Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are
welcome to redistribute it under certain conditions. Type `flac' for
details.
LAME 3.97 32bits (http://www.mp3dev.org/)
Using polyphase lowpass filter, transition band: 18671 Hz - 19205 Hz
Encoding <stdin>
to /Volumes/FreeNAS/MEDIA/MP3_new/2Pac/2Pacalypse Now/
1jvGmLGt0G.tmp
Encoding as 44.1 kHz VBR(q=2) j-stereo MPEG-1 Layer III (ca. 7.3x)
qval=3
01-Young Black Male.flac: done
[macbaddy:~] sjalloq%
And that completes without any problems also.
Ta.
------------------------------
Date: Tue, 27 Nov 2007 16:50:53 -0500
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: Failed with exit code 65280.
Message-Id: <m1oddfbbnm.fsf@dot-app.org>
lbo_user <shareef.jalloq@lightblueoptics.com> writes:
> Having added Sherman's code to get the actual error
Thanks for the vote of confidence, but it's not my code - I just copied it
from "perldoc -f system". :-)
> Can't init outfile '/Volumes/FreeNAS/MEDIA/MP3_new/2Pac/2Pacalypse Now/
> OwbFwjqwWP.tmp'
> child exited with value 255
That error message is from flac, not Perl. Did you ask the flac author what
it means?
sherm--
--
WV News, Blogging, and Discussion: http://wv-www.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Tue, 27 Nov 2007 16:04:58 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Failed with exit code 65280.
Message-Id: <474c948a$0$502$815e3792@news.qwest.net>
lbo_user wrote:
> On 27 Nov, 21:06, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
> wrote:
>
>> Hu.. permission problem? Does the file exist?
>>
>
> Not a permissions problem. The destination directory is readable and
> writable by all. I can touch a file without any problems.
>
>>> "flac" --decode --stdout "2Pac/2Pacalypse Now/01-Young Black
>>> Male.flac"| lame --noreplaygain --preset standard - "/Volumes/FreeNAS/
>>> MEDIA/MP3_new/2Pac/2Pacalypse Now/OwbFwjqwWP.tmp"
>> That's the exact command that's executed?
>>
>> "flac" --decode ...
>> ^ ^ ?????
>>
>> And it works perfectly when you run it from the command line?
>>
>
> Yes, that's the exact command. The script changes directory to the
> source directory, so when I run it directly on the command line I just
> need to add the source path as follows:
And you're sure it changes directory?
What if you go to /tmp, or something, and run it with --stdout
"blah/abc.flac" (e.g. the file doesn't exist.)
Maybe you should show us the code. Simplify it, test it, and post it,
because if it runs via command line, it'll run via system, so you
obviously are doing something that's not quite right.
>
> [macbaddy:~] sjalloq% "flac" --decode --stdout "/Volumes/FreeNAS/MEDIA/
> FLAC/2Pac/2Pacalypse Now/01-Young Black Male.flac"| lame --
> noreplaygain --preset standard - "/Volumes/FreeNAS/MEDIA/MP3_new/2Pac/
> 2Pacalypse Now/1jvGmLGt0G.tmp"
You're not proving anything there. Change to the directory, you
think your program is changing to, and run the exact command
you posted as your program's output. Either that or use
the full path in your program, to ensure the path or CWD
isn't a problem.
Also, you don't need the double quotes around flac.
------------------------------
Date: Tue, 27 Nov 2007 22:16:35 +0000
From: zaphod <abc@def.com>
Subject: How much validation when using Mail::Sendmail?
Message-Id: <13kp5q3jds15v24@corp.supernews.com>
I've been using an NMS form_mail script for a while but would like to use
the simpler Mail::Sendmail module and wrap my own custom HTML. The NMS
script uses very detailed checks for characters and URLs etc. How much of
this validation is needed when using Mail::Sendmail. None of the
documentation mentions how much is taken care of by the module. What exactly
do I need to validate besides a valid email regex?
Zaphod
------------------------------
Date: Tue, 27 Nov 2007 23:51:00 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How much validation when using Mail::Sendmail?
Message-Id: <5r3l6tF1296m6U1@mid.individual.net>
zaphod wrote:
> I've been using an NMS form_mail script for a while but would like to
> use the simpler Mail::Sendmail module and wrap my own custom HTML. The
> NMS script uses very detailed checks for characters and URLs etc. How
> much of this validation is needed when using Mail::Sendmail. None of the
> documentation mentions how much is taken care of by the module. What
> exactly do I need to validate besides a valid email regex?
No validation is _needed_, I suppose, and as long as we are just talking
about name, subject and the actual message, there is not much to
validate IMO. However, validating the length of the total message is
advisable.
As regards "a valid email regex", how do you define "valid", and what
kind of regex do you think will take care of that?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 27 Nov 2007 23:02:42 +0000
From: zaphod <abc@def.com>
Subject: Re: How much validation when using Mail::Sendmail?
Message-Id: <13kp8gi219npn37@corp.supernews.com>
Gunnar Hjalmarsson wrote:
> zaphod wrote:
>> I've been using an NMS form_mail script for a while but would like to
>> use the simpler Mail::Sendmail module and wrap my own custom HTML. The
>> NMS script uses very detailed checks for characters and URLs etc. How
>> much of this validation is needed when using Mail::Sendmail. None of
>> the documentation mentions how much is taken care of by the module.
>> What exactly do I need to validate besides a valid email regex?
>
> No validation is _needed_, I suppose, and as long as we are just talking
> about name, subject and the actual message, there is not much to
> validate IMO. However, validating the length of the total message is
> advisable.
>
> As regards "a valid email regex", how do you define "valid", and what
> kind of regex do you think will take care of that?
>
Well, I appreciate the only truly valid email address is one that conforms
strictly to the relevant RFC but Mail::Sendmail comes with its own regex
which is supposed to be reliable for most real-world cases.
Zaphod
------------------------------
Date: Tue, 27 Nov 2007 14:25:48 -0800 (PST)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: interesting case of data corruption, and its cause
Message-Id: <3f2f38fd-1f35-428f-99da-c3e0b75d4f57@y43g2000hsy.googlegroups.com>
On Nov 23, 3:34 am, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
>
> Oh, all agreed. I now understand (and have done) the localisation of $_.
>
> My point is that this syndrome is fairly easy to fall into,
> and doesn't appear to be widely known or spoken of.
Heh... I had a similar problem once with a module I wrote. I
created a module that would output an image in .pbm (P4) format by
printing the output with print() statements.
The odd thing was, when I wrote a one-liner Perl script that used
my module (with the -Mmodule switch), sometimes everything worked
well, and other times extra bytes seemed to mysteriously show up in
the output file, corrupting the file.
After experimenting around, I realized that the corruption only
happened when I used the -l switch (which both chomps input and prints
a newline on output). The fact that I wrote a one-liner with the -l
command was making the print() statements in my module print out an
extra byte (a newline character) per print() statement that I hadn't
counted on.
To fix this problem, I had to local()ize the $\ variable inside my
module by adding the following line before my module's print()
statements:
local $\; # don't automatically print newlines
# (even with the '-l' switch)
Like your issue, mine is also one that doesn't appear to be widely
known or spoken of.
Just thought I would share.
-- Jean-Luc
------------------------------
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 V11 Issue 1072
***************************************