[26677] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8784 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 21 14:05:46 2005

Date: Wed, 21 Dec 2005 11:05:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 21 Dec 2005     Volume: 10 Number: 8784

Today's topics:
    Re: How to give (put to browser) someone PDF document,  axel@white-eagle.invalid.uk
    Re: How to give (put to browser) someone PDF document,  <phaylon@dunkelheit.at>
    Re: How to give (put to browser) someone PDF document,  <1usa@llenroc.ude.invalid>
    Re: How to give (put to browser) someone PDF document,  <abigail@abigail.nl>
    Re: My Regexp  XML Parser -> Structured Perl Data, Cut  <tadmc@augustmail.com>
    Re: split by word using | as delimiter <rvtol+news@isolution.nl>
    Re: split by word using | as delimiter <sdn.girths00869@zoemail.net>
    Re: split by word using | as delimiter <bob@dont.spam.me>
    Re: split by word using | as delimiter (Anno Siegel)
    Re: split by word using | as delimiter axel@white-eagle.invalid.uk
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 21 Dec 2005 11:30:12 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: How to give (put to browser) someone PDF document, with hidden path to document.
Message-Id: <81bqf.12614$iz3.12566@text.news.blueyonder.co.uk>

Tad McClellan <tadmc@augustmail.com> wrote:
> MAX <max@max.hr> wrote:
 
>> How to give (put to browser) someone PDF document, with hidden path to
>> document.
 
 
> print() the appropriate headers to STDOUT
> open() the file
> binmode() the input and output filehandles
> readline() from the file and print() to STDOUT
> close() the file

I have never worked out how to pass the correct name of the file
rather than the file being downloaded with the name of foo.pl
but that is not a Perl question.

Axel
 


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

Date: 21 Dec 2005 12:38:28 GMT
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: How to give (put to browser) someone PDF document, with hidden path to document.
Message-Id: <43a94cc4$0$9650$9b4e6d93@newsread2.arcor-online.net>

axel@white-eagle.invalid.uk wrote

> I have never worked out how to pass the correct name of the file
> rather than the file being downloaded with the name of foo.pl
> but that is not a Perl question.

OT, but I think it was a Content-Disposition header like:
  Content-Disposition: attachment; filename=world-takeover.pdf

hth, p

-- 
Better to reign in hell than to serve in heaven.
                        -- John Milton, Paradise Lost


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

Date: Wed, 21 Dec 2005 12:47:56 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to give (put to browser) someone PDF document, with hidden path to document.
Message-Id: <Xns97334F590B9AAasu1cornelledu@127.0.0.1>

axel@white-eagle.invalid.uk wrote in
news:81bqf.12614$iz3.12566@text.news.blueyonder.co.uk: 

> Tad McClellan <tadmc@augustmail.com> wrote:
>> MAX <max@max.hr> wrote:
>  
>>> How to give (put to browser) someone PDF document, with hidden path
>>> to document.
>  
>  
>> print() the appropriate headers to STDOUT
>> open() the file
>> binmode() the input and output filehandles
>> readline() from the file and print() to STDOUT
>> close() the file
> 
> I have never worked out how to pass the correct name of the file
> rather than the file being downloaded with the name of foo.pl
> but that is not a Perl question.

I have not worked it out either, but

<URL:http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1>

See also:

<URL:http://support.microsoft.com/kb/q279667/>

<URL:http://support.microsoft.com/kb/q260519/>

Hope this gives you a head start. I am sure someone over at 
comp.infosystems.www.authoring.cgi will have answers if you run into 
difficulties.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: 21 Dec 2005 18:34:54 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How to give (put to browser) someone PDF document, with hidden path to document.
Message-Id: <slrndqj82e.c5.abigail@alexandra.abigail.nl>

MAX (max@max.hr) wrote on MMMMCDXCIV September MCMXCIII in
<URL:news:do8p6b$acb$1@ss405.t-com.hr>:
''  How to give (put to browser) someone PDF document, with hidden path to
''  document.
''  If I use locate, user can see exact location of PDF document.
''  Perl script work on Microsoft IIS server and that cud be problem if I wont
''  to use password on folder.


I don't know about the configuration possibilites about IIS, but 
with Apache, I'd just tell it to map the path '/whatever/document.pdf'
to the "real" location of the document.

But that's not a Perl question.


Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


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

Date: Wed, 21 Dec 2005 08:10:56 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: My Regexp  XML Parser -> Structured Perl Data, Cut & Paste Version, No Module's (Vol I)
Message-Id: <slrndqiojg.3v6.tadmc@magna.augustmail.com>

robic0 <> wrote:


> ## -- XML start & end regexp substitution delimeter chars --


   delimeter: noun, scale used to weigh and price cold cuts.
              also the unit of length for salamis. -- Uri Guttman

   (Message-ID: <x74quoa5nu.fsf@mail.sysarch.com>)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 21 Dec 2005 09:52:58 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: split by word using | as delimiter
Message-Id: <dob8q7.13s.1@news.isolution.nl>

Eric J. Roode schreef:
> William:

>> my @lines = <DUMMY_FD>;
>> foreach my $currentLine ( @lines )  {
>
> Strictly speaking, it is not wrong to do the above.  But it generally
> makes more sense to write the above as:
>
>     while (my $currentLine = <DUMMY_FD>)  {
>
> Why read the entire file into memory, when you're only dealing with
> one line at a time?

That distinction seams not clear to many Perl programmers.

Compare this version:

  #!/usr/bin/perl
  use strict; use warnings;

  while (<>) {
    chomp;
    print "$.\t$_\n";
  }

to this one: (s/while/for/)

  #!/usr/bin/perl
  use strict; use warnings;

  for (<>) {
    chomp;
    print "$.\t$_\n";
  }

From perlfaq4:
Use of ".." in a "for" loop will iterate over the range, without
creating the entire range.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Wed, 21 Dec 2005 06:39:05 -0600
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: split by word using | as delimiter
Message-Id: <Xns97334E226EFE0sdn.comcast@216.196.97.136>

"Dr.Ruud" <rvtol+news@isolution.nl> wrote in news:dob8q7.13s.1
@news.isolution.nl:

> Eric J. Roode schreef:
>> William:
> 
>>> my @lines = <DUMMY_FD>;
>>> foreach my $currentLine ( @lines )  {
>>
>> Strictly speaking, it is not wrong to do the above.  But it generally
>> makes more sense to write the above as:
>>
>>     while (my $currentLine = <DUMMY_FD>)  {
>>
>> Why read the entire file into memory, when you're only dealing with
>> one line at a time?
> 
> That distinction seams not clear to many Perl programmers.
> 
> Compare this version:
[...]
> to this one: (s/while/for/)
[...]

I'll grant you that -- the difference between <> in a 'while' and in a 
'for' is subtle, annoyingly so.

Nut I frequently see beginners *explicitly* reading all the lines in a file 
into an array, and then iterating over that array, as the OP did above.

-- 
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`


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

Date: Wed, 21 Dec 2005 13:20:47 GMT
From: Bob <bob@dont.spam.me>
Subject: Re: split by word using | as delimiter
Message-Id: <pan.2005.12.21.13.20.46.618634@dont.spam.me>

On Wed, 21 Dec 2005 06:39:05 -0600, Eric J. Roode wrote:


> 
> Nut I frequently see beginners *explicitly* reading all the lines in a
> file into an array, and then iterating over that array, as the OP did
> above.

("But I ... ?)

In any case, as a perl dabbler, I can tell you why some of these
inappropriate techniques are used. Often I need to get something working
in perl where there is already a fairly complex set of perl scripts
involved and I need to add or change just a small part of it.

Not being a perl expert I look for example code and piece things together.
If I need to get from A to Z and I can find A->B, B->C, C->Z that's
what gets used even if there is a better way.

Now to give myself a little more credit I do try to find the best way but
sometimes I just don't find it.

The perl book I use for reference (Programming Perl) seems to focus on:
	Facts (like trrying to learn a language fom a dictionary)
	Advanced features (e.g. arrays of hashes)
	Clever tricks

I guess I need a better overall education in perl.

Bob


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

Date: 21 Dec 2005 14:57:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: split by word using | as delimiter
Message-Id: <dobqg1$qqn$1@mamenchi.zrz.TU-Berlin.DE>

Bob  <bob@dont.spam.me> wrote in comp.lang.perl.misc:
> On Wed, 21 Dec 2005 06:39:05 -0600, Eric J. Roode wrote:
> 
> 
> > 
> > Nut I frequently see beginners *explicitly* reading all the lines in a
> > file into an array, and then iterating over that array, as the OP did
> > above.
> 
> ("But I ... ?)
> 
> In any case, as a perl dabbler, I can tell you why some of these
> inappropriate techniques are used. Often I need to get something working
> in perl where there is already a fairly complex set of perl scripts
> involved and I need to add or change just a small part of it.
> 
> Not being a perl expert I look for example code and piece things together.
> If I need to get from A to Z and I can find A->B, B->C, C->Z that's
> what gets used even if there is a better way.

We have a deliberately disparaging term for that: cargo cult programming.
The idea is that parts of machinery are put together without understanding
their function, with less than optimal results.

(The analogy is also disparaging to the people who practice what is known
as "cargo cults".  Their motives are not really understood.  This is, one
hopes, not deliberate.)

The fact that cargo cult programming  "gets things done" really only works
in one-off solutions.  When you have to make something work once, with one
set of data, and never again, then an anything-goes approach is fine,
including shameless cargo-culting.

For anything that gets re-used, it is likely to break down in border-line
cases (because the parts don't fit together neatly), or under load (because
the solution is inefficient).  Changing it, for one of these or other
reasons, is particularly hard, because there are parts that aren't
understood, so can't be changed.

> Now to give myself a little more credit I do try to find the best way but
> sometimes I just don't find it.

That is very good, not just for reasons of programming morals, but you
get better-quality software out of it.  Cargo-cult programs are shoddy,
not only in an aesthetical, but in a practical sense.

> The perl book I use for reference (Programming Perl) seems to focus on:
> 	Facts (like trrying to learn a language fom a dictionary)

Yes, it's a reference (and more).

> 	Advanced features (e.g. arrays of hashes)

Those are essential to modern Perl programming.

> 	Clever tricks

Only very few are there just for their cutesey-factor.  Perhaps what
you call "clever tricks" is what we call "idioms", handy solutions
for recurring problems that have become fixed phrases.

> I guess I need a better overall education in perl.

The best education is practice, practice, practice.

The problem with printed material is that it ages rapidly.  _Programming
Perl_ is more than just a reference.  It is written to be read cover
to cover, and it's well worth while doing so, even including the reference
parts.  However, some aspects have changed (IO, Unicode), new standard
modules have evolved, so parts of it aren't quite up to date anymore.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Wed, 21 Dec 2005 17:49:47 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: split by word using | as delimiter
Message-Id: <%Agqf.12795$iz3.11637@text.news.blueyonder.co.uk>

Bob <bob@dont.spam.me> wrote:
> Now to give myself a little more credit I do try to find the best way but
> sometimes I just don't find it.
 
> The perl book I use for reference (Programming Perl) seems to focus on:
>        Facts (like trrying to learn a language fom a dictionary)
>        Advanced features (e.g. arrays of hashes)
>        Clever tricks

Perhaps you should add the Perl Cookbook to your library.

Axel
 


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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