[25253] in Perl-Users-Digest
Perl-Users Digest, Issue: 7498 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 9 00:05:57 2004
Date: Wed, 8 Dec 2004 21:05:07 -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, 8 Dec 2004 Volume: 10 Number: 7498
Today's topics:
Can't find Cyrus::Imap module. <sam.wun@authtec.net>
Re: Generate Squential Numbers? <ahamm@mail.com>
Re: How to detect an undefined SV* value in XS? <kalinaubears@iinet.net.au>
Re: HTML2JPEG <henq _ replace 0 by o <hvtijen@h0tmail.c0m>>
Re: HTML2JPEG <romm@empire.tau.ac.il>
Re: HTML2JPEG <jurgenex@hotmail.com>
Re: kindergarten array vs. for question <jidanni@jidanni.org>
Re: Matching words and letters <1usa@llenroc.ude.invalid>
Re: MS Perl question -- how to use hacked script to wor <lawshouse.public@btconnect.com>
Re: MS Perl question -- how to use hacked script to wor <djcameron60616@yahoo.com>
Re: MS Perl question -- how to use hacked script to wor <1usa@llenroc.ude.invalid>
Re: MS Perl question -- how to use hacked script to wor <kalinaubears@iinet.net.au>
Re: New comp.lang.perl.misc mirror site at lampforums.o <tadmc@augustmail.com>
Re: Obtaining length of binary string <1usa@llenroc.ude.invalid>
Re: Paragraph separation for DOS files on Unix <tadmc@augustmail.com>
Re: Perl classes NOT in separate files <andy.glew@intel.com>
Re: Perl some time hank with system command. <kalinaubears@iinet.net.au>
Re: Question on loops and return values <djcameron60616@yahoo.com>
regular expressions problem <humbads1@hotmail.com>
Re: Seeking Internet Protection Service <nospam@bigpond.com>
Re: Seeking Internet Protection Service <alarmprosnail@snailgmail.com>
Re: Web Form search and open pdf <mbudash@sonic.net>
Re: Web Form search and open pdf <emschwar@fc.hp.com>
Re: Web Form search and open pdf <mbudash@sonic.net>
Re: why the following HereDoc print don't work? <zhao_bingfeng@topsec.com.cn>
Re: why the following HereDoc print don't work? <spamtrap@dot-app.org>
Re: why the following HereDoc print don't work? <bart.lateur@pandora.be>
Re: why the following HereDoc print don't work? <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 09 Dec 2004 11:08:38 +0800
From: sam <sam.wun@authtec.net>
Subject: Can't find Cyrus::Imap module.
Message-Id: <cp8h4m$1jnl$1@news.hgc.com.hk>
Hi,
I search the cpan.org website, but could not find a download link for
this module.
Can anyone tell me where can I download this perl module?
Note, this is not the same as the old IMAP::Admin module written few
years ago. I m looking for Cyrus::Imap.
Thanks
Sam
------------------------------
Date: Thu, 9 Dec 2004 15:58:57 +1100
From: "Andrew Hamm" <ahamm@mail.com>
Subject: Re: Generate Squential Numbers?
Message-Id: <31q4cjF3eitdkU1@individual.net>
Josef Moellers wrote:
>
> Isn't "unlikely" a synonym for "will not happen during tests or qa,
> but will happen when the customer does important work"?
It can also mean it will happen several times in testing, and then it will
cause delay for weeks because it never recurs on the development machine.
------------------------------
Date: Thu, 09 Dec 2004 00:33:25 +0000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: How to detect an undefined SV* value in XS?
Message-Id: <41b7acc8$0$25770$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
xhoster@gmail.com wrote:
>
> SvANY doesn't seem to work properly for me.
SvTYPE seems to be produces identical results. Seems to me that they're
both functioning correctly - it's just that the fields being examined
are not being set as (you and?) I expect.
>
> It claims a variable that was once defined but is now undef as if it
> were defined. It also treats array slots which are off the end of the
> array differently than those "inside" the array (but never assigned to).
Devel::Peek can be put to good use here.
>
> use strict;
use Devel::Peek;
> use Inline 'C' ;
>
> my @x;
> $x[3]=5;
> $x[1]=4;
> $x[1]=undef;
> $x[2]='';
>
> my $h=4;
Dump($h);
print "##############\n";
> $h=undef;
Dump($h);
print "##############\n";
# You'll note that the only change is to
# the flags - so, yes, you probably do
# need to check the flags to detect this.
> print foo($h);
>
> foreach (0..6) {
> print foo($x[$_]);
> };
>
> __DATA__
> __C__
>
> int foo(SV* sv) {
> if (SvANY(sv) == NULL ) return 1;
> return 0;
> };
>
In the case of arguments received from "off the end of the array" I
don't know how you should set about detecting them. Perhaps you can work
it out by looking at what gets Dump()ed. It's probably best to make sure
that they can't get passed in to foo(). If you need a definitive answer
to that problem, and you don't get it here, you could try mailing the XS
list at perl-xs at perl.org. (See http://lists.perl.org if you want to
subscribe.)
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Thu, 9 Dec 2004 01:26:19 +0100
From: "henq" <henq _ replace 0 by o <hvtijen@h0tmail.c0m>>
Subject: Re: HTML2JPEG
Message-Id: <41b79c26$1$21106$e4fe514c@news.xs4all.nl>
Would http://freshmeat.net/projects/htmldoc/ help?
Regards,
Henk
www.windsurfpedia.com
"Katja Zinchenko" <katja_zina@web.de> schreef in bericht
news:Pine.LNX.4.58.0412081919410.6966@isar.geschichte.uni-muenchen.de...
> *** Roman M. Parparov, 07-Dec-04, 14:06 h ***
>
>> katja <katja_zina@web.de> wrote:
>> > How can I convert an Internet-page to a PDF/JPEG-file from a
>> > Perl-script under Linux? (I would like to make a screenshot from a
>> > command line).
>> > Thank you
>> > Katja
>>
>> Since every browser for every platform for every user renders the WWW
>> pages differently, it is unclear whether your task is well-defined, thus
>> an answer should not be possible. You can download the contents of a web
>> page as a text file easily. Converting text files on Linux is often
>> done using wv suite (wvText, wvPDF et al.) which operates installed
>> converting programs like latex, distill and others through a shell script
>> wrapper.
>
> Thanks for the hint, and sorry, yes, my question was too vague. What I
> wanted to
> ask is: Is there a perlish way to save the contents of a web page to an
> image
> file exactly the way a browser (any recent browser) would render it? I'd
> like to
> pass my script a url and automatically get a kind of screen shot of the
> web
> page. There doesn't seem to be a perl module (at least not on CPAN) to
> that
> purpose, and as far as I could find out, mozilla, firefox, galeon,
> konqueror and
> opera don't support any command line options to have them print to a file.
>
> Thank you,
> Katja
------------------------------
Date: Thu, 9 Dec 2004 00:30:14 +0000 (UTC)
From: "Roman M. Parparov" <romm@empire.tau.ac.il>
Subject: Re: HTML2JPEG
Message-Id: <cp86am$l1q$1@news.iucc.ac.il>
Katja Zinchenko <katja_zina@web.de> wrote:
> Thanks for the hint, and sorry, yes, my question was too vague. What I wanted to
> ask is: Is there a perlish way to save the contents of a web page to an image
> file exactly the way a browser (any recent browser) would render it? I'd like to
> pass my script a url and automatically get a kind of screen shot of the web
> page. There doesn't seem to be a perl module (at least not on CPAN) to that
> purpose, and as far as I could find out, mozilla, firefox, galeon, konqueror and
> opera don't support any command line options to have them print to a file.
> Thank you,
> Katja
But even the same browser would show it differently for various users.
You must also realize that most of the sites do not fit within one browser
window which is about 1024x768 pixels in size.
The only way that comes to mind - an abstract implementation:
1) Launch the browser to the requested URL from a perl script.
Your browser and whatever it displays are an X11 window within your
window manager/desktop environment.
2) Use the perl library corresponding to your window manager or even an
X11 perl interface to capture the window into an image.
OR
2) Use scriptlets supplied with your window manager (some have them) that
do the window capture. AFAIK Afterstep has this ability. I am not sure
but it is possible that X11 package has a program to take a shot of a full
desktop. Then, knowing your browser X11 geometry you can crop out the
browser itself.
The image would usually be saved in the XWD format.
3) Use an image conversion library of perl (or an external application)
to convert XWD to JPG or whatever.
Note: all this might be done with a shell script and existing Linux
utilities without Perl.
--
Roman M. Parparov - NASA EOSDIS project node at TAU technical manager.
Email: romm@empire.tau.ac.il http://www.nasa.proj.ac.il/
Phone/Fax: +972-(0)3-6405205 (work), +972-(0)50-734-18-34 (home)
----------------------------------------------------------------------
The economy depends about as much on economists as the weather does on
weather forecasters.
-- Jean-Paul Kauffmann
------------------------------
Date: Thu, 09 Dec 2004 04:40:54 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: HTML2JPEG
Message-Id: <qHQtd.3458$mn6.1863@trnddc07>
Katja Zinchenko wrote:
> Thanks for the hint, and sorry, yes, my question was too vague. What
> I wanted to ask is: Is there a perlish way to save the contents of a
> web page to an image file exactly the way a browser (any recent
> browser) would render it?
Of course. And it is so trivial that you don't even need Perl.
Just use Lynx. It has an option to write the rendered text to a file:
-dump
dumps the formatted output of the default document or one specified on the
command line to standard out.
Further details see
http://lynx.isc.org/current/lynx2-8-5/lynx_help/Lynx_users_guide.html
jue
------------------------------
Date: Wed, 08 Dec 2004 09:25:11 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: Re: kindergarten array vs. for question
Message-Id: <87acspponc.fsf@jidanni.org>
I read perldata and perllol. How do I fill in the for() so "new
array" gets printed twice instead of six times, without changing other
lines of the program?
my @a=(1,2,3); my @b=(4,5,6);
for( .....@a......@b.........what do I write?.........)
print "new array\n"; #this line get printed only twice, not six times?
for($_){
print "element $_\n"}}
------------------------------
Date: 9 Dec 2004 04:35:56 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Matching words and letters
Message-Id: <Xns95B9F00E0493asu1cornelledu@132.236.56.8>
Sandman <mr@sandman.net> wrote in
news:mr-EF7164.22335808122004@individual.net:
> I have a series of letters, say "kljetilamnop", then I have a big
> textfile with legit words, but let's use a short one here:
>
> mall
> bill
> kill
> lot
> pile
> antilope
> hello
>
> Now, I want to cycle through this word list and match it to the
> letters, and return true if the word can be formed by the letters. So,
> the above would return:
>
> mall
> kill
> lot
> antilope
pile should be in that list as well.
Now, undoubtedly, there is a better way to do this, but here is something
that works for the data you posted:
#! /usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $source = normalize('kljetilamnop');
LINE: while(my $word = <DATA>) {
chomp $word;
my $target = normalize($word);
for my $c (keys %{ $target }) {
next LINE unless(
defined($source->{$c}) && ($source->{$c} >= $target->{$c})
);
}
print "$word\n";
}
sub normalize {
my ($string) = @_;
my @letters = split //, $string;
my %count;
$count{$_}++ for (@letters);
return \%count;
}
__DATA__
mall
bill
kill
lot
pile
antilope
hello
D:\Home\Dload>perl rs.pl
mall
kill
lot
pile
antilope
> which leads me to the other part of my problem.
I am going to ignore that part.
> So, any help appreciated.
Hope this helps.
Sinan.
------------------------------
Date: Wed, 08 Dec 2004 23:19:31 +0000
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin)
Message-Id: <od2fr0pto2perg74a149qotnpt773b1vk6@4ax.com>
On 8 Dec 2004 11:59:05 -0800, "James" <djcameron60616@yahoo.com>
wrote:
>I have altered a couple scripts to work
Indeed you might have but what you posted isn't one of them, at least
not any more. It's got serious syntax errors.
I use Perl under windows mostly so I did copy your code to see if I
could help. Unfortuately ActiveState's Perl (which I have and which
is a very common Perl implementation for Windows) doesn't have the
Win32 modules you are using, and I wasn't able to find any substitutes
in the time I had available to look. Sorry..
I think your question is to do with the loops and what not, rather
than the details of the Windows API code. Can I suggest that you hack
a version of your code so it doesn't need the API calls - hard-code
some suitable values - and then see if you can make that work? If you
can't it would be easy to post it here so that someone (like me, but
preferably someone more skilled) could then actually test your code
without having to go on a scavenger hunt for the required Win32 API
modules.
large snip ..
># Writing out the result set for this server\\share combo.
># print HANDLE2 "@Drivearray[0], @Drivearray[2], $Utilpercentage,
>$Free1, $Used1,
>
>$Total1 ";
That line's got an unmatched quote in it. Did you comment out the
first line of a multi-line statement?
--
Henry Law <>< Manchester, England
------------------------------
Date: 8 Dec 2004 17:28:07 -0800
From: "James" <djcameron60616@yahoo.com>
Subject: Re: MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin)
Message-Id: <1102555687.323162.82810@f14g2000cwb.googlegroups.com>
Henry Law wrote:
> On 8 Dec 2004 11:59:05 -0800, "James" <djcameron60616@yahoo.com>
> wrote:
Hi Henry and thanks for your time,
>
> >I have altered a couple scripts to work
>
> Indeed you might have but what you posted isn't one of them, at least
> not any more. It's got serious syntax errors.
>
> I use Perl under windows mostly so I did copy your code to see if I
> could help. Unfortuately ActiveState's Perl (which I have and which
> is a very common Perl implementation for Windows) doesn't have the
> Win32 modules you are using, and I wasn't able to find any
substitutes
> in the time I had available to look. Sorry..
I thought it was just me. I had originally tried to get a script
working with the AdminMisc package from roth.net, but I could not get
it to work with Active State Perl or Indigo Perl on Windows 2000,
because of a missing .pll (dll?) file that I searched for and could not
find either. I tried using Win32 and Win32API calls on this script.
For all the time I tried to invest in piecing together other people's
code, I should have spent the time learning it in and out and writing
my own. The reverse of an engineer I guess :)
>
> I think your question is to do with the loops and what not, rather
> than the details of the Windows API code. Can I suggest that you
hack
> a version of your code so it doesn't need the API calls - hard-code
> some suitable values - and then see if you can make that work? If
you
> can't it would be easy to post it here so that someone (like me, but
> preferably someone more skilled) could then actually test your code
> without having to go on a scavenger hunt for the required Win32 API
> modules.
I will try the hard coding, even if I have to do it with code from the
.pm file or not. The below line was one of several lines in an
original script which is also connected to the current main while loop
and a few lines below that while statement as well. I will try and get
a full independent script wiorking to a degree tonight and repost.
(oh joy in some of your minds i'm sure :)
>
> large snip ..
>
> ># Writing out the result set for this server\\share combo.
> ># print HANDLE2 "@Drivearray[0], @Drivearray[2], $Utilpercentage,
> >$Free1, $Used1,
> >
> >$Total1 ";
> That line's got an unmatched quote in it. Did you comment out the
> first line of a multi-line statement?
> --
>
> Henry Law <>< Manchester, England
Thanks again,
James
------------------------------
Date: 9 Dec 2004 03:32:51 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin)
Message-Id: <Xns95B9E55D4BD4Easu1cornelledu@132.236.56.8>
"James" <djcameron60616@yahoo.com> wrote in
news:1102535945.679552.290720@z14g2000cwz.googlegroups.com:
> So the question is how to get this function (GetDriveSpace) to be
> passed an array, essentially - is this impossible potentially because
> of the module design? Resources.pm is the module used with this
> script. ShowKeys is what returns total, used and free space -- so this
> is a third factor in manipulating this array.
> I'm really trying to get the values for used, total and free space -
> and I'm not quite sure how to get at it, and this is already taking too
> long for me to figure out.
It would be useful if you learned a little bit of Perl first.
> use lib "$ENV(HOME)/site/lib";
What do you think this does?
> no lib ".";
Why do you think this is necessary?
> use Win32::Resources;
From:
http://search.cpan.org/~fabpot/Win32-Resources-0.02/lib/Win32/Resources.pm
Win32::Resources allows you to deal with windows
executable (.exe or .dll) resources (load, update
and delete resources).
What does this have to do with getting drive space info?
> use Win32API::Resources;
OK. This module is not available through ppm but I found it on CPAN.
Downloaded and installed it and read the docs. Have you tried that?
> # use strict;
> # use warnings;
Why are these commented out?
> my @Drives = Win32API::Resources::GetDrives();
> my %DRVSpace = Win32API::Resources::GetDriveSpace("C:\\");
> my $pathtofiles = "\\C:\\scripts\\";
> my $pathtoserverslist = "\\\\xxxxxnnnnnn\\";
> my $Threshold = "80";
> my $last_updated = localtime (time);
I give up. This crap is much too hard to read. So, you want to:
1. Find out what are the valid drive assignments on your system
2. Find out how much space is on each one
Why not do that?
use strict;
use warnings;
use Win32API::Resources;
use Data::Dumper;
sub get_drive_space_info {
my @drives = Win32API::Resources::GetDrives();
my %drives;
for (@drives) {
$drives{$_} = { Win32API::Resources::GetDriveSpace($_) };
}
return \%drives;
}
sub print_drive_space_info {
my %ds_info = %{ $_[0] };
for my $d (sort keys %ds_info) {
my %drive = %{ $ds_info{$d} };
print "Drive $d\n";
next if exists $drive{0};
for my $k (keys %drive) {
print "\t$k => $drive{$k}\n";
}
}
}
print_drive_space_info(get_drive_space_info());
__END__
Adapt this script to your needs.
Sinan.
------------------------------
Date: Thu, 09 Dec 2004 02:32:35 +0000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin)
Message-Id: <41b7c8b6$0$25786$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
James wrote:
.
>
> Example: GetDrives expects a string or empty list, and with the
> empty list a foreach loop spits out all drive letters.
> Example: In using GetDriveSpace, it returns only the values for C:\
> (or whatever ("x:\\") letter you feed it.
>
> So the question is how to get this function (GetDriveSpace) to be
> passed an array, essentially - is this impossible potentially because
> of the module design?
Yep ... well actually it's the *function* design that makes it
impossible, as the function takes a scalar variable (not a list or a
reference to a list) as its only argument. At least that's the way it is
with the Win32::AdminMisc version of the function.
You would need to do (untested):
use warnings;
use Win32::AdminMisc;
my @drives = GetDrives();
for(@drives) {
my @space = GetDriveSpace($_);
print "$_: @space\n";
}
__END__
Install Win32::AdminMisc using ppm if you can't build it from source.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Wed, 8 Dec 2004 17:08:50 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: New comp.lang.perl.misc mirror site at lampforums.org
Message-Id: <slrncrf2c2.6k6.tadmc@magna.augustmail.com>
Jim Keenan <jkeen_via_google@yahoo.com> wrote:
>> We actually had a debate here regarding that--I thought it was Perl,
>> but then, somebody convinced me it was an acronym and thus should be
>> PERL, like NASA.
>>
>
> It's more a retronym, i.e., the name Perl came first, and then came
> various attempts to figure out if that was an abbreviation for
> something.
I like calling it a "bacronym", it is backwards from the usual.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 9 Dec 2004 04:57:52 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Obtaining length of binary string
Message-Id: <Xns95B9F3C612F44asu1cornelledu@132.236.56.8>
Brian McCauley <nobull@mail.com> wrote in
news:corsm2$36s$1@sun3.bham.ac.uk:
> Perl User wrote:
>
>> I read encrypted data from a server and save it in a variable. Now, I
>> need to send this back to the server along with a number that tells how
>> many bytes long the binary data is.
>>
>> I've tried
>> $x = read_data_from_server($args);
>> $y = length $x;
>> send_data_to_server($x,$y);
>>
>> I am not sure if the length function is the right way to count the
>> number of bytes in the string $x.
>
> It is right since you say it's a binary string. If it were a text
> string then length() would return the number of characters.
>
> If you want to force length() to count bytes even in text strings:
>
> use bytes;
On the other hand, the following might be better in that it would allow the
OP to selectively decide whether he wants characters or bytes to be
counted.
use strict;
use warnings;
use bytes ();
my $s = "\x{2022}";
print bytes::length($s), "\n", length($s);
Sinan
------------------------------
Date: Wed, 8 Dec 2004 17:49:05 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Paragraph separation for DOS files on Unix
Message-Id: <slrncrf4nh.6k6.tadmc@magna.augustmail.com>
Oliver Heidelbach <ohei@nospam.snafu.de> wrote:
> I am regularly shifting DOS formatted files to Unix for
> further processing and having to convert those before
> touching with Perl is a major annoyance.
If you use the correct mode ("ASCII" or "text") when FTPing the
files, then you won't have any annoying conversions to do because
the FTP program will do them for you.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 08 Dec 2004 19:07:23 -0800
From: Andy Glew <andy.glew@intel.com>
Subject: Re: Perl classes NOT in separate files
Message-Id: <q5iis7ckw44.fsf@plxc0250.pdx.intel.com>
> > To my surprise
>
> > package foo {
> > ...
> > }
>
> > seems to work.
>
> No it does not.
Sorry again, I'm full of typos.
To my surprise
sub bar {
...
{
package foo;
....
}
}
seems to work, although names in foo
are defined absolutely.
---
But I'm probably wrong, and really should post
an experiment. Won't bother, because it
was the nesting I most wanted.
------------------------------
Date: Thu, 09 Dec 2004 01:30:12 +0000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Perl some time hank with system command.
Message-Id: <41b7ba16$0$25771$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
jl_post@hotmail.com wrote:
> Michele Dondi wrote:
>
>>>Define "to hank".
>
>
> Sisyphus replied:
>
>>I think the OP means "hang" - where the process just
>>sits there doing nothing, and fails to terminate.
>
>
>
> Hmmm... Let's see if Perl agrees with you. :)
>
>
>>perl -MText::Soundex -le "print soundex('hank')"
>
> H520
>
>
>>perl -MText::Soundex -le "print soundex('hang')"
>
> H520
>
One marvels at the fact that the Earth managed to rotate on its own
axis, one revolution per day, *before* Text::Soundex was written ;-)
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: 8 Dec 2004 18:04:24 -0800
From: "James" <djcameron60616@yahoo.com>
Subject: Re: Question on loops and return values
Message-Id: <1102557864.955122.235100@c13g2000cwb.googlegroups.com>
Hi Tad,
> Please show *real code*!
> use lib "$ENV(HOME)/site/lib"; # occasionally perl whines about not
> ^ ^
> ^ ^ {HOME}
Tad thanks .. I did not catch that at all.
>> our $file = (<SD>,"growth.cvs"); # output data file
>> our $file2 = (<SD>,"machines.cvs"); # input data file
> Where is the SD filehandle open()ed?
I have to apologize to everyone and thank them at the same time, that
was a horrible version of my non-working script that was posted. A new
one was posted today. Under a MS-blah header.
I do not believe in hindsight that it was ever opened.
> Why are you using package variables instead of lexical variables?
This I will have to re-read on, I can't recall what the difference is
between them, but if I think I know what they are, I believe I was
using package variables because they were what I thought was necessary.
>> our $let = ['A-Z']; # character value for
drive letters
> You never make use of this variable, and it almost certainly
> is not what you think it is.
I thought it was used in a foreach for a loop control variable
associated with an array, but I could be wrong on that too. I was
trying to define a range of characters in a variable (which I guess
would have to be an array anyway).
> It is a reference to an anonymous array with 1 element in it.
> our @line = ""; # was going to be used for
file looping
> How may elements are you expecting to be in @line right here?
> Were you expecting zero elements, an empty array?
> That isn't what you are getting there...
I was expecting an empty array actually, or at least null values in
it.
>> open (file2,"+<"); # open machines input file for read
> You are opening for read AND write, the comment is a trick!
> Did you mean to put a filename in there somewhere?
> You should use UPPER CASE for filehandles.
> You should always, yes *always*, check the return value from open().
I thought the + was to keep it from being clobbered..I would have to
put a filename in there I guess, I thought it was defined up top with
the filehandle. I have taken your advice and started using uppercase
for all filehandles. Why does the return value matter? Wouldn't it
just open or fail (die)?
I generally (now) use ((|| -or- or) die) after the open.
>> while <file2> # loop while not eof in machines.cvs
> Syntax error.
> Show *real code*!
>> foreach $machine (<file2>)
> You are reading from the _same_ filehandle in 2 different places
> in your code. Is that what you want to do?
> The while loop (if it compiled) would only execute one time.
> The foreach provides list context, so it will slurp to the end of
file.
Man this script was a piece. I believe what I was trying to do was
loop through the machines listed by name in the file, does foreach only
provide list context?
>> chop ($last);
> That is how we removed newlines 8 years ago. Where did you learn
that?
> Nowadays you should use chomp() to remove newlines.
I am now using chomp(); I learned chop(); in an old NT book that had a
Perl script in it to do roughly the same thing.
>> $curr = %DRVSpace;
> This most certainly does not do what you think it does.
> The value of a hash in scalar context is not of interest to
> a Perl programmer, it is only of interest to a perl programmer.
So would it be $curr = /%DRVSpace to get the value of the key, or doyou
have to explicitly go through the (sort(keys /%DRVSpace);?
>> $last = eval { $curr / 5 }; # bogus value for testing, should be
>> $gvalue = eval { $curr - $last }; # growth rate difference
>> $grate = eval { ($gvalue / $last) * 100 }; # growth rate
percentage
> Can you tell us why you are using eval() there?
I thought eval was used for numeric expressions assigned to variables,
or maybe I'm confusing it with a bash statement?
Thanks for your time.
James
------------------------------
Date: 8 Dec 2004 21:00:34 -0800
From: "Shailesh Humbad" <humbads1@hotmail.com>
Subject: regular expressions problem
Message-Id: <1102568434.743762.32960@z14g2000cwz.googlegroups.com>
I want to parse the values from the second-to-last row in an html
table.
...
<tr class="odd">
<td style="text-align: right;" nowrap="nowrap">99</td>
<td style="text-align: right;" nowrap="nowrap">111</td>
<td style="text-align: right;" nowrap="nowrap">52255</td>
<td style="text-align: right;" nowrap="nowrap">333</td>
<td style="text-align: right;" nowrap="nowrap">2323</td>
</tr>
<tr class="totals">
...
I can identify the last row by the "totals" class. So I want the regex
to work backward from there and get the values in each of the cells of
the previous row. It should ignore all prior content and whitespace
between tags. Can anyone help? Here is what I have so far:
/([\s\S]*?)<tr class\=\"totals/
------------------------------
Date: Thu, 09 Dec 2004 11:26:03 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Seeking Internet Protection Service
Message-Id: <31pntcF3dv6iuU1@individual.net>
Gerald Newton3 wrote:
> I am willing to pay $3,000 per year for an Internet Protection Service.
*PLONK*
------------------------------
Date: Wed, 08 Dec 2004 22:45:28 -0600
From: G. Morgan <alarmprosnail@snailgmail.com>
Subject: Re: Seeking Internet Protection Service
Message-Id: <41d3d837.235976896@schoolofhardknocks.edu>
On Wed, 8 Dec 2004 12:37:38 -0900 "Gerald Newton3"
used 14 lines of text to write in newsgroup: alt.engineering.electrical
>Yes, I am willing to pay this price.
Good. Expect to hear from your ISP.
abuse@acsalaska.net
*plonk*
--
-Graham
Remove the 'snails' from my email
------------------------------
Date: Thu, 09 Dec 2004 00:23:25 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Web Form search and open pdf
Message-Id: <mbudash-30D2FC.16232808122004@typhoon.sonic.net>
In article <eto3bygihjg.fsf@wilson.emschwar>,
Eric Schwartz <emschwar@fc.hp.com> wrote:
> "Paul Lalli" <mritty@gmail.com> writes:
> > If you just want the PDF displayed in the User's browser's location bar,
> > then you should have your CGI program redirect to the PDF, rather than
> > print the contents of the PDF.
>
> That only works if the PDFs are under the webserver's document root,
> and there are many good reasons you may not want to do that. If
> that's not the case, then you do need to use your CGI program to print
> it to the browser. In which case to set the name, I have always found
> setting the filename in the MIME Content-Disposition header to do the
> trick. This might look like (untested);
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> use CGI;
> use File::Basename;
>
> my $pdfpath = '/path/to/filename.pdf'
> open my $pdf, '<', $pdfpath or die "Can't open $pdfpath: $!";
>
> print header(-type => 'application/pdf',
> -content_disposition => 'inline; filename='.basename($pdfpath));
> print while (<$pdf>);
>
> -=Eric
redirect to a script that pushes back the pdf (as the o.p. did), but
pass the pdf name in the path info, thusly:
http://www.domain.com/path/to/script/pdfname
every browser i've tried will then use the pdf name as the file name,
since it's at the end of the url. you can access the pdf name in
$ENV{PATH_INFO}. it will likely have a '/' prefix, so you'll need to
deal with that.
works great for me for years.
--
Michael Budash
------------------------------
Date: Wed, 08 Dec 2004 18:44:04 -0700
From: Eric Schwartz <emschwar@fc.hp.com>
Subject: Re: Web Form search and open pdf
Message-Id: <etoy8g8gs9n.fsf@wilson.emschwar>
Michael Budash <mbudash@sonic.net> writes:
> redirect to a script that pushes back the pdf (as the o.p. did), but
> pass the pdf name in the path info, thusly:
>
> http://www.domain.com/path/to/script/pdfname
That works too, but you probably don't want to use the full path to
the pdf-- otherwise, you've just opened up a huge security risk. Not
that you advocated that, just pointing it out in case someone reading
your suggestion didn't think of it.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Thu, 09 Dec 2004 01:51:15 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Web Form search and open pdf
Message-Id: <mbudash-4FBB64.17511808122004@typhoon.sonic.net>
In article <etoy8g8gs9n.fsf@wilson.emschwar>,
Eric Schwartz <emschwar@fc.hp.com> wrote:
> Michael Budash <mbudash@sonic.net> writes:
> > redirect to a script that pushes back the pdf (as the o.p. did), but
> > pass the pdf name in the path info, thusly:
> >
> > http://www.domain.com/path/to/script/pdfname
>
> That works too, but you probably don't want to use the full path to
> the pdf-- otherwise, you've just opened up a huge security risk. Not
> that you advocated that, just pointing it out in case someone reading
> your suggestion didn't think of it.
>
> -=Eric
absolutely. the only indication of the pdf shold be its name. the script
can handle push its content back from its actual location on the server.
--
Michael Budash
------------------------------
Date: Thu, 9 Dec 2004 09:43:37 +0800
From: "bingfeng" <zhao_bingfeng@topsec.com.cn>
Subject: Re: why the following HereDoc print don't work?
Message-Id: <cp8arq$2649$1@mail.cn99.com>
Oh, no, there is NO anything before the second "EOF" and I use indent
correctly, as you said, when I posting, my new reader trim all leader spaces
automatically:( The worse thing is I encountered another similar question
now and I doubt whether it is bug of perl 5.8.4. The following codes does
not work still:
<CODE>
use strict;
use warnings;
print <<EOF;
Help text:
Command line is:
Datecheck [options] <files> [<files>...]
where:
[Option] are to be defined
EOF
</CODE>
But other similar codea in another script worked correctly!
<CODE>
#! usr/bin/perl
use strict;
use warnings;
my $header = "define.h";
my $source = "parse.c";
my $func = "int Parse(char* pData, enum TOSTYPE type, void *pResult)";
open HEADER, '>', $header or die "cannot open the \'$header\': $!";
open SOURCE, '>', $source or die "cannot open the \'$source\': $!";
my $time = localtime;
print HEADER <<"EOF";
/*
* Interface definition header file of Parse(), generated by perl script
*
* File name : $header
* Last generated time : $time
*/
#ifndef DEFINE_H
#define DEFINE_H
EOF
# the fillowing omitted
</CODE>
I'm crazying now...
"Bart Lateur" <bart.lateur@pandora.be> wrote in message
news:rnbdr0dcv803uj2f8bsinh5fe9uqqdqa4h@4ax.com...
> ÕÔ±û·å wrote:
>
> >Perl complained "Can't find string terminator "EOF" anywhere before EOF
at
> >XXX(line No.)".
> >What happened and why?
>
> Check your line holding the "EOF". It is likely there is some whitespace
> on it.
>
> --
> Bart.
------------------------------
Date: Wed, 08 Dec 2004 21:41:25 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: why the following HereDoc print don't work?
Message-Id: <8_-dnfQwDtXIJircRVn-oA@adelphia.com>
ÕÔ±û·å wrote:
> Perl complained "Can't find string terminator "EOF" anywhere before EOF at
> XXX(line No.)".
> What happened and why?
Looks to me like the "EOF" is on the last line of your script, which
doesn't have a newline at the end of it.
Solution: Add a blank line to the end of your script.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Thu, 09 Dec 2004 03:53:17 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: why the following HereDoc print don't work?
Message-Id: <p0jfr056679f09vi8bpd7k0astrlt8bqad@4ax.com>
bingfeng wrote:
>Oh, no, there is NO anything before the second "EOF" and I use indent
>correctly, as you said,
It needn't be before it. Trailing spaces have just the same effect.
--
Bart.
------------------------------
Date: 9 Dec 2004 03:59:21 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: why the following HereDoc print don't work?
Message-Id: <Xns95B9E9D9C66F1asu1cornelledu@132.236.56.8>
"bingfeng" <zhao_bingfeng@topsec.com.cn> wrote in
news:cp8arq$2649$1@mail.cn99.com:
> I encountered another similar question now and I doubt whether
> it is bug of perl 5.8.4.
This brings to mind:
#11907 Looking for a compiler bug is the strategy of LAST resort. LAST
resort.
and
#11938 If you have `some weird error', the problem is probably with your
frobnitzer.
as well as
#11958 The bug is in you, not in Perl.
from MJD's timeless post (http://tinyurl.com/4pz2t)
> The following codes does not work still:
>
> <CODE>
> use strict;
> use warnings;
>
> print <<EOF;
> Help text:
> Command line is:
> Datecheck [options] <files> [<files>...]
> where:
> [Option] are to be defined
> EOF
> </CODE>
Funny ... odd ... curious ...
D:\Home\Dload>perl t3.pl
Help text:
Command line is:
Datecheck [options] <files> [<files>...]
where:
[Option] are to be defined
> But other similar codea in another script worked correctly!
#11948 Perhaps your veeblefitzer is clogged.
> I'm crazying now...
You and me both ...
> "Bart Lateur" <bart.lateur@pandora.be> wrote in message
> news:rnbdr0dcv803uj2f8bsinh5fe9uqqdqa4h@4ax.com...
Oooops ... didn't see this. Don't top-post.
Sinan.
------------------------------
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 7498
***************************************