[18227] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 395 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 2 06:10:27 2001

Date: Fri, 2 Mar 2001 03:10:12 -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: <983531412-v10-i395@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 2 Mar 2001     Volume: 10 Number: 395

Today's topics:
    Re: Perl, Cookies, and Apache. <bart.lateur@skynet.be>
        print using () functions and lists <alun.moon@unn.ac.uk>
        Proper way to include perl output in IIS <azzaro@oswego.edu>
    Re: PROPOSAL: Graphics::ColorNames (Anno Siegel)
        redirect problem with large downloads <rthomasboyd@hotmail.com>
        Serial port example from perlopentut (Miguel Cruz)
        SIGINT <tfiedler@zen.moldsandwich.com>
    Re: SIGINT <tfiedler@zen.moldsandwich.com>
    Re: What is \cM ? (Peter J. Acklam)
        Win32 CGI file access problem <azzaro@oswego.edu>
    Re: Win32 CGI file access problem <wyzelli@yahoo.com>
    Re: Win32 CGI file access problem <azzaro@oswego.edu>
    Re: Win32 CGI file access problem <wyzelli@yahoo.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 02 Mar 2001 09:54:52 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl, Cookies, and Apache.
Message-Id: <peru9t09plgcefuts70esb11st8glb9b90@4ax.com>

Parrot wrote:

>I'd like to explain though - I find jeopard posting to be much more
>efficient in cases, like this one, where you are only giving a response on
>one thing.

Allow me to disagree. It's only still readable if you're reading a whole
thread in one go. If it's been days since you've read the previous
message, you'll have to read the quoted part first, anyway, and then it
becomes annoying (spaghetti reading).

-- 
	Bart.


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

Date: 02 Mar 2001 10:21:00 +0000
From: Alun Moon <alun.moon@unn.ac.uk>
Subject: print using () functions and lists
Message-Id: <ud7c0wjxv.fsf@unn.ac.uk>

I had a little discussion with a colleague recently concerning
the use of 
   print("hello world\n");
rather than
   print "hello world\n";

He was intending to use the former () to teach students hew to perl.
I felt that the later was better, as seen in the perldocs and the 
Camel book(s) (Leaning Perl, Programming Perl).

I was concerned that there were side effects of using () that
were bad habits to teach students.

Having read through the docs perlfunc and Programming Perl, I'm a little
unclear.

The section on Terms and List Operators (pg 77) implies that there
are effects of using () in the print, making it a function rather
that a list operator.  But in the back (pg 548) it says ``if in
doubt perenthisise''.

I'm farly convinced I was right to suggest teaching print without
() was right.  Was I?

What exactly is the effect of using () on not in print (and other
operators)?  I'm still not clear having read the books and docs.

Thanks

Alun


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

Date: Fri, 2 Mar 2001 06:59:50 GMT
From: "Matthew Azzaro" <azzaro@oswego.edu>
Subject: Proper way to include perl output in IIS
Message-Id: <G9K5xu.4Hy@oswego.Oswego.EDU>

I would like to be able to include output from a Perl cgi app in my web
page, using MS IIS 5. From searching the docs, the only way i can tell to do
this is using the <!--#exec...--> directive. I heard this is a security risk
and not the proper way to handle this situation. What is the correct way??
Thank you!
-Matt
 ...it was so much easier on unix....




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

Date: 2 Mar 2001 09:58:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <97nqrn$snc$1@mamenchi.zrz.TU-Berlin.DE>
Keywords: Clarence, affectionate, parapsychology, transmittance

According to Mark Jason Dominus <mjd@plover.com>:
> In article <97l52r$3bq$1@mamenchi.zrz.TU-Berlin.DE>,
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >> >          *get_colour = *get_couleur = *get_colore = \ &get_color;
> >>
> >> This also aliases $get_colour and $get_couleur, etc.
> >
> >Uh, no.  Assignment of a reference to a typeglob is selective.
>
> Your code performs one selective assignment of a reference to a typeglob,
> and two unselected assignments of entire typeglobs to typeglobs.
>
> The assignments to *get_colour and *get_coleur are not selective.

That's right.  The value of an assignment (taken as an expression)
is its left hand side after the assignment has happened, not the
value assigned.  In cases like this it makes a difference.

Though, since this is Perl, there are exceptions:  The behavior
of "$scalar = () = @array;" can't be explained this way.

> (As an aside, I would like to see a ban on the phrase 'Uh, no.'  At
> best, it is just impolite. ...

Is that how it sounds?  I've always taken it to be a less formal
way of saying "I disagree", but then there is a fine line beyond
which being "less formal" becomes impolite.  That was not my
intention.

Anno



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

Date: Thu, 1 Mar 2001 22:21:57 -0800
From: "rthomasboyd" <rthomasboyd@hotmail.com>
Subject: redirect problem with large downloads
Message-Id: <g5Fn6.1430$q64.272510@e3500-chi1.usenetserver.com>

I have a script that redirects a link and writes the URL to a file . My
problem is that when it logs a large PDF file it keeps recording over and
over again. Attached is the script. I am not sure if there is something I
did wrong or if maybe files time out then log back in to finish downloading.
Any help would be great.

Thanks Dan

#!C:/Perl/bin/perl.exe -w

$url = $ENV{'QUERY_STRING'};
chomp($url);
if ($url eq 'stats'){
&stats;
}
if ($url eq 'total'){
&total;
}

print "Location: $url\n\n";

################## PRINT TO A FILE ALL ENTERYS
open (SAFE, '>>hits.txt') ||
die ("no file");
@all = <SAFE>;
print SAFE "$url\n";
close(SAFE);

############## START CHECK TO SEE IF NEW
open (OUTFILE, 'counts.txt') || die ("no file");
@all = <OUTFILE>;
close(OUTFILE);

foreach $line(@all){
chomp($line);
($curl, $n) = split(/,/, $line);
if ($curl eq $url){
&MATCH ($curl, $n, @all);
}
}

open (NEW, '>>counts.txt') || die ("no file");
@in = <NEW>;
print NEW "$url,1\n";
close(NEW);
exit;


############# SUBS HERE

########## Stats Page ################
sub stats {
print "Content-type: text/html\n\n";

open (PAGE, 'page1.htm') || die ("no file");
@out = <PAGE>;
close(NEW);
print "@out";
print "<h3>This is a list of redirected links<br>and the number of times
they have been visited</h3>";
open (NEW, 'counts.txt') || die ("no file");
@in = <NEW>;
close(NEW);
foreach $f(@in){
print "$f<br>";
}
print "</td></tr></body></html>";
exit;
}

sub total {
print "Content-type: text/html\n\n";


open (PAGE, 'page1.htm') || die ("no file");
@out = <PAGE>;
close(NEW);
print "@out";
print "<h3>This is a list of all redirected links</h3>";
open (NEW, 'hits.txt') || die ("no file");
@in = <NEW>;
close(NEW);
foreach $f(@in){
print "$f<br>";
}
print "</td></tr></body></html>";
exit;
}

##### If A MATCH IS FOUND ######
sub MATCH {
print "Found a match<br>";

open (FILE, '>counts.txt') || die ("no file");
@out = <FILE>;

foreach $U(@all){
chomp $U;
if ($U ne "$url,$n"){
print FILE "$U\n";
}
}
$n++;
print FILE "$url,$n\n";
close(FILE);

exit;
}






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

Date: Fri, 02 Mar 2001 07:03:41 GMT
From: mnc@admin.u.nu (Miguel Cruz)
Subject: Serial port example from perlopentut
Message-Id: <hBHn6.6677$jP.830131@typhoon2.ba-dsg.net>


I'm trying to talk to a modem. As a starting point I've taken the code from
the open tutorial (perldoc perlopentut):

  #!/usr/bin/perl

  sysopen(TTYIN, "/dev/cuaa0", O_RDWR | O_NDELAY | O_NOCTTY)
    or die "Can't open modem (in): $!";
  open(TTYOUT, "+>&TTYIN")
    or die "Can't open modem (out): $!";
  $ofh = select(TTYOUT);
  $| = 1;
  select ($ofh);
  print TTYOUT "at\015";
  $reply = <TTYIN>;
  print "$reply\n";

Unfortunately, it doesn't work:
 
  Can't open modem (out): Invalid argument at ./modem.pl line 5.

I've read over the documentation for open and this seems fine. Not only
that, but the code itself came out of the documentation. "Invalid argument"
is a less-than-illumating message.

This is perl 5.005_03 on FreeBSD, if that is relevant.

Any ideas? I'd really prefer to do this from the ground up rather than using
a gigantic pre-rolled module, because I'd like to learn exactly what's going
on every step of the way. Unfortunately I've run aground rather early!

Thanks for any help.

miguel


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

Date: Fri, 02 Mar 2001 09:23:25 GMT
From: Ted Fiedler <tfiedler@zen.moldsandwich.com>
Subject: SIGINT
Message-Id: <Pine.LNX.4.21.0103020424270.12767-100000@zen.moldsandwich.com>




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

Date: Fri, 02 Mar 2001 09:24:40 GMT
From: Ted Fiedler <tfiedler@zen.moldsandwich.com>
Subject: Re: SIGINT
Message-Id: <Pine.LNX.4.21.0103020425240.12768-100000@zen.moldsandwich.com>


On Fri, 2 Mar 2001, Ted Fiedler wrote:

> 
> 

oops...

i didnt mean to post...




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

Date: 02 Mar 2001 10:22:15 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: What is \cM ?
Message-Id: <wksnkwy1ce.fsf@math.uio.no>

Micah Cowan <micah@cowanbox.com> writes:

> J Garcia <garcia868@yahoo.com> writes:
> 
> > I know that \c[ is the control character, but what is
> > \cM? thanks for helping out.
> 
> Newline character.

No, the newline character is \cJ (decimal 10).  \cM is carriage
return (decimal 13).

Peter

-- 
sub int2roman{@x=split//,sprintf'%04d',shift;@r=('','I','V','X','L','C','D'
,'M');@p=([],[1],[1,1],[1,1,1],[1,2],[2],[2,1],[2,1,1],[2,1,1,1],[1,3],[3])
;join'',@r[map($_+6,@{$p[$x[0]]}),map($_+4,@{$p[$x[1]]}),map($_+2,@{$p[$x[2
]]}),map($_+0,@{$p[$x[3]]})];}print "@{[map{int2roman($_)}@ARGV]}\n";#JAPH!


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

Date: Fri, 2 Mar 2001 04:46:09 GMT
From: "Matthew Azzaro" <azzaro@oswego.edu>
Subject: Win32 CGI file access problem
Message-Id: <G9Jzrq.H1D@oswego.Oswego.EDU>

I'm trying to  have my perl script access a file in the same directory
(cgi-bin) on my server. It works fine at the command prompt, but when I run
it on the server, it cannot open the file. My permissions appear to be set
right, and i've tried just about every combination in hopes of figuring it
out. Do I have to map a path to the current directory, like I would have to
do in VBScript? I am not using the CGI module.. Below is the code. Please
email advice to azzaro@oswego.edu. Thank you.

################################
#! /usr/local/bin/perl -w
use Win32;

#READ INPUT FILE
if (! open QUOTES,"quotes.dat") {
#   print "Error opening file: $!\n";
print <<As_Is;
Content-type: text/html

Error reading file!                            #THIS IS WHERE IT BOMBS ON
THE SERVER, BUT NOT AT THE COMMAND PROMPT!

As_Is
exit(0)
}


srand;
rand($.) <1 and ($line=$_) while <QUOTES>;
close QUOTES;

@quote = split(/\*/,$line);

print <<As_Is;
Content-type: text/html

<HTML><BODY><TABLE><TR><TD><I>$quote[0]</TD></TR><TR><TD
ALIGN=RIGHT>$quote[1]</TD></TR></TABLE></BODY></HTML>

As_Is

exit (0);




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

Date: Fri, 2 Mar 2001 15:44:53 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Win32 CGI file access problem
Message-Id: <9IGn6.28$GN1.5405@vic.nntp.telstra.net>

"Matthew Azzaro" <azzaro@oswego.edu> wrote in message
news:G9Jzrq.H1D@oswego.Oswego.EDU...
> I'm trying to  have my perl script access a file in the same directory
> (cgi-bin) on my server. It works fine at the command prompt, but when
I run
> it on the server, it cannot open the file. My permissions appear to be
set
> right, and i've tried just about every combination in hopes of
figuring it
> out. Do I have to map a path to the current directory, like I would
have to
> do in VBScript? I am not using the CGI module.. Below is the code.
Please
> email advice to azzaro@oswego.edu. Thank you.

Three things to be aware of.

1)  If you print $! in your error, you will be told WHY it failed
(permissions, file does not exist etc)

2) You are probably not where you think you are in the tree, so specify
the file explicityly ('d:/inetpub/wwwroot/website/cgi-bin/quotes.dat')

3) The web server is a different user than you at the command prompt, so
the permission to check are those of the web-server user, not yours.


> ################################
> #! /usr/local/bin/perl -w
> use Win32;
>
> #READ INPUT FILE
> if (! open QUOTES,"quotes.dat") {

If you insist on negative logic, then change this to be explicit
drive/path/file (use forward slashes, that is OK on windows)

> #   print "Error opening file: $!\n";
> print <<As_Is;
> Content-type: text/html
>
> Error reading file!                            #THIS IS WHERE IT BOMBS
ON
> THE SERVER, BUT NOT AT THE COMMAND PROMPT!

Include the $! here (I see you use it above)

> As_Is
> exit(0)
> }

The webserver user is probably !USR_servername or similar.

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";






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

Date: Fri, 2 Mar 2001 06:37:12 GMT
From: "Matthew Azzaro" <azzaro@oswego.edu>
Subject: Re: Win32 CGI file access problem
Message-Id: <G9K4w6.3sK@oswego.Oswego.EDU>

AH HAH! I used the $! and you were right, "file does not exist". I put the
whole path and it works..but isnt this a security problem, or only if my
permissions arent set right? Thank you so much for your help!
-Matt

"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:9IGn6.28$GN1.5405@vic.nntp.telstra.net...
> "Matthew Azzaro" <azzaro@oswego.edu> wrote in message
> news:G9Jzrq.H1D@oswego.Oswego.EDU...
> > I'm trying to  have my perl script access a file in the same directory
> > (cgi-bin) on my server. It works fine at the command prompt, but when
> I run
> > it on the server, it cannot open the file. My permissions appear to be
> set
> > right, and i've tried just about every combination in hopes of
> figuring it
> > out. Do I have to map a path to the current directory, like I would
> have to
> > do in VBScript? I am not using the CGI module.. Below is the code.
> Please
> > email advice to azzaro@oswego.edu. Thank you.
>
> Three things to be aware of.
>
> 1)  If you print $! in your error, you will be told WHY it failed
> (permissions, file does not exist etc)
>
> 2) You are probably not where you think you are in the tree, so specify
> the file explicityly ('d:/inetpub/wwwroot/website/cgi-bin/quotes.dat')
>
> 3) The web server is a different user than you at the command prompt, so
> the permission to check are those of the web-server user, not yours.
>
>
> > ################################
> > #! /usr/local/bin/perl -w
> > use Win32;
> >
> > #READ INPUT FILE
> > if (! open QUOTES,"quotes.dat") {
>
> If you insist on negative logic, then change this to be explicit
> drive/path/file (use forward slashes, that is OK on windows)
>
> > #   print "Error opening file: $!\n";
> > print <<As_Is;
> > Content-type: text/html
> >
> > Error reading file!                            #THIS IS WHERE IT BOMBS
> ON
> > THE SERVER, BUT NOT AT THE COMMAND PROMPT!
>
> Include the $! here (I see you use it above)
>
> > As_Is
> > exit(0)
> > }
>
> The webserver user is probably !USR_servername or similar.
>
> Wyzelli
> --
> ($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
> it around');
> for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
> $_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
>
>
>
>




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

Date: Fri, 2 Mar 2001 16:51:38 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Win32 CGI file access problem
Message-Id: <WHHn6.1$zS1.389@vic.nntp.telstra.net>

"Matthew Azzaro" <azzaro@oswego.edu> wrote in message
news:G9K4w6.3sK@oswego.Oswego.EDU...
> AH HAH! I used the $! and you were right, "file does not exist". I put
the
> whole path and it works..but isnt this a security problem, or only if
my
> permissions arent set right? Thank you so much for your help!

Having your permissions set correctly is always a security issue, but
coding a drive/path/filename is not so much a security issue as a
configuration one (ie when you change servers, you may have to edit the
script, or changes between local testing and your server config).

The drive/path/filename would not be visible to a web-user of your cgi
script at all (unless you had some configuration error which displayed
the source-code)

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";





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

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 V10 Issue 395
**************************************


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