[23619] in Perl-Users-Digest
Perl-Users Digest, Issue: 5826 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 19 03:05:45 2003
Date: Wed, 19 Nov 2003 00:05:13 -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, 19 Nov 2003 Volume: 10 Number: 5826
Today's topics:
[OT] Re: Creating UNICODE filenames with PERL 5.8 <usenet@morrow.me.uk>
Re: Additional regex question (Tad McClellan)
Re: Creating UNICODE filenames with PERL 5.8 (Tad McClellan)
Re: Creating UNICODE filenames with PERL 5.8 <tassilo.parseval@rwth-aachen.de>
Re: extract block of text (mike)
Re: How can I append todays date to the file name? <me@privacy.net>
Re: Image::Info::TIFF - multi-page tiff images page cou <mgjv@tradingpost.com.au>
Re: Include &/or option in flatfile db query.. <asu1@c-o-r-n-e-l-l.edu>
MIME::Lite - From email address to name of the company. <provicon@earthlink.net>
Re: MIME::Lite - From email address to name of the comp <jwillmore@remove.adelphia.net>
Re: multilinepattern match <sunil_franklin@hotmail.com>
Need help wih tr/// operator <raisin@delete-this-trash.mts.net>
Re: Need help wih tr/// operator <mb@uq.net.au.invalid>
Re: Need help wih tr/// operator <krahnj@acm.org>
Re: Need help wih tr/// operator <asu1@c-o-r-n-e-l-l.edu>
Re: Perl sendmail going to spam folders? <me@privacy.net>
Re: perldoc installation <me@privacy.net>
Processing web pages downloaded <provicon@earthlink.net>
Re: Program that prints its source code <bik.mido@tiscalinet.it>
Project Organization chance@austin.rr.com
Protecting Source code of a perl script <senthil.raja@adcc.alcatel.be>
Re: regex to convert 1000000 -> 1,000,000 ? <uri@stemsystems.com>
Re: regex to convert 1000000 -> 1,000,000 ? (Tad McClellan)
Re: regex to convert 1000000 -> 1,000,000 ? <uri@stemsystems.com>
Re: SOAP::Lite versus DBI (Bryan Castillo)
Re: where is DBI::DWIM? <mb@uq.net.au.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 19 Nov 2003 02:36:48 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: [OT] Re: Creating UNICODE filenames with PERL 5.8
Message-Id: <bpel00$sl6$1@wisteria.csv.warwick.ac.uk>
yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote:
> Ben Morrow (usenet@morrow.me.uk) wrote:
> : OK, your problem here is that Win2k is being stupid about Unicode: any
> : sensible OS that understood UTF8 would be fine :).
>
> Hum, NT has been handling unicode for at least ten years (3.5, 1993) by
> the simple expedient of using 16 bit characters. It is hardware that is
> stupid, by continuing to use ancient tiny 8 bit elementary units.
OK, I invited that with gratuitous OS-bashing :)... nevertheless:
1. Unicode is *NOT* a 16-bit character set. UTF16 is an evil bodge to
work around those who started assuming it was before the standards
were properly in place.
2. Given that the world does, in fact, use 8-bit bytes, any 16-bit
encoding has this small problem of endianness... again, solved
(IMHO) less-than-elegantly by the Unicode Consortium.
3. Given that the most widespread character set is likely to be either
ASCII or Chinese ideograms, and ideograms won't fit into less than
16 bits anyway, it seems pretty silly to encode a 7-bit charset
with 16 bits per character.
4. It also seems pretty silly to break everything in the world that
relies on a byte of 0 meaning end-of-string, not to mention '/'
being '/' (or '\', or whatever, as appropriate).
et cetera
Ben
--
And if you wanna make sense / Whatcha looking at me for? (Fiona Apple)
* ben@morrow.me.uk *
------------------------------
Date: Tue, 18 Nov 2003 21:24:46 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Additional regex question
Message-Id: <slrnbrloju.goa.tadmc@magna.augustmail.com>
Bryan <bryan@akanta.com> wrote:
> I need to process the file and dump the results into a new file. The
> file should be processed in the following manner:
> 1. Any line that starts with '+' should be untouched and dumped to the
> new file
> 2. Any lines that are not empty should be joined with whatever lines are
> not empty following them, up to the empty line.
> 3. The joined line needs to be searched for a pattern and then truncated
> after the pattern.
> Suggestions appreciated,
------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
my $search = 'ddddeee';
local $/ = ''; # enable paragraph mode
while ( <DATA> ) {
my($first, $rest) = split /\n/, $_, 2;
$rest =~ tr/\n//d;
$rest =~ s/($search).*/$1/;
print "$first\n$rest\n"
}
__DATA__
+some identifying string 1
aaabbbbcccccdddd
eeeffffaaabcbcbaad
jjkalddd
+some identifying string 2
ggaadryyyyssaaad
ddddeeeakkkkalllla
asdfffff
------------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 18 Nov 2003 21:17:46 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Creating UNICODE filenames with PERL 5.8
Message-Id: <slrnbrlo6q.goa.tadmc@magna.augustmail.com>
Allan Yates <allan@yates.ca> wrote:
> PERL is an acronym,
No it isn't smarty pants.
> P.S. Please don't even think of chastising me for top posting versus
> bottom posting. Different people have different preferences.
No chastisment, just ignoration in perpetuity.
*plonk*
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Nov 2003 07:39:12 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Creating UNICODE filenames with PERL 5.8
Message-Id: <bpf6n0$5j9$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Allan Yates:
> P.S. Please don't even think of chastising me for top posting versus
> bottom posting. Different people have different preferences.
Right. And unless you write those articles solely for yourself, the
preferences of your readers count and not yours. So stop top-posting or
the regulars will stop reading your posts.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 18 Nov 2003 23:12:13 -0800
From: s99999999s2003@yahoo.com (mike)
Subject: Re: extract block of text
Message-Id: <dfd17ef4.0311182312.19a26a6c@posting.google.com>
Dave Weaver <zen13097@zen.co.uk> wrote in message news:<slrnbrjq93.4l0.zen13097@wormhole.homelinux.org>...
> On Mon, 17 Nov 2003 16:51:28 +0000 (UTC),
> Ben Morrow <usenet@morrow.me.uk> wrote:
> >
> > <untested>
> >
> > perl -ne'next if /^\s*$/; print if m|/* -+ Heading2| .. m|/* -+ Heading3|'
> >
>
> ITYM:
>
> perl -ne'next if /^\s*$/; print if m|/\* -+ Heading2| .. m|/\* -+ Heading3|'
>
> <also untested>
>
> Dave.
Thanks everyone for the tips that you have given
I went back to try out this piece instead
while($line=<FILE>)
{
chomp($line);
if ( $line =~ m/\/\* -+ $search*/ ) {
while ( $nextline = <FILE>)
{
if ( $nextline =~ m|\/\* -+| )
{
last;
}
print "$nextline" ;
}
}
i think it works ok (please correct me if i am wrong thanks :-)... but
i read from perl docs that "last" exits the current
so was wondering is it necessary to put a "last" just before ending
the outer
while...
while($line=<FILE>)
{
chomp($line);
if ( $line =~ m/\/\* -+ $search*/ ) {
while ( $nextline = <FILE>)
{
if ( $nextline =~ m|\/\* -+| )
{
last;
}
print "$nextline" ;
}
last;
}
------------------------------
Date: Wed, 19 Nov 2003 17:36:24 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: How can I append todays date to the file name?
Message-Id: <bpes1r$1n97so$1@ID-172104.news.uni-berlin.de>
"Dariush" <LinuxTeam@yahoo.com> wrote in message
news:d83f36a4.0311180715.5f89eb1f@posting.google.com...
> Hello every one.
>
> I'm no expert at perl.
>
> I would like to append todays date to the file name
Your example inserts, not appends.
>
> I have many files that arrive daily
>
> filename.pdf and so on
>
> How can I rename the files to
>
> filename_DDMMYY.pdf
>
> so the output would be
>
> filename_18112003.pdf
Suggest you use a better date format YYYYMMDD so that it will easily sort.
#!/usr/bin/perl
use strict;
use POSIX;
my $today = strftime("%Y%m%d",localtime);
foreach my $file (</dir/with/files/*.pdf>) {
my ($filename,$ext) =$file =~ /(.*)\.(\w+)$/;
rename $file, "${filename}_$today.$ext" or warn "Can not rename $file
$!\n";
}
------------------------------
Date: 19 Nov 2003 05:25:55 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Image::Info::TIFF - multi-page tiff images page count
Message-Id: <slrnbrlvn5.q43.mgjv@verbruggen.comdyn.com.au>
On 18 Nov 2003 07:52:45 -0800,
ifiaz <ifiaz@hotmail.com> wrote:
> How can I get a page count of a multi-page .tif image.
>
> I browsed in CPAN, but I can't find the TIFF.pm.
Image::TIFF is part of the Image-Info package. If you install the
package, you'll have it. You can't, or at least shouldn't, ever try to
get separate files out of a distribution.
However, I don't think that that supports multi-image formats (I might
be wrong. I haven't actually tried it, just browsed the documentation).
> Is there any way to get the page count in perl?
Image::Magick will be able to tell you this. You open the image as an
IM object, and then you just count the number of elements in it.
> If not, what is the easiest way to do it using C, etc.?
Probably also with the ImageMagick libary, or maybe directly with the
freely available tiff library (www.libtiff.org), possibly already on
your system, depending on your OS and vendor.
> Could someone give me the easiest steps to do it as I am quite
> new to perl and programming?
Lessee..
#!/opt/perl/bin/perl
use strict;
use warnings;
use Image::Magick;
# Create a multi-image TIFF document
{
my $im = Image::Magick->new();
# Read some JPG images
my $rc = $im->Read(glob("/tmp/P*.JPG"));
die $rc if $rc;
# Save the whole thing as a TIFF file
$rc = $im->Write("foo.tiff");
die $rc if $rc;
}
# Read the TIFF document
{
my $im = Image::Magick->new();
my $rc = $im->Read("foo.tiff");
die $rc if $rc;
# An Image::Magick object is just a reference to an array, with
# each element an image.
my $n_images = @$im;
print "I've got $n_images images\n";
}
Note that Image::Magick generally relies on an external tiff library
to write and read images.
> Just a side question:
> Is tiff the only format that supports multi-page images,
> or are there any other and if any, what are those?
Photoshop, MNG, ImageMagick's MIFF format, GIMP XCF, GIF, PostScript,
PDF, FAX, FITS (I believe), The various Flash and Macromedia formats,
MPEG, and many others. Not all of these are pure image formats or even
mainly image formats, and what a "frame/page/image/layer" in each of
these means is often application dependent. In fact, what multiple
images in a single TIFF document mean is dependent on the encoding and
context.
Martien
--
|
Martien Verbruggen | We are born naked, wet and hungry. Then
Trading Post Australia | things get worse.
|
------------------------------
Date: 19 Nov 2003 02:44:39 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Include &/or option in flatfile db query..
Message-Id: <Xns9437DD2BD3BC6asu1cornelledu@132.236.56.8>
ohmy9od@yahoo.com (Oeln) wrote in news:ffde43bc.0311162254.298c4521
@posting.google.com:
> I've got a flat text file db (tab delimited) & a form that lets one
> query it online. In its current incarnation, it only lets one input a
> term to look for in the file, & outputs the lines in the file which
> include that term. If the input 'term' incldes ' ', it considers it
> one term. I'd like to increase its functionality by including the &/or
> option (&, of course, therefore identifying each term input to the
> form individually).
>
> The form that includes the query option:
>
> <form method="post" action="cgi-bin/odb.pl">
> <input type="text" name="input">
> <input type="hidden" name="oper" value="query">
> <input type="submit" value="Okay">
> <input type="reset" value="Clear">
> </form>
>
> In odb.pl I've got the following in order to parse the form itself:
>
> if ($ENV{'REQUEST_METHOD'} eq 'POST') {
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs)
> {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $contents{$name} = $value;
> }
> }
Hmmmm ... Gunnar, if you need any more proof that my objection this code
from the "arrange form data in same order as on form" thread was based on
the fact that it seems to be very prolifically copied and pasted by
clueless people, look no further.
> I've then got, in order to do the query, the following:
>
> if ($contents{'oper'} eq "query") {
> open (FILE, "$odb") || do {&no_open;};
> &output_header;
> &output_open;
Do you know why you have an ampersand preceding the function calls?
> $count=0;
> @ordered = sort(<FILE>);
Is reading the whole file in really a good idea? And, if you are going to
read the whole file in and, still go through each item, why are you sorting
the lines?
>
> foreach $pair (@ordered) {
> if ($pair =~ /$contents{'input'}/gi) {
> $count++;
> @item = split(/\t/, $pair);
> &output_item;
> }
> }
This is the point I get impatient and frustruted and ignore the rest of
your post. Instead of writing in a prose style and expecting your readers
to figure out how multiple bits of code relate to each other, you should
try to include self contained code and data others can try out to see
what's happening as well as what expect the code to do etc etc. Please see
the posting guidelines posted here regularly.
perldoc -q intersection
might help.
> The interesting thing is this: I've got the following it &output_item:
>
> sub output_item {
> print <<"OUTPUT";
> <tr>
> <td>$item[0]</td>
> <td>$item[1]</td>
> <td>$item[2]</td>
> </tr>
> OUTPUT
> }
>
> In the output I'm getting now, there is an increase in table cells if
> I've input a term that ought to be found in the text file. If I input
> a term that it won't find, it gives me no table cells. I'm getting
> this impression by looking at the table border outline cells in the
> output - it's like it's finding the items in the file & outputting
> empty table cells like I've indicated if it finds a term; but it's not
> including the text in $item[0], $item[1], etc. I've got no idea why,
> or where the issue is, if I'm overlooking the obviuos or not..
who knows?
do you have
use strict;
and
use warnings;
at the top of your code?
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Wed, 19 Nov 2003 05:40:13 GMT
From: "John B. Kim" <provicon@earthlink.net>
Subject: MIME::Lite - From email address to name of the company..
Message-Id: <1nDub.5461$sb4.698@newsread2.news.pas.earthlink.net>
I have the code below that sends email with attachment using MIME::Lite:
========================================================
use strict;
use MIME::Lite;
use Net::SMTP;
my $from = 'askjinu@yahoo.com';
my @addweek1 = qw(provicon@earthlink.net
);
my $Fnameweek1 = 'guide.pdf';
my $subject='Subject Material';
for my $address (@addweek1) {
my $msg = MIME::Lite->new (
From => $from,
To => $address,
Subject => $subject,
Type =>'multipart/related');
.......
=======================================================
The code is all worked out, and works fine. But I am trying to better this
code by adding just one more change.
When I send an email using above code, recipients gets my email addresss,
askjinu@yahoo.com in their mail box.
I wish From information to be JinuAcademy rather than askjinu@yahoo.com.
Can anyone please tell me how to realize this??
Any help will be deeply appreciated.
John
------------------------------
Date: Wed, 19 Nov 2003 06:04:41 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: MIME::Lite - From email address to name of the company..
Message-Id: <20031119010440.62b753aa.jwillmore@remove.adelphia.net>
On Wed, 19 Nov 2003 05:40:13 GMT
"John B. Kim" <provicon@earthlink.net> wrote:
> I have the code below that sends email with attachment using
> MIME::Lite:========================================================
> use strict;
> use MIME::Lite;
> use Net::SMTP;
>
> my $from = 'askjinu@yahoo.com';
Try:
my $from = 'JinuAcademy <askjinu@yahoo.com>';
However, I'm not 100% sure this will work.
<snip>
> Any help will be deeply appreciated.
And any was offered.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Collaboration, n.: A literary partnership based on the false
assumption that the other fellow can spell.
------------------------------
Date: Wed, 19 Nov 2003 09:23:11 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: Re: multilinepattern match
Message-Id: <tYBub.26$wC5.154@news.oracle.com>
> @news.oracle.com:
>
> > Hi,
> > I have to match a string like
> >
> > "end;
> > /"
> >
> > in a file. Any suggestions on how to do this?
>
> /"end;
> \/"/
>
> or
>
> m!"end;
> /"!
>
> What's so hard about that? :-)
> - --
> Eric
The hard part is "how do I get the file contents (which may be huge) into a
string variable"
or is line by line from the file the only option?
Thanks,
Sunil.
------------------------------
Date: Tue, 18 Nov 2003 21:47:12 -0600
From: Master Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Need help wih tr/// operator
Message-Id: <MPG.1a24a3bcb9bb2d3a9896d8@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
I need help with solving a problem with the tr/// operator
$v1 = "aeiou";
$v2 = "AEIOU";
$string1 = "Hello out there";
$string1 =~ tr/${v1}/${v2}/;
print "$string1\n";
The output I see is
Hello out there
Why weren't *all* the vowels translated?
I am running perl 5.8.0 under Windows XP.
I have even tried using an eval statement, but with no luck.
------------------------------
Date: Wed, 19 Nov 2003 14:19:16 +1000
From: Matthew Braid <mb@uq.net.au.invalid>
Subject: Re: Need help wih tr/// operator
Message-Id: <bper04$fff$1@bunyip.cc.uq.edu.au>
Master Web Surfer wrote:
> [This followup was posted to comp.lang.perl.misc]
>
> I need help with solving a problem with the tr/// operator
>
>
> $v1 = "aeiou";
> $v2 = "AEIOU";
> $string1 = "Hello out there";
> $string1 =~ tr/${v1}/${v2}/;
> print "$string1\n";
>
> The output I see is
>
> Hello out there
>
> Why weren't *all* the vowels translated?
>
> I am running perl 5.8.0 under Windows XP.
>
> I have even tried using an eval statement, but with no luck.
Unfortunately tr/// does not do interpolation of variables. What you're
asking tr/// to do here is replace '$' with '$', '{' with '{', 'v' with
'v', '1' with '2', and '}' with '}'.
ie, if you change your string to "Hello out there 123" you'll end up
with "Hello out there 223". According to the docs (perldoc perlop, do a
search for 'tr/') the only way to do it is wrap it in a stringy eval,
which is nasty for a whole bunch of other reasons.
MB
------------------------------
Date: Wed, 19 Nov 2003 04:35:21 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Need help wih tr/// operator
Message-Id: <3FBAF304.9375A368@acm.org>
Master Web Surfer wrote:
>
> I need help with solving a problem with the tr/// operator
>
> $v1 = "aeiou";
> $v2 = "AEIOU";
> $string1 = "Hello out there";
> $string1 =~ tr/${v1}/${v2}/;
> print "$string1\n";
>
> The output I see is
>
> Hello out there
>
> Why weren't *all* the vowels translated?
Unlike m// and s///, tr/// doesn't interpolate so you are translating
'$' to '$' and '{' to '{' and 'v' to 'v' and '1' to '2' and '}' to '}'.
One way to do what you want is:
$string1 =~ s/[$v1]/\u$1/g;
John
--
use Perl;
program
fulfillment
------------------------------
Date: 19 Nov 2003 05:06:04 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Need help wih tr/// operator
Message-Id: <Xns94381084B39Easu1cornelledu@132.236.56.8>
Master Web Surfer <raisin@delete-this-trash.mts.net> wrote in
news:MPG.1a24a3bcb9bb2d3a9896d8@news.mts.net:
> [This followup was posted to comp.lang.perl.misc]
>
> I need help with solving a problem with the tr/// operator
>
>
> $v1 = "aeiou";
> $v2 = "AEIOU";
> $string1 = "Hello out there";
> $string1 =~ tr/${v1}/${v2}/;
> print "$string1\n";
>
> The output I see is
>
> Hello out there
>
> Why weren't *all* the vowels translated?
>
> I am running perl 5.8.0 under Windows XP.
>
> I have even tried using an eval statement, but with no luck.
This indicates that you have read perldoc perlop, especially:
Because the transliteration table is built at
compile time, neither the SEARCHLIST nor the
REPLACEMENTLIST are subjected to double quote
interpolation. That means that if you want to
use variables, you must use an eval():
Here is what works for me
C:\Home>cat t.pl
#! perl
use strict;
use warnings;
my $v1 = 'aeiou';
my $v2 = 'AEIOU';
my $s = 'Hello out there';
for ($s) {
eval qq(tr /$v1/$v2/);
die $@ if $@;
}
print $s, "\n";
C:\Home>t.pl
HEllO OUt thErE
I am not sure this is the best 'solution' as I am not that well versed in
Perl.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Wed, 19 Nov 2003 17:39:43 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: Perl sendmail going to spam folders?
Message-Id: <bpes82$1n0q2u$1@ID-172104.news.uni-berlin.de>
"Duke of Hazard" <faraz_hussain@yahoo.com> wrote in message
news:d5052c5d.0311181021.5211bdfa@posting.google.com...
> I am using sendmail in a perl script to send a message to the email
> address provided in a web form. The problem is that this message
> always end up in the person's spam/bulk folder. I don't know what it
> is about the sendmail that makes yahoo think it is spam. Below is my
> code pasted below:
What makes you think it has anything to do with sendmail and I can't think
what relevance you think Perl is to this.
Spam filters work on any number of components of the email, the most
important (and obvious) being the subject and contents.
[snipped code]
------------------------------
Date: Wed, 19 Nov 2003 17:26:22 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: perldoc installation
Message-Id: <bperf1$1na9m4$1@ID-172104.news.uni-berlin.de>
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:bpcvsq$7gg$1@mamenchi.zrz.TU-Berlin.DE...
> Tintin <me@privacy.net> wrote in comp.lang.perl.misc:
> > This is just a comment/observation about people who reply that if
perldoc
> > isn't on the system, then your Perl installation is broken/defective.
> >
> > Well, that maybe one interpretation, but keep in mind that Perl as
included
> > on later releases of Solaris doesn't include the Perl documentation.
This
>
> Which versions would that be? It just doesn't make sense. In Solaris 8
> and 9 the Perl documentation is contained in package SUNWpl5p.
Does that include perldoc? (I'm not in front of a Solaris box at the
moment)
------------------------------
Date: Wed, 19 Nov 2003 05:46:16 GMT
From: "John B. Kim" <provicon@earthlink.net>
Subject: Processing web pages downloaded
Message-Id: <IsDub.5474$sb4.818@newsread2.news.pas.earthlink.net>
I have web pages downloaded:
1.html
2.html
3.html... and so on..
When I was downloading this pages, it is supposed to download in a
consecutive numbers, but sometimes, some of the numbers in sequence gets
missed.
Now using HTML::TokeParser, I process these web pages downloaded in order to
retrieve only the information I need from the page, but when the page number
skips, the program gets stuck.
Can anybody tell me how I can change the code below so that when certain web
page number skips, it goes to the next number??
I enclose the code I currently use to carry this job out:
======================================================
use HTML::TokeParser;
$number = 1;
while ($number < 96) {
my $ns="C:\\ChoiBiz4Less\\$number.html";
my $stream = HTML::TokeParser->new($ns);
open(OUT, '>>c:\\ChoiBiz4Less.txt');
while (my $token=$stream->get_token) {
if ($token->[0] eq 'S' and $token->[1] eq 'td' and $token->[4] eq '<td>') {
$text_string=$stream->get_trimmed_text('/td');
print OUT "$text_string;" ;}
if ($token->[0] eq 'E' and $token->[1] eq 'tr') {
print OUT "\n";}
}
$number = $number+1;
}
=============================================
------------------------------
Date: Wed, 19 Nov 2003 07:34:16 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Program that prints its source code
Message-Id: <21ukrv08d3ogrvch83f5clvnevdigs21kl@4ax.com>
On Tue, 18 Nov 2003 18:56:02 -0000, "David K. Wall"
<usenet@dwall.fastmail.fm> wrote:
>If I want a program to print its own source code, is there any reason
>to prefer one of these code snippets over the other? Or is there an
>even better way to do it?
This is called a 'quine'. Try and search this NG for that word on
google!
>The context I'm thinking of is a CGI program that can be used as
>working code and also optionally provide a copy of itself to interested
>persons. (Obviously I'd have to provide proper HTTP headers....)
>
>Snippet 1:
>
>seek DATA, 0, 0;
>print <DATA>;
>__DATA__
>
>Snippet 2:
>
>open SELF, $0 or die "Error opening self for reading";
>print <SELF>;
I think that these would be considered both "illegal" quines for most
definitions of quine.
Benjamin Goldberg (who used to be one of the most valuable
contributors to this NG since when I first joined it - BTW: where is
he now?) posted more complex, nontrivial quines in the thread "Perl
Golf on my Mind" in January.
Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
------------------------------
Date: Wed, 19 Nov 2003 06:44:05 GMT
From: chance@austin.rr.com
Subject: Project Organization
Message-Id: <bpf4ip$msc$1@localhost.localdomain>
So anybody out there have any advice on how to organize a
big perl project?
Pretty much all I'm looking for is philosophical banter on
merits of
1) setting PERLIB
2) setting PERL5LIB
3) perl -Idirs
4) 'use lib "../dir/dir";',
followed my 'use module;' (which resides in '../dir/dir/')
5) something I don't know about
I've got all my stuff checked in to a CVS repository,
and I want multiple experimental implementations to
be able to work at the same time, so absolute paths are
ruled out.
This feels like an instance where having Makefiles and
associated cruft is actually an advantage. Maybe its just
a mental block my part though.
Right now, I'm using method (4), which feels like putting
the the -I flag (to gcc) in a C file. just feels kinda
icky and wrong.
any better way to do this ?
--
I used to think government was a necessary evil.
I'm not so sure about the necessary part anymore.
------------------------------
Date: Wed, 19 Nov 2003 12:47:39 +0530
From: Senthilraja <senthil.raja@adcc.alcatel.be>
Subject: Protecting Source code of a perl script
Message-Id: <3FBB1913.2CF04140@adcc.alcatel.be>
I've written a perl script for a high security application and hence I
want to protect the source code of the perl script, even from the
administrator of the application.
Is there any way to convert the perl script source into some sort of exe
or binary file, without affecting the functioning of the script?
TIA.
regards,
Senthil.
------------------------------
Date: Wed, 19 Nov 2003 02:23:21 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: regex to convert 1000000 -> 1,000,000 ?
Message-Id: <x7islhf65m.fsf@mail.sysarch.com>
>>>>> "SH" == Sam Holden <sholden@flexal.cs.usyd.edu.au> writes:
SH> On Tue, 18 Nov 2003 16:57:32 -0800,
SH> Wally Sanford <wsanford@wallysanford.com> wrote:
>>
>> Assumign the knew person knows of man, yes this is true.
SH> How do you propose perl make the documentation available in such a way
SH> that people who don't know how to read the documentation in the standard way
SH> can still find it?
SH> Mental telepathy or something?
have you forgotten about the PSI::ESP module on cpan? just have the
newbies use that before they learn any perl and they will instantly know
how to find and read all the docs in any format. hell, in any language
since they will be able to read the minds of perl hackers from around
the world.
as for sanford and this thread, drop both already. he has no clue about
bootstrapping docs nor teaching.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 18 Nov 2003 22:38:11 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regex to convert 1000000 -> 1,000,000 ?
Message-Id: <slrnbrlstj.gtk.tadmc@magna.augustmail.com>
Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "SH" == Sam Holden <sholden@flexal.cs.usyd.edu.au> writes:
>
> SH> On Tue, 18 Nov 2003 16:57:32 -0800,
> SH> Wally Sanford <wsanford@wallysanford.com> wrote:
> >>
> >> Assumign the knew person knows of man, yes this is true.
>
> SH> How do you propose perl make the documentation available in such a way
> SH> that people who don't know how to read the documentation in the standard way
> SH> can still find it?
>
> SH> Mental telepathy or something?
>
> have you forgotten about the PSI::ESP module on cpan? just have the
> newbies use that before they learn any perl and they will instantly know
> how to find and read all the docs in any format.
Assumign (sic) the knew (sic) person knows of PSI::ESP, yes this is true.
Rather than installing perldoc, a proper install should insert
multiple brain cells and interconnect them.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 19 Nov 2003 04:51:16 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: regex to convert 1000000 -> 1,000,000 ?
Message-Id: <x74qx1ezaz.fsf@mail.sysarch.com>
>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
TM> Uri Guttman <uri@stemsystems.com> wrote:
>>>>>>> "SH" == Sam Holden <sholden@flexal.cs.usyd.edu.au> writes:
>>
SH> On Tue, 18 Nov 2003 16:57:32 -0800,
SH> Wally Sanford <wsanford@wallysanford.com> wrote:
>> >>
>> >> Assumign the knew person knows of man, yes this is true.
>>
SH> How do you propose perl make the documentation available in such a way
SH> that people who don't know how to read the documentation in the standard way
SH> can still find it?
>>
SH> Mental telepathy or something?
>>
>> have you forgotten about the PSI::ESP module on cpan? just have the
>> newbies use that before they learn any perl and they will instantly know
>> how to find and read all the docs in any format.
TM> Assumign (sic) the knew (sic) person knows of PSI::ESP, yes this is true.
balderdash! proper use of PSI::ESP doesn't require knowing about the
module. the module should properly detect those who need to use it and
self install. if it doesn't, that means either the module or the person
has a major bug and should be reported to their maintainer.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 18 Nov 2003 22:17:51 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: SOAP::Lite versus DBI
Message-Id: <1bff1830.0311182217.47f1042c@posting.google.com>
Kirk Strauser <kirk@strauser.com> wrote in message news:<njeq81x058.ln2@news.conpoint.com>...
> I'm hoping to build a SOAP server to wrap a FoxPro database.
>
> I built a minimal server:
>
> -----------------------------------------------------------
> #!/usr/bin/perl -w
>
> use strict;
> use SOAP::Transport::HTTP;
> use FoxPro;
>
> my $daemon = SOAP::Transport::HTTP::Daemon
> -> new (LocalPort => 8080, Reuse => 1)
> -> dispatch_to('FoxPro')
> ;
>
> print "Contact to SOAP server at ", $daemon->url, "\n";
> $daemon->handle;
> -----------------------------------------------------------
>
> and a package to handle the backend:
>
> -----------------------------------------------------------
> #!/usr/bin/perl -w
>
> package FoxPro;
>
> use strict;
> use DBI;
>
> # Create a new FoxPro object
> sub new
> {
> my $self = shift;
> my $dbpath = shift || '.';
> my $class = ref($self) || $self;
> bless {'_dbpath' => $dbpath} => $class;
> }
>
> # Execute a query on a named table and return a handle to the result.
> sub execute
> {
> my $self = shift;
> my $query = shift;
> my $limit = shift || 10;
> my $dbh = DBI->connect("DBI:XBase:$self->{'_dbpath'}") or die $DBI::errstr;
> my $sth = $dbh->prepare($query);
> $sth->execute();
> return $sth;
> }
> -----------------------------------------------------------
>
> Now, I can use the FoxPro module locally, but when I run the little server
> and try to pull results from it, I get errors like:
>
> dbih_getcom handle DBI::st=HASH(0x86848dc) is not a DBI handle (has no magic)
>
> I've Googled about, and it seems that other people have had similar
> problems, but I've never found an answer to their questions. Is there
> some problem passing around statement handles via SOAP::Lite that doesn't
> exists when calling the modules locally?
I don't know for sure but.....
I imagine that a statement handle object is a complex object that
probably has some C code behind it. Perhaps it has a C struct stashed
away in the implementation with pointers to various places in memory.
In which any case, the object wouldn't serialize very well over a
network connection. There are some things that just don't serialize
very well. You might want to try keeping the object stored in a hash
within the server code and return the key through the soap calls.
This key would be the first argument of all your methods and you would
use that to look up the real object and call the methods on that.
Very similar to the idea of a session.
------------------------------
Date: Wed, 19 Nov 2003 14:06:30 +1000
From: Matthew Braid <mb@uq.net.au.invalid>
Subject: Re: where is DBI::DWIM?
Message-Id: <bpeq86$kps$1@bunyip.cc.uq.edu.au>
Eric Wilhelm wrote:
> On Tue, 18 Nov 2003 05:12:33 -0600, Tore Aursand wrote:
>
>
>>Everywhere on this way you know for sure what/who the instance is, so
>>why do you need to re-create your relationship with the instance for
>>each of the parts above?
>>
>>More code-related, these three would look like this:
>>
>> 1. Read data from a database
>> 2. Do something with the data
>> 3. Get rid of the data (ie. save and dispose, or just dispose)
>>
>>Where do _you_, in _your_ application, loose control over what you're
>>working with?
>
>
> The situation that I have is that 3-4 programs are responsible for
> creating one record in a table. The first application may set 2-3
> columns, another application sets 1 column, etc.
BEGIN;
if (not UPDATE table SET column = value WHERE key = rowid) {
if (not INSERT INTO table (key, column) VALUES (rowid, value)) {
ROLLBACK;
die "FAILED TO UPDATE!\n";
}
}
COMMIT;
In other words:
1) Start a transaction
2) Try an update
-> If the update affects zero rows, try an insert
-> -> If the insert fails, rollback and die
3) Commit the transaction
Absolutely no select is necessary, and you don't need to use some kind
of bodgy roll-your-own SQL extension.
MB
------------------------------
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.
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 5826
***************************************