[16407] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3819 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 27 09:05:30 2000

Date: Thu, 27 Jul 2000 06: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: <964703113-v9-i3819@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 27 Jul 2000     Volume: 9 Number: 3819

Today's topics:
        "Illegal seek" error while opening filehandles sm108@hotmail.com
        Byte swapping: Win32 Perl script reading UNIX file <cingram-at-pjocs-dot-demon-dot-co-dot-uk>
    Re: CGI passing parameters <six4eight@NOSPAMhotmail.com>
    Re: CGI passing parameters <bart.lateur@skynet.be>
    Re: Critiques, please (Marcel Grunauer)
    Re: Critiques, please (Villy Kruse)
    Re: difference between two times in seconds <bart.lateur@skynet.be>
    Re: exactly WHEN will PP-3rd be in bookstores, etc?  An <iltzu@sci.invalid>
    Re: File path, Select value, Redirect Basic =?iso-8859- (Bernard El-Hagin)
    Re: File path, Select value, Redirect Basic ?’s mandbinc@rocketmail.com
    Re: Formatting text file <iltzu@sci.invalid>
    Re: pattern match <jimmy.lantz@ostas.lu.se>
        Problem executing Perl script on Apache server with Fre apolinad@my-deja.com
    Re: Problem executing Perl script on Apache server with <red_orc@my-deja.com>
        Problems wit Win32::TieRegistry <Roger.Tillmann@extern.rwso.de>
    Re: Saving space in a hash <iltzu@sci.invalid>
    Re: Search Question <tom.kralidis@ccrs.nrcanDOTgc.ca>
        security issue <bdcomNObdSPAM@ri.cgocable.ca.invalid>
    Re: security issue <tom.kralidis@ccrs.nrcanDOTgc.ca>
    Re: seeing $main::FOO in used module (Marcel Grunauer)
    Re: seeing $main::FOO in used module <iltzu@sci.invalid>
    Re: shifting strings <iltzu@sci.invalid>
    Re: start perlscript as nt service <Peter.Dintelmann@dresdner-bank.com>
    Re: Suggestion for syntax change <elephant@squirrelgroup.com>
    Re: user login NT <Peter.Dintelmann@dresdner-bank.com>
    Re: Was Why won't  "use strict;"  work? (Keith Calvert Ivey)
        Why doesn't my Perl script execute? apolinad@my-deja.com
    Re: Why doesn't my Perl script execute? (matt venn)
    Re: Why doesn't my Perl script execute? <red_orc@my-deja.com>
    Re: Why use anonymous? <elephant@squirrelgroup.com>
    Re: Why use anonymous? <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Jul 2000 10:11:34 GMT
From: sm108@hotmail.com
Subject: "Illegal seek" error while opening filehandles
Message-Id: <8lp1sk$7rv$1@nnrp1.deja.com>

I am trying to open a filehandle to write to a file
called "../dir/name/FILENAME".  I take files uploaded from a web form
and want to dump them to files (the file name changes each time - I'm
NOT trying to append).

I've tried

- open FH, ">../dir/name/FILENAME" or die $!; #relative path
- open FH, ">/home/steve/dir/name/FILENAME" or die $!; #full path
I have also tried changing ">" to "+>".

In all cases perl dies with an "Illegal seek" error.
The directories are all chmod 777.  The files don't initially exist, or
should be clobbered if they do.

Any idea what this message is?  I've tried to look it up in the camel
book, the "perl*" manpages, perl.org, cpan.org, deja.com and other
places, no joy.

If you have any idea what the problem is, please help me :-(

thanx :-)

Steve


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


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

Date: Thu, 27 Jul 2000 12:47:02 +0100
From: "Clyde Ingram" <cingram-at-pjocs-dot-demon-dot-co-dot-uk>
Subject: Byte swapping: Win32 Perl script reading UNIX file
Message-Id: <964698103.11197.0.nnrp-03.9e98e5bc@news.demon.co.uk>

Using od -x on an NT PC to look at a UNIX file over the LAN, I see that
bytes are swapped when od displays the file contents, compared to running
the UNIX od -c command on the UNIX system where the same file lives.

I believe this is stopping file seek calls from working properly when a
Win32 Perl program reads a UNIX log file.

Can anyone suggest how to get the 'read' function to quietly do any
necessary byte swapping?  How would the undelying software know, in any
case, that the file being read is on platform that uses different
byte-ordering (little- vs. big-endian) compared to the local platform
running the script?

Tks for any help.

Clyde







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

Date: Thu, 27 Jul 2000 10:23:53 GMT
From: "Eelke Kleijn" <six4eight@NOSPAMhotmail.com>
Subject: Re: CGI passing parameters
Message-Id: <Z4Uf5.3853$Gd1.35667@Typhoon.bART.nl>

You are right, the way I did this was using socket.pm to connect to another
webserver. Let's say the script you are trying to pass parameters to is
named test.cgi. This is how I passed my paramaters:

___________________________________________

use CGI qw(:standard);
use Socket;

$proto = getprotobyname('tcp');
$host = gethostbyname('your.webserver')
$port = 80;
$sin = sockaddr_in($port, $host);

socket(Socket_Handle, PF_INET,SOCK_STREAM, $proto);
connect(Socket_Handle,$sin);

select (Socket_Handle); $| = 1; select STDOUT;
print Socket_Handle "GET
http://your.webserver/cgi-bin/test.cgi?num=$num&file=$file HTTP/1.0\n\n";

_________________________________________________________________-

In this way you open a connection to the webserver, and use GET to transfer
the parameters just as your browser would do. Don't know if this is the
fastest way though...

Eelk Kleijn

Mouse wrote:
> /cgi-bin/GETFILE?file... cannot be run, because command will not be
> found. There should not be ? char after GETFILE.
>
> Alex




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

Date: Thu, 27 Jul 2000 11:44:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: CGI passing parameters
Message-Id: <iu70oskid51mcn9v4j044clrq70p668f76@4ax.com>

Eelke Kleijn wrote:

>the way I did this was using socket.pm to connect to another
>webserver.

Gee, that looks complicated.  Why not skip the low-level stuff, and use
LWP, like LWP::Simple for the straightforward stuff, and LWP::UserAgent
for less trivial tasks?

    use LWP::Simple;
    $result = get("http://www.server.invalid/cgi-bin/script.pl?get=go");

-- 
	Bart.


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

Date: Thu, 27 Jul 2000 10:08:01 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: Critiques, please
Message-Id: <slrn8o02pe.1d6.marcel@gandalf.local>

On Wed, 26 Jul 2000 22:16:05 -0500 (CDT), BUCK NAKED1
<dennis100@webtv.net> wrote:

>>>dennis100@webtv.net wrote: 
>>>seek(COUNT, 0, 0) or die "can't >>REWIND to beginning of data
>>>file: $!"; 
>
>>marcel@codewerk.com wrote: 
>>REWIND? Are you running your
>>web site off a tape drive? 
>
>Is this a semantics argument? I think I get your point though(improper
>wording?). Are you saying that the file doesn't actually "rewind?"
>Perhaps I should verbalize it as "can't POINT to beginning of file" or
>"can't FIND beginning of data file" for my die statement?

Oh well, it was supposed to be funny. Sure I know what rewind() is,
but since Perl doesn't have it, I thought, why not just say 'seek'?

-- 
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();


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

Date: 27 Jul 2000 12:36:57 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Critiques, please
Message-Id: <slrn8o0b78.696.vek@pharmnl.ohout.pharmapartners.nl>

On Thu, 27 Jul 2000 10:08:01 GMT, Marcel Grunauer <marcel@codewerk.com> wrote:

>
>Oh well, it was supposed to be funny. Sure I know what rewind() is,
>but since Perl doesn't have it, I thought, why not just say 'seek'?
>

Which word makes most sence.  Seek is comething you do to a disk unit
to locate the heads on a certain cylinder.  Rewind is what you do
to a reel of tape.



Villy


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

Date: Thu, 27 Jul 2000 10:45:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: difference between two times in seconds
Message-Id: <tb40os4snu9tm3vodg1qd5dki8is6e2co6@4ax.com>

Abigail wrote:

>And in my sig is a regex solving Towers of Hanoi (requires a pre 5.6.0
>to work).

>%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
>(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi

	s/(?=ABC)/map"\$_",/

and it works on 5.6 too.

It requires a command line argument = number of disks, to work.

-- 
	Bart.


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

Date: 27 Jul 2000 11:48:32 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: exactly WHEN will PP-3rd be in bookstores, etc?  Anyone know?
Message-Id: <964697887.10221@itz.pp.sci.fi>

In article <8lom6h$9ei$1@slb6.atl.mindspring.net>, David Combs wrote:
>PS: after asking my PPv3 question (that started this
>thread), I went to oreilly and saw that it finally
>had been issued -- then went to bookpool to see
>if they had it (else would have gone to
>www.readmedotdoc.com "readme.doc", but with longwinded
>url, which is better (in price) than amazon, but
>not as low as bookpool, or amazon) for it.

Parse error near ", or amazon)" - misplaced parentheses?

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Thu, 27 Jul 2000 13:04:06 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: File path, Select value, Redirect Basic =?iso-8859-1?Q?=3F=92s?=
Message-Id: <slrn8o0chb.61h.bernard.el-hagin@gdndev25.lido-tech>

On Thu, 27 Jul 2000 12:24:54 GMT, mandbinc@rocketmail.com
<mandbinc@rocketmail.com> wrote:
>Is there something that I need to explain better?

Yeah, you need to explain what you have tried already and what problems
you ran across when you did.

>I'm pretty confident that these are basics issues for the expert Perl
>programmers that visit this discussion....

Which doesn't mean you'll get a working script for free just because it
would be easy for someone to provide you with one. It doesn't work that
way.

Bernard
--
perl -le 'open(JustAnotherPerlHacker,"")or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

Date: Thu, 27 Jul 2000 12:24:54 GMT
From: mandbinc@rocketmail.com
Subject: Re: File path, Select value, Redirect Basic ?’s
Message-Id: <8lp9mi$ctv$1@nnrp1.deja.com>

Is there something that I need to explain better?  I'm pretty confident
that these are basics issues for the expert Perl programmers that visit
this discussion....

Thanks for the help in advance.


In article <8lmmeq$f8i$1@nnrp1.deja.com>,
  mandbinc@rocketmail.com wrote:
> 1. I have an HTML file with a form.  When the user presses a submit
> button a Perl script is executed.  In my Perl script I need to know
the
> name and path of the HTML file that calls the Perl script (the HTML
> file will vary).  I my Perl file I will be opening the HTML file and
> replacing some data (parsing and re-writing).  How can I find out the
> file to open (in my Perl file I set this equal to $file_dir).  I need
> to know this at the start of my Perl script so I can open the file and
> read its contents into @filedata.
>
> 2. IN the HTML form file, I have a select command (NAME=”select”).  I
> want to set a variable ($select_value) in my Perl file equal to the
> option value selected by the user in the HTML file.  I though I could
> use:  $select_value=param(‘select’) at the start of my Perl file, but
> it does not work.  How can I do this?
>
> 3. After my Perl script executes, I want to return to the original
HTML
> file the user started from (although it will be updated with the new
> data).  Again this file will vary, but I will know the name within the
> Perl file (if someone helps me with number one above).  How can I end
> my Perl file with a command that returns to this HTML file – the name
> of this file is $file_dir in my Perl script.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: 27 Jul 2000 11:25:54 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Formatting text file
Message-Id: <964695964.5583@itz.pp.sci.fi>

In article <tpMf5.10331$Mt.126398@nnrp1.ptd.net>, Coy wrote:
>Regardless, it was an attempt to be helpful. If there were more people
>who at least attempted to be helpful, the world would be a better place.

"The road to hell is paved with good intentions."

Your advice had a _negative_ usefulness value - anyone who tried it
would've spent that much more time looking for the solution than if
they had not stumbled across it.

You would've been more helpful by not posting at all.

I know that seems unfair and insulting.  I don't like it myself.  But
such is the nature of life, and Usenet in particular.  Please do not
blame the messenger if you do not like the message.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.




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

Date: Thu, 27 Jul 2000 13:04:53 +0200
From: Jimmy Lantz <jimmy.lantz@ostas.lu.se>
Subject: Re: pattern match
Message-Id: <39801756.83146535@ostas.lu.se>

Hi Lauren,
I must have misinterpreted the question because I thought he had a lot
of lines of this pattern 
someinof | moreinfo | evenmore | more |
someinof | moreinfo | evenmore | more |
someinof | moreinfo | evenmore | more |
someinof | moreinfo | evenmore | more |

and for me I read in the file into @lines and then do a foreach as below....


open(DATA, "<$file") or die "cannot read FILE";
@lines=<DATA>;
close(DATA);

foreach $line (@lines)
{
$line =~ /(.*)\|(.*)\|(.*)\|(.*)\|$/;
my($someinof) = $1;
my($moreinfo) = $2;
my($evenmore) = $3;
my($more) = $4;
# then do something with the data on each row....
}

I might be mistaken ...
Cheers 
Jimmy.


Lauren Smith wrote:
> 
> Jimmy Lantz <jimmy.lantz@ostas.lu.se> wrote in message
> news:397F25BE.11481918@ostas.lu.se...
> > "Mark W. Schumann" wrote:
> > >
> > > In article <397f111e$0$8317$7f8943f3@newsreader.visi.com>,
> > > Jim <webmaster@ej-sunglasses.com> wrote:
> > > >
> > > > someinof | moreinfo | evenmore | more |
> > > >
> > > >I want to assign each variable a name ( $a= someinfo, $b= moreinfo
> ect..)
> > > >So I need to read the file until the pipe ( | ) is found, name it,
> continue
> > > >reading until the next pipe is found- name that something else ect...
> > > >I know there has to be an easy way to do this using pattern matching,
> but I
> > > >am new to Perl and cant figure out how to do it.   Thanks for any help
> > >
> > > $ perldoc -f split
> 
> > Even better, pattern memory.
> > you should look up on Regular expressions and pattern memory, by
> > using ().
> 
> How is that better?
> 
> Please code the equivalent regex to
> 
> @info = split / \| /, $string;
> 
> Lauren


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

Date: Thu, 27 Jul 2000 10:51:09 GMT
From: apolinad@my-deja.com
Subject: Problem executing Perl script on Apache server with FreeBSD
Message-Id: <8lp46t$9af$1@nnrp1.deja.com>

When I execute a script (written in Perl 5) in Win NT system, it works
fine. But when I run the same script on an Apache server (Pair
Networks), I get an error message as:

Internal Server Error
Premature end of script headers: /path/to/myscript.pl

Moreover, when I tried executing the script on my remote serevr (using
Telnet), I got a set of errors as:

Illegal modulus of constant ) in "inputvars="

where, "inputvars=" has been declared as an associative array (my %
inputvars = &read_query_string) and the said subroutine returned an
associative array.

I want to know why this occurs -- is there any other alternative to
declaring an associative array in UNIX platform?



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


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

Date: Thu, 27 Jul 2000 12:45:44 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Problem executing Perl script on Apache server with FreeBSD
Message-Id: <8lpatn$dsj$1@nnrp1.deja.com>

In article <8lp46t$9af$1@nnrp1.deja.com>,
  apolinad@my-deja.com wrote:

>
> Illegal modulus of constant ) in "inputvars="
>
> where, "inputvars=" has been declared as an associative array
> (my % inputvars = &read_query_string) and the said subroutine

aha!  there is a space between % and inputvars.  that is no associative
array, that is a modulus operator.

> returned an associative array.
>


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


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

Date: Thu, 27 Jul 2000 13:32:16 +0200
From: Roger Tillmann <Roger.Tillmann@extern.rwso.de>
Subject: Problems wit Win32::TieRegistry
Message-Id: <39801DC0.3958136B@extern.rwso.de>

Please help me :-))

I have the following problem: I need to import a user-registry in the
local registry, then I have to do some changes and afterwards save it
again.

I tried the following code:

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

use Win32::TieRegistry;
# use strict;

my $path = "C:\\Dokumente und Einstellungen\\Administrator\\ntuser.dat";

my $okay;
my $newKey;
my $key;

$key= new Win32::TieRegistry "LMachine", {Access=>KEY_ALL_ACCESS} || die
"$^E\n";

$okay = $key->AllowLoad(1);
print "Okay: $okay\n";

$newKey = $key->Load("$path", "TEST2")|| die "$^E";

system("pause");
print $newKey;

$newKey->{"FooCorp/"} =
 {
  "FooWriter/" => {
   "/Version" => "4.032",
   "Startup/" => {
    "/Title" => "FooWriterDeluxe",
   },
   "Compitibility/" => {
    "/Autoconvert" => "Always",
   },
  },
  "/License" =>"liwgfd",
 };

system("pause");
print $newKey;

$okay = $newKey->UnLoad;
print "Okay: $okay\n"
---------------------------------------------------------------------------------

I can open the registry, load the hive and save it (sometimes). I can't
make any changes to it. On other times, I can't even unload it.

Can someone tell me what I'm doing wrong?

Thanx

Roger

P.S.: I'm using W2K and Activestate Perl 613

Thanx



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

Date: 27 Jul 2000 12:13:26 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Saving space in a hash
Message-Id: <964699611.13932@itz.pp.sci.fi>

In article <397F5D6C.2E5330C4@mail.tju.edu>, George M. Kuetemeyer wrote:
>Russ Jones wrote:
>> I'm building a hash that contains the same line of data, referenced
>> three different ways, like this:
>>
>>         $snmp{$ip}    = $snmp_info;
>>         $snmp{$dns}   = $snmp_info;
>>         $snmp{$alias} = $snmp_info;
>>
>>         (repeat for about five thousand different ip's)
>> I use the storable module to save and later read the hash to/from disk
>> and having the data in there three times seems like a mighty waste of
>> space in my program, and a might waste of I/O time when I have to load
>> the hash to look up the data. Is there some more efficient way of
>> doing this?

First question: What kind of scalars are the values?

If they're references, then the actual data already gets stored only
once.  If they're strings, and significantly longer than the keys, you
could try storing references to those strings instead.


>You could play around with a compound key approach:
>Access could be via grep:
>You would reduce your entries to 1/3 of the original. On the other hand,
>access would not be as direct and maybe not as fast.

Maybe?  In this case it would be over five thousand times slower.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Thu, 27 Jul 2000 07:27:13 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: Re: Search Question
Message-Id: <39801C91.7384B511@ccrs.nrcanDOTgc.ca>

Paul Moseley wrote:
> 
> I have a search engine at www.marketchat.co.uk its a financial site that
> searches for stockmarket websites in the uk and us.  Im not an expert
> on CGI/Perl prgramming and got the program from a website.  It works
> well, Would it be very hard to change the script to include on Add your
> URL to have a radio button with US Site / UK Site and then on the search
> display a Flag for the right country, or is this to hard to do , just a
> thought
> 
> Paul
> 
> p.moseley@btinternet.com

Wouldn't be *that* hard.  You'd have to put a form to add an URL, take
the URL as an argument, then add it to the appropriate index (file |
database).

 ..Tom
-- 
=================================
Tom Kralidis
Geo-Spatial Developer
Canada Centre for Remote Sensing
Tel: (613) 947-1828
Fax: (613) 947-1408
http://www.nrcan.gc.ca/~tkralidi/
=================================


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

Date: Thu, 27 Jul 2000 05:37:27 -0700
From: hifive <bdcomNObdSPAM@ri.cgocable.ca.invalid>
Subject: security issue
Message-Id: <0ffb0dd0.d4bc539b@usw-ex0103-024.remarq.com>

Hi !

Got a little question. I manage a web site that is hosted by
11net.com. They provide me with a secure server but only for the
pages that need ssl, for the rest(html) they are hosted on a
regular server. i am aware that the data are not completely safe
because they are sent via e-mail and i would like to install a
cgi (called encrypt-it)but i have no space to do so on this
server (the secured one) but i have a cgi-bin on the other one.

First question : Would it be safe to call a cgi on another
server ?

Sec question : What is the proper way do do it, if it's safe ?
               <FORM METHOD="POST" ACTION="??????encrypt.cgi">

Thank's for your help




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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: Thu, 27 Jul 2000 08:48:25 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: Re: security issue
Message-Id: <39802F99.FF0CE6AB@ccrs.nrcanDOTgc.ca>

hifive wrote:
> 
> Hi !
> 
> Got a little question. I manage a web site that is hosted by
> 11net.com. They provide me with a secure server but only for the
> pages that need ssl, for the rest(html) they are hosted on a
> regular server. i am aware that the data are not completely safe
> because they are sent via e-mail and i would like to install a
> cgi (called encrypt-it)but i have no space to do so on this
> server (the secured one) but i have a cgi-bin on the other one.
> 
> First question : Would it be safe to call a cgi on another
> server ?

As long as your code is safe.

> 
> Sec question : What is the proper way do do it, if it's safe ?
>                <FORM METHOD="POST" ACTION="??????encrypt.cgi">
> 
> Thank's for your help
> 

<FORM METHOD="POST" ACTION="http://other.server.com/cgi-bin/file.cgi">

 ...

</FORM>

 ..Tom
-- 
=================================
Tom Kralidis
Geo-Spatial Developer
Canada Centre for Remote Sensing
Tel: (613) 947-1828
Fax: (613) 947-1408
http://www.nrcan.gc.ca/~tkralidi/
=================================


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

Date: Thu, 27 Jul 2000 10:16:01 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: seeing $main::FOO in used module
Message-Id: <slrn8o039o.1d6.marcel@gandalf.local>

On Thu, 27 Jul 2000 01:29:59 GMT, newt@veko.ne.mediaone.net
<newt@veko.ne.mediaone.net> wrote:

>Can the code inside a module 'see' values from the script that uses them?
[...]
>I've found that I can _create_ $main::VAL from my package if it doesn't
>exist yet, but if it alredy exists, the package can't see its value.


Dunno, this works for me:


    #!/opt/perl/bin/perl

    use warnings;
    use strict;

    our $VAL;
    $VAL = "HI";
    bar::barprint();

    package bar;

    sub barprint {
	print "main::VAL is $main::VAL\n";
    };

    1;

    __END__

    main::VAL is HI

Did you declare your $VAL with my() ? Because then (AFAIK) the other
package can't see it, as it's not in main's symbol table.

-- 
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();


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

Date: 27 Jul 2000 12:30:53 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: seeing $main::FOO in used module
Message-Id: <964700547.13207@itz.pp.sci.fi>

In article <rgMf5.50354$Q8.388049@typhoon.ne.mediaone.net>, newt@veko.ne.mediaone.net wrote:
>--------foo.pl-------
>#!/usr/bin/perl
>$VAL = "HI";
>use bar;
>---------------------

"use" is a compile-time directive.  It is executed first, no matter
where you put it.

This should work:

  #!/usr/bin/perl
  BEGIN { $VAL = "HI"; }
  use bar;

So should this:

  #!/usr/bin/perl
  $VAL = "HI";
  eval "use bar";

Or this:

  #!/usr/bin/perl
  $VAL = "HI";
  require bar;

None of them do exactly the same thing, though.  The documentation
will tell you the details.  If you have perl installed, try typing the
following at your shell prompt:

  perldoc -f use
  perldoc -f require
  perldoc perlmod
  perldoc perl

If you don't have perl on your system, or just prefer to read the docs
on the web, they can also be found at http://www.perl.com/

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: 27 Jul 2000 12:19:52 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: shifting strings
Message-Id: <964700229.5801@itz.pp.sci.fi>

In article <8lnucq$f3r$1@brokaw.wa.com>, Lauren Smith wrote:
>$tmp = $str1;                    # Store $str1 for later
>$str2 = chop $str1;              # Get the first character of $str1
>$str1 = $tmp;                    # Restore $str1
>($str1, $str2) = ($str2, $str1); # Swap $str1, $str2

Is this one more example of "Perl Bowling"?  Why not use:

  chop($str2 = $str1);

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Thu, 27 Jul 2000 12:53:58 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: start perlscript as nt service
Message-Id: <8lp4bn$f5n5@intranews.dresdnerbank.de>

    Hi,

haggi@work schrieb in Nachricht <397FE7B6.A38A0B06@tappe.net>...
>is it possible to start a perlscript as soon as the winNT machine boots?

    take srvany.exe from the NT Resource Kit and wrap your
    code in a service.

>I want it to run in the background, it contains a forever-loop.

    Be careful with those loops. They may take up all of your cpu
    resources. If you run into this trouble sleep() a little bit in your
    loop.

    Best regards,

        Peter Dintelmann





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

Date: Thu, 27 Jul 2000 11:42:27 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Suggestion for syntax change
Message-Id: <MPG.13eabd573b833ec5989693@news>

Keith G. Murphy writes ..
>jason wrote:
>> 
>[cut]
>> but Bart's argument about the fact that before any evaluation of '..' is
>> done in list index any negative arguments are just converted to relative
>> indices from the end of the list is compelling
>> 
>> the main part of the behaviour that I want consistent is that '..'
>> counts down when the first argument is larger than the second (and both
>> are positive) .. so that things like
>> 
>>   (localtime)[2..1]
>> 
>> can be done .. as long as the special treatment is only for negative
>> indices then I think it would work ok .. AND .. I think it's more
>> consitent than what I originally proposed .. here's why...
>> 
>> essentially we're just debating about evaluation order .. -1 always
>> means the index of the last element .. so if [2..-1] equates to [2,1,0,-
>> 1] then it means that the '..' is done first and THEN the '-1' is given
>> it's special meaning
>> 
>> the other (and I'm now thinking MORE consitent behaviour) is for '-1' to
>> be interpreted first and THEN the '..' is evaluated so you get [2..-1]
>> equating to [2..4] for a 5 element list .. then the '..' is done and you
>> get [2,3,4]
>> 
>> I see that as very useful .. AND (thanks to Bart's explanation) more
>> consistent
>
>I absolutely agree: the '-1' should be evaluated first, and I'm glad
>Bart's shown you the light.
>
>Now, what should be the interpretation of:
>
>[2..-2]
>
>in the case of a 3-element list?  That comes out to [2..1], so should we
>yield a two-element list ([2] and [1]), or the empty list?  You would
>probably say the former.  I'm still not sure I like that: see below.

I do think the former .. there are really two changes that I'm 
proposing (now) .. (1) '..' should work for creating both an 
incrementing and a decrementing lists and (2) in list index context the 
evaluation of negative indices should take a higher precedence than the 
evaluation of '..'

>> of course - out of a list index context '-1' has no special meaning ..
>> so
>> 
>>   for(2..-1)
>> 
>> would equate to
>> 
>>   for(2,1,0,-1)
>> 
>This is one thing that troubles me, and what I was getting at with all
>my verbiage in my last post.  It's a change from current behavior.
>
>But what bugs me the most, and that I can imagine biting someone, is
>this kind of behavior, back in the list case:
>
>Imagine that you were trying to take successively smaller slices from a
>list (not such an unrealistic thing to do), starting at a certain point,
>going to the end of the list, then end-1, etc., terminating when you
>reach a certain end point.  This would seem a pretty good approach:
>
>my $start = 2;
>my $last_end = &some_calculation;
>for ($end = -1; $end >= $last_end; $end--) {
>	@myslice = @mylist[$start..$end];
>}
>
>Now, for $end >= 2 things are fine.  But imagine that $last_end turns
>out to be 0.  As soon as $end < 2, by my interpretation @myslice starts
>turning into the empty list.  By yours, we get slices with elements
>[2,1] and [2,1,0].  

shrug .. Larry's reverse solution certainly solves the issue of '..' 
counting up only .. I guess it's very open to interpretation .. for me I 
like the idea of '..' counting down or up

>It's also interesting that by changing this syntax I could have
>simplified my 'for' loop above.
>
>By your interpretation:
>
>for ($end..$last_end)
>
>would count down nicely.

*8^) .. as would Larry's reverse solution with the current '..' 
behaviour

>I would suggest that something like:  
>
>for ($end.-.$last_end)
>
>would be better, to explicitly specify descent.  Maybe we need three
>operators:
>
>'..' (jason-style wraparound)
>
>'.+.' (current '..' behavior: ascent only)
>
>'.-.' (descent only)
>
>The more I look at it, the more I like it.  I *do* think it's good. 
>(Anyone catch the song-lyric reference?)
>
>But since '..' for wraparound would change the current behavior of for
>loops, maybe some of these would be better:
>
>'...' or '.?.' or ' to ' (jason-style wraparound)
>
>'..' or '.+.' or ' upto ' (current '..' behavior: ascent only)
>
>'.-.' or ' downto ' (descent only)
>
>
>Wouldn't:
>
>for ($last downto $first) { }
>
>be a sweet thing to be able to do?  :-)

I'm less and less convinced of my position now that Larry has opened my 
eyes a little *8^)

maybe the only change worth doing is to raise the evaluation precedence 
of the magic negative index so that it's evaluated before a '..' is done 
to give the behaviour that you originally spoke of

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


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

Date: Thu, 27 Jul 2000 12:55:50 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: user login NT
Message-Id: <8lp4f7$f6n2@intranews.dresdnerbank.de>

    Hi,

haggi@work schrieb in Nachricht <397FE88D.4131DC0A@tappe.net>...
>is there a possiblility to recognize if a user is logged in on WinNT with a
perl
>script?
>At the moment i do it with a search for the "EXPLORER" process, but this is
not
>really the best way I think.

    just an idea: What is the value of $ENV{'USERNAME'} if no
    user is logged in?

    Best regards,

        Peter Dintelmann





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

Date: Thu, 27 Jul 2000 11:51:13 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Was Why won't  "use strict;"  work?
Message-Id: <3981216a.42455438@news.newsguy.com>

dennis100@webtv.net (BUCK NAKED1) wrote:

>I don't know what happened. It could be my newsreader?... WebTV doesn't
>quote well, and my PC's ISP's mail service is always screwing up... and
>both of them wrap lines that I wish they wouldn't... and  I also suspect
>that many of the mistakes are my own doing.
>
>I really think the questions were good ones, though. I'm sorry to hear
>that you decided to ignore the "content" due to its form. I assure you
>that it  was not intentional.

No doubt your newsreader makes it easy to post messages as HTML,
and the problem was unintentional.  But people aren't
necessarily ignoring your message out of spite.  The way you
posted it, many people can't even see the content, or if they
can it's too buried in junk to read, so you can hardly expect
them to give you an answer.  Repost in plain text, and you may
get the help you're seeking.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 27 Jul 2000 11:02:25 GMT
From: apolinad@my-deja.com
Subject: Why doesn't my Perl script execute?
Message-Id: <8lp4s0$9mq$1@nnrp1.deja.com>

I have written a Perl script using Perl5 and executed it on a Win NT
machine where it worked up to expectations.

But when I uploaded the script (as an ASCII file with permissions set
to 0755) to my web server at Pair Networks which uses an Apache server
with FreeBSD OS, my script returns an error as:

Internal Server Error
Premature end of script headers

Besides, when I tried checking for syntax errors on the remote system
(using Telnet), I got the following messages:

Illegal modulus of constant 0 in "inputvars="
Syntax error "my $count"

where, "inputvars=" was declared as :
    my %inputvars = &read_query_string;

I want to know if there is an alternate way to declare an associative
array or a way to do the same work without using an associative array.


Apolina Das


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


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

Date: Thu, 27 Jul 2000 11:23:01 GMT
From: matt@NOSPAMraas.screaming.net (matt venn)
Subject: Re: Why doesn't my Perl script execute?
Message-Id: <39801a9a.4778511@news.ntlworld.com>

you might find that the first problem is to do with window$ putting
both newlines and carriage returns, when there should only be
newlines.
some editors for window$ allow you to convert the file to unix first.

you can get rid of the carriage returns by replacing all ^M chars with
nothing.

to check whether you have any in the first place, type 
head <filename> | od -c

carriage returns are shown as \r and newlines as \n

hope that helps,
matt


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

Date: Thu, 27 Jul 2000 12:43:11 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Why doesn't my Perl script execute?
Message-Id: <8lpaou$dpo$1@nnrp1.deja.com>

In article <8lp4s0$9mq$1@nnrp1.deja.com>,
  apolinad@my-deja.com wrote:

> Internal Server Error
> Premature end of script headers

possibly because you have _no_ script headers.  if you are using the CGI
module,  make sure you are printing header

If not, make sure your first print statement is:

print "Content-type: text/html\n\n";
>
> Besides, when I tried checking for syntax errors on the remote system
> (using Telnet), I got the following messages:
>
> Illegal modulus of constant 0 in "inputvars="
> Syntax error "my $count"
>
> where, "inputvars=" was declared as :
>     my %inputvars = &read_query_string;
>

are you certain there is no space between % and inputvars?


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


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

Date: Thu, 27 Jul 2000 11:51:51 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Why use anonymous?
Message-Id: <MPG.13eabe28c76835ad989694@news>

Nobody writes ..
>In article <MPG.13e952d8398d5c9a98968c@news>,
>jason  <elephant@squirrelgroup.com> wrote:
>>Nobody writes ..
>>>In article <397CA69B.A9495E2D@west.net>, John Callender  <jbc@west.net> wrote:
>>>>awilcox@contract.East.Sun.COM wrote:
>>>>> 
>>>Hmmm.  I've built these kinds of structures before, but never thought of them
>>>as 'anonymous', since they were simply part of a larger structure that did 
>>>have a name.  The example that the interview twit used was a single unnamed
>>>hash...
>>
><snip>
>>
>>#!/usr/bin/perl -w
>>use strict;
>>
>># create an anonymous hash and assign it's reference to $h
>>my $h = { name => 'jason king'
>>        , email => 'elephant@squirrelgroup.com'
>>        , newsgroup => 'c.l.p.misc'
>>        };
>>
>
>Okay, I think my problem is probably more a semantic one than a
>Perl one.  I would never use the term 'anonymous' to refer to the
>above, though I do see where it's coming from.  To me, that's just
>indirect addressing a.k.a. references a.k.a. pointers (my first 
>programming language back in 1982 was Pascal :-)  

the only moral that I can pry from this saga is - don't work for people 
who rate knowledge higher than skill

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


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

Date: Thu, 27 Jul 2000 12:19:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why use anonymous?
Message-Id: <fr90osku3bg87bfpsdadlc972fpc30uk93@4ax.com>

Nobody wrote:

>Hmmm.  I've built these kinds of structures before, but never thought of them
>as 'anonymous', since they were simply part of a larger structure that did 
>have a name.

It's an array of hashes. The array has a name, but the hashes are
anonymous.

Now, look, in Perl, "anonymous" has a particular meaning. The following
code snippets have the same effect:

	$entry{jason} = { name => 'jason king'
          , email => 'elephant@squirrelgroup.com'
          , newsgroup => 'c.l.p.misc'
        };

	{
	    my %hash = (name => 'jason king'
              , email => 'elephant@squirrelgroup.com'
              , newsgroup => 'c.l.p.misc'
	    );
	    $entry{jason} = \%hash;
	}

but while the former uses an actual anonymous hash, the latter uses a
reference to a simple hash that goes out of scope, leaving only the
reference through the main hash.

So, in short, an anonymous array is created using "[...]" and an
anonymous hash through "{...}", but you can get the same net effect
through other means, not using actual anonymous arrays/hashes.

-- 
	Bart.


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

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


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