[13994] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1404 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 17 03:11:24 1999

Date: Wed, 17 Nov 1999 00:10:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942826215-v9-i1404@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 17 Nov 1999     Volume: 9 Number: 1404

Today's topics:
        NT and network drives <jc@OPENetwork.com>
    Re: NT and network drives (Martien Verbruggen)
    Re: NT and network drives <computers_guy@hotmail.com>
        OO question <jamus@bigfoot.com>
        Perl error with two users getting same SID. <paros@mindspring.com>
    Re: Perl error with two users getting same SID. (Sam Holden)
        Script Effiency <rgrnbrg@xmission.com>
    Re: Script Effiency <uri@sysarch.com>
        Tracking Form Submissions? <tdk@cris.com>
    Re: Trying to use a variable as an operator <rick.delaney@home.com>
    Re: Use of uninitialized value <jeff@vpservices.com>
    Re: Use of uninitialized value <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 16 Nov 1999 22:27:02 -0500
From: Jean-Claude Chetrit <jc@OPENetwork.com>
Subject: NT and network drives
Message-Id: <38322085.7425FF87@OPENetwork.com>

Hi,

I have to run a perl script each day at 6
a.m.on an NT
machine, so I thought I would use the NT
scheduler or
the Norton scheduler.

Now the script works fine from a DOS prompt,
i.e. it sees the network drive P:.

But whenever I run the script from the
scheduler,
and even though I first reconnect to the P:
drive and can
issue successfully
        DIR P: > C:\DIRP.TXT
the perl script does not see the P: drive!!!

I can be reached from 9 a.m. to 4:30 pm. at
212-638-0599, or by e-mail, of course. Thanks



--
Jean-Claude Chetrit        OPENetwork, Inc.
215 Berkeley Place         Voice:
718-398-3838
Brooklyn, NY 11217         Fax:
718-638-2240
Home: 718-638-2266      e-mail:
jc@OPENetwork.com
URL:  http://home.dti.net/open/
    ____  ___  _____  __
__                  __
   / __ \/ _ \/ __/ |/ /__ / /__    _____
____/ /__
  / /_/ / ___/ _//    / -_) __/ |/|/ / _ \/
__/  '_/
  \____/_/  /___/_/|_/\__/\__/|__,__/\___/_/
/_/\_\

          Power Tools for Power Users




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

Date: Wed, 17 Nov 1999 05:55:13 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: NT and network drives
Message-Id: <slrn834gq2.fbm.mgjv@verbruggen.comdyn.com.au>

On Tue, 16 Nov 1999 22:27:02 -0500,
	Jean-Claude Chetrit <jc@OPENetwork.com> wrote:
[reformat]

> I have to run a perl script each day at 6 a.m.on an NT machine, so I
> thought I would use the NT scheduler or the Norton scheduler.
> 
> Now the script works fine from a DOS prompt, i.e. it sees the
> network drive P:.

Then there is no problem with the script. Is there?

> But whenever I run the script from the scheduler, and even though I
> first reconnect to the P: drive and can issue successfully DIR P: >
> C:\DIRP.TXT the perl script does not see the P: drive!!!

Maybe you should ask on an NT group whether disk mappings are
available from within those tools. It's not inconceivable that they
aren't. But since the perl script works from the command line, there
is nothing wrong with that.

> I can be reached from 9 a.m. to 4:30 pm. at 212-638-0599, or by
> e-mail, of course. Thanks

Sorry, I don't want to spend that much money on an International call
just to tell you that. Or maybe.. It's 4:55 pm here now.. 9 am to 4.30
pm? I wonder whether it would be worth giving you a call.. Or maybe
I'll wait until tomorrow morning 9 am :) NAw, you'll probably be in
bed, and won't thank me for it.

Sorry, but if you post here, you'll have to come back here to collect
the answers. If it's important enough to ask, it should be important
enough to read this group.

Martien
-- 
Martien Verbruggen                      |
Interactive Media Division              | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Wed, 17 Nov 1999 14:19:52 +0800
From: Funny Guy <computers_guy@hotmail.com>
Subject: Re: NT and network drives
Message-Id: <38324907.B140379B@hotmail.com>

If you are using AT command, pls check the scheduler service as
administrator startup.
I think P drive is your mapping drive, you need to add a command line
for connect to the share directory.
For example:
net use p: \\server_name\shared
dir p: >c:\dirp.txt

Jean-Claude Chetrit wrote:

> Hi,
>
> I have to run a perl script each day at 6
> a.m.on an NT
> machine, so I thought I would use the NT
> scheduler or
> the Norton scheduler.
>
> Now the script works fine from a DOS prompt,
> i.e. it sees the network drive P:.
>
> But whenever I run the script from the
> scheduler,
> and even though I first reconnect to the P:
> drive and can
> issue successfully
>         DIR P: > C:\DIRP.TXT
> the perl script does not see the P: drive!!!
>
> I can be reached from 9 a.m. to 4:30 pm. at
> 212-638-0599, or by e-mail, of course. Thanks
>
> --
> Jean-Claude Chetrit        OPENetwork, Inc.
> 215 Berkeley Place         Voice:
> 718-398-3838
> Brooklyn, NY 11217         Fax:
> 718-638-2240
> Home: 718-638-2266      e-mail:
> jc@OPENetwork.com
> URL:  http://home.dti.net/open/
>     ____  ___  _____  __
> __                  __
>    / __ \/ _ \/ __/ |/ /__ / /__    _____
> ____/ /__
>   / /_/ / ___/ _//    / -_) __/ |/|/ / _ \/
> __/  '_/
>   \____/_/  /___/_/|_/\__/\__/|__,__/\___/_/
> /_/\_\
>
>           Power Tools for Power Users



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

Date: Wed, 17 Nov 1999 00:08:21 -0500
From: jamus jegier <jamus@bigfoot.com>
Subject: OO question
Message-Id: <38323844.A78B5302@bigfoot.com>

Here is what I'm trying to do:

my $mystuff=sub {
    mycall1($arg1);
    mycall2($arg2);
}

my $myobject=object->new;
$myobject->go($mystuff);

Where mycall[12] are instance methods of $myobject.  In the function
called go, there will be quite a few calls to methods that are in the
same instance, so I would like to avoid if at all possible:

my $mystuff=sub {
    my $self=shift;
    $self->mycall1($arg1);
    $self->mycall2($arg2);
}

Is there any way to do this?

jamus



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

Date: Tue, 16 Nov 1999 18:16:08 -0800
From: "Charis Lemonopoulos" <paros@mindspring.com>
Subject: Perl error with two users getting same SID.
Message-Id: <80t31c$3lq$1@nntp6.atl.mindspring.net>

Hello all,

I am having a problem which I am unable to explain. I am using the
CGI.pm library to set and get cookies. Today two people were trying to
access my software at the same time and they were both receiving the
same value for the cookie.

The first thing my software does is to get the user's cookie. If the
cookie does not exist, the software creates a unique ID and saves it in
the cookie. The cookie is only valid during one session of a browser. I
am 100% positive that the generated ID is unique. I can not explain why
the second person received the first person's ID as soon as she opened a
brand new session of the IE.

The two people accessing the software were going through the same
firewall from the same LAN.

1) Could there be a problem with the firewall configuration
2) or the http daemon
3) or ...

Please respond to naxos@home.com

Any help is greatly appreciated.

Ginger




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

Date: 17 Nov 1999 02:24:34 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl error with two users getting same SID.
Message-Id: <slrn8344fh.2lc.sholden@pgrad.cs.usyd.edu.au>

On Tue, 16 Nov 1999 18:16:08 -0800,
	Charis Lemonopoulos <paros@mindspring.com> wrote:
>Hello all,
>
>I am having a problem which I am unable to explain. I am using the
>CGI.pm library to set and get cookies. Today two people were trying to
>access my software at the same time and they were both receiving the
>same value for the cookie.
>
>The first thing my software does is to get the user's cookie. If the
>cookie does not exist, the software creates a unique ID and saves it in
>the cookie. The cookie is only valid during one session of a browser. I
>am 100% positive that the generated ID is unique. I can not explain why
>the second person received the first person's ID as soon as she opened a
>brand new session of the IE.

This is not a perl problem, unless the problem is with generating the
IDs in perl. But since you yourself have said that that is not the problem,
why did you post here?

I can think of at least one option for two browsers sharing the same
cookies, but it would be off-topic in the newsgroup so I won't mention it.

Chances are your IDs are not unique though...

>
>Please respond to naxos@home.com

Put it in the reply-to and it may have been done...

-- 
Sam

Another result of the tyranny of Pascal is that beginners don't use
function pointers.
	--Rob Pike


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

Date: Tue, 16 Nov 1999 22:56:36 -0700
From: Ryan Greenberg <rgrnbrg@xmission.com>
Subject: Script Effiency
Message-Id: <B45791A4.984%rgrnbrg@xmission.com>

Hello,

    I'm fairly new to this group, and I only started working with Perl about
two weeks ago. I finally put together my first script using the Perl Black
Book reference guide I bought. Although the script does what I want, is
there a resource I can consult to see if I am using awkward methods to
acomplish my goal?
    I realize this is probably something I will pick up with time, but if
someone has a few moments to look over the short script below and perhaps
offer a few comments, I would appreciate it. (Also note: most of the
comments in the script aren't for other people, as I'm sure they denote
things fairly obvious; they are there so I don't forget what something
means).

Thanks,
Ryan
--
Ryan Greenberg - rgrnbrg@xmission.com

--
This CGI script opens a text file on the server and returns the contents in
HTML format. The first version I wrote uses a "while" loop and the second
version uses a "foreach" loop.
--
Version 1
--
#!/usr/bin/perl -w

# $title is the name of the window specified in the <TITLE> HTML tag
# $stitle, section title, is the name specified at the top of the red bar

$title = 'JM | Perl Testing';
$stitle = 'Perl Testing';

# Open the output file

# Print standard HTML header
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>$title</TITLE></HEAD>\n";

# Print the BODY tag with the colors used at judgememorial.com
print "<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#0000CC\" ALINK=\"#0000FF\"
VLINK=\"#000000\">\n";

# Open the alumni.txt file stored in the same directory as the script
open (ALUMNI, "alumni.txt") or die("Unable to open alumni.txt");

# As long as there are lines left in alumni.txt, read those lines
while ($person = <ALUMNI>) {

  # Add the lines just read as an element to the people array, @people
  push(@people,$person);

}

# Close the alumni.txt file; all necessary data has been read from it
close ALUMNI;

# Print the TABLE. Note that the ROWSPAN is equal to the number of
# elements in the people array, @people

print "<TABLE BORDER=0 WIDTH=\"100%\" HEIGHT=\"100%\">\n<TR><TD
BGCOLOR=\"#CC0000\" ALIGN=CENTER VALIGN=TOP WIDTH=\"10%\"
ROWSPAN=$#people><A HREF=\"../main.shtml\"><IMG SRC=\"../images/subred.gif\"
WIDTH=130 HEIGHT=45 ALT=\"Judge Memorial\" BORDER=0></A><HR WIDTH=\"50%\"
ALIGN=LEFT NOSHADE SIZE=3><FONT SIZE=4>$section</FONT></TD>";

# While there are still elements in the people array, @people
while (@people) {

  # Remove the first element of the array
  # Store it in the scaler $individual
  $individual = shift(@people);
  
  # Split the scaler $individual based on comma
  # into the array @individual
  @individual = split(",", $individual);
  
  # Print the information for the current
  # person in the array @individual
  print "<TR><TD>@individual[1] @individual[0]</TD>";
  print "<TD>@individual[2]</TD>";
  print "<TD>@individual[3]</TD>";
  print "<TD><A 
HREF=\"mailto:@individual[4]\">@individual[4]</A></TD></TR>\n";

}
  
# Print the standard closing for the HTML file
print "</TABLE></BODY></HTML>";

--
Version 2
--

#!/usr/bin/perl -w

# $title is the name of the window specified in the <TITLE> HTML tag
# $stitle, section title, is the name specified at the top of the red bar

$title = 'JM | Perl Testing';
$stitle = 'Perl Testing';

# Open the output file

# Print standard HTML header
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>$title</TITLE></HEAD>\n";

# Print the BODY tag with the colors used at judgememorial.com
print "<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#0000CC\" ALINK=\"#0000FF\"
VLINK=\"#000000\">\n";

# Open the alumni.txt file stored in the same directory as the script
open (ALUMNI, "alumni.txt") or die("Unable to open alumni.txt");

# As long as there are lines left in alumni.txt, read those lines
while ($person = <ALUMNI>) {

  # Add the lines just read as an element to the people array, @people
  push(@people,$person);

}

# Close the alumni.txt file; all necessary data has been read from it
close ALUMNI;

# Print the TABLE. Note that the ROWSPAN is equal to the number of
# elements in the people array, @people

print "<TABLE BORDER=0 WIDTH=\"100%\" HEIGHT=\"100%\">\n<TR><TD
BGCOLOR=\"#CC0000\" ALIGN=CENTER VALIGN=TOP WIDTH=\"10%\"
ROWSPAN=$#people><A HREF=\"../main.shtml\"><IMG SRC=\"../images/subred.gif\"
WIDTH=130 HEIGHT=45 ALT=\"Judge Memorial\" BORDER=0></A><HR WIDTH=\"50%\"
ALIGN=LEFT NOSHADE SIZE=3><FONT SIZE=4>$section</FONT></TD>";

# While there are still elements in the people array, @people

foreach $individual (@people) {
  
  @individual = split(",", $individual);
  
  # Print the information for the current
  # person in the array @individual
  # Remember that $scaler[0] is essentially @array[0]
  # but with better form.
  print "<TR><TD>$individual[1] $individual[0]</TD>";
  print "<TD>$individual[2]</TD>";
  print "<TD>$individual[3]</TD>";
  print "<TD><A 
HREF=\"mailto:@individual[4]\">$individual[4]</A></TD></TR>\n";

}
  
# Print the standard closing for the HTML file
print "</TABLE></BODY></HTML>";



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

Date: 17 Nov 1999 01:12:12 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Script Effiency
Message-Id: <x7aeodtznn.fsf@home.sysarch.com>

>>>>> "RG" == Ryan Greenberg <rgrnbrg@xmission.com> writes:

  RG>     I'm fairly new to this group, and I only started working with
  RG> Perl about two weeks ago. I finally put together my first script
  RG> using the Perl Black Book reference guide I bought. Although the
  RG> script does what I want, is there a resource I can consult to see
  RG> if I am using awkward methods to acomplish my goal?

never heard of that book. just by that fact i will downgrade it. point
out its home page to me and any reviews you know about and i will add it
to my perl books page.

  RG> HTML format. The first version I wrote uses a "while" loop and the
  RG> second version uses a "foreach" loop.

why are you concerned with efficiency for such a dinky cgi script? will
it be hit hundreds of times a second? don't worry about perl efficiency
until you know enough perl to know what that means. too many people
think about optimization before getting it to work correctly. anyhow,
here are my pithy comments:

  RG> #!/usr/bin/perl -w

-w good; not using strict bad.

  RG> # $title is the name of the window specified in the <TITLE> HTML
  RG> tag # $stitle, section title, is the name specified at the top of
  RG> the red bar

your comments (most are deleted) are of the type $i++ # increment $i

comments should tell the reader WHY you are doing something while the
code says WHAT you are doing.

  RG> # Open the output file

don't see any open statements anywhere.

  RG> print "<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#0000CC\" ALINK=\"#0000FF\"
  RG> VLINK=\"#000000\">\n";

you have a severe case of backslashitis. your html is highly
illegible. learn alternate quoting constructs like qq and here docs (<<).

  RG> # Open the alumni.txt file stored in the same directory as the script
  RG> open (ALUMNI, "alumni.txt") or die("Unable to open alumni.txt");

die good. put $! in the die message.

  RG> while ($person = <ALUMNI>) {

  RG>   push(@people,$person);

  RG> }

that could be done with

	@people = <ALUMNI> ;

  RG> print "<TABLE BORDER=0 WIDTH=\"100%\" HEIGHT=\"100%\">\n<TR><TD
  RG> BGCOLOR=\"#CC0000\" ALIGN=CENTER VALIGN=TOP WIDTH=\"10%\"
  RG> ROWSPAN=$#people><A HREF=\"../main.shtml\"><IMG SRC=\"../images/subred.gif\"

ROWSPAN will be missing one alumnus. $#people is the index of the last
element, not the number of elements in the array.

  RG> while (@people) {
  RG>   $individual = shift(@people);

	for $individual (@people) {

  RG>   print "<TR><TD>@individual[1] @individual[0]</TD>";
  RG>   print "<TD>@individual[2]</TD>";
  RG>   print "<TD>@individual[3]</TD>";
  RG>   print "<TD><A 
  RG> HREF=\"mailto:@individual[4]\">@individual[4]</A></TD></TR>\n";

here docs are your friend. i wonder if the perl black book even mentions them.


  RG> foreach $individual (@people) {
  
	while( @people ) {

		$individual = shift @people ;

:-)


so why post two copies of the entire program just to show how to write
the same loop with while and foreach? if you want to actually measure
ther relative efficiencies (but as i said why bother) use the
Benchmark.pm module.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 17 Nov 1999 00:51:00 -0500
From: "Kevin J. Bennett" <tdk@cris.com>
Subject: Tracking Form Submissions?
Message-Id: <38324244.CBAAE999@cris.com>

Hello,

I have a standard HTML  form that collects data and submits to another
site other
than mine? Is there anyway through an HTML tag or CGI script to log the
submissions on my machine and pass the data on to the desired host at
the same time transparent to the user through the one submit button?

Thanks,
Kevin.



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

Date: Wed, 17 Nov 1999 04:45:12 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Trying to use a variable as an operator
Message-Id: <383232F4.5CEA96E2@home.com>

[posted & mailed]

Greg Bacon wrote:
> 
> In article <V1gY3.18604$YI2.798318@typ11.nn.bcandid.com>,
>         kragen@dnaco.net (Kragen Sitaker) writes:
> 
> : I always thought it was a shame Perl didn't have anything like APL's
> : "reduce" operator -- +/, x/, etc.  Now I know the shocking truth.
> 
> Have you seen mjd's implementation of reduce in Perl? 

And don't forget Graham Barr's implementation of reduce in XS.  Check
out List::Util (formerly builtin) on CPAN.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 17 Nov 1999 02:59:30 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Use of uninitialized value
Message-Id: <383219C9.96C9FAF6@vpservices.com>

Rowan Blaqflame wrote:
> 
> my $complaint = param('complaint');
> if ( length($complaint) > 0 ) { $complaint = "complaint='" . $complaint
> . "'";
>     } else { $complaint = "complaint=NULL"; }

If zero and the empty string are the same as NULL, then you could use an
or:

    my $complaint = param('complaint') || 'NULL';
    $complaint    = qq/complaint='$complaint'/;

Otherwise, you could use defined and an if-then-else shorthand:

    my $complaint = defined param('complaint')
                  ? q/complaint='/ . param('complaint') . q/'/
                  : 'complaint=NULL';

Either of those will avoid the uninitialized value warning.

-- 
Jeff


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

Date: Tue, 16 Nov 1999 23:30:47 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Use of uninitialized value
Message-Id: <MPG.129bf978a08c0a8598a219@nntp.hpl.hp.com>

In article <383219C9.96C9FAF6@vpservices.com> on 17 Nov 1999 02:59:30 
GMT, Jeff Zucker <jeff@vpservices.com> says...
> Rowan Blaqflame wrote:
> > 
> > my $complaint = param('complaint');
> > if ( length($complaint) > 0 ) { $complaint = "complaint='" . $complaint
> > . "'";
> >     } else { $complaint = "complaint=NULL"; }
> 
> If zero and the empty string are the same as NULL, then you could use an
> or:
> 
>     my $complaint = param('complaint') || 'NULL';
>     $complaint    = qq/complaint='$complaint'/;

I doubt that q{complaint='NULL'} would be useful SQL.  (Your quote 
delimiters are weird, because I keep looking for a regex between the 
slashes.)
 
> Otherwise, you could use defined and an if-then-else shorthand:
> 
>     my $complaint = defined param('complaint')
>                   ? q/complaint='/ . param('complaint') . q/'/
>                   : 'complaint=NULL';

That is better (i.e., correct).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

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


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