[22726] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4947 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 6 18:06:33 2003

Date: Tue, 6 May 2003 15:05:08 -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           Tue, 6 May 2003     Volume: 10 Number: 4947

Today's topics:
        "-s" if not a switch then what? <samj@austarmetro.com.au>
    Re: "-s" if not a switch then what? <nobody@dev.null>
    Re: "-s" if not a switch then what? <noreply@gunnar.cc>
    Re: Adding time in perl (AJ Miller)
        Can't Create Text Files, Config problem (Mike)
    Re: Can't Create Text Files, Config problem <tony_curtis32@yahoo.com>
    Re: Can't Create Text Files, Config problem <matt@nospam.liek.net>
    Re: Can't Create Text Files, Config problem <goedicke@goedsole.com>
    Re: clearing stdin <schnozx@hotmail.com>
    Re: Design Opinions - Dealing with Constants (Malcolm Dew-Jones)
    Re: Design Opinions - Dealing with Constants <kevin.vaughn@ttu.edu>
    Re: Design Opinions - Dealing with Constants <kevin.vaughn@ttu.edu>
    Re: Design Opinions - Dealing with Constants <tzz@lifelogs.com>
    Re: Design Opinions - Dealing with Constants <henq _ replace 0 by o <hvtijen@h0tmail.c0m>>
        foolproof requires (Analysis&Solutions)
    Re: Forcing an rvalue context on a scalar expression <skuo@mtwhitney.nsc.com>
    Re: Forcing an rvalue context on a scalar expression (Anno Siegel)
    Re: Forcing an rvalue context on a scalar expression (Anno Siegel)
    Re: Forcing an rvalue context on a scalar expression <uri@stemsystems.com>
    Re: forcing downloads <mdudley@execonn.com>
    Re: forcing downloads (Malcolm Dew-Jones)
        Install/setup Net::SSH::PERL (Anand Ramamurthy)
    Re: Install/setup Net::SSH::PERL (Quackie)
    Re: Newbie question Perl Print function using files <REMOVEsdnCAPS@comcast.net>
        Open With? <taariqq@yahoo.com>
        Undefined Subroutine & And A dying CGI <member29223@dbforums.com>
    Re: What is good to learn <cwilbur@mithril.chromatico.net>
    Re: XO host can't use CHMOD (tcnolan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 06 May 2003 21:03:39 GMT
From: "Sam Jesse" <samj@austarmetro.com.au>
Subject: "-s" if not a switch then what?
Message-Id: <3eb8232a@news.comindico.com.au>

Hello.. I am reading this book "Elements of Programming with Perl", in this
example I am trying to understand in the print line, what is the meaning of
"-s" after the "if".
I thring to thing of many things. like it can not be a command line switch.
searahes the help docs, book indexs... etc

Thanks

    open(DIR, 'ls |') || die "can't fork: $!";
    while (<DIR>) {
        chomp;
        print "$_" if -s $_ > 5000;
    }
    close(DIR) || die "failed $!";




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

Date: Tue, 06 May 2003 21:42:29 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: "-s" if not a switch then what?
Message-Id: <3EB82BF6.40205@dev.null>



Sam Jesse wrote:

> Hello.. I am reading this book "Elements of Programming with Perl", in this
> example I am trying to understand in the print line, what is the meaning of
> "-s" after the "if".
> I thring to thing of many things. like it can not be a command line switch.
> searahes the help docs, book indexs... etc
> 
> Thanks
> 
>     open(DIR, 'ls |') || die "can't fork: $!";
>     while (<DIR>) {
>         chomp;
>         print "$_" if -s $_ > 5000;
>     }
>     close(DIR) || die "failed $!";
> 


-s is a filetest operator which returns the size of the file in its 
argument (which in your case is in $_). Its documentation is safely 
hidden in perlfunc, and perldoc -f -X will reveal it to you.





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

Date: Tue, 06 May 2003 23:40:38 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: "-s" if not a switch then what?
Message-Id: <b99adr$gi6uf$1@ID-184292.news.dfncis.de>

Sam Jesse wrote:
> ... I am trying to understand in the print line, what is the meaning of
> "-s" after the "if".

     http://www.perldoc.com/perl5.8.0/pod/func/-X.html

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 6 May 2003 12:48:36 -0700
From: ajmiller@crutchfield.com (AJ Miller)
Subject: Re: Adding time in perl
Message-Id: <f13dd2ac.0305061148.2c7a71e6@posting.google.com>

Many Thanks All.  Date::Manip worked beautifully :-)


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

Date: 6 May 2003 12:10:46 -0700
From: csdude@hotmail.com (Mike)
Subject: Can't Create Text Files, Config problem
Message-Id: <46cdc619.0305061110.13863d23@posting.google.com>

Hey,

I've been working on a several programs at the local school, and we've
had a problem that no one can seem to solve. The Apache 1.3.12 web
server is hosted in Unix, and we're running Perl 5.6.1.

When I write a program designed to create a database (any type), if I
run it directly from Unix it will create the database no problem. But
if I run it from the web browser first, I just get an Internal Server
Error. If I manually create the text file and chmod it to 666, though,
it will run from the browser just fine.

For example, the following program will run fine from Unix and create
the test.txt file, and once I've run it from Unix I can run it from
the browser just fine. But if I run it from the browser without
running it first through Unix, it does not create the database and I
get an error:

#!/usr/bin/perl
$name=Mike;

open(OUTFILE, ">>test.txt") or die "Error opening test.txt. $!,
stopped";
print OUTFILE "$name\n";
close(OUTFILE);

print "Location: http://www.myurl.com\n\n";
exit;


I'm thinking that this has to either be a problem with Apache (which I
couldn't find anything) or Perl configurations. Does anyone have an
idea on what I should modify? I read through all of the .conf files,
and didn't see anything that referenced this.

TIA,

Mike


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

Date: Tue, 06 May 2003 14:19:26 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Can't Create Text Files, Config problem
Message-Id: <87n0hz51dt.fsf@limey.hpcc.uh.edu>

>> On 6 May 2003 12:10:46 -0700,
>> csdude@hotmail.com (Mike) said:

> When I write a program designed to create a database
> (any type), if I run it directly from Unix it will
> create the database no problem. But if I run it from the
> web browser first, I just get an Internal Server
> Error. If I manually create the text file and chmod it
> to 666, though, it will run from the browser just fine.

http://www.boutell.com/openfaq/cgi/8.html

hth
t


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

Date: Tue, 06 May 2003 19:24:19 GMT
From: Matt Van Zilen <matt@nospam.liek.net>
Subject: Re: Can't Create Text Files, Config problem
Message-Id: <DZTta.4268$zh4.983141499@newssvr10.news.prodigy.com>

The user account that apache is running as cannot create files in that 
directory. You could change the file permissions in the directory.

Mike wrote:
> Hey,
> 
> I've been working on a several programs at the local school, and we've
> had a problem that no one can seem to solve. The Apache 1.3.12 web
> server is hosted in Unix, and we're running Perl 5.6.1.
> 
> When I write a program designed to create a database (any type), if I
> run it directly from Unix it will create the database no problem. But
> if I run it from the web browser first, I just get an Internal Server
> Error. If I manually create the text file and chmod it to 666, though,
> it will run from the browser just fine.
> 
> For example, the following program will run fine from Unix and create
> the test.txt file, and once I've run it from Unix I can run it from
> the browser just fine. But if I run it from the browser without
> running it first through Unix, it does not create the database and I
> get an error:
> 
> #!/usr/bin/perl
> $name=Mike;
> 
> open(OUTFILE, ">>test.txt") or die "Error opening test.txt. $!,
> stopped";
> print OUTFILE "$name\n";
> close(OUTFILE);
> 
> print "Location: http://www.myurl.com\n\n";
> exit;
> 
> 
> I'm thinking that this has to either be a problem with Apache (which I
> couldn't find anything) or Perl configurations. Does anyone have an
> idea on what I should modify? I read through all of the .conf files,
> and didn't see anything that referenced this.
> 
> TIA,
> 
> Mike



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

Date: Tue, 06 May 2003 19:54:28 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: Re: Can't Create Text Files, Config problem
Message-Id: <m3znlzyhp2.fsf@mail.goedsole.com>

Dear Y'all - 

Tony Curtis <tony_curtis32@yahoo.com> writes:

> >> On 6 May 2003 12:10:46 -0700,
> >> csdude@hotmail.com (Mike) said:
> 
> > a program [...] if I run it directly from Unix [...] no
> > problem. But if I run it from the web browser first, I just get an
> > Internal Server Error.
> 
> http://www.boutell.com/openfaq/cgi/8.html

My bet is that it's a security autorization problem see the section
"Permissions and Paths: Why Can't My Script Access My Files?" on the
excellent page Tony references above.

I've experienced this problem about a zillion times where the account
you log in with has permission to do something, but the highly
restrictive account that the web server runs as doesn't have those
permissions.  Be aware that you're letting the whole world "use" the
web server so it's a *very* good thing if it can't do much.  

Do a "ps -ef" on your linux box and you should find that the "owner"
of the httpd processes is "nobody".  That's the account that needs the
permissions your script requires.  And (not to harp) but the
permissions you're close to letting anyone who can access your web
server have.

     Yours -      Billy

============================================================
     William Goedicke     goedicke@goedsole.com            
                          http://www.goedsole.com:8080      
============================================================

          Lest we forget:

There may be no stupid questions, but there's no 
shortage of morons asking them.

		- William Goedicke


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

Date: Tue, 06 May 2003 21:04:16 GMT
From: "Lee&James" <schnozx@hotmail.com>
Subject: Re: clearing stdin
Message-Id: <krVta.12599$Jf.6526522@news1.news.adelphia.net>

I want to send a message to the screen and then read any input that the user
has entered after I sent the message. If the user presses enter before I
send a message to the screen I'll be picking up that data. I want to make
sure I only get data the user entered after he has seen the message, so I
want to make sure stdin is empty before I send the message. However, if I
try to read stdin before sending the message, I'll block waiting for input.

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:b95cbs$2av$1@mamenchi.zrz.TU-Berlin.DE...
> Lee&James  <schnoz@adelphia.net> wrote in comp.lang.perl.misc:
> > On a windows platform I want to clear stdin before putting out a message
> > and then reading stdin. Can someone tell me how to do this?
>
> "stdin" is a file handle (well, STDIN is).  What do you mean by "clearing
> stdin"?
>
> Anno




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

Date: 6 May 2003 11:59:31 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Design Opinions - Dealing with Constants
Message-Id: <3eb80613@news.victoria.tc.ca>

Kevin Vaughn (kevin.vaughn@ttu.edu) wrote:

: Now a specific question - How do I get perl to stop giving me the error
: "Global symbol $constant_from_environment requires explicit package name at
: $line_number" when I have strict turned on?


In your globals file, environment.pl, include one more variable that is
the list of the global variable names, and then use that list to declare
which variables you use in the scripts. 

something like

	# environment.pl
	$useful_path = 'the/path';
	@some_things = ('One', 'Two' );

	@global_var_names = qw( $useful_path @some_things);

now when ever you use your globals, do something like the following

	# script.pl

	# BEGIN needed so the globals load before the "use..." statements
	BEGIN{ require "environment.pl" }
	use strict;
	use vars @main::global_var_names;

	$useful_path	# no error
	$usefull_path 	# typo detected


You can even make the environment.pl use strict also, which helps to avoid
typos in it as well, if you change the order around, something like

	# environment.pl
	use strict;
	BEGIN{ @main::global_var_names = qw( $useful_path @some_things) }
	use vars @main::global_var_names ;

        $useful_path = 'the/path';
        @some_things = ('One', 'Two' );

(I'm not sure if the ordering here is correct)


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

Date: Tue, 6 May 2003 14:11:31 -0500
From: "Kevin Vaughn" <kevin.vaughn@ttu.edu>
Subject: Re: Design Opinions - Dealing with Constants
Message-Id: <vbg27a297o6rd6@corp.supernews.com>

Interesting....

So what did you finally decide to do?

-Kevin

"PropART" <temp1_NO_SPAM_@williamc.com> wrote in message
news:3EB7F4B3.74FD93AA@williamc.com...
>
>
> Kevin Vaughn wrote:
> >
> > I've created a large number of scripts that reference a single file
> > containing all of my constants.  I named the file environment.pl.  The
file
> > mainly contains paths.  I include environment.pl using a "required"
> > statement.
> >
> > Is this good or bad design?  I'm particularly interested in the
downsides.
> >
> > Now a specific question - How do I get perl to stop giving me the error
> > "Global symbol $constant_from_environment requires explicit package name
at
> > $line_number" when I have strict turned on?
> >
> > I'm trying to get my head around the lexical vs. package scope thing,
but
> > it's not coming easy for some reason.  Do I have to go through creating
a
> > package, or can I use "our"?
> >
> > -Kevin
>
>
> See thread above from last night, "Including files in Perl". It covers
> almost exactly the same problem.
>
> IMO it's good design, because you have all your constants in one place.
> I'm no Perl expert, though.
>
> --williamc




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

Date: Tue, 6 May 2003 14:18:42 -0500
From: "Kevin Vaughn" <kevin.vaughn@ttu.edu>
Subject: Re: Design Opinions - Dealing with Constants
Message-Id: <vbg2kosjl9hg3d@corp.supernews.com>

I'm not necessarily afraid of creating a package.  I'm just looking for
multiple ways to accomplish this task.  Is putting the variables in a
package the most efficient way to do things?

-Kevin

> I'm not sure of the OO design implications, as I'm no OO purist, but I
> "sort of" do this kind of thing as well. For example, I have a single
> package that contains all of my "error objects and methods". If there
> is an error string to be added or changed, I dont have to slog though
> the 400 some odd package- I know they are all in there.
>
> In your case I see something similar- if its a constant you know its
> in the constant package. Seems like a good idea.
>
> I guess the downside might be seperating the constants from their
> "point of use", assuming some have a single point. However, in the
> case of error objects and in your case, constants, its more common to
> find multiple uses of the object. Therefore, it deserves a more global
> locale, ergo its own package.
>
> I'm not sure why you're saying you have to "go through creating a
> package" like its some laborious effort. Its really not that dramatic-
> add
>
>  package constantPak;
>
> at the top, put
>
>   use constantPak;
>
> in your code, oh and if you're using Perl n for any n<6, then of
> course you'll need a TRUE value returned, hence a 1; at the end of the
> package.
>
> So there really isn't much to "go though". It's relatively painless-
> certainly much easier than programming a PDP-8 from the frontpanel
> binary switches! ha...
>
> The downsides- well as I said in some cases the constant will be
> removed from its point of use which may make it a bit more difficult
> to maintain in some respects. But in our case I think things are MORE
> mainatinable this way since everyone on the design team knows that all
> errors are in the error package.
>
> -Gx




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

Date: Tue, 06 May 2003 15:39:46 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Design Opinions - Dealing with Constants
Message-Id: <4n65onsw3h.fsf@lockgroove.bwh.harvard.edu>

On Tue, 6 May 2003, kevin.vaughn@ttu.edu wrote:
> I've created a large number of scripts that reference a single file
> containing all of my constants.  I named the file environment.pl.
> The file mainly contains paths.  I include environment.pl using a
> "required" statement.
> 
> Is this good or bad design?  I'm particularly interested in the
> downsides.

I consider it a bad design to do a 'require' when you don't have to,
although a lot of people disagree.

You're basically trying to have a configuration file, so check out the
AppConfig module or something similar.  Or are your variables in a
complex structure?  It doesn't seem to be the case.

AppConfig lets you do this:

# $config->VAR() eq 'value'
VAR = value
# $config->HASH()->{K} eq 'V'
HASH K = V
# $config->A()->[0] eq 'First' (A is an array)
A = First
A = Second

> Now a specific question - How do I get perl to stop giving me the
> error "Global symbol $constant_from_environment requires explicit
> package name at $line_number" when I have strict turned on?
> 
> I'm trying to get my head around the lexical vs. package scope
> thing, but it's not coming easy for some reason.  Do I have to go
> through creating a package, or can I use "our"?

Use AppConfig instead of creating a bunch of variables.

Ted


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

Date: Tue, 6 May 2003 22:17:28 +0200
From: "henq" <henq _ replace 0 by o <hvtijen@h0tmail.c0m>>
Subject: Re: Design Opinions - Dealing with Constants
Message-Id: <3eb8185a$0$45379$1b62eedf@news.wanadoo.nl>


I don't have the code at hand, but I thought using a global hash was also a
practical solution. You trade the package name for the name of the hash,
though.

~h.

(from scratch)
-----
#myConfig.pm:

   package myConfig;
   our %config;

   %config = (
       path_a => '/foo/bar',
   ...
   }
   1;

-------------
#usage:

   *config       = \%::config;
   eval require "$myConfig.pm" or die $!;

   print $config{path_a};










"Kevin Vaughn" <kevin.vaughn@ttu.edu> schreef in bericht
news:vbfemoj1e9hba1@corp.supernews.com...
> I've created a large number of scripts that reference a single file
> containing all of my constants.  I named the file environment.pl.  The
file
> mainly contains paths.  I include environment.pl using a "required"
> statement.
>
> Is this good or bad design?  I'm particularly interested in the downsides.
>
> Now a specific question - How do I get perl to stop giving me the error
> "Global symbol $constant_from_environment requires explicit package name
at
> $line_number" when I have strict turned on?
>
> I'm trying to get my head around the lexical vs. package scope thing, but
> it's not coming easy for some reason.  Do I have to go through creating a
> package, or can I use "our"?
>
> -Kevin
>
>




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

Date: Tue, 6 May 2003 19:52:15 +0000 (UTC)
From: info@analysisandsolutions.com (Analysis&Solutions)
Subject: foolproof requires
Message-Id: <b993pf$e7a$1@reader1.panix.com>

Hi Folks:

I've got a module on my website for public consumption which validates 
credit card numbers.  I'm reworking it so error messages are 
internationalized.  The internationalization is performed by creating 
separate language files.  Each of those files set common variables but 
with their respective languages.  I then require that language file 
depending on the $Language parameter given to the method.

The trick is to make sure the appropriate path is used to get the language
file, regardless of the current working directory and operating system.  
Below are summarizations of the key parts of the files to demonstrate my
approach.  Is this approach foolproof?  Is there a more elegant way to do
it?

vvvvvvvvvv  ./ccvs.pm  (in part) vvvvvvvvvvvvvvvvv

package CreditCardValidationSolution;

use File::Spec::Functions;
use File::Basename;
use File::stat;

sub validateCreditCard(\$;\$\@\$\$\$) {

    $self->{CCVSError} = '';

    my($Number, $Language, $Accepted, $RequireExp, $Month, $Year) = @_;

    my @Dirs = File::Spec->splitdir(dirname(File::Spec->rel2abs(__FILE__)));
    my $File = File::Spec->catfile(@Dirs, 'language',
                                   "ccvs_$Language.properties");
    if (!stat($File)) {
        $self->{CCVSError} = "The $Language language file can't be found";
        return 0;
    }
    require $File;

}

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

vvv ./language/ccvs_en.properties  (in part)  vvvv

$CCVSErrYearFormat   = 'Year has invalid format';
$CCVSErrExpired      = 'Card has expired';

1;

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Thanks,

--Dan

-- 
     FREE scripts that make web and database programming easier
           http://www.analysisandsolutions.com/software/
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7th Ave #4AJ, Brooklyn NY    v: 718-854-0335   f: 718-854-0409


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

Date: Tue, 6 May 2003 12:05:50 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Forcing an rvalue context on a scalar expression
Message-Id: <Pine.GSO.4.21.0305061204110.24147-100000@mtwhitney.nsc.com>

On 6 May 2003, Brian McCauley wrote:

> What is the simplest way to force an rvalue context on a scalar
> expression?
> 
> For example, consider:
> 
> my @q;
> foo($q[-1]);
> 
> This generates "Modification of non-creatable array value attempted,
> subscript -1" because it's trying to evaluate $q[-1] as an lvalue but
> I just wanted foo's $_[0]=undef.
> 
> I can easily, but not very elegantly, fix this by saying:
> 
> my $last_q = $q[-1];
> foo($last_q);
> 
> Or even...
> 
> foo(my $last_q = $q[-1]);
> 
> Or, without a varaiable, but more perversely...
> 
> foo(&{sub { $q[-1] }});
> 
> Anyone got any less ugly solutions?
> 
> 





Do you consider this less ugly?

foo(${\(defined $q[-1]? $q[-1]: undef)});


-- 
Regards,
Steven



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

Date: 6 May 2003 21:21:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Forcing an rvalue context on a scalar expression
Message-Id: <b9990s$ef$1@mamenchi.zrz.TU-Berlin.DE>

Brian McCauley  <nobull@mail.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> 
> > Brian McCauley  <nobull@mail.com> wrote in comp.lang.perl.misc:
> > > What is the simplest way to force an rvalue context on a scalar
> > > expression?
> > > 
> > > For example, consider:
> > > 
> > > my @q;
> > > foo($q[-1]);
> > > 
> > > This generates "Modification of non-creatable array value attempted,
> > > subscript -1" because it's trying to evaluate $q[-1] as an lvalue but
> > 
> > Isn't that a bug?  I mean, you're not assigning anything, are you?
> 
> No, see Abigail's explaination of what's going on.
> 
> > > foo(&{sub { $q[-1] }});
> > 
> > Along the same line as sub {...}:
> > 
> >     foo( do { $q[-1] } );
> > 
> > and, found coincidentally, and not quite understood:
> > 
> >     do( scalar $q[ -1]);
> 
> Strange!  By rights _neither_ of those should work.  Both do{} and
> scalar() still return lvalues.  If using $q[-1] in an lvalue context
> where @q=() is wrong then it should always be wrong.

But there is no lvalue context for a subroutine argument, otherwise
foo( 'xyz') would be an error.  Only if you try to assign to $_[ 0]
in the sub an error happens.  $q[ -1] should behave the same way.
After all, it's legal to read an undef from large negative array indices
in other situations.

> Hmmm... actually it's probably good that do{} works this way, perhaps
> do{} should be documented as behaving this way then we could rely on
> it.

I don't think any workaround is needed in the long run.  It's a bug in
5.8.0 (I haven't checked bleadperl).

Anno


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

Date: 6 May 2003 21:33:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Forcing an rvalue context on a scalar expression
Message-Id: <b999nr$ef$2@mamenchi.zrz.TU-Berlin.DE>

Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> Brian McCauley (nobull@mail.com) wrote on MMMDXXXV September MCMXCIII in
> <URL:news:u98ytk6yc9.fsf@wcl-l.bham.ac.uk>:
> :}  What is the simplest way to force an rvalue context on a scalar
> :}  expression?
> :}  
> :}  For example, consider:
> :}  
> :}  my @q;
> :}  foo($q[-1]);
> :}  
> :}  This generates "Modification of non-creatable array value attempted,
> :}  subscript -1" because it's trying to evaluate $q[-1] as an lvalue but
> :}  I just wanted foo's $_[0]=undef.
> 
> The problem is your use of -1 as index on an empty array. An empty array
> has no elements, so it certainly doesn't have a last element. Due to Perl
> using 'call by implicite reference' when calling functions with arguments,
> it must know which element you mean, just in case foo assigns to $_ [0].
> 
> Consider this:
> 
>     sub foo {$_ [0] = 1}
>     my @q;
>     foo $q [2];
>     print scalar @q;
> 
> This prints 3 because you created $q [2]. But suppose you had called
> 'foo $q [-1]', how large should @q be afterwards? Which element was
> created? 

All true, but the error shouldn't happen just because foo( $q[ -1]) is
called, only when foo() actually tries to assign to its argument.

Anno


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

Date: Tue, 06 May 2003 21:56:25 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Forcing an rvalue context on a scalar expression
Message-Id: <x7y91jrb7a.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
  >> 
  >> Consider this:
  >> 
  >> sub foo {$_ [0] = 1}
  >> my @q;
  >> foo $q [2];
  >> print scalar @q;
  >> 
  >> This prints 3 because you created $q [2]. But suppose you had called
  >> 'foo $q [-1]', how large should @q be afterwards? Which element was
  >> created? 

  AS> All true, but the error shouldn't happen just because foo( $q[ -1]) is
  AS> called, only when foo() actually tries to assign to its argument.

but a sub call creates an alias to that element which doesn't exist. it
can be undef since there is no slot to create alias to. 

this generates the same error so it is not a sub related problem. you
can't take a ref or make an alias to an unknown slot in the array. the
-1 index implies you have at least one slot in the array so you can get
its size and index from the end.

perl -e '$r = \$a[-1]'
Modification of non-creatable array value attempted, subscript -1 at -e line 1.

it is the -1 index which is causing the problem and i don't feel it is a
bug. you can't index from the end when you have no elements - there is
no end to use.

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, 06 May 2003 15:09:46 -0400
From: Marshall Dudley <mdudley@execonn.com>
Subject: Re: forcing downloads
Message-Id: <3EB8087A.5AF139D1@execonn.com>

Malcolm Dew-Jones wrote:

> Marshall Dudley (mdudley@execonn.com) wrote:
> : I have a customer who's web site I am doing who sells ebooks.  These
> : books come in several formats, pdf, html, zip, MS reader, rocket file,
> : Mobi file.
>
> : I have two problems.
>
> and neither of them have anything to do with perl, so it's not clear why
> you would post this here.  Also, a search of some kind, (google is often
> used for this) would probably lead you to numerous answers for this/these
> questions, or groups that deal with them.
>
> : The first problem is that I cannot find a mime type for some of these
> : formats.  Thus I have no idea what I should be putting in the content
> : type header part.
>
> The mime rfc has various suggestions to handle this situation.
>
> : But more importantly if there is a way I can force the file to download,
>
> No, this is always at the option of the brower, though it is true that
> some data types are more likely to be handled by saving the data in a
> file.
>

application/octet-streambin is what is needed as it turns out.

>
> : that would be better.  The reason is that people end up purchasing the
> : book, then during the several days it can take to read it, end up with
> : the browser crashing or Windows crashing, or end up closing it out
> : prematurily.
>
> How is that a problem?  Surely the software accounts for that sort of
> problem (doesn't it?).

Since I really have no idea what software they may be using, then probably
not. I know for example that the pdf viewer I have will not allow me to save
the pdf file to the disk that I use, and neither will my doc file viewer.

> What happens if the user has a transmission
> problem during the initial transfer, perhaps someone picks up the phone in
> the other room and the computers phone connection goes bad, how do you
> handle that?
>

If the transfer did not complete, then they are allowed to download again, so
that is not a problem, and it is fully automated, requiring no human
intervention.

>
> : Then they are unable to finish the book, and want to get it again free.
>
> Not really - they paid for it didn't they - you kind of owe it to them.

If you buy a book, then lose it, do you expect the store to give you another
copy?  In this case the cost of giving them a second copy is much more than
the original, since the original is totally automated, but to give them
another copy requires human intervention, which of course costs time and
money.

>
>
> : So what I need is to know if there is any type I can specify for them
> : that will always result in a download?
>
> As above, no.

application/octet-streambin is the correct answer.

>
>
> : I tried this question in the html group, but I think eeryone there only
> : knows how to set types to do what you want from the windows user end,
> : not the server end.
>
> The html group probably deals with text/html most of the time.

Obviously.

Marshall




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

Date: 6 May 2003 14:37:09 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: forcing downloads
Message-Id: <3eb82b05@news.victoria.tc.ca>

Marshall Dudley (mdudley@execonn.com) wrote:
: Malcolm Dew-Jones wrote:


: application/octet-streambin is what is needed as it turns out.

I have never heard of that type.  I don't see it in the rfc.  Perhaps you
mean application/octet-stream ?

: >
: > : that would be better.  The reason is that people end up purchasing the
: > : book, then during the several days it can take to read it, end up with
: > : the browser crashing or Windows crashing, or end up closing it out
: > : prematurily.
: >
: > How is that a problem?  Surely the software accounts for that sort of
: > problem (doesn't it?).

: Since I really have no idea what software they may be using, 

That would be _your_ software, used to send the data to them, and they
will expect it to ensure they get a useable product after paying good
money. 

: then probably
: not. I know for example that the pdf viewer I have will not allow me to save
: the pdf file to the disk that I use, and neither will my doc file viewer.

In other words you are already aware that when you deliver the book then
simply performing a network transmission is not enough to ensure they get
what they paid for. 

: >
: > : Then they are unable to finish the book, and want to get it again free.
: >
: > Not really - they paid for it didn't they - you kind of owe it to them.

: If you buy a book, then lose it, do you expect the store to give you another
: copy? 

If the store mails me a book and the packaging does not protect it, or the
delivery company dumps it in the ditch outside my house instead of putting
it in the letter box, or leaves it on the step outside and it gets stolen
instead of informing me I need to come and get it, or if someone picks it
up from the post office and they don't check it's me by getting my
signature on the receiving receipt - then yes, they would have to send me
another.  If your simple download of a file does not ensure the customer
receives a usable version of what they purchased then you can't expect to
get much repeat or referal business, and in fact you can expect some irate
people to sue you for non-delivery of goods - and you can show all the
network logs you like of finished transmissions, but you won't have any
kind of signature from the user ackowledging they got the product. 


 In this case the cost of giving them a second copy is much more than
: the original, since the original is totally automated, but to give them
: another copy requires human intervention, which of course costs time and
: money.

That's only true if you have a simplistic software that does not handle
the expected problems.  There is no reason why the software could not
handle this automatically, except that you haven't put that functionality
in.  Your initial questions show that you are well aware that simply
sending the data does not ensure the user has a usable copy.  There are
examples of sites that deal with this sort of potential problem.  (E.g. 
the user gets a download token so that they have ample opportunity to
solve any such problems, and/or unpackaging receipts that prove the user
has got the download, and/or the user gets a package specific passwords so
they can re-access a download at any time within a purchased time frame,
and probably other strategies as well). 

$0.02


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

Date: 6 May 2003 11:50:44 -0700
From: anand_ramamurthy@yahoo.com (Anand Ramamurthy)
Subject: Install/setup Net::SSH::PERL
Message-Id: <761041e6.0305061050.17cd5e54@posting.google.com>

I am trying to install Net::SSH::PERL in Windows 2000 & Windows XP.
Net::Telnet is working fine for me.

I am looking for a detailed installation or setup instructions for
Net::SSH::PERL. This module seem to have a lot of dependencies and
I am not sure what is the right order.

I am getting error while installing Math::GMP. 
I get following error:
---------------------------------- Begin --------------------------------------
C:\Downloads\PERL\Math-GMP-2.03>perl makefile.pl
Checking if your kit is complete...
Looks good
Note (probably harmless): No library found for '-lgmp'
Writing Makefile for Math::GMP

C:\Downloads\PERL\Math-GMP-2.03>nmake

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

        cl -c    -nologo -Gf -W3 -MD -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT
 -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPE
RL_MSVCRT_READFIX -MD -DNDEBUG -O1    -DVERSION=\"2.03\"  -DXS_VERSION=\"2.03\"
 "-IC:\Perl_5.8.0\lib\CORE"   GMP.c
GMP.c
GMP.xs(4) : fatal error C1083: Cannot open include file: 'gmp.h': No such file o
r directory
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.

C:\Downloads\PERL\Math-GMP-2.03>
---------------------------------- Begin --------------------------------------


I tried to get GMP and build it. I did not find any instructions for building
it on Windows platform. How do I build GMP library for Windows platform.

If anybody has made some notes while installing Net::SSH::PERL, please 
mail me a copy.

I appreciate any/all help.

Regards,

-anand
anand_ramamurthy@yahoo.com


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

Date: 6 May 2003 13:58:29 -0700
From: minh_quoc@yahoo.com (Quackie)
Subject: Re: Install/setup Net::SSH::PERL
Message-Id: <39787a94.0305061258.64a9b9bb@posting.google.com>

If u use this package on Windows, don't use Net::SSH::Perl, it won't
work. Use Net::SSH::W32Perl instead.

You can get the binary of this W32Perl package by running this command
in your Perl/bin directory on Windows


ppm install --location=http://www.soulcage.net/ppds Net-SSH-W32Perl


anand_ramamurthy@yahoo.com (Anand Ramamurthy) wrote in message news:<761041e6.0305061050.17cd5e54@posting.google.com>...
> I am trying to install Net::SSH::PERL in Windows 2000 & Windows XP.
> Net::Telnet is working fine for me.
> 
> I am looking for a detailed installation or setup instructions for
> Net::SSH::PERL. This module seem to have a lot of dependencies and
> I am not sure what is the right order.
> 
> I am getting error while installing Math::GMP. 
> I get following error:
> ---------------------------------- Begin --------------------------------------
> C:\Downloads\PERL\Math-GMP-2.03>perl makefile.pl
> Checking if your kit is complete...
> Looks good
> Note (probably harmless): No library found for '-lgmp'
> Writing Makefile for Math::GMP
> 
> C:\Downloads\PERL\Math-GMP-2.03>nmake
> 
> Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
> Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
> 
>         cl -c    -nologo -Gf -W3 -MD -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT
>  -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPE
> RL_MSVCRT_READFIX -MD -DNDEBUG -O1    -DVERSION=\"2.03\"  -DXS_VERSION=\"2.03\"
>  "-IC:\Perl_5.8.0\lib\CORE"   GMP.c
> GMP.c
> GMP.xs(4) : fatal error C1083: Cannot open include file: 'gmp.h': No such file o
> r directory
> NMAKE : fatal error U1077: 'cl' : return code '0x2'
> Stop.
> 
> C:\Downloads\PERL\Math-GMP-2.03>
> ---------------------------------- Begin --------------------------------------
> 
> 
> I tried to get GMP and build it. I did not find any instructions for building
> it on Windows platform. How do I build GMP library for Windows platform.
> 
> If anybody has made some notes while installing Net::SSH::PERL, please 
> mail me a copy.
> 
> I appreciate any/all help.
> 
> Regards,
> 
> -anand
> anand_ramamurthy@yahoo.com


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

Date: Tue, 06 May 2003 17:03:09 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Newbie question Perl Print function using files
Message-Id: <Xns9373B79A32DE3sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Kasp" <kasp@epatra.com> wrote in
news:b98b65$cre$1@newsreader.mailgate.org: 

>> print CSVFILE "${firstname} , ${lastname} , ${gender}";
> 
> try instead
>     print CSVFILE "$firstname , $lastname , $gender";

Exactly how will that help?

If someone is asking for help, and you endeavor to help them, don't
just guess at the solution.  If you come up with a solution, test two
things: First, that you can replicate the OP's problem; and second,
that your proposed solution actually solves the problem.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+uDD6Y96i4h5M0egRAvbnAJ44o9lVmURHGYGfo5z39BqAXtyA5gCfYVmn
uXyFsXPw9pbFrsyOyY+CSiQ=
=0JRf
-----END PGP SIGNATURE-----


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

Date: Tue, 6 May 2003 17:03:19 -0400
From: "Tariq" <taariqq@yahoo.com>
Subject: Open With?
Message-Id: <b997rt02km4@enews2.newsguy.com>

Hello all,

I am trying to learn a little Perl, and I was going thru the book 'Teach
yourself Perl in 21 days'. Unfortunately the book is written for the Unix
OS, and I am trying the code on win2k.

I have installed Apache and Perl successfully, using the package
'indigoperl', and have run a program successfully, using the tutorial on
perl.about.com.

However, when I try the following interactive listing from the Perl book,
the application asks me to 'Open With', and displays a list of applications!

I know the shebang line has to be changed to "#!perl". Which I have done,
but I just can't figure out how to run this interactive program ... it won't
ask for input on the command line, as I had thought.

Any help would be greatly appreciated, and here is the listing.





1: #!/usr/local/bin/perl

2: $inputline = <STDIN>;

3: print( $inputline );



Sincerely,

Tariq




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

Date: Tue, 06 May 2003 19:28:55 +0000
From: euology2000 <member29223@dbforums.com>
Subject: Undefined Subroutine & And A dying CGI
Message-Id: <2846894.1052249335@dbforums.com>


Error:
The soupermail CGI died due to the following error:

Unable to find or read the config file - read
http://soupermail.sourceforge.net/faq.html#configprob
-----------------------------------------------------------------------
----------
Check your soupermail configuration or contact: kinderc@aii.edu
informing them of the error, and how and where it occured.
-----------------------------------------------------------------------
----------
Soupermail Release Version 1.0.8


Now, I have changed, moved, edited, checked, read over, looked up,
everything that I possibly can/could as to why I am still recieving this
error...it see's the config file, but it won't read it....?  0_o


but wait wait...I'm not done yet!
as well as trying to use this script i also am attempting formmail NT.

but I am recieving errors in that as well...

CGI Error
The specified CGI application misbehaved by not returning a complete set
of HTTP headers. The headers it did return are:

Undefined subroutine &main::fill_recipients called at
C:\studenthomepage\helpforms\cgi-bin\FormMail.pl line 103.


If i rewrite line 103 ever again...there will be murders!

Now, I'm not much of of a webservering person, I know html, some
macromedia and alittle java.  My work talked me into making a simple
mailto: form to be hosted on our network for our administration.  Simple
enough, Finished it in a couple days.  Well plans changed and I managed
to get talked, no wait...pushed into createing a submissions form on the
antique beast of a webserver we have here.  Now nobody in my dept
(technology) knows jack about this thing, so I've been on my own.

Honestly, I'm not even sure if my SMPT is even configured correctly, but
considering how completely behind and lagging this thing was, to where
it is now is..amazing.

If anybody can give me a hand, DEAR GOD DO SO!!!  I may go crazy if I
have to deal with this anymore..

if you need more info, email me at kinderc@aii.edu

--
Posted via http://dbforums.com


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

Date: Tue, 06 May 2003 20:13:33 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: What is good to learn
Message-Id: <87r87bsuok.fsf@mithril.chromatico.net>

Joe Creaney <mail@annuna.com> writes:

> I would like to be able to get an entry level job programming.  I am
> teaching myself C++ and Perl.  I am getting pretty good.  I am
> planning to learn to make GUIs with TK.  I am looking for some
> advice on how much I need to know and what is good for someone to
> pay me to show up and write code.

You need to know as much as possible.  I'd say that at a minimum you
ought to know about various data structures, algorithm complexity,
parsing and perhaps compiling, and object-oriented design.  Some
operating system design courses will expose you to the problems in
parallel processing; while it's unlikely you will ever work on an
operating system, especially in perl, concepts like mutual exclusion
will serve you well in a distributed environment like the web. You
also need experience producing clear and maintainable code; this
usually isn't something you learn unless other people are involved in
the process.  You also ought to be familiar with basic programming in
several *different* languages -- LISP or Scheme, Smalltalk, C, Eiffel,
Prolog, and Self.  Finally, you need to know how to solve problems,
how to read for content, and how to do research.

That's probably not the answer you wanted.  

Charlton



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

Date: 6 May 2003 12:55:08 -0700
From: tcnolan@optonline.net (tcnolan)
Subject: Re: XO host can't use CHMOD
Message-Id: <9f360d9e.0305061155.b1a2372@posting.google.com>

Michael,

Thank you...that did help and I was able to find the problem.

Terry


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

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


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