[16568] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3980 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 10 21:05:28 2000

Date: Thu, 10 Aug 2000 18:05: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: <965955913-v9-i3980@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 10 Aug 2000     Volume: 9 Number: 3980

Today's topics:
    Re: 'require'd functions access main variables <tim@ipac.caltech.edu>
        -T and %ENV{'PATH'} <johnny@johnnyamos.com>
    Re: [Q]s: sizeof in perl, ioctl.ph... <abe@ztreet.demon.nl>
    Re: Active Perl for Linux...   <bkennedy@hmsonline.com>
    Re: Active Perl for Linux... <lauren_smith13@hotmail.com>
    Re: Active Perl for Linux... (brian d foy)
    Re: Apache/EmbPerl on Win32 Platform <elephant@squirrelgroup.com>
    Re: Cant figure this out. <elephant@squirrelgroup.com>
    Re: Date convert <abe@ztreet.demon.nl>
    Re: File handle and symbolic link <elephant@squirrelgroup.com>
        http get w/ authentication weiqingh@my-deja.com
    Re: integers <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: integers <abe@ztreet.demon.nl>
    Re: multi file modules <elephant@squirrelgroup.com>
    Re: multi file modules <memmett@fraser.sfu.ca>
    Re: multi file modules <elephant@squirrelgroup.com>
    Re: Need help with simple cgi code <tony_curtis32@yahoo.com>
    Re: Perl 5.005_03 script does not work in 5.6.0 <tripix@metaverse.fsnet.co.uk>
    Re: Perl 5.005_03 script does not work in 5.6.0 <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Perldoc, Redirect Output to File? WinNT <abe@ztreet.demon.nl>
    Re: Putting data into a form. <callgirl@la.znet.com>
    Re: reg expressions - protect html <callgirl@la.znet.com>
    Re: Uploading Images centelec@my-deja.com
    Re: warning/var weirdness (or is it?) <elephant@squirrelgroup.com>
    Re: zgrep <*@qz.little-neck.ny.us>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 10 Aug 2000 16:48:44 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: 'require'd functions access main variables
Message-Id: <39933F5C.AB322970@ipac.caltech.edu>

Blair Heuer wrote:
> In the main script:
> 
>     &load( 'standard' );
> 
> In a required 'parse.pl' file:
> 
>     sub load() {

Do you know what 'sub load() {...}' means? See perlsub. The '()' is a prototype
telling perl that load doesn't take any args. If you call it as you did you
should get an error message. Do you? Is that the problem? Or is something not as
you think, or not as you're showing?

A short User's Guide to using CLPM:

You're not revealing enough here. I want to see how you're doing the requires
and what the error messages you're getting are. What isn't working exactly, and
how do you know? You're also showing too much; I don't need to know all that the
subs do, just the parts that go wrong. Fake up a test case like this:

(-w and 'use strict' not employed for brevity. But you *are* using them, aren't
you?)

main:
  require 'a.pl';
  $global=1;
  print_global();
a.pl:
  sub print_global { print "$global\n"; }
  1;

What happens?


--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Fri, 11 Aug 2000 00:37:22 GMT
From: Johnny Amos <johnny@johnnyamos.com>
Subject: -T and %ENV{'PATH'}
Message-Id: <39934D19.FC4E9124@johnnyamos.com>

I am writing a script (my first) and i am using Taint mode.
I forgot to set %ENV{'PATH'} initially and got the usual warning, but
when I set %ENV{'PATH'} I got a 500 Server Error message instead.

Here's how I set %ENV{'PATH'}:

$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/lib';

What am I doing wrong?

Johnny
--


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

Date: Fri, 11 Aug 2000 01:23:19 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: [Q]s: sizeof in perl, ioctl.ph...
Message-Id: <hrd6ps0lecrrotflnj5jfbg0pg3413lulk@4ax.com>

On 10 Aug 2000 12:30:44 -0400, kj0 <kj0@mailcity.com> wrote:

> I have:
> 
>   $x = pack "L", 1;
> 
> I want to follow it with:
> 
>   syswrite OUT, $x, $sizeof_x;
> 
> But I know of no easy, portable way of finding out what $sizeof_x
> should be.  (Obviously, this is a gap in my knowledge, because it is
> just not possible that Perl would lack the functionality of C's
> sizeof.)

No need for it in this case:

	perldoc -f pack

	L An unsigned long value.
		(This 'long' is _exactly_ 32 bits, which may differ from
		what a local C compiler calls 'long'.  If you want
		native-length longs, use the '!' suffix.)

But if you don't believe perlfunc:

	perl -e '$x = pack "L", 1;print length $x;'

-- 
Good luck,
Abe


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

Date: Thu, 10 Aug 2000 23:47:14 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Active Perl for Linux...  
Message-Id: <6aHk5.92124$A%3.1250593@news1.rdc2.pa.home.com>


"Lou Moran" <lmoran@wtsg.com> wrote in message
news:8vOSOQ4MBGAr6pkczJUWnGYu0xM0@4ax.com...
> --Any advantages, dis-advantages?

You get all the advantages/disadvantages of rpm packages - the good things
would be easy install/verification/upgrade/un-install.  The bad things would
be little/no ability to customize - it looks like the activestate packages
have thread support bultin the binary for instance.  As to advantages to Red
Hat Perl, I think that also is installed via a rpm package, and there are
too many dependencies to remove it gracefully.  Trying to add another perl
rpm may really mess things up, I would recommend installing the latest Perl
in a different directory (which 5.6.0 should), and changing the symlinks in
/bin.

--Ben Kennedy




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

Date: Thu, 10 Aug 2000 15:04:04 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Active Perl for Linux...
Message-Id: <8mv8pf$c36$1@brokaw.wa.com>


Lou Moran <lmoran@wtsg.com> wrote in message
news:GB6TOXV9wtr8uMv86FRiU8ur=cyN@4ax.com...
> Kent,
>  ActiveState calls their product ActivePerl...  They have Linux
> distros available (RH rpm, Debian, Linux AS...) so I was merely
> wondering if there would be any advantage or disadvantage to using it
> over the pre-installed Perl from my RH 6.2 distro, or the Perl
> available at www.perl.org (et al).

ActiveState's distribution is likely a lot more up to date than the one that
came with RH.

Lauren





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

Date: Thu, 10 Aug 2000 18:28:34 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Active Perl for Linux...
Message-Id: <brian-ya02408000R1008001828340001@news.panix.com>

In article <GB6TOXV9wtr8uMv86FRiU8ur=cyN@4ax.com>, Lou Moran <lmoran@wtsg.com> posted:

>  ActiveState calls their product ActivePerl...  They have Linux
> distros available (RH rpm, Debian, Linux AS...) so I was merely
> wondering if there would be any advantage or disadvantage to using it
> over the pre-installed Perl from my RH 6.2 distro, or the Perl
> available at www.perl.org (et al).

www.perl.org doesn't have a software archive.  use www.cpan.org
for all of your Perl source needs :)

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Fri, 11 Aug 2000 00:44:51 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Apache/EmbPerl on Win32 Platform
Message-Id: <MPG.13fde9ef414202dc989696@localhost>

Par Svensson wrote ..
>I have downloaded the binary distribution of Apache/EmbPerl (perl-win32-bin-0
>and installed it, following the instructions. However, after starting the Apa
>server and loading a file containing embedded Perl, the Perl code just shows 
>without being executed. I have tried both using the httpd.conf-dist-win and
>httpd.conf-perl configuration files, both including the line 
>LoadModule perl_module modules/ApacheModulePerl. 
>I am running Windows 98 and my test file was:
>
><HTML>
><BODY>
>[- $a=5 -]
>[+ $a +]
></BODY>
></HTML>
>
>
>The documentation doesn't say much about Win32-installation at all. Hope
>someone can help me, or give me a pointer in the right direction.

this is not a Perl issue .. it's an issue with installing a handler on 
an Apache web server (it's also a problem that you would face whether on 
Win32 or not) .. please post your question to an appropriate newsgroup

AND your newsreader has set your line width to at least 86 chars .. it 
should be something closer to 72 (to allow a reasonable number of 
followups) .. you'll find that my newsreader is just going to truncate 
those lines

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 10 Aug 2000 23:12:59 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Cant figure this out.
Message-Id: <MPG.13fdd468f9c0a41b989693@localhost>

Anno Siegel wrote ..
>jason  <elephant@squirrelgroup.com> wrote in comp.lang.perl.misc:
>>psycho wrote ..
>>>Easily put, need to be able to cut the last part of a scarlar at
>>>a determind character.  There would be more then of these
>>>characters, but the last one and all data after that character
>>>is to be deleted.
>>
>>  perldoc -f substr
>>  perldoc -f rindex
>
>Why rindex?  The way I understand the OP, everything after (and including)
>the *first* occurence of some character is to be deleted.

the originator's words are still included in this forward .. don't know 
how you can be misinterpreting them so much

  "...the last one and all data after that character is to be deleted."

stop doing those things that make you go blind *8^)

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 11 Aug 2000 00:27:32 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Date convert
Message-Id: <2ia6psc33d12h93k4bsnn0nse45av470fs@4ax.com>

On Thu, 10 Aug 2000 13:54:52 GMT, bakhshek@essilor.fr wrote:

 ...

> 	$tt = 13165;
> 	$tt %= 3600;
> 	$tt ==> 3.65694444444444;   # comment faire pour n'avoir que 3

No it's not. $tt ==> 2365
although 
	$tt /= 3600;
will give that result.

	perldoc integer

Please post real code the next time.

-- 
Good luck,
Abe


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

Date: Thu, 10 Aug 2000 23:57:57 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: File handle and symbolic link
Message-Id: <MPG.13fddef0423c82af989694@localhost>

Yidao Cai wrote ..
>1. File handle
>
>Suppose in Sub1, we open "fileA" with
>
>open(FIN, "<$filename);
>
>where $filename = "fileA".
>
>Now we call Sub2, and Sub2 call Sub1 and use the same open() line, only
>that $filename = "fileB". Now the since FIN is associated with "fileB"
>and we have no way to access "fileA" again.
>
>Is there a my() equivelent for file handles?

how exciting .. you've found a genuine situation where you get to use 
'local'

'local'ise the filehandle typeglob inside sub2 .. it will be restored on 
exit

  perldoc -f local
  perldoc perlsub

you could also use an expression in place of the filehandle in the 
open so that there are actually two different filehandles depending on 
the caller .. eg.

  open $filename, "<$filename";

which will mean that you can use the filehandle fileA for fileA and 
fileB for fileB (obviously there are limits to the characters that a 
filehandle can consist of - so use this method with caution)

>2. Symbolic link
>
>SymLink is soft-link to "realDir".
>
>-f SymLink   returns true
>-f SymLink/   returns false
>
>Why is this? 

sorry .. don't know that one

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 11 Aug 2000 00:24:32 GMT
From: weiqingh@my-deja.com
Subject: http get w/ authentication
Message-Id: <8mvh3t$h42$1@nnrp1.deja.com>

hi there,

i know many people have asked this question b4. and i tried the sample
code in the perldoc lwpcook

      use LWP::UserAgent;
      $ua = new LWP::UserAgent;
      $req = new HTTP::Request GET => 'http://my.yahoo.com/';
      $req->authorization_basic('aas', 'mypassword');
      print $ua->request($req)->as_string;

i still cannot get myyahoo's page. the one i got is the login page
instead. any ideas what i did wrong? thanx in advance.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 10 Aug 2000 14:24:48 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: integers
Message-Id: <39931DA0.7F83384E@jpl.nasa.gov>

King Verence wrote:
> 
> I have a Javascript routine that encrypts numbers, below. It encrypts
> and decrypts fine, but when I rewrite it in perl (see snippet), it
> breaks, I think because of the different ways perl and JS use
> integers.
> 
> I believe that the JS code works with int being 32bit signed, and perl
> is too clever.
> 
> Anyone know how to get round the unstrict typing to preserve the
> functionality in perl ( I really don;t want to use another language if
> at all avoidable)

use integer; doesn't help here.  You're best bet might be to code these
functions in C and write an XS interface to it.  Also, search CPAN. 
Perl code is the wrong tool for this job.

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Fri, 11 Aug 2000 01:13:30 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: integers
Message-Id: <gec6ps8lfhlk13slbm9jp1uvs82ode1drr@4ax.com>

On Thu, 10 Aug 2000 17:07:36 +0100, King Verence
<verence1964@hotmail.com> wrote:

 ...

> sub encipher
> {
>         $y     = $_[0];
> 	$z     = $_[1];
> 	$a     = $_[2];
> 	$b     = $_[3];
> 	$c     = $_[4];
> 	$d     = $_[5];

That could be writen as:
	my($y, $z, $a, $b, $c, $d) = @_;

>         $sum   = 0x0;
> 	$delta = 0x9E3779B9;
> 	$n     = 32;
>         while ($n-- > 29) {
That 29 was 0 in the JS code.

>                 $sum += $delta;
>                 $y += ($z << 4) + $a ^ $z + $sum ^ ($z >> 5) + $b;
>                 $z += ($y << $4) + $c ^ $y + $sum ^ ($y >> 5) + $d;
> 	}
>         $_[0] = $y;
>         $_[1] = $z;

you could use a slice for that:
	@_[0, 1] = ($y, $z);

But remember that both will change the values of the first two
parameters (the originals passed to the sub).
If you don't want that, have your sub just return the list:

	return ($y, $z);

and call your sub like:

	my($p3, $p4) = encipher(....);

I can't say anything in relation to your Subject: (integers), since you
didn't provide any testdata with expected output.

-- 
Good luck,
Abe


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

Date: Thu, 10 Aug 2000 23:00:08 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: multi file modules
Message-Id: <MPG.13fdd15b84dc78b2989691@localhost>

Matthew Emmett wrote ..
>jason <elephant@squirrelgroup.com> writes:
>
>> at a guess .. your use line has Modules::RosterUI in it .. you
>> realise that will make Perl look for 'Modules/RosterUI.pm' in the
>> directories in @INC .. if Roster.pm and RosterUI.pm are in the same
>> directory then you should probably just have
>> 
>>   use RosterUI;
>> 
>
>In the "main" script, I have "use Modules::Roster;", so the Modules
>directory isn't in @INC.  That's why I have to do "use
>Modules::RosterUI;".

I didn't say that the Modules directory would be in @INC .. I said that 
Perl will be looking IN the directories in @INC FOR the Modules 
directory .. but it doesn't really matter - because you'd be getting a 
very obvious error from that anyway

>> it would seem that you've got things pretty messed up and that
>> whatever is 'use'ing Roster is also 'use'ing RosterUI .. perhaps it
>> should just use Roster which in turn uses RosterUI
>
>That's what it does.  Hmmm.... thanks for your thoughts though.  Any
>other suggestions?

so the main program just uses Roster and then Roster uses RosterUI .. so 
what's $top set to ? .. where does this Frame() method come from ?

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 10 Aug 2000 16:30:54 -0700
From: Matthew Emmett <memmett@fraser.sfu.ca>
Subject: Re: multi file modules
Message-Id: <yvw93dkclmmp.fsf@fraser.sfu.ca>

jason <elephant@squirrelgroup.com> writes:

> Matthew Emmett wrote ..
> >jason <elephant@squirrelgroup.com> writes:
> >
> >> at a guess .. your use line has Modules::RosterUI in it .. you
> >> realise that will make Perl look for 'Modules/RosterUI.pm' in the
> >> directories in @INC .. if Roster.pm and RosterUI.pm are in the same
> >> directory then you should probably just have
> >> 
> >>   use RosterUI;
> >> 
> >
> >In the "main" script, I have "use Modules::Roster;", so the Modules
> >directory isn't in @INC.  That's why I have to do "use
> >Modules::RosterUI;".
> 
> I didn't say that the Modules directory would be in @INC .. I said that 
> Perl will be looking IN the directories in @INC FOR the Modules 
> directory .. but it doesn't really matter - because you'd be getting a 
> very obvious error from that anyway

Right, err, sorry, I think I said that wrong.  I meant to say that I
have to have "use Modules::RosterUI;" because the Modules directory
isn't in INC.

> >> it would seem that you've got things pretty messed up and that
> >> whatever is 'use'ing Roster is also 'use'ing RosterUI .. perhaps it
> >> should just use Roster which in turn uses RosterUI
> >
> >That's what it does.  Hmmm.... thanks for your thoughts though.  Any
> >other suggestions?
> 
> so the main program just uses Roster and then Roster uses RosterUI

Right.  The main program has "use Modules::Roster;" and Roster.pm has
"use Modules::RosterUI;".

 ./shddb  (the main program)
 ./Modules/Roster.pm
 ./Modules/RosterUI.pm


> so what's $top set to ? .. where does this Frame() method come from

$top is a Tk widget.  The Frame() method comes from the Tk module.

I think the problem is that (somehow) the methods defined in RosterUI
aren't considered part of the Roster class.  I say this because I have
to explicity pass them $self.  I don't see anything obviously wrong,
do you?  Anyways, I don't want to keep pestering everyone.  I just
wanted to make sure that I wasn't doing something totally silly.  

Well, back to punting...

Thanks for your help,
Matt





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

Date: Fri, 11 Aug 2000 00:35:00 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: multi file modules
Message-Id: <MPG.13fde7a01b97b15c989695@localhost>

Matthew Emmett wrote ..

  [ attributions stripped - it's just me an' Emmett ]

>> >> it would seem that you've got things pretty messed up and that
>> >> whatever is 'use'ing Roster is also 'use'ing RosterUI .. perhaps it
>> >> should just use Roster which in turn uses RosterUI
>> >
>> >That's what it does.  Hmmm.... thanks for your thoughts though.  Any
>> >other suggestions?
>> 
>> so the main program just uses Roster and then Roster uses RosterUI
>
>Right.  The main program has "use Modules::Roster;" and Roster.pm has
>"use Modules::RosterUI;".
>
>./shddb  (the main program)
>./Modules/Roster.pm
>./Modules/RosterUI.pm

ok .. but is the absolute path to that top level directory explicitly 
mentioned in @INC ? .. or are you relying on the fact that the current 
directory (in the form of '.') is always in @INC ?

if it's the latter then that's where the 'use Modules::RosterUI.pm' will 
break down when used inside Roster.pm .. because Roster.pm is in the 
 ./Modules directory .. and so for Perl THAT directory is the current 
directory .. so it goes looking for

  ./Modules/Modules/RosterUI.pm

just give it a try .. in Roster.pm try just 'use'ing RosterUI.pm .. see 
what happens

>> so what's $top set to ? .. where does this Frame() method come from
>
>$top is a Tk widget.  The Frame() method comes from the Tk module.

ok .. so shddb 'use's Tk as well and passes the value for $top into the 
Roster constructor ? .. ok then the problem is almost certainly the 
above one with the 'use'

>I think the problem is that (somehow) the methods defined in RosterUI
>aren't considered part of the Roster class.

if the 'use' is wrong then they're not there at all .. but in any case 
they will never be part of the Roster class .. they'll be part of the 
RosterUI class

maybe (if the 'use' thing isn't the problem) have a read of perltoot .. 
that might clear up some issues

  perldoc perltoot

>I don't see anything obviously wrong, do you?  Anyways, I don't want
>to keep pestering everyone.  I just wanted to make sure that I wasn't
>doing something totally silly.

still not sure that you're not doing that 'use' all wrong

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 10 Aug 2000 19:37:41 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Need help with simple cgi code
Message-Id: <87d7jgy6ne.fsf@limey.hpcc.uh.edu>

>> On Wed, 9 Aug 2000 16:17:31 -0500,
>> "Peter" <peterclones@hotmail.com> said:

> I'm a newbie with cgi scripting so need a quick hand in
> writing this simple code.  I'm trying to write a script
> that grabs the 'HTTP_REFERER' info from the Environment
> variables and prints it to a text file.  Each time the
> script is run I'd like it to add it to the list that's
> already there in the text file.  I know this is terrible
> easy to do but I'm merely a beginner.  Here's what I
> have so far:

> #!/usr/bin/perl

    #!/usr/bin/perl -w
    use strict;

will help you catch lots of problems while you are
developing.

> $caller = $ENV{'HTTP_REFERER'};

you should check here to make sure that the referer is
actually set to something, before writing it to the file.

> open SITES,">sites.txt";

OK, heads up!  You're writing to a file in a CGI program.
You'll need to implement locking to prevent multiple
instances of the program from overwriting each other.

In a CGI context, you'll probably need to put in the full
path to the file, this being a major gotcha as the CGI
execution environment is usually very different from a
login shell.

Also I suspect you should be appending to the file (>>)
and you should check whether the open succeeded,

    my $filename = 'sites.txt';
    open SITES, ">> $filename" or die "$0 can't open $filename: $!\n";

Putting

    use CGI::Carp 'fatalsToBrowser';

in your program will allow such die messages to appear in
your browser, rather than secreted in the web server's
logfiles.

> print $caller;

you're printing this to stdout, not to the file,

    print SITES "$caller\n";

A timestamp here might be helpful, perldoc -f localtime.

> close SITES;

You might want to check the close() as well, see above.

You have to return something to the browser (or whatever
is causing your program to be invoked).  Take a long hard
look at "perldoc CGI" for the CGI.pm module.  This will
solve about 98.3% of yor initial problems with CGI
programming in perl.

NB: questions specifically concerned with CGI aren't
on-topic in this group, you should use
comp.infosystems.www.authoring.cgi instead.

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Thu, 10 Aug 2000 23:00:54 +0100
From: Wayne Keenan <tripix@metaverse.fsnet.co.uk>
Subject: Re: Perl 5.005_03 script does not work in 5.6.0
Message-Id: <39932616.8C3243D6@metaverse.fsnet.co.uk>

Stuart Moore wrote:
> 
> The web hosting company we use have recently upgraded from Perl 5.005_03 to
> Perl 5.6.0
> Three of my scripts no longer work; all report
> 
> Modification of a read only value attempted at xxx.pl line nnn
> 
> and in each case the line number is in the same common function:
> 
> sub subs
> {
>  # args: $searchstring, then hash of replace what with what.
>  my ($searchstring, %replacewith, $searchfor);
>  chomp(@_);
>  $searchstring = shift @_;
>  %replacewith = @_;
>  foreach $searchfor (keys %replacewith)
>   {
>   $searchstring =~ s/$searchfor/$replacewith{$searchfor}/gi;
>   }
>  return $searchstring;
> }
> 

instead:

chomp $searchstring;
 

> One fails on chomp(@_); and the other two give the line number of the { in
> the foreach loop. I'm guessing that it's because one of the parameters to
> the function has been marked as read-only (I suspect the one ladled
> $searchstring, as it's the only one the function attempts to change).

not quite right, chomp is a list operator and thus will change (what will be)
$searchstring AND all keys and values of (what will be) %replacewith

> Presumably the one failing on chomp contains a string that needs to be
> truncated, whereas on the others it is not until the regular expression that
> the script tries to change any of the values. $searchstring is a string
> that's been made by reading a template file, and the others are just from a
> hash (I know it'd be more efficient with references, but I'm not yet fully
> confident with them, and this is good enough for me). Typical uses in my
> scripts are:
> 
>  open TEMPLATE, "template.html";
>  my @template=<TEMPLATE>;
>  close TEMPLATE;
>  my $template=join "", @template;
>  print subs($template,%replace);
> 
> or
> 
>  print &subs($data{'header'},'£links',$links,'£message',$message);
> 
> (Note that in this last example $data{'header'}originally came from a file,
> but unlike the example above it was not the whole file, just a selected
> portion of it, just in case that's relevant)
> 
> I apologise if this is something that's well known about the new version and
> I should have heard of it - if there are any worthwhile forums/mailing lists
> that point out these kind of things, I'll be glad to hear of them

I dont use version 5.6, but I would have thought it should work. ;)

> 
> Many thanks
> 
> Stuart Moore


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

Date: Thu, 10 Aug 2000 15:23:34 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Perl 5.005_03 script does not work in 5.6.0
Message-Id: <39932B66.10DA902B@jpl.nasa.gov>

Stuart Moore wrote:
> The web hosting company we use have recently upgraded from Perl 5.005_03 to
> Perl 5.6.0
> Three of my scripts no longer work; all report
> 
> Modification of a read only value attempted at xxx.pl line nnn

See
<http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-06/msg00303.html>
for a related issue.  It seems that perl 5.6.0 became more strict about
modifying references to string literals.  Couldn't find a reference in
perldelta however :(

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Fri, 11 Aug 2000 01:36:44 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Perldoc, Redirect Output to File? WinNT
Message-Id: <9je6ps4sae3717urj4ckts5vaa5hdijif9@4ax.com>

On Thu, 10 Aug 2000 17:21:33 GMT, Jerry Leventer <9jerry9@my-deja.com>
wrote:

> In article <8knqn3$srf$1@nnrp1.deja.com>,
>   Jerry Leventer <9jerry9@my-deja.com> wrote:
> > I am running perl v5.6.0, bld 615 on WinNT4.0.
> >
> > I would like to redirect the perldoc output to a file so I can print
> > it out or view it in a text editor such as 'vi'.
> > Is there a way to do this?  I tried,
> >
> >         perldoc perldoc > file
> >
> 
> My Latest Observations:
> 
> The redirection seems to work on NT but not on Win95.  Has anyone else
> experienced this?
> 
>         perldoc extutils::installed > file
> 
Maybe pod2text.bat is what you're looking for?
It won't do perldoc's -f or -q

-- 
Good luck,
Abe


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

Date: Thu, 10 Aug 2000 16:57:26 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: Putting data into a form.
Message-Id: <39934166.BFDFC286@la.znet.com>

***
Goodness Gracious Alive! Did I ever make
a mess of my first article. One article
cancelled. Another posted. I am sorry
if you see this article twice!

* feels like the airhead she is *

***


emavres@yahoo.com wrote:

My word, a fake email address at yahoo, posted
via fake dejavu through a fake proxy server. You
must be someone famous to place so much effort
into concealing yourself!

 
> I would like to get data from a file and place it into 
> a form on an HTML page when the user selects a button.
> I know how to get form data using perl but cant figure 
> out how to write data into some of the form elements.

You know how to collect form data using Perl, therefore
you also know how to include data in an html print using
Perl. Is this not so?

* laughs *


> The form only has text fields.

No form action tag? No submit button?
Ok, I will meet you halfway and leave
out submit buttons for my examples.

Ahem...

There must be fifty ways to leave your lover and
just as many ways print data into a form action.
Below are three methods of many using bare bones 
skeleton scripts for examples.

I like this Array method. Already enclosed in
quotes which includes neat spaces between elements
with no need for extra coding. Cleaned up single
string is kinda nice as well. Personally, I loathe
messy document sources. See these all the time.
Most unprofessional. A messy single string is
certainly not the way to go although it works,
if you don't mind words running together and
a rather shameful document source.

Nothing to this, right? Just a matter of printing
whatever data into your VALUE for a form text box.

Now you know what you already knew. So what method
of fifty will you use to do something you most likely
have no intent of doing?

Godzilla!


 
TEST SCRIPTS:
_____________

#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

print "Method One - Array within quotes: \n";

open (DATA, "test.txt");
@Array = <DATA>;
close (DATA);
chomp @Array;

print "
  <html>
  <form action=\"test.cgi\">
  <input type=\"text\" name=\"Data\" value=\"@Array\">
  </form></html>";

print "\n\n\nMethod Two - Messy single string: \n";

$/ = "";
open (DATA, "test.txt");
$data = <DATA>;
close (DATA);

print "
  <html>
  <form action=\"test.cgi\">
  <input type=\"text\" name=\"Data\" value=\"$data\">
  </form></html>";

print "\n\n\nMethod Three - Cleaned up single string: \n";

$/ = "";
open (DATA, "test.txt");
$data = <DATA>;
close (DATA);

$data =~ s/\n/ /g;
chop ($data);

print "
  <html>
  <form action=\"test.cgi\">
  <input type=\"text\" name=\"Data\" value=\"$data\">
  </form></html>";

exit;


CONTENTS OF TEST.TXT:
____________________

line one
line two
line three


PRINTED RESULTS:
________________

Method One - Array within quotes:

  <html>
  <form action="test.cgi">
  <input type="text" name="Data" value="line one line two line three">
  </form></html>


Method Two - Messy single string: 

  <html>
  <form action="test.cgi">
  <input type="text" name="Data" value="line one
line two
line three
">
  </form></html>


Method Three - Cleaned up single string:

  <html>
  <form action="test.cgi">
  <input type="text" name="Data" value="line one line two line three">
  </form></html>


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

Date: Thu, 10 Aug 2000 15:36:36 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: reg expressions - protect html
Message-Id: <39932E74.A6B065A2@la.znet.com>

Russ Jones wrote:

> > > Lots of meaningless stuff gets included where
> > > you would think it shouldn't.

> > This is especially true of newsgroup articles.
 
> (more crap snipped)
 
> I was referring to your meaningless drivel, you twit.
 
> ps: I wish you'd just use one email account.
> plonk again.


Yep, lots of meaningless stuff in newsgroup articles.

I only have one email address which I 'unmung' periodically
as a courtesy to people. You have a problem with this?
Probably not, based on your killfiling people based
on who they are, rather than what they say.

Hmm... * thinks bigot *

Another Blessing from Heaven in one day! 

This is blessing in my not being subjected so much to
the usual insults, vulgarities, threats, racial slurs,
email bombing and outright crime so common within this
newsgroup. Best of all, our family has not needed to
contact law enforcement for over a month now, to register
our concerns about crimes being committed against us
by regulars here.

Indeed, God is smiling upon our little family!
I am grateful.

Godzilla!


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

Date: Thu, 10 Aug 2000 22:48:26 GMT
From: centelec@my-deja.com
Subject: Re: Uploading Images
Message-Id: <8mvbfp$d8h$1@nnrp1.deja.com>

In article <Pine.GHP.4.21.0008102319150.10110-100000@hpplus03.cern.ch>,
  "Alan J. Flavell" <flavell@mail.cern.ch> wrote:
> On Thu, 10 Aug 2000 centelec@my-deja.com wrote:
>
> >         My server is using Windows NT.
>
> binmode(); for input and output.
>
>

Thanks Alan. That worked like a charm. I really appreciate it.
       Bob


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 10 Aug 2000 23:08:59 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: warning/var weirdness (or is it?)
Message-Id: <MPG.13fdd36f6a6b2b7c989692@localhost>

Ben Kennedy wrote ..
>
>"fvw" <fvw+usenet@var.cx> wrote in message news:965879311ZGS.fvw@var.cx...
>> I have the following code:
>>
>> #!/usr/bin/perl -w
>> my $a='foo';
>> my $b="${a}${a}[";
>> print $b;
>
>I can give some insight, maybe someone else can add sone
>
>the "my $a = 'foo'" introduces a lexical $a - which means $main::a does not
>exist
>
>when you interpret "${a}${a}[", the first ${a} is not being treated like a
>symbolic reference - the second one is - for example
>
>#!/usr/bin/perl -w
>my $a = 'foo';
>$main::a = 'bar';
>
>my $b = "${a}${a}[ ${'a'}";
>print $b . "\n";
>
>My guess (which may be wrong) is that in the first case, the perl
>preprocessor optimizes away the first curlies to "$a${a}[" - this allows the
>first $a to point to the lexical $a - while adding the [ (or a left curly)
>forces the curlies to act as a symbolic deref, which by definition cannot
>point to a lexical var.

that's a good guess .. but I still see it as a bug .. something like - 
in order to resolve the ambiguity imposed by the '[' Perl does the wrong 
thing with the '{}'s which results in them being evaluated in symbolic 
deref circumstances

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 10 Aug 2000 22:51:50 GMT
From: Eli the Bearded <*@qz.little-neck.ny.us>
Subject: Re: zgrep
Message-Id: <eli$0008101816@qz.little-neck.ny.us>

In comp.lang.perl.misc, dsivasan  <dsivasan@ford.com> wrote:
> This is a multi-part message in MIME format.

Ugh.

> Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"

What good is this on Usenet?

> Is there an alternative to zgrep (grep through zip files) in Perl ?

Zip files? The zgrep I know does gzip files, but a general purpose
compressed file grep could be handy.

#!/usr/bin/perl -w
# Grep through possibly compressed files.
# Eli the Bearded		10 Aug 2000
use strict;
use vars qw($file $filtfile %filt $re $ext);

%filt = (
	'z'    => 'gzip -d <',	# .z is very old gzip
	'Z'    => 'gzip -d <',	# 'compress -d', properly
	'gz'   => 'gzip -d <',	# gzip
	'tgz'  => 'gzip -d <',	# tar gzip, won't work cleanly
	'bz2'  => 'bzip2 -d <',	# bzip2
	'zip'  => 'unzip -p',	# zip, won't work cleanly
#	'C'    => 'unpack <',	# pack is ancient, likely suffix conflict
);

$_ = shift;
die "$0: usage\n\t$0 regexp file [...]\n"
	unless defined($_) and defined($ARGV[0]);

$re = qr/$_/;

for $file (@ARGV) {

  if ($file =~ /\.(\w+)$/) {
    $ext = $1;
    if (defined($filt{$ext})) {
      $filtfile = $filt{$ext} . " $file|";
    } else {
      $filtfile = "< $file";
    }
  } else {
    $filtfile = "<$file";
  }

  if(!open(FILE, $filtfile)) {
    $filtfile =~ s/\|$//;
    warn "Can't open '$filtfile': $!\n";
    next;
  }
  
  while(<FILE>) {
    print "$file: $_" if /$re/;
  }
  close FILE;
}
exit(0);
__END__


Elijah
------
off the top of my head


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3980
**************************************


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