[16303] in Perl-Users-Digest
Perl-Users Digest, Issue: 3715 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 09:57:55 2000
Date: Tue, 18 Jul 2000 06:57:46 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963928665-v9-i3715@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 18 Jul 2000 Volume: 9 Number: 3715
Today's topics:
Help required with script (ShadowNateY2K)
Re: Help required with script (Alan J. Flavell)
Re: Help Wanted (Mark W. Schumann)
Re: Help with Regular Expression (Tad McClellan)
Re: Help with Regular Expression (Tad McClellan)
Re: Help with Regular Expression (Godzilla!)
Re: Help with Regular Expression (Tad McClellan)
Re: HELP! Problem with warning on filehandle (Tad McClellan)
Re: HELP! Problem with warning on filehandle (Ed Foy)
Help, Please in Interpreting Syntax (Martin McCormick)
help: executing a WinNT process ()
hohoh:how create & do I really need? ()
How can i identify a "Not Integer" string ? (Election)
Re: How can i identify a "Not Integer" string ? (jason)
Re: How can i identify a "Not Integer" string ? (Bob Walton)
Re: How can i identify a "Not Integer" string ? (Abigail)
How can I print date on an include file (John)
Re: How can I print date on an include file (Drew Simonis)
Re: How can I print date on an include file (Tony Curtis)
Re: How can I print date on an include file (John)
Re: How can I print date on an include file (John)
Re: How can I use HTML::Parser to get images from HTML (Jonathan Stowe)
Re: How do I set/get cookies ? (jraff)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Jul 2000 02:40:13 GMT
From: shadownatey2k@aol.com.bbs@openbazaar.net (ShadowNateY2K)
Subject: Help required with script
Message-Id: <3bQiWE$WTt@openbazaar.net>
Can anyone offer assistance with this script? It's a script that reads in a
URL and the title of a website, numbers them and outputs them to a text file.
I ran it through the interpreter and it says that there is a carriage return on
line 1 that shouldn't be there. And while I'm thinking "yeah, I know there's a
carriage return there" I'm stuck figuring out what to do about it. So if
anyone can help me, that would be great. Email me or respond through this
group. Thanks! And now the script...
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;
$FORM{$name}=$value;
}
#Read counter file
$i = 0;
open(file1,"/usr/services/u/direwolf/public_html/transform_home/count.txt");
#Increment counter and close file
$inputline=<file1>;
$i = $inputline;
close(file1);
$i++;
open(file1a,">/usr/services/u/direwolf/public_html/transform_home/count.txt");
print(file1a,$i);
#Open and write to output file
open(outfile,">>/usr/services/u/direwolf/public_html/transform_home/output
.txt");
print(outfile,$i);
print outfile "\n";
print outfile "$FORM{'title'} \n"
print outfile "$FORM{'address'} \n"
close(outfile);
#Print return text
print"Content-type: text/html\n\n";
print"Thank you!";
------------------------------
Date: 17 Jul 2000 09:40:04 GMT
From: flavell@mail.cern.ch.bbs@openbazaar.net (Alan J. Flavell)
Subject: Re: Help required with script
Message-Id: <3bR7T4$VCJ@openbazaar.net>
On 17 Jul 2000, ShadowNateY2K wrote:
> Can anyone offer assistance with this script?
CGI.pm, and the other advice frequently posted to this group.
------------------------------
Date: 18 Jul 2000 00:00:01 GMT
From: catfood@apk.net.bbs@openbazaar.net (Mark W. Schumann)
Subject: Re: Help Wanted
Message-Id: <3bRU04$TrX@openbazaar.net>
In article <39734D40.DAC9B62A@earthlink.net>,
Bob Kling <bbkling@earthlink.net> wrote:
>Programmer Needed Full Time: Work at Home
>Ideal person would be strong in Perl, with some Java, and some SQL.
>Server admin skills a big plus; Unix and some NT
Sorry, this is not a jobs posting group.
>Also it would be a super help if anyone reading this could tell me if
>there is a job posting service that has a "work at home" job section?
>All the prominant job sites do not have this category. Thank you very
>much.
Sorry, this is not a jobs-posting help group either.
------------------------------
Date: 15 Jul 2000 22:10:02 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: Help with Regular Expression
Message-Id: <3bQ06Q$Vu4@openbazaar.net>
On Sat, 15 Jul 2000 21:28:35 GMT, Brian Scheller <bscheller@[nospam]mmcable.com> wrote:
>I am attempting to utilize the
>split function to parse a string into an array. However, the character used
>as the field separator also sometimes occurs within the string without being
>a field separator.
If you can identify these non-separator separator characters, then
you can change them to something else, split, then change them
back.
>I am attempting to parse an XML attribute value in which semicolons have
>been used to separate several terms. However, because the document is in
>Spanish, there are several character entities that also occur within the
>text.
Oh good.
You can identify the non-separator separator characters
(because XML defines what an "entity" is allowed to contain).
>Can anyone offer a suggestion of a regular
>expression that would ignore the constructs of &[^;]*;, i.e. character
>entities, but still be able to find the other semicolon?
You can write a much tighter pattern than that for an
XML entity reference:
----------------------------------
#!/usr/bin/perl -w
use strict;
$_ = 'Engaños (Quackery);Fraude en el campo de la salud (Health fraud)';
my @fields = special_split($_);
foreach ( @fields ) {
print "'$_'\n";
}
sub special_split {
my($str) = @_;
die "delimiter found in string! ($str)" if $str =~ /:::/;
# semicolons marking end of entity become 3 colons
$str =~ s/(&[a-zA-Z][a-zA-Z0-9._-]*);/$1:::/g;
my @fields = split /;/, $str;
s/:::/;/g foreach @fields; # patch up the entity ends
return @fields;
}
----------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Jul 2000 13:10:03 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: Help with Regular Expression
Message-Id: <3bQNRR$TuM@openbazaar.net>
On Sat, 15 Jul 2000 20:39:51 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>Tad McClellan wrote:
>
>(snipped blatherings)
>
>
>> >Godzilla Rocks!
>
>> Says you.
>
>
>Reads like insane jealousy to me Mr. McClellan.
No, it reads like the only person that says you are great is you,
which is a statistically insignificant sample size.
>Doesn't it just piss you off to have to change givens,
>have to change parameters,
No, but you do.
>otherwords tell some lies
>to massage and band-aid your bruised fragile ego?
I did not tell lies.
Every condition I gave where your code fails _is_ a condition
where your code fails!
What lie(s) are you referring to?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 15 Jul 2000 23:50:01 GMT
From: godzilla@stomp.stomp.tokyo.bbs@openbazaar.net (Godzilla!)
Subject: Re: Help with Regular Expression
Message-Id: <3bQ2ZP$UXw@openbazaar.net>
Brian Scheller wrote:
> I need some help developing a regular expression....
> ...the string that I am attempting to parse looks like:
> "Engaños (Quackery);Fraude en el campo de la salud (Health fraud)"
> This string has two different terms....
> Engaños (Quackery)
> Fraude en el campo de la salud (Health fraud)
> My initial attempt to use just a semicolon fails because the ñ character is
> reprented as ñ. Can anyone offer a suggestion of a regular
> expression that would ignore the constructs of &[^;]*;, i.e. character
> entities, but still be able to find the other semicolon? ....
In closing you will find a test script and printed results.
You will read four no-brainer methods to attain your goal.
First method locates " ;F " in your string and replaces
the semi-colon with a split vertical bar, then splits
your string into two variables, as you request. This
method relies on your dictionary being standardized
with a capital letter always following a semi-colon,
which it should if a commercial dictionary or correctly
written dictionary if privately created.
My second method locates " ); " and replaces the
semi-colon with a ¦ as in my first method and
subsequent methods. This one relies on your
parenthetical topic term being there.
Next to last method, third method, is a simple
split on semi-colon then glue it back together
into two variables as you intend.
Final method, my favorite, removes your problem
entity, splits, then replaces the entity.
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
## Method 1
$string = "Enga ños (Quackery);Fraude en el campo de la salud
(Health fraud)";
$string =~ s/;([A-Z])/¦$1/;
($var1, $var2) = split (/¦/, $string);
print "Semi-Colon / Capital Letter Method: \n\n";
print " Variable One: $var1 \n\n Variable Two: $var2";
## Method 2
$string = "Enga ños (Quackery);Fraude en el campo de la salud
(Health fraud)";
$string =~ s/(\));/$1¦/;
($var1, $var2) = split (/¦/, $string);
print "\n\n\nRight Parenthesis / Semi-Colon Method: \n\n";
print " Variable One: $var1 \n\n Variable Two: $var2";
## Method 3
$string = "Enga ños (Quackery);Fraude en el campo de la salud
(Health fraud)";
($var1, $var1a, $var2) = split (/;/, $string, 3);
$var1 = join (";", $var1, $var1a);
print "\n\n\nSplit And Join Method: \n\n";
print " Variable One: $var1 \n\n Variable Two: $var2";
## Method 4
$string = "Enga ños (Quackery);Fraude en el campo de la salud
(Health fraud)";
$string =~ s/(&[a-zA-Z]+;)/¿/;
$temp = $1;
($var1, $var2) = split (/;/, $string);
$var1 =~ s/¿/$temp/;
print "\n\n\nRemove / Replace Entity Method: \n\n";
print " Variable One: $var1 \n\n Variable Two: $var2";
print "
\n\n\n\nGodzilla Rocks!";
exit;
PRINTED RESULTS:
________________
Semi-colon / Capital Letter Method:
Variable One: Enga ños (Quackery)
Variable Two: Fraude en el campo de la salud (Health fraud)
Right Parenthesis / Semi-Colon Method:
Variable One: Enga ños (Quackery)
Variable Two: Fraude en el campo de la salud (Health fraud)
Split And Join Method:
Variable One: Enga ños (Quackery)
Variable Two: Fraude en el campo de la salud (Health fraud)
Remove / Replace Entity Method:
Variable One: Enga ños (Quackery)
Variable Two: Fraude en el campo de la salud (Health fraud)
Godzilla Rocks!
--
$godzilla = "godzilla rocks!";
srand(time() ^ ($$ + ($$ << 15)));
sub randcase
{ rand(40) < 20 ? "\u$1" : "\l$1" ; }
$godzilla =~ s/([a-z])/randcase($1)/gie;
print $godzilla; exit;
------------------------------
Date: 16 Jul 2000 02:50:01 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: Help with Regular Expression
Message-Id: <3bQ7KP$Vi5@openbazaar.net>
On Sat, 15 Jul 2000 16:57:10 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>Brian Scheller wrote:
>
>> I need some help developing a regular expression....
>
>> ...the string that I am attempting to parse looks like:
>
>> "Engaños (Quackery);Fraude en el campo de la salud (Health fraud)"
^
^ what if that needed to be an upper case O ?
>> Can anyone
^^^^^^
Be careful with that part...
>> offer a suggestion of a regular
>> expression that would ignore the constructs of &[^;]*;, i.e. character
>> entities, but still be able to find the other semicolon? ....
>
>
>In closing you will find a test script and printed results.
>You will read four no-brainer methods to attain your goal.
Read the next paragraph.
Recognize the restrictions it requires.
Then just stop reading if you are clever.
>First method locates " ;F " in your string and replaces
>the semi-colon with a split vertical bar, then splits
>your string into two variables, as you request. This
>method relies on your dictionary being standardized
>with a capital letter always following a semi-colon,
>which it should if a commercial dictionary or correctly
>written dictionary if privately created.
So if you have a special character (i.e. an entity)
preceding an upper case character anywhere in your data,
this method will not work correctly.
e.g.
&tiny-right-arrow;Arrow is pointing at me;Definition of "arrow is pointing at me".
Also, if you have a field that does not start with a upper
case letter this method will not work correctly.
Also also, if you ever have more than 2 fields,
this method will not work correctly.
I think it is possible to get a solution that will avoid
all of those restrictions...
>Godzilla Rocks!
Says you.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Jul 2000 14:30:04 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: HELP! Problem with warning on filehandle
Message-Id: <3bNJVU$Uy3@openbazaar.net>
On Wed, 12 Jul 2000 11:43:18 GMT, Ed Foy <ed@nospam.com> wrote:
>Subject: HELP! Problem with warning on filehandle
^^^^^
^^^^^
You might want to avoid doing that in the future, as it likely
*reduces* the number of people that will read your article.
I have that 5-character substring in my (scoring) killfile.
Most days I don't have time to look down there in the auto-deleted
posts. I had a little extra time today, else I wouldn't have seen
it either.
You have only 40 precious characters to out-compete the other
199 posts in a day (Nobody reads _all_ of them. Most filter
based on what is in the Subject: header).
Spending five of your 40 on pleading is unwise.
_Every_ post here wants "Help!".
Including it does not add any useful information.
(despite the fact that _I_ make use of it :-)
"Choosing Good Subject Lines":
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
>Environment: Perl 5.00404 on UNIX.
>
>My 12-year-old daughter has decided to learn Perl.
Way cool!
>She is getting a
>warning on a filehandle that neither of us can figure out. Here is her
>source code:
>
>#!/usr/local/bin/perl5 -w
use strict; # teach her to put on her seat belt!
(though you may already have this in the main program)
>require 5.004;
>
>package EMAIL;
>
>sub SendMail {
>
> my ($To,$From,$Subject,$Body) = @_;
See if adding this debugging code helps (untested):
warn "\$To is undef\n" unless defined $To;
warn "\$From is undef\n" unless defined $From;
warn "\$Subject is undef\n" unless defined $Subject;
warn "\$Body is undef\n" unless defined $Body;
> open (SENDMAIL, "|/usr/lib/sendmail -oi -t") or die "Cannot open
>mail program: $!\n";
Your diagnostic message is a little misleading there.
If the die() executes, it will NOT be anything related to the
program that you are trying to invoke.
See the Perl FAQ, part 8:
"Why doesn't open() return an error when a pipe open fails?"
> print SENDMAIL <<"EndOfMail";
>To: $To
>From: $From
>Subject: $Subject
>
>$Body
>
>EndOfMail
>
> close(SENDMAIL);
> die "Mail program failed: $?" if $?;
>}
>
>1;
>
>When the above subroutine is called,
You should have shown us the _call_, that may show where the problem is...
>Perl gives the following warning:
>
>"Use of uninitialized value at EMAIL.pl line 13."
When perl says "uninitialized value" think "undef".
>Perl is complaining about the "print SENDMAIL..." line.
Which includes all of the here-doc too (parsers just make
their "best guess" when giving line numbers).
One of the 4 variables in the here-doc has the undef value.
>I can see no
>problem with the here document.
Me either.
But the variables are set from subroutine args, but we cannot
see the args that it was called with.
>The filehandle SENDMAIL is initialized.
Filehandles do not generate that warning message, variables do.
>There are no variables in the main program that have either the name
>SENDMAIL or EndOfMail.
First, neither of those are variables (variables start with a
"funny character": $, @, %).
(well, first-class variables do anyway)
SENDMAIL is a filehandle.
EndOfMail is a string terminator.
Second, even if they were variables (let's discuss $To for instance),
having a $To in the main program file would not be a problem, because
$To is a lexical variable in your "library" file.
( I assume separate files, since you end the one above with 1; )
my()d variables cannot be seen/affected in any file other than the
file that contains the my() statement.
>I can find no problems with the code and the
>subroutine works as expected, that is, sends mail. I'm stumped. Does
>anyone have an idea as to what this warning message is about?
Have you looked up what the authors of the message have to say
about their message?
perldoc perldiag
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Jul 2000 17:40:03 GMT
From: ed@nospam.com.bbs@openbazaar.net (Ed Foy)
Subject: Re: HELP! Problem with warning on filehandle
Message-Id: <3bNOT5$XCD@openbazaar.net>
Tad McClellan wrote in message ...
>On Wed, 12 Jul 2000 11:43:18 GMT, Ed Foy <ed@nospam.com> wrote:
>
>>Subject: HELP! Problem with warning on filehandle
> ^^^^^
> ^^^^^
>
>You might want to avoid doing that in the future, as it likely
>*reduces* the number of people that will read your article.
Thanks Tad. I've started doing Perl about 3 months ago, although I've
been programming for 30 years. Yet another 'protocol' to add to the
list. <g>
>>Environment: Perl 5.00404 on UNIX.
>>
>>My 12-year-old daughter has decided to learn Perl.
>
>
>Way cool!
Sure is! Her own idea and until now she's been working on her own. Hey,
she's a 'big girl' now and can do things for herself. Can't argue that.
In three short weeks and basically on her own she has gone from knowing
nothing about computer programming to having created a simple website
(doing all the HTML coding herself) and writing some elementary CGI
scripts. This is the first time she has ask for any programming help.
Amazing.
>use strict; # teach her to put on her seat belt!
>
>(though you may already have this in the main program)
She already has in main. Actually, she bugs me about it because I don't
put it in my code first thing. Horror of horrors, I'll write code then
add strict later but before I compile. She finds this unacceptable. I
think she need to take up watching television...<g>
>> open (SENDMAIL, "|/usr/lib/sendmail -oi -t") or die "Cannot open
>>mail program: $!\n";
>
>
>Your diagnostic message is a little misleading there.
>
>If the die() executes, it will NOT be anything related to the
>program that you are trying to invoke.
Hahaha...yes, I know. But from my daughters point of view it is quite
simple - mail didn't get sent.
>You should have shown us the _call_, that may show where the >problem
is...
I thought about it but I was trying to keep the clutter down. The
semantics of the call were what would be expected so it didn't really
contribute anything. It turns out the problem was, in fact, one of the
variables being undefined. The variables are initialized in main some
distance away from the actual call to the subroutine so that it would
not have been helpful to have shown a call that was semantically
correct.
>>Perl is complaining about the "print SENDMAIL..." line.
>
>
>Which includes all of the here-doc too (parsers just make
>their "best guess" when giving line numbers).
This is the part I overlooked. I focused on the lexical line and not the
semantic line and so overlooked the embedded variables. It happens, not
often, but sometimes...->
>>The filehandle SENDMAIL is initialized.
>
>
>Filehandles do not generate that warning message, variables do.
Now that is some very useful info! Thanks, I'm still ramping up on
Perl. My biggest headache is that Perl is enough like, and different
enough from, the C and UNIX shells that I'm so familiar with that it
gets me into trouble quite readily...especially when doing C, Perl, and
shells concurrently. Ouch!
>>There are no variables in the main program that have either the >>name
SENDMAIL or EndOfMail.
>
>First, neither of those are variables (variables start with a
>"funny character": $, @, %).
Yes, I know. Somewhere in the Camel book I read something about
filehandles possibly colliding with variables which is why I made this
reference. Off the top of my head I can't remember exactly what the book
said on the subject.
>Have you looked up what the authors of the message have to say
>about their message?
>
> perldoc perldiag
Yup, got the perldocs online locally. But as it goes...some days the
brainfarts win...<g>
Thanks, Tad, for taking the time to provide a good overview. I'm passing
it along to my daughter.
If you would be so kind as to take a look at another post I put here
with one of those aweful subject lines, "HELP: Bizarre BEGIN block
problems" it would be much appreciated. I'm sure the cause of the
problem is obvious as I've been fighting with it for two weeks. I just
haven't been able to get the beans out of the brain to get into the
obvious mode.
Thanks again!
Ed
------------------------------
Date: 13 Jul 2000 15:30:03 GMT
From: wb5agz@dc.cis.okstate.edu.bbs@openbazaar.net (Martin McCormick)
Subject: Help, Please in Interpreting Syntax
Message-Id: <3bOAYR$Xbj@openbazaar.net>
I need some help interpreting an expression in a perl script
that I am modifying. This script analyses the start of authority or
SOA record used in domain name servers to make sure it is good. Well,
the rules have changed so I need to change the game just a bit.
The present routine simply copies all lines beginning with a ;
from the source file to several other files. This allows one to have
comments in the name server data base before any actual information is
found.
I now need to add a name server directive which looks like:
$ttl 86400
The script sees this rightly as corruption and, as designed,
errors out.
I am trying to modify it enough to allow for this line, but
not totally destroy the testing.
I see perl scripts about once every 6 months so I freely admit
to not knowing as much as I should about this.
The portion of the script I need to change reads as follows
with my interpretation of what I think its doing.
sub update_serial {
local($i);
print "\nUpdating the serial number in the source file...\n" if $chatty;
open(SOURCE, "+<$source_file") ||
&give_up("unable to open $source_file for read/write (to update serial)");
#Do that if the file wouldn't open.
# Check out the first line as the start of the SOA data. Skip any
# prior comments, counting them so that we know how many lines to
# copy when copying the SOA data.
for (;;)
#I think that is just the start of the copy loop.
{
$_ = <SOURCE>;
#This appears to be the counter that keeps track of where the comments
#end.
last if (!/^\s*$/ && !/^\s*;/);
#This appears to look for blank lines and lines that start with ; so I
#thought, "Why not lines that start with $?"
$soa_count++;
#Incriment the counter.
}
That appears to be the tester. I tried:
for (;;)
{
$_ = <SOURCE>;
last if (!/^\s*$/ && !/^\s*;/ && !/^\s*\$/);
$soa_count++;
}
and it had absolutely no effect at all. It didn't even break things.
I figure if I make the lines that start with $ look like
comments, they should just get included along with blank lines and
lines starting with ; as comments.
This is not the best solution in the world, but it should
allow this change.
Martin McCormick WB5AGZ Stillwater, OK
OSU Center for Computing and Information Services Data Communications Group
Thank you for looking at this.
------------------------------
Date: 17 Jul 2000 16:00:01 GMT
From: sanjay33@my-deja.com.bbs@openbazaar.net ()
Subject: help: executing a WinNT process
Message-Id: <3bRHO1$U0K@openbazaar.net>
I am trying to run a program on NT through my perl scripy using the
'system` command
ie,
system("c:/my files/test.exe");
The problem is caused by the space in the direcroty name which WinNT
allows. The shell complains about this call saying that it is not
recognised as an executable program.
Can anyone tell me how to solve it?
thanks
sanjay
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Jul 2000 16:50:03 GMT
From: ollie_spencer@my-deja.com.bbs@openbazaar.net ()
Subject: hohoh:how create & do I really need?
Message-Id: <3bNNER$X5l@openbazaar.net>
I have data that I am trying to read into an hohoh, to the present
all futile. I include the relevant code snippet below:
commented lines there represent some attempts.
$Wafer changes slowly, $ChipCoord changes faster: $TestName is key and
$Testvalue is value of the data in the "real hash" which has some 500
data pairs.
I earlier assumed the line:
$TestData{$Wafer}{$ChipCoord}{$TestName=>$TestValue}
actually created the hohoh, mainly because I could read back the
key-value pairs $TestData{Wafer} and the result as espected was a
reference. I doubt even that now, since I have not been able to resolve
that reference! I have searched the O'Reilly books at my
disposal and through various search engines on the internet for perl
hash info. I found lots of hits, but only one to hohoh's, and that was
botched up- The example code didn't run for me - it was riddled with
syntax errors!
Can someone help?
Thanks in any case for reading the message.
Please post to this forum or e-mail me: ollie.spencer@lmco.com
Ollie Spencer
=====> BEGIN SNIPPET
# $NumOfTests=0;$kk=0;$l=""
#######################################################################
# A line in DEFECTS (except the first) has the pattern:
# 9|2/7|PAD|PADPCK0708|.2268E-0003
#######################################################################
while (<DEFECTS>){
chop();
if (!/^\s*\w/){$headline=$_; next;};
next if /^\s*$/; #skip blank lines
($Wafer,$ChipCoord,$TestMacro,$TestName,$TestValue)=split(/\|/);
# $Tests{$TestName}= $TestValue;
# $TestData{$Wafer}{$ChipCoord){$TestName}->$TestValue;
# $TestData{$Wafer=>{$ChipCoord=>{$TestName=>$TestValue } } };
$TestData{$Wafer}{$ChipCoord}{$TestName=>$TestValue} ;
if($kk++>45285){print "$kk:
$Wafer<>$ChipCoord<>$TestName<>$TestValue<\n";};
if($kk>45290){print "$kk: $Testdata{$TestData=>$Wafer} \n";};
}
# while(($k,$v) = each %Tests) {print "$k = $v\n"};
# while(($k,$v) = each %Tests) {printf(OUTFILE "%s = %#7.5E4\n",
$k, $v)}
for $key1(keys %TestData) {
$key2=$TestData{$key1};
print "$key1 $key2\n"; #gives correct $Wafer and a reference
# for $key2(keys(%($TestData->$key1)) ) {
# print "$key1 $key2\n";
# }
}
====>END SNIPPET
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 18 Jul 2000 00:10:01 GMT
From: election@qualitynet.net.bbs@openbazaar.net (Election)
Subject: How can i identify a "Not Integer" string ?
Message-Id: <3bRUCU$Ufw@openbazaar.net>
Hello everybody ...
I'm a beginner programmer in perl and I'd like to know ,
How can identify a "Not Integer" string in perl ? actually
I've got a string that stores the result like this
$string = int($n1 / $n2);
but it always gives me an integer number , so what should i do ?
------------------------------
Date: 18 Jul 2000 00:30:04 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: How can i identify a "Not Integer" string ?
Message-Id: <3bRUbS$Tzd@openbazaar.net>
Election wrote ..
> I'm a beginner programmer in perl and I'd like to know ,
>How can identify a "Not Integer" string in perl ?
one of many ways is
$string =~ /\D/;
>actually I've got a string that stores the result like this
>
>$string = int($n1 / $n2);
>
>but it always gives me an integer number , so what should i do ?
I don't know how this question relates to the first question - so
they're answered separately
what do you mean what should you do ? .. you asked for it to be
converted to an integer .. so you get an integer .. I bet $n1 is also
being divided by $n2 .. something else you asked for - and got
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 18 Jul 2000 01:00:03 GMT
From: bwalton@rochester.rr.com.bbs@openbazaar.net (Bob Walton)
Subject: Re: How can i identify a "Not Integer" string ?
Message-Id: <3bRVR3$UST@openbazaar.net>
Election wrote:
>
> Hello everybody ...
> I'm a beginner programmer in perl and I'd like to know ,
> How can identify a "Not Integer" string in perl ? actually
> I've got a string that stores the result like this
>
> $string = int($n1 / $n2);
>
> but it always gives me an integer number , so what should i do ?
It is unclear what you actually want, but if you want a real string
stored in $string, you could do:
$string = int($n1 / $n2) . '';
which will coerce the result of int into a string. Note that this is
mostly not needed in Perl because numbers and strings freely convert as
needed automatically.
--
Bob Walton
------------------------------
Date: 18 Jul 2000 02:50:03 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: How can i identify a "Not Integer" string ?
Message-Id: <3bRYKV$Wv_@openbazaar.net>
Election (election@qualitynet.net) wrote on MMDXIII September MCMXCIII in
<URL:news:8l0s1b$j5f1@news.qualitynet.net>:
&& Hello everybody ...
&& I'm a beginner programmer in perl and I'd like to know ,
&& How can identify a "Not Integer" string in perl ? actually
&& I've got a string that stores the result like this
&&
&& $string = int($n1 / $n2);
&&
&& but it always gives me an integer number , so what should i do ?
Good. So, you discovered that int() does what it is supposed to do.
I fail to see your problem.
Abigail
--
print v74.117.115.116.32, v97.110.111.116.104.101.114.32,
v80.101.114.108.32, v72.97.99.107.101.114.10;
------------------------------
Date: 16 Jul 2000 21:50:04 GMT
From: john99@NOSPAMcanada.com.bbs@openbazaar.net (John)
Subject: How can I print date on an include file
Message-Id: <3bQb5U$VPc@openbazaar.net>
Hello,
I have a perl script running on my site.
It has a feature that enables me to add headers and footers of my own.
They look like this:
sub Header { print qq!
<head>
<title>myheader</title>
</head>
<body>
$date
!;
}1;
Within the place where it says $date i would like to call my date
program. It is also a perl script.
Does anyone one how can I implement this?
SSI doesn't work.
Thank you all in advance
------------------------------
Date: 16 Jul 2000 22:10:02 GMT
From: care227@attglobal.net.bbs@openbazaar.net (Drew Simonis)
Subject: Re: How can I print date on an include file
Message-Id: <3bQbUQ$WXu@openbazaar.net>
John wrote:
> I have a perl script running on my site.
> It has a feature that enables me to add headers and footers of my own.
> They look like this:
> sub Header { print qq!
> <head>
> <title>myheader</title>
> </head>
> <body>
> $date
> !;
> }1;
>
> Within the place where it says $date i would like to call my date
> program. It is also a perl script.
>
Backticks are your friend.
$date = `your_date_program`;
print $date;
------------------------------
Date: 16 Jul 2000 22:20:02 GMT
From: tony_curtis32@yahoo.com.bbs@openbazaar.net (Tony Curtis)
Subject: Re: How can I print date on an include file
Message-Id: <3bQbh1$UmI@openbazaar.net>
>> On Sun, 16 Jul 2000 21:52:39 GMT,
>> John <john99@NOSPAMcanada.com> said:
> Hello, I have a perl script running on my site. It has
> a feature that enables me to add headers and footers of
> my own. ...
> Within the place where it says $date i would like to
> call my date program. It is also a perl script.
See the entry for "qx" in "perldoc perlop".
> Does anyone one how can I implement this? SSI doesn't
> work.
I don't think SSI is relevant here.
Using POSIX::strftime and localtime might be a better way
of getting the date (without the overhead of a new shell
process).
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: 16 Jul 2000 23:40:00 GMT
From: john99@NOSPAMcanada.com.bbs@openbazaar.net (John)
Subject: Re: How can I print date on an include file
Message-Id: <3bQdl0$Wny@openbazaar.net>
Thank you very much.
I had tried exactly what you've suggested before but at that time I had
quotes instead of backsticks.
It now works flawlessly.
Thanx again
Drew Simonis wrote:
>
> John wrote:
>
> > I have a perl script running on my site.
> > It has a feature that enables me to add headers and footers of my own.
> > They look like this:
> > sub Header { print qq!
> > <head>
> > <title>myheader</title>
> > </head>
> > <body>
> > $date
> > !;
> > }1;
> >
> > Within the place where it says $date i would like to call my date
> > program. It is also a perl script.
> >
>
> Backticks are your friend.
>
> $date = `your_date_program`;
> print $date;
------------------------------
Date: 16 Jul 2000 23:50:01 GMT
From: john99@NOSPAMcanada.com.bbs@openbazaar.net (John)
Subject: Re: How can I print date on an include file
Message-Id: <3bQeBP$V8U@openbazaar.net>
Thank you for your response, I've solved the problem.
I should find a good perl5 book that I can afford.
Regards
Tony Curtis wrote:
>
> >> On Sun, 16 Jul 2000 21:52:39 GMT,
> >> John <john99@NOSPAMcanada.com> said:
>
> > Hello, I have a perl script running on my site. It has
> > a feature that enables me to add headers and footers of
> > my own. ...
>
> > Within the place where it says $date i would like to
> > call my date program. It is also a perl script.
>
> See the entry for "qx" in "perldoc perlop".
>
> > Does anyone one how can I implement this? SSI doesn't
> > work.
>
> I don't think SSI is relevant here.
>
> Using POSIX::strftime and localtime might be a better way
> of getting the date (without the overhead of a new shell
> process).
>
> hth
> t
> --
> "With $10,000, we'd be millionaires!"
> Homer Simpson
------------------------------
Date: 13 Jul 2000 06:10:03 GMT
From: gellyfish@gellyfish.com.bbs@openbazaar.net (Jonathan Stowe)
Subject: Re: How can I use HTML::Parser to get images from HTML file
Message-Id: <3bNi6U$Y1Y@openbazaar.net>
On Wed, 12 Jul 2000 01:28:09 GMT salvadorej@my-deja.com wrote:
>
> how to get a list of URLs for images contained in an HTML file.
>
Heres one I made earlier :
#!/usr/bin/perl -w
package GetIMG;
@ISA = qw(HTML::Parser);
require HTML::Parser;
use strict;
my $parser = new GetIMG;
$parser->parse_file($ARGV[0]);
sub start()
{
my($self,$tag,$attr,$attrseq,$orig) = @_;
if ( $tag eq 'img')
{
for (keys %{$attr} )
{
print "$_ = > $attr->{$_}\n";
}
}
}
You might want to read the HTML::Parser manpage for more on this or check
out <http://www.gellyfish.com/htexamples/> for a brief explantation.
BTW with version 3 of HTML::Parser one could do :
#!/usr/bin/perl -w
use HTML::Parser;
use strict;
my $parser = HTML::Parser->new( api_version => 3,
start_h => [ \&start,"tagname,attr"];
$parser->parse_file($ARGV[0]);
sub start()
{
my($tag,$attr) = @_;
if ( $tag eq 'img')
{
for (keys %{$attr} )
{
print "$_ = > $attr->{$_}\n";
}
}
}
Which in this case isnt much simpler but doesnt need the sub-classing.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 16 Jul 2000 17:40:02 GMT
From: jraff@home.com.bbs@openbazaar.net (jraff)
Subject: Re: How do I set/get cookies ?
Message-Id: <3bQUT2$XLf@openbazaar.net>
One might want to look at;
http://search.cpan.org/doc/LDS/CGI.pm-2.68/CGI/Cookie.pm
------------------------------------------------------------------
<martho@my-deja.com> wrote in message news:8ksimn$t9$1@nnrp1.deja.com...
> How do I set/get cookies in Perl-CGIs ?
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3715
**************************************