[31724] in Perl-Users-Digest
Perl-Users Digest, Issue: 2987 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 12 18:10:11 2010
Date: Sat, 12 Jun 2010 15:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 12 Jun 2010 Volume: 11 Number: 2987
Today's topics:
Re: access to files in multiple combinations of folders <tnp@invalid.invalid>
Re: binmode for readling the whole file? <john@castleamber.com>
Re: binmode for readling the whole file? sln@netherlands.com
Creating pdf output file HerbF@earthlink.net
Re: Creating pdf output file <jurgenex@hotmail.com>
Re: Creating pdf output file HerbF@earthlink.net
Re: Creating pdf output file <john@castleamber.com>
Re: Creating pdf output file HerbF@earthlink.net
Re: Creating pdf output file <jurgenex@hotmail.com>
Re: Creating pdf output file HerbF@earthlink.net
Re: File::Slurp/IO::String/wantarray interaction bug <willem@turtle.stack.nl>
Re: How to return the line number that right next to a <pengyu.ut@gmail.com>
Re: How to return the line number that right next to a <rvtol+usenet@xs4all.nl>
Re: How to return the line number that right next to a <tadmc@seesig.invalid>
Re: How to return the line number that right next to a <willem@turtle.stack.nl>
Re: ignoring namespaces? sln@netherlands.com
Re: Why does perl allow so many different ways of doing <hjp-usenet2@hjp.at>
Re: Why does perl allow so many different ways of doing <hjp-usenet2@hjp.at>
Re: Why does perl allow so many different ways of doing <hjp-usenet2@hjp.at>
Re: Why does perl allow so many different ways of doing <hjp-usenet2@hjp.at>
Re: Windows and Linux Tips <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 12 Jun 2010 09:56:34 +0100
From: The Natural Philosopher <tnp@invalid.invalid>
Subject: Re: access to files in multiple combinations of folders?
Message-Id: <huvi42$7bh$5@news.albasani.net>
Marious Barrier wrote:
> On 06/10/2010 06:54 PM, Geoff wrote:
>> Hello
>>
>> I would like website users to be able to have access to the files in
>> any combination of folders.
>>
>> Say there are 20 folders, each with different files in them. User A
>> needs access to files in folders 1, 2 and 3, user B access to files in
>> folders 7, 10, 15 and 20 and so on.
>>
>> Now I know I can have a .htaccess file in each folder but that would
>> mean giving user A three different user name and password
>> combinations, user B four different combinations.
>>
>> Is there a better way?!
>>
>> Cheers
>>
>> Geoff
>
> I would handle everything through PHP.
and mysql.
Stick the files in a database, where you can create any sort of access
controls you want.
------------------------------
Date: Sat, 12 Jun 2010 01:43:10 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: binmode for readling the whole file?
Message-Id: <87vd9o69a9.fsf@castleamber.com>
"Uri Guttman" <uri@StemSystems.com> writes:
> it matters on winblows.
I guess you mean Windows?
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Sat, 12 Jun 2010 08:45:53 -0700
From: sln@netherlands.com
Subject: Re: binmode for readling the whole file?
Message-Id: <hda7161gr92303219hlt8ejimpqjn4vp2i@4ax.com>
On Fri, 11 Jun 2010 20:31:02 -0500, Tad McClellan <tadmc@seesig.invalid> wrote:
>sln@netherlands.com <sln@netherlands.com> wrote:
>> On Fri, 11 Jun 2010 12:48:17 -0500, John Bokma <john@castleamber.com> wrote:
>>
>>>Tad McClellan <tadmc@seesig.invalid> writes:
>>>
>>>> Use binmode on binary files.
>>>>
>>>> Do not use binmode on text files.
>>>
>>>/unless/ you want the data as it is on disk, for example to
>>>calculate a check sum.
>>>
>> Semantics! You wouldn't create a check sum on a text file.
>
>
>I create checksums on text files fairly often.
Oh yeah, for what? Spend a lot of time on it do ya?
>
>
>> Otherwise it wouldn't be a text file, it would be
>> a binary file.
>
>
>Nonsense!
???? You mean no sense. Its semantics..
>
>What makes you think that taking a checksum changes a file's type?
What is a file type and how do you change it?
Oh yeah, you create checksums on text files all the time.
------------------------------
Date: Sat, 12 Jun 2010 09:27:12 -0700
From: HerbF@earthlink.net
Subject: Creating pdf output file
Message-Id: <l6d7161t6gkbbnbpf3ucfdjbbiit6qmih0@4ax.com>
I have a Perl script that generates an HTML page and sends it to a
recipient via email. I would prefer to send the recipient a pdf document
instead of the HTML page. Is there "an easy" method of doing this within
the Perl script?
TIA, Herb
------------------------------
Date: Sat, 12 Jun 2010 10:07:53 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Creating pdf output file
Message-Id: <fmf7161o7bc6o18urq0psoaknn5p26gva6@4ax.com>
HerbF@earthlink.net wrote:
>I have a Perl script that generates an HTML page and sends it to a
>recipient via email. I would prefer to send the recipient a pdf document
>instead of the HTML page. Is there "an easy" method of doing this within
>the Perl script?
I suppose you checked http://search.cpan.org/search?query=PDF&mode=all
already?
jue
------------------------------
Date: Sat, 12 Jun 2010 10:36:18 -0700
From: HerbF@earthlink.net
Subject: Re: Creating pdf output file
Message-Id: <s6h7161mvlscg4ioa1tbf674821jvcm6ji@4ax.com>
Jürgen Exner wrote:
>HerbF@earthlink.net wrote:
>>I have a Perl script that generates an HTML page and sends it to a
>>recipient via email. I would prefer to send the recipient a pdf document
>>instead of the HTML page. Is there "an easy" method of doing this within
>>the Perl script?
>
>I suppose you checked http://search.cpan.org/search?query=PDF&mode=all
>already?
>
Yes, thank you I have. As a Perl neophyte, I was prompted to ask because
of the existence of multiple modules and my confusion at which one to
select.
Thanks for answering my question.
Herb
------------------------------
Date: Sat, 12 Jun 2010 13:47:24 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: Creating pdf output file
Message-Id: <87ljak84w3.fsf@castleamber.com>
HerbF@earthlink.net writes:
> I have a Perl script that generates an HTML page and sends it to a
> recipient via email. I would prefer to send the recipient a pdf document
> instead of the HTML page. Is there "an easy" method of doing this within
> the Perl script?
Check out the "Converting HTML to PDF with Webkit" thread of last week,
especially the answers by Dr.Ruud ;-)
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Sat, 12 Jun 2010 12:41:02 -0700
From: HerbF@earthlink.net
Subject: Re: Creating pdf output file
Message-Id: <vjo716tqg97cc7t7hq7a05044nt8l3mjd1@4ax.com>
John Bokma wrote:
>HerbF@earthlink.net writes:
>
>> I have a Perl script that generates an HTML page and sends it to a
>> recipient via email. I would prefer to send the recipient a pdf document
>> instead of the HTML page. Is there "an easy" method of doing this within
>> the Perl script?
>
>Check out the "Converting HTML to PDF with Webkit" thread of last week,
>especially the answers by Dr.Ruud ;-)
Thanks, John, I did. It appears that webkit is an external program that
reads a screen and converts it to pdf. I need to do this within Perl, on
my remote (CGI) server.
H-
------------------------------
Date: Sat, 12 Jun 2010 13:48:11 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Creating pdf output file
Message-Id: <ges7169elple8531799ouag6feen8ucuus@4ax.com>
HerbF@earthlink.net wrote:
>Jürgen Exner wrote:
>
>>HerbF@earthlink.net wrote:
>>>I have a Perl script that generates an HTML page and sends it to a
>>>recipient via email. I would prefer to send the recipient a pdf document
>>>instead of the HTML page. Is there "an easy" method of doing this within
>>>the Perl script?
>>
>>I suppose you checked http://search.cpan.org/search?query=PDF&mode=all
>>already?
>>
>Yes, thank you I have. As a Perl neophyte, I was prompted to ask because
>of the existence of multiple modules and my confusion at which one to
>select.
So your question wasn't so much "is there an easy method" but rather
"which of the modules do you recommend". Different question, different
answer.
Well, from the documentation it looks like PDF::Create is easy to use
for simple documents. If you want to create more complex documents then
I would assume you will need an understanding of how PDF works.
jue
------------------------------
Date: Sat, 12 Jun 2010 14:10:03 -0700
From: HerbF@earthlink.net
Subject: Re: Creating pdf output file
Message-Id: <rst716de1rj6bqbih1a6ad4ilsfo64a7r8@4ax.com>
Jürgen Exner wrote:
>HerbF@earthlink.net wrote:
>>Jürgen Exner wrote:
>>
>>>HerbF@earthlink.net wrote:
>>>>I have a Perl script that generates an HTML page and sends it to a
>>>>recipient via email. I would prefer to send the recipient a pdf document
>>>>instead of the HTML page. Is there "an easy" method of doing this within
>>>>the Perl script?
>>>
>>>I suppose you checked http://search.cpan.org/search?query=PDF&mode=all
>>>already?
>>>
>>Yes, thank you I have. As a Perl neophyte, I was prompted to ask because
>>of the existence of multiple modules and my confusion at which one to
>>select.
>
>So your question wasn't so much "is there an easy method" but rather
>"which of the modules do you recommend". Different question, different
>answer.
>
>Well, from the documentation it looks like PDF::Create is easy to use
>for simple documents. If you want to create more complex documents then
>I would assume you will need an understanding of how PDF works.
>
Thanks.
H-
------------------------------
Date: Sat, 12 Jun 2010 08:45:54 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: File::Slurp/IO::String/wantarray interaction bug
Message-Id: <slrni16ia2.250t.willem@turtle.stack.nl>
kj wrote:
) OK, I found out one more detail. If I replace the original second block
)
) {
) my $io_string = IO::String->new( slurp( $0 ) );
) printf ">>>%s<<<\n", scalar $io_string->READLINE;
) printf ">>>%s<<<\n", scalar $io_string->READLINE;
) }
)
) with
)
) {
) my $io_string = IO::String->new( scalar slurp( $0 ) ); # <- only this line changed
) printf ">>>%s<<<\n", scalar $io_string->READLINE;
) printf ">>>%s<<<\n", scalar $io_string->READLINE;
) }
)
) now the output is identical for both blocks.
)
) Still, this is quite a curveball. I see that in the original
) version, the call to slurp was happenning in a list context, and
) this probably messes up the string that actually gets used to define
) the IO::String object. But still, this does not explain why READLINE
) believes its in a list context. (I'm sorry that I can't show this
) easily; one needs to step there with the debugger).
When I saw your first post, it was immediately apparent to me that the
call to slurp was being evaluated in list context, and that caused it
to pass only the first line to the IO::String object.
The READLINE context is a red herring. Maybe you misinterpreted the
debugger output, maybe the debugger did something strange, maybe something
else happened. In any case, it's quite clear that it *is* being called in
scalar context, because that final fix works like it should.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
------------------------------
Date: Fri, 11 Jun 2010 21:13:25 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Re: How to return the line number that right next to a match?
Message-Id: <03a490e6-cc81-40e4-87d3-17a9cbefcab9@q12g2000yqj.googlegroups.com>
On Jun 11, 11:00=A0pm, "Dr.Ruud" <rvtol+use...@xs4all.nl> wrote:
> Peng Yu wrote:
> > After I did a regex match, I want to figure out what the line number
> > is after the match in (). =A0Is there an easy way to do it?
>
> > $string =3D~ /xxxx(somepattern)yyyy/;
>
> Do you mean that your $string contains multiple lines?
Yes. $string contains multiple lines.
------------------------------
Date: Sat, 12 Jun 2010 06:38:29 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: How to return the line number that right next to a match?
Message-Id: <4c130f45$0$22940$e4fe514c@news.xs4all.nl>
Peng Yu wrote:
> On Jun 11, 11:00 pm, "Dr.Ruud" <rvtol+use...@xs4all.nl> wrote:
>> Peng Yu wrote:
>>> After I did a regex match, I want to figure out what the line number
>>> is after the match in (). Is there an easy way to do it?
>>> $string =~ /xxxx(somepattern)yyyy/;
>>
>> Do you mean that your $string contains multiple lines?
>
> Yes. $string contains multiple lines.
So how did they end up there, did you slurp a file into it?
If so, then why not just process the file line-by-line?
You can still use a while-loop on the $string, for example:
my $n = 0;
while ( my ($line) = $string =~ /.*/g ) {
++$n;
print "$n ($1)\n" if $line =~ /xxxx(somepattern)yyyy/;
}
--
Ruud
------------------------------
Date: Fri, 11 Jun 2010 23:58:58 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: How to return the line number that right next to a match?
Message-Id: <slrni164lk.55m.tadmc@tadbox.sbcglobal.net>
Peng Yu <pengyu.ut@gmail.com> wrote:
> After I did a regex match, I want to figure out what the line number
> is after the match in (). Is there an easy way to do it?
>
> $string =~ /xxxx(somepattern)yyyy/;
----------------
#!/usr/bin/perl
use warnings;
use strict;
my $string = 'xxxxxxxsomepatternyyyyyyy';
print __LINE__, "\n" if $string =~ /xxxx(somepattern)yyyy/;
----------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Sat, 12 Jun 2010 09:19:16 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: How to return the line number that right next to a match?
Message-Id: <slrni16k8k.25a0.willem@turtle.stack.nl>
Peng Yu wrote:
) After I did a regex match, I want to figure out what the line number
) is after the match in (). Is there an easy way to do it?
)
) $string =~ /xxxx(somepattern)yyyy/;
Just count the newlines in the substring up to the (somepattern) capture.
my $linenr = substr($string, 0, $+[-1]) =~ tr/\n//;
See 'perldoc perlvar' for an explanation of the @+ array.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
------------------------------
Date: Sat, 12 Jun 2010 13:13:12 -0700
From: sln@netherlands.com
Subject: Re: ignoring namespaces?
Message-Id: <qhq716t59nfvsem57lmn004gdq90cbq708@4ax.com>
On Wed, 09 Jun 2010 22:02:32 +0100, Peter Flynn <peter.nosp@m.silmaril.ie> wrote:
>sln@netherlands.com wrote:
>> On Mon, 07 Jun 2010 12:32:15 +0100, Peter Flynn <peter.nosp@m.silmaril.ie> wrote:
>[...]
>>> I always counsel to avoid the non-XML approach
>[...]
>> This might parse it (with a slight bit of validation)
>
>It occurs to me that you can combine both methods, iff the document is
>well-formed.
>
>Run onsgmls -wxml /usr/share/xml/declaration/xml.dcl doc.xml >doc.esis
>to get the ESIS, and then tweak the W3C's esis2xml.py script to re-form
>the XML document, omitting the namespaces. Or write your own in Perl...
>
>///Peter
Hey thanks!
------------------------------
Date: Sat, 12 Jun 2010 11:54:41 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Why does perl allow so many different ways of doing essentially the same thing?
Message-Id: <slrni16mb1.ju3.hjp-usenet2@hrunkner.hjp.at>
On 2010-06-11 10:11, Peng Yu <pengyu.ut@gmail.com> wrote:
> On Jun 10, 8:32 am, Ted Zlatanov <t...@lifelogs.com> wrote:
>> But deciding what will be in the API is a very hard task, and
>> implementing it will be no easier.
>
> Agreed.
>
> I think this is a more important problem than figuring out how many
> ways of programming there are and choosing the best one out of them,
I think you are looking at it the wrong way. You think that just because
Perl provides multiple ways to do something you have to explore all of
them and find out which is best. But that isn't true. You just have to
find one way. And because there are multiple ways, there is likely to be
one way which is very similar to the way you would like to solve the
problem. You don't have to think "Well, I would like to do X, but the
language doesn't let me. But I could do Y and Z and that should do the
same".
Perl is an executable brain dump.
> in the sense that once such choice has been figured out in a given
> context, then just package it into an API then people don't have to
> worry about it in the future.
Have you looked at CPAN yet? A lot of people have packaged stuff into an
API. So you just have to worry about which API to pick :-).
hp
------------------------------
Date: Sat, 12 Jun 2010 11:58:27 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Why does perl allow so many different ways of doing essentially the same thing?
Message-Id: <slrni16mi3.ju3.hjp-usenet2@hrunkner.hjp.at>
On 2010-06-10 02:59, Peng Yu <pengyu.ut@gmail.com> wrote:
> According to Programming Perl, more than one way may not always be
> better. But I just don't see more than one way is better at all.
>
> I think that any code can be encapsulated in a subroutine or a class.
> To the end user, the actually implementation doesn't matter.
No, but it does matter to the programmer. Programming languages are
there for the programmer, not the user. Somebody will have to write and
maintain that subroutine and it is important that this person can
express the function of the subroutine in a natural way. Otherwise we
could just have stuck with machine language.
hp
------------------------------
Date: Sat, 12 Jun 2010 12:05:53 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Why does perl allow so many different ways of doing essentially the same thing?
Message-Id: <slrni16n02.ju3.hjp-usenet2@hrunkner.hjp.at>
On 2010-06-11 09:55, Peng Yu <pengyu.ut@gmail.com> wrote:
> On Jun 10, 10:14 am, Charlton Wilbur <cwil...@chromatico.net> wrote:
>> >>>>> "PY" == Peng Yu <pengyu...@gmail.com> writes:
>> PY> In this sense, there were a subroutine that can read multiple
>> PY> lines from a file. There is no need that the users should
>> PY> understand the different ways of reading muliple lines as
>> PY> discussed in other thread mentioned the original post.
>>
>> Ah, but the reason there are multiple ways to do things is because the
>> choice of which way to do things depends on the context.
>>
>> The best way to read *three* lines from a file is not the best way to
>> read *ten thousand* lines from a file. Instead of mandating one way,
>> the Perl philosophy is to assume that you're a competent programmer who
>> can judge the quality of various solutions for yourself.
>
> Rather than being hypothetically saying there are different ways of
> coding for different parameter values. I'd like to see what the best
> code is for reading three lines and what is the best code is for
> reading 10000 lines?
Three lines I would just slurp into memory. I would probably do the same
for 10000 lines. But for 10000000 lines, I would process them line by
line, keeping only the information absolutely needed.
Then it depends on the frequency of the task. If I have a piece of code
which needs to read the same file pretty frequently (say about once per
second) and the file might change at random moments, then:
* for a 3 line file I would just read the file every time
* for a 10000 line file I would check whether the file has actually
changed before reading it again.
Oh, and this is almost independent of the language. TIMTOWTDI in every
language.
hp
------------------------------
Date: Sat, 12 Jun 2010 12:09:48 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Why does perl allow so many different ways of doing essentially the same thing?
Message-Id: <slrni16n7c.ju3.hjp-usenet2@hrunkner.hjp.at>
On 2010-06-11 18:21, Christian Winter <thepoet_nospam@arcor.de> wrote:
> I'd say the same is true for Perl. Its power lies in the fact
> that it gives the possibility to work one step closer to the
> machine than with other competing languages like e.g. Java, C#
> or PHP.
For me Java is a lot closer to the machine then Perl.
hp
------------------------------
Date: Sat, 12 Jun 2010 03:20:05 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Windows and Linux Tips
Message-Id: <5mn6161vusii92l7sdmhekqnhg3lefdt5n@4ax.com>
pavelhaque <pavelhaque@gmail.com> wrote:
>Hi friends,
Spammers don't have friends.
>Do u need Windows and Linux Tips?
Did you mean "Does U need ...."?
How should we know? Knowbody around here knowns U. You would have to ask
U, not us.
jue
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 2987
***************************************