[19477] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1672 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 31 18:10:26 2001

Date: Fri, 31 Aug 2001 15:10:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <999295813-v10-i1672@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 31 Aug 2001     Volume: 10 Number: 1672

Today's topics:
    Re: Perl script calling shell script failing (Eric Bohlman)
    Re: Q: File globbing and scalar vars <newspost@coppit.org>
    Re: Q: File globbing and scalar vars (Eric Bohlman)
    Re: registration worries <gnarinn@hotmail.com>
        Simplewire SMS with Perl (SoftwareSleuth)
        Syntax for using POSIX _exit? (Stan Brown)
    Re: Syntax for using POSIX _exit? <ilya@martynov.org>
    Re: Syntax for using POSIX _exit? <cberry@cinenet.net>
        Vintage versions of perl (Lijiv Khil)
    Re: Vintage versions of perl (Mark Jason Dominus)
    Re: Vintage versions of perl (Greg Bacon)
    Re: Weird -w behaviour (Benoit Gauthier)
    Re: Weird -w behaviour <gnarinn@hotmail.com>
    Re: Why do tabs eliminate the rest of the line? (Sara)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 31 Aug 2001 18:36:55 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Perl script calling shell script failing
Message-Id: <9molg7$l42$1@bob.news.rcn.net>

Google_Don <dvmak@att.net> wrote:
> I have a dynamic web page that on Post calls a perl script. This is
> used for uploading files from a PC to a server. In the perl script I
> call a shell script that ftp's the file to another server. (If we had
> NET:FTP installed I'd use that)

> When all is done the perl script calls another web page where the
> status is displayed.

> The problem:

> The file does get created and the ftp succeeds, the url is built for
> return but I keep getting the Apache Internal server error and the log
> shows:
> <ip cut> malformed header from script. Bad header=File Transfer
> Successful <dir cut>

> If I remark out the actual system call all is fine. 

> Something with the display of the output and return from the shell
> script that perl doesn't like. What am I missing here?

The fact that at the time you call your shell script, some or all of the 
headers that you printed out are still sitting inside buffers and 
therefore the output from the shell script gets sent to the server before 
it's seen all your headers.  Autoflush your Perl program's output (see the 
description of $| in perlvar if you don't already know how).



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

Date: Fri, 31 Aug 2001 14:56:23 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Q: File globbing and scalar vars
Message-Id: <3B8FDDD7.8060407@coppit.org>

Ronald Blaschke wrote:

> On Fri, 31 Aug 2001 10:29:04 -0400, David Coppit <newspost@coppit.org> wrote:
> 
>>perl -e '$a = "*";print <$a>'
>>
>>fails
>>
>>perl -e "$a = "*";print <$a\0>'
>>
>>succeeds
>>
>>Why?
>>
> 
> perl -w -e '$a = "*";print <$a>'
> readline() on unopened filehandle * at -e line 1.
> 
> Makes sense to you?


Not really... Perl is not globbing. I would think that Perl would do 
string substitution, then glob the result. Instead it's not globbing on 
*. For example, this works:

perl -e '$a = "*";print glob($a)'

With a little more research, I see a discussion in perlop about this, 
but I guess I don't understand it clearly. :(

David



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

Date: 31 Aug 2001 21:09:56 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Q: File globbing and scalar vars
Message-Id: <9mouf4$7j3$1@bob.news.rcn.net>

David Coppit <newspost@coppit.org> wrote:
>>>perl -e '$a = "*";print <$a>'
>>>
>>>fails

What's inside the angle brackets is a simple scalar variable, so perl 
DWIMs the angle-bracket operator to an indirect filehandle read.


>>>perl -e "$a = "*";print <$a\0>'
>>>
>>>succeeds

What's inside the angle brackets is neither a simple scalar variable nor a 
bareword, so perl DWIMs it to a glob.

>>>
>>>Why?
>>>
>> 
>> perl -w -e '$a = "*";print <$a>'
>> readline() on unopened filehandle * at -e line 1.
>> 
>> Makes sense to you?


> Not really... Perl is not globbing. I would think that Perl would do 
> string substitution, then glob the result. Instead it's not globbing on 
> *. For example, this works:

> perl -e '$a = "*";print glob($a)'

No DWIMmery needed here; you've explicitly requested a glob.


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

Date: Fri, 31 Aug 2001 19:00:04 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: registration worries
Message-Id: <999284404.348872086033225.gnarinn@hotmail.com>

In article <5370f8aa.0108301506.a953820@posting.google.com>,
Mr. Green <greenseaweed@aol.com> wrote:

(snipped code to produce unique 4 digit number to be used as
file name presumablu under cgi)

in addition to other remarks you have received, let me add
that this strategy to produce unique filenames under concurrent
environment is unsafe.

consider these points:

as the number of allocated files approaches 9000, it will
take more and more time to find a unused number. at last your
program will hang indefinitely when all the bins have been filled.

when your server receives 2 request simultaneously, there is
a small probability that both will be allocated the same number.

this probability may be small, but why take chances, when a different
approach can easily remove it

gnari


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

Date: 31 Aug 2001 14:38:37 -0700
From: howhow82@hotmail.com (SoftwareSleuth)
Subject: Simplewire SMS with Perl
Message-Id: <8048c9d1.0108311338.7f571da8@posting.google.com>

To send SMS using Perl, try Simplewire. They have a Developer Program
at http://devprogram.simplewire.com or just go to
http://www.simplewire.com. They have SMS Software Development Kits,
including ActiveX, Java, Perl, PHP and Shared Object, and a network to
connect to hundreds of networks.


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

Date: 31 Aug 2001 14:31:35 -0400
From: stanb@panix.com (Stan Brown)
Subject: Syntax for using POSIX _exit?
Message-Id: <9mol67$d3b$1@panix1.panix.com>

I'm trying to use the POSIX _exit function, and I'm having trouble with the
syntax,

use POSIX (_exit);  Gives me a "bareword" warning, what is the correct
syntax?




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

Date: 31 Aug 2001 22:39:46 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Syntax for using POSIX _exit?
Message-Id: <873d68dqfh.fsf@abra.ru>

>>>>> On 31 Aug 2001 14:31:35 -0400, stanb@panix.com (Stan Brown) said:

SB> I'm trying to use the POSIX _exit function, and I'm having trouble with the
SB> syntax,

SB> use POSIX (_exit);  Gives me a "bareword" warning, what is the correct
SB> syntax?

It should be

    use POSIX qw(_exit); 


-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Fri, 31 Aug 2001 18:44:38 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: Syntax for using POSIX _exit?
Message-Id: <Xns910E777791246cberrycinenetnet1@207.126.101.92>

stanb@panix.com (Stan Brown) wrote in news:9mol67$d3b$1@panix1.panix.com:
> I'm trying to use the POSIX _exit function, and I'm having trouble with
> the syntax,
> 
> use POSIX (_exit);  Gives me a "bareword" warning, what is the correct
> syntax?

That'd probably be on account of that there bareword, _exit. :)

The import list has the same semantics as any other list (though it's 
evaluated at compile rather than runtime).  The names of desired imported 
symbols are strings, and should be treated that way.  Two ways to do this 
are

  use POSIX ('_exit');
  use POSIX qw( _exit );

I tend to prefer the latter, since I like using one style for all cases, and 
longer import lists are much neater if you do qw() and thus avoid internal 
commas and quotes in the list itself.

-- 
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake



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

Date: 31 Aug 2001 11:09:43 -0700
From: lijivnews@yahoo.com (Lijiv Khil)
Subject: Vintage versions of perl
Message-Id: <1b7d9ca0.0108311009.2b418c4e@posting.google.com>

Hi,
 From where can I download old versions of perl source? Version 1.0 or
v0.1 for example.

regards,
Lijiv


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

Date: Fri, 31 Aug 2001 18:24:57 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Vintage versions of perl
Message-Id: <3b8fd678.2d54$224@news.op.net>

In article <1b7d9ca0.0108311009.2b418c4e@posting.google.com>,
Lijiv Khil <lijivnews@yahoo.com> wrote:
> From where can I download old versions of perl source? 

http://www.etla.org/retroperl/


>Version 1.0 or v0.1 for example.

Version v0.1 is not available.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Fri, 31 Aug 2001 18:40:18 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Vintage versions of perl
Message-Id: <tovmgijqfrhge5@corp.supernews.com>

In article <3b8fd678.2d54$224@news.op.net>,
    Mark Jason Dominus <mjd@plover.com> wrote:

: In article <1b7d9ca0.0108311009.2b418c4e@posting.google.com>,
: Lijiv Khil <lijivnews@yahoo.com> wrote:
:
: >Version 1.0 or v0.1 for example.
: 
: Version v0.1 is not available.

Didn't Larry say it's classified?

Greg
-- 
If you lie to the compiler, it will get its revenge.
    -- Henry Spencer 


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

Date: Fri, 31 Aug 2001 17:52:08 GMT
From: gauthier@circum.com (Benoit Gauthier)
Subject: Re: Weird -w behaviour
Message-Id: <3b8fcde1.29888525@news.videotron.ca>

(2001.08.31, 13:48)

>I've seen similar behavior with text that I've scp'd from Windows to Unix.
>No apparent ^M characters anywhere, yet they're clearly still there.  I've
>even run text through dos2unix and *still* had bizarre behavior (i.e. there
>were still ^M chars somewhere).  An 'od' should show you for sure.

I have discovered that the problem stemmed from having zipped the
scripts in DOS (which left the 0D0Ax end-of-lines) and then unzipped
them in Linux (still with the 0D0Ax), then FTPed back to a Windows
computer in ASCII mode (which added a 0Dx to each line). A similar
problem would occur after unzipping under Linux and then attempting to
run the scripts since there would be 0D0Ax end-of-lines.

I have now reverted to editing all of my scripts in "Unix" mode under
Windows using TextPad (the greatest text editor on earth). This way,
no more confusion.

Thanks all for your help.



Benoît Gauthier, mailto:gauthier@circum.com
Réseau Circum inc. / Circum Network Inc.

Enregistrez votre adresse élec. pour être informé(e)
des nouvelles de Circum à l'URL http://circum.com

Register your e-mail to be informed of Circum news at
http://circum.com

74, rue du Val-Perché, Hull, Québec (Canada) J8Z 2A6
+1 819.770.2423  télec. fax: +1 819.770.5196

==============================================

* * * Essayez des options : courriel avec The Bat!, Web avec Opera
* * * Try alternatives : e-mail with The Bat!, Web with Opera
http://www.ritlabs.com/the_bat/
http://www.opera.com/


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

Date: Fri, 31 Aug 2001 19:27:19 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Weird -w behaviour
Message-Id: <999286039.912923921830952.gnarinn@hotmail.com>

In article <3b8f6922.4093852@news.videotron.ca>,
Benoit Gauthier <gauthier@circum.com> wrote:
>On Thu, 30 Aug 2001 23:01:56 -0400, Samneric
><samneric@tigerriverOMIT-THIS.com> wrote:
>>> [Thu Aug 30 21:13:26 2001] [error] (2)No such file or directory: exec
>>> of /.../test.cgi failed
>>
>>"/usr/bin/perl^M" isn't on your server. No such file.
>>"/usr/bin/perl -w^M" is.
>>
>>Your script contains carriage returns.
>
>3) I do normally edit my scripts in Windows and then FTP them to the
>server. I do that with all my scripts. Why would this one bug?

you probably used binary mode.

when transferring files between OSes with different EOL conventions,
you should use text mode on text files, and binary mode on ALL other files

to remove carriage returns from file 'myfile':
  perl -pi.bak -e's/\015//g;' myfile
this will backup the original as 'myfile.bak'

i usually keep this executable script in my path:
  #!/usr/bin/perl -pi
  s/\015//g;
it will remove carriage returns from the files given as arguments,
(and not create backup files)

gnari


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

Date: 31 Aug 2001 13:20:28 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Why do tabs eliminate the rest of the line?
Message-Id: <776e0325.0108311220.53e55c22@posting.google.com>

trammell@haqq.hypersloth.invalid (John J. Trammell) wrote in message news:<slrn9ot6m9.6r5.trammell@haqq.hypersloth.net>...
> On 30 Aug 2001 06:54:07 -0700, Sara <genericax@hotmail.com> wrote:
> > I have a statement like:
> > 
> >  my $beginc="
> > *
> > * JOB#$newjob   $today
> > * $newjob       ITEM: $l{LA}    PRICE: $l USD
> > ";
> > 
> > where TABS are inserted before $today and ITEM. When this prints I end
> > up with:
> > 
> > *
> > * JOB#30339
> > * B3459
> > 
> > So it appears that everything after the inserted TAB characters is
> > erased. Why?
> 
> I am unable to duplicate your error.  Why don't you just use \t 
> to indicate a tab anyhow?

\t is an option, as was just using spaces which is what i did for now.
Trouble with \t is it's difficult to line up with other non-tabbed
items since its not WYSIWYG.

If it ain't broke don't fix it so I guess I'll just leave it as spaces
now. Thanks for the tips. If I can get it to misbehave again maybe I
can capture some details.

Have a nice Labour Day!


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

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.  

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 1672
***************************************


home help back first fref pref prev next nref lref last post