[25244] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7489 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 7 03:05:57 2004

Date: Tue, 7 Dec 2004 00: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           Tue, 7 Dec 2004     Volume: 10 Number: 7489

Today's topics:
    Re: file handle problem <someone@example.com>
    Re: file handle problem <ahamm@mail.com>
    Re: How to detect an undefined SV* value in XS? <jl_post@hotmail.com>
    Re: How to detect an undefined SV* value in XS? <tassilo.von.parseval@rwth-aachen.de>
    Re: kindergarten array vs. for question <emschwar@fc.hp.com>
    Re: kindergarten array vs. for question <ahamm@mail.com>
    Re: Need to locate beginner/intermediate training cours <tadmc@augustmail.com>
        Newbie LWP Question on multi-stage forms... <truesail@yahoo.com>
    Re: Newbie LWP Question on multi-stage forms... <spamtrap@dot-app.org>
        newsgroup inhabitants (was: Solaris taking...) <ahamm@mail.com>
    Re: Perl some time hank with system command. <jl_post@hotmail.com>
    Re: Perl some time hank with system command. <jl_post@hotmail.com>
        Printing Data usinf Perl to an HTML does not work with  islamabadi@yahoo.com
    Re: RegExp Help <ahamm@mail.com>
    Re: RegExp Help <ihatespam@hotmail.com>
        The Perl Review, with cheaper subscription options <comdog@panix.com>
    Re: Using Perl to align text in an HTML page <truesail@yahoo.com>
    Re: Using Perl to align text in an HTML page <ceo@nospam.on.net>
    Re: Using Perl to align text in an HTML page <ceo@nospam.on.net>
    Re: vbscript or perl <not@home.net>
    Re: vbscript or perl <josef.moellers@fujitsu-siemens.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 07 Dec 2004 02:41:01 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: file handle problem
Message-Id: <1L8td.34046$cE3.29958@clgrps12>

Anno Siegel wrote:
> John W. Krahn <krahnj@telus.net> wrote in comp.lang.perl.misc:
> 
>>Anno Siegel wrote:
>>
>>>John W. Krahn <krahnj@telus.net> wrote in comp.lang.perl.misc:
>>>
>>>>newbie wrote:
>>>>
>>>>>Thanks guys, I get the point of not putting large file in memory. I got a
>>>>>new question. Say I have a bunch of large files, and I want to just get rid
>>>>>of the last line of each of these large files. Is there a simpler way
>>>>>without reading in and outputing the file?
>>>>
>>>>perldoc -f truncate
>>>
>>>...probably in combination with File::ReadBackwards.
>>
>>The OP said that he didn't want to read in the file so presumably he already 
>>knows the length of the last line?
> 
> What are you doing?  Applying logic to Usenet postings? :)

As well as correct spelling, grammar and punctuation!   ;}


John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 7 Dec 2004 16:44:38 +1100
From: "Andrew Hamm" <ahamm@mail.com>
Subject: Re: file handle problem
Message-Id: <31kuaaF3bvq4fU1@individual.net>

newbie wrote:
> Thanks guys, I get the point of not putting large file in memory. I
> got a new question. Say I have a bunch of large files, and I want to
> just get rid of the last line of each of these large files. Is there
> a simpler way without reading in and outputing the file?

Did you ever get a solution? Apart from some useful pointers, I can't see
one. There's a few ways. One is a simple re-write loop which stores the
previous line:

my $buffer;
if($buffer = <IFD>) {
    while(<IFD>) {
        print OFD $buffer;
        $buffer = $_;
    }
}

the last line will not be printed.

The suggestion to use truncate is also reasonable:

$size = 0;
# $pos gets the (potential) start of the next line
while($pos = ftell IFD, <IFD>) {
    # if there really was a next line, save it
    $size = $pos;
}

truncate IFD, $size;

NOTE: I haven't actually tested this last one, but it looks reasonable :-)
If it fails repost and I'll put in a bit more effort




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

Date: 6 Dec 2004 18:44:11 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: How to detect an undefined SV* value in XS?
Message-Id: <1102387451.307270.281670@z14g2000cwz.googlegroups.com>

Sisyphus wrote:
> From within the XS code I think you need to examine
> the 'ANY' field using the SvANY macro - which you'll
> find in sv.h, though it's not documented *anywhere*
> afaict.
>
> if(SvANY(sv) == NULL) printf("It's undef");
> else printf("It aint undef");


Thanks for the response, Rob.

I looked around a little more and I was able to find what I was
looking for.  It turns out that the "sv.h" header file defines a value
called SVt_NULL that is returned by the SvTYPE() macro.  So I can do
what I want like this:

if (SvTYPE(sv) == SVt_NULL)  printf("It's undef");
else  printf("It aint undef");

And just like SvANY(), SVt_NULL isn't mentioned anywhere in "perldoc
perlapi".  Go figure.

I'll test out your code soon and see if it works.
Thanks again, Rob.

   -- Jean-Luc



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

Date: Tue, 7 Dec 2004 07:26:59 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: How to detect an undefined SV* value in XS?
Message-Id: <slrncraj9j.rg.tassilo.von.parseval@localhost.localdomain>

Also sprach J. Romano:

> Dear Perl community,
>
>    I have a problem here and I'm hoping that someone can help.
>
>    I am writing some XS code, and I need to detect whether a value
> accessed through an SV pointer is defined or undefined.  I read
> "perldoc perlapi", and the closest I could find was this excerpt:
>
>  SvTRUE  Returns a boolean indicating whether Perl would
>          evaluate the SV as true or false, defined or unde-
>          fined.  Does not handle 'get' magic.
>
>                  bool    SvTRUE(SV* sv)
>
> This is great for discovering a variable's boolean value, but I need
> some way of knowing if an SV* was undefined when it was passed in.  I
> suppose I could always do this:
>
>       char *valueStr;
>       STRLEN valueLen;
>       valueStr = SvPV(*value, valueLen);
>
> and then valueStr would be "" and valueLen would be 0 if *value
> contains an undefined value.  However, valueStr and valueLen would
> both be the same thing if *value pointed to an empty string.  

Right. Use SvOK to check whether an SV is defined.

>The
> line:
>
>       bool truthValue = SvTRUE(*value);
>
> returns false for both undefined values and empty strings, which means
> that it can't differentiate between them, either.
>
>    So I can't figure out how to check to see if an SV* value is
> defined or not.  Any test I perform (with SvPV, SvTRUE, or SvIV) gives
> the same results when used with empty strings and undefined values. 
> This causes a problem if I need to know for sure which was passed in.
>
>    For those interested, I tried these commands:
>
>> perl -MDevel::Peek -e '$a = ""; Dump($a)'
> SV = PV(0x80f5a84) at 0x80fc9f8
>   REFCNT = 1
>   FLAGS = (POK,pPOK)
>   PV = 0x8102a70 ""\0
>   CUR = 0
>   LEN = 1
>
>> perl -MDevel::Peek -e '$a = undef; Dump($a)'
> SV = NULL(0x0) at 0x80fc9f8
>   REFCNT = 1
>   FLAGS = ()
>
> Unfortunately, I'm not too familiar with Devel::Peek to really know
> how to use its "Dump" output to my advantage.  I see that with an
> undefined value, SV equals NULL, but according to the debugger, it's
> definitely set to some non-NULL value.  Likewise, when I dump an empty
> string, the "Dump" output says that LEN equals 1, but according when I
> make the following call:
>
>       valueStr = SvPV(*value, valueLen);
>
> valueLen gets set to zero (as it does with an undefined value).

LEN (corresponding to SvLEN) returns the size of the character buffer in
an SV. CUR (SvCUR) on the other hand is the length of the string stored
inside which is usually LEN-1. 

The output of Devel::Peek::Dump is quite straight-forward really. It
tells you how an SV looks on the inside which can be an invaluable debug
help. In order to understand it, you have to know what the various
flags in sv.h mean because they ultimately determine how perl treats an
SV:

    ethan@ethan:~$ perl -MDevel::Peek -e '$a = 1; $a = 0.02; $a = "3";
    Dump($a)'
    SV = PVNV(0x817c970) at 0x8160b30
      REFCNT = 1
      FLAGS = (POK,pPOK)
      IV = 1
      NV = 0.02
      PV = 0x815d4a0 "3"\0
      CUR = 1
      LEN = 2

In $a, three different values have been stored (and they are all present
at the same time). The POK tells perl that only the PV value (the
string) should be used. But it doesn't have to be like that:

    ethan@ethan:~$ perl -MScalar::Util=dualvar -MDevel::Peek -e '$a = 0.02; $a = dualvar(1, "3"); Dump($a)'
    SV = PVNV(0x81d9a48) at 0x814cc6c
      REFCNT = 1
      FLAGS = (IOK,POK,pIOK,pPOK)
      IV = 1
      NV = 0.02
      PV = 0x815d4d0 "3"\0
      CUR = 1
      LEN = 2

The same three values, only this time IOK and POK are set so perl will
use the IV slot in numeric context and PV otherwise.

So the flags such as SVf_(IOK|NOK|POK|ROK) tell perl what type of value
it should expect to find in the SV. Other flags are related to garbage
collection (e.g. SVf_PADMY which is only set on lexicals and indicates
that the SV is subject to refcounting and garbage-collecting).

>    Maybe the key to checking an undefined value is to check the FLAGS?
>  Or is there an easier way to do this that I'm not aware of?

Yes, it's all in the flags. SvOK checks for the pseudo-flags SVf_OK
which is

#define SVf_OK		(SVf_IOK|SVf_NOK|SVf_POK|SVf_ROK| \
			 SVp_IOK|SVp_NOK|SVp_POK)

so from an XS point of view, a value is defined if it is either an
integer, a double, a string or a reference.

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: Mon, 06 Dec 2004 16:17:41 -0700
From: Eric Schwartz <emschwar@fc.hp.com>
Subject: Re: kindergarten array vs. for question
Message-Id: <eto7jnvuicq.fsf@wilson.emschwar>

Dan Jacobson <jidanni@jidanni.org> writes:
> my @a=(1,2,3); my @b=(4,5,6);
> for((((@a))),(((@b)))){ #What do I have to do to this line to make

Yikes!  You need a quick trip to 'perldoc perldata'. Do not pass go,
do not collect $200.  I'm not trying to make you feel bad here, but
this is very basic stuff.  If you didn't read this in perldata, you
probably need to sit down and read that manpage, and probably at least
skim perltoc as well.

A short excerpt from perldata:

       LISTs do automatic interpolation of sublists.  That is, when a
       LIST is evaluated, each element of the list is evaluated in
       list context, and the resulting list value is interpolated into
       LIST just as if each individual element were a member of LIST.

So, what you're iterating over is the list (((@a))),(((@b))), which is
equivalent to (@a),(@b), which is equivalent to @a,@b, which is in
turn reduced to a list containing all the elements of @a followed by
all the elements of @b.

As a stylistic aside, if I ever find myself using $_ explicitly in a
loop, that's usually a sign to me that I need to be using an explicit
name for the variable.  In your case, I might write it:

for my $element (@a,@b) {
 ...
}

And then use $element where you have $_.  This won't work in EVERY
case, but it does work 9 times out of 10.

>   print "new array\n"; #this line get printed only twice, not six times?
>   for($_){
>     print "element $_\n"}}

Also, this is kinda ugly from a personal POV: it doesn't match any
standard indenting style I'm familiar with, and it makes it harder to
find the close bracket for the outer for by hiding it at the end of
the inner for.  And even that one might be missed on a cursory
reading.

Anyway, to answer your question, the "right" answer depends on why you
want to know.  If you want to count how many arrays you put in the top
of the for loop, well, that's a bit odd, since you're specifying them
explicitly.  You probably want to iterate over references to the
arrays, except then you lose the name of the array when you do so (not
sure if that would be a problem or not).

That might look like:

for my $array_ref (\@a, \@b) {
    print "new array, ref value: [$ref]";
}

read perlretoot for more info on references in Perl.  Also perlref.

-=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: Tue, 7 Dec 2004 10:32:25 +1100
From: "Andrew Hamm" <ahamm@mail.com>
Subject: Re: kindergarten array vs. for question
Message-Id: <31k8gfF3cn8u3U1@individual.net>

Dan Jacobson wrote:
> my @a=(1,2,3); my @b=(4,5,6);
> for((((@a))),(((@b)))){
>    #What do I have to do to this line to make
>    #this line get printed only twice, not six times?
>    print "new array\n";
>    for($_){
>       print "element $_\n"
>    }
> }

I see what you are trying to achieve (I think) and you will need to use
references. The answer will be more complicated than you might expect!

my @a = (1, 2, 3);
my @b = (4, 5, 6);

for(\@a, \@b) {
    print "new array\n";
    for(@$_) {
        print "  element $_\n";
    }
}

No matter how many (  ) you wrap around a list, it is flattened down to a
single-level list in Perl. So your attempt to make

    (((@a))),(((@b)))

is the same as

    @a, @b

Which is given to "for"; and guess what, "for" takes a list which is
logically (and syntactically) wrapped in another ( ) so you get

    (@a, @b)

which ultimately yields

    (1, 2, 3, 4, 5, 6)

my solution takes the "address of" @a and @b by applying  the \ operator.
NOTE: Perl is higherlevel than a machine-oriented language like C or C++,
so calling it an "address of" is not strictly true. There is more in a
Perl "reference" than just a simple address. But for practical purposes
it's very simple to informally consider it to be an address if that helps
you to understand.

Now, my outside for loop gets two values: the address of @a and the
address of @b. This gives you the two prints of the line you want.

The next problem is getting to the values "pointed to" or referred to by
the reference. If $X contains a reference, then "pretend" or treat it as a
unit which is a variable name:

    $thingy       # a scalar variable
    @listy        # an array variable
    $$rthingy    # dereference a reference to a scalar variable
    @$rlisty     # dereference a reference to an array variable

for total safety while you are learning, it's safer to write

    ${$rthingy}  @{$rlisty}

because the { } puts a very clear boundary around the reference, and
really makes it clear what goes with what.

There's no point in me going any further here because the subject is
wellcovered in the doco. See

    perldoc perlreftut

and

    perldoc perlref

and study well. References are very powerful, a bit mind-bending, and are
central to the Perl way of making complex data structures.




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

Date: Mon, 6 Dec 2004 17:49:58 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Need to locate beginner/intermediate training course in the UK
Message-Id: <slrncr9s16.56n.tadmc@magna.augustmail.com>

SarahEmmm <sarah_mould@hotmail.com> wrote:

> Tad - yes, that was it! Sadly, I don't think the boss will spring for a
> course outside the UK, so I can't suggest Stonehenge ;) The UK list
> contains a number of companies who sound reasonable: I would be most
> grateful for feedback on
> http://www.wellho.co.uk/
> http://www.netspinner.co.uk/Training.html
> http://www.mag-sol.com/
> http://www.perlcourses.co.uk/
> if you have any knowledge of them.


I don't know of any of the companies, but that isn't too surprising,
I'm not up on things in that part of the World.

3 out of the 4 of them have no information on the trainers, only
on the companies. That worries me. If they had a "Perl name" trainer
they would be advertising it, I'd think...

www.mag-sol.com lists Dave Cross as the trainer. 

I know Dave, he is most certainly the Real Deal.



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


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

Date: 6 Dec 2004 15:25:35 -0800
From: "TB" <truesail@yahoo.com>
Subject: Newbie LWP Question on multi-stage forms...
Message-Id: <1102375535.003872.188990@f14g2000cwb.googlegroups.com>

I am fairly new to the Perl and LWP world but completely consumed by
the power and flexibility.

I am trying to load an initial page which prompts for a userID password
(not htaccess or realms) that is application driven.  I create a new
UserAgent, then do a post with the user and password fileds.  Seems to
work, returns "200 OK" in the success field...but doesn't seem to care
what password I use (unlike when I manual type it in a browser).  Any
help would be appreciated (I tried WWW::Mechanize too, same results).

Once past that, I need to enter two date fields, then click a link.

What's the best method to accomplish this?  Any help/samples
appreciated...meanwhile I am hacking away at the Perl & LWP book with
much success on their samples...just not on my code.
Please, go easy on me...and I promise to be a good Perl convert.



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

Date: Tue, 07 Dec 2004 00:37:42 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Newbie LWP Question on multi-stage forms...
Message-Id: <y6OdnRWR7tw63CjcRVn-2A@adelphia.com>

TB wrote:

> I am trying to load an initial page which prompts for a userID password
> (not htaccess or realms) that is application driven.  I create a new
> UserAgent, then do a post with the user and password fileds.  Seems to
> work, returns "200 OK" in the success field...but doesn't seem to care
> what password I use (unlike when I manual type it in a browser).

That goes with the territory - since the page you're fetching isn't 
using HTTP authorization, the HTTP status you get back isn't going to 
indicate whether or not your login succeeded. Whether the password was 
correct or not, the CGI ran without problems and produced correct 
output, so the "200 OK" status is appropriate.

To determine whether your login was a success, you need to parse the 
result (I assume it's HTML) to look for the relevant text.

> Once past that, I need to enter two date fields, then click a link.
> 
> What's the best method to accomplish this?

Have a look at WWW::Mechanize.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Tue, 7 Dec 2004 10:05:43 +1100
From: "Andrew Hamm" <ahamm@mail.com>
Subject: newsgroup inhabitants (was: Solaris taking...)
Message-Id: <31k6ucF3ble85U1@individual.net>

Tad McClellan wrote:
> Andrew Hamm <ahamm@mail.com> wrote:
>
>> Why is this ng so full
>> of pedantic fools?
>
>
> We like you too.

Hey, I took that back in the next message. Plus, "full of" doesn't exclude
the existence of more decent people too. I'm complaining about the people
you are perhaps more steely enough to do constant battle with. I got fed
up with it months and months ago. I don't think I've really hung around or
contributed for more than a year. Maybe two - whenever the switchover from
c.l.p to c.l.p.m was being put through.

I don't know why people just can't be nice to each other and try to be
helpful instead of scoring geek points from winning interminable
arguments. From your other message, krakle always trolls does (s)he?
Anonymity gives these people too much scope and safety...

How do you get the strength to keep contributing day after day? You have a
supply of really strong coffee perhaps?




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

Date: 6 Dec 2004 19:07:39 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Perl some time hank with system command.
Message-Id: <1102388859.435449.32660@f14g2000cwb.googlegroups.com>

Lim kiang Leng wrote:
>> I have a problem by using the perl command. Some time it
>> hank with the system command. such as below.

Michele Dondi replied:
> Define "to hank". This is not a joke: I'm not a native English
> speaker and I couldn't find it in my dictionary. May well be
> slang, but I'm not familiar with it.


For the record, "Hank" is an English nickname that's short for
"Henry" ("Enrico").  Although I doubt that's what he meant.

If he IS referring to a person's name, his sentence might be better
written as:

>> Sometimes, Hank, with the system command I get the
>> text below:

which sounds better, but I have no idea who this Hank person would be.

The name "Hank" should not be confused with the word "hanky," which
is short for "hankerchief" ("fazzoletto").

If you think "Hank" is a strange nickname for "Henry," you're not
the only one.  After all, even the Homestar Runner said in his
proclamation, "Henceforth, those named Henry will no longer be allowed
to call themselves Hank. That's just too much of a stretch."  (This
discussion is getting off-topic, so I'll end it here.)

   -- Jean-Luc



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

Date: 6 Dec 2004 19:20:18 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Perl some time hank with system command.
Message-Id: <1102389618.517702.97150@f14g2000cwb.googlegroups.com>

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

So, it looks like Perl's Soundex module agrees with you, as both words
return a code of H520.

But there are other words that also have Soundex code H520:

Haines hammock Hans Hanukkah haunch Haynes Heinz
hence Hines hinge homage hong honk Honshu hummock
humus hunch hung hunk Hyannis hying

Maybe the original poster mean that his computer "honks" (or
"beeps") when the system() command is used.  But I'm sure you're right,
Rob... he probably mean "hangs."  (But if his script were "hying," I'd
really have no idea what he would be talking about...)

   -- Jean-Luc



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

Date: 6 Dec 2004 22:36:27 -0800
From: islamabadi@yahoo.com
Subject: Printing Data usinf Perl to an HTML does not work with large amount of data
Message-Id: <1102401387.275274.47110@z14g2000cwz.googlegroups.com>

have a perl code that is connecting to Oracle DB and retrieving data.
I am currently experiencing the following issues:

After data is reterieved if I try to output a HTML table by using the
following code, the web browser displays data okay for say about 20
records. But if I have more than twenty records the web browser almost
never completes.

print "<table cellspacing=10>\n";
while ( my @row = $sth->fetchrow_array() ) {

print "<TR>";
for ($i=0; $i <= $#row; $i++) {
print "<TD>$row[$i]</TD>";
}
print "</TR>\n";
}

If I try to output just the data as follows:

while ( my @row = $sth->fetchrow_array() ) {
for ($i=0; $i <= $#row; $i++) {
print "<TD>$row[$i]</TD>";
}
}

It works faster but still does not return all the data. That is it
outputs 50% of the data, and the web browser then keeps working but
never retrieves more data.

There is some buffer when Perl outputs to html. If the output is less
than that buffer, then the web page displays normally else it gets
stuck. When I click the stop button on the web browser, it then display
everything in the buffer. Interesting thing is that whenever I stop the
loading of the webpage, after 10 secs or after 10 minutes, it is the
same output in the buffer.

Does anyone know if I should be manually flushing the buffer to html,
and how?

I do have header,etc. properly in the script so that does not seem to
be the problem, also it does work for small amount of data.



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

Date: Tue, 7 Dec 2004 16:32:16 +1100
From: "Andrew Hamm" <ahamm@mail.com>
Subject: Re: RegExp Help
Message-Id: <31ktj4F3cdga3U1@individual.net>

Indigo5 wrote:
> This may be a simple question, but how would I use a regular
> expression to convert reals to integers whenever possible.  For
> example, if I had the following lines
>
> 25.010      36.5     20.00
> 22.3          19.       35.
>
>
> I would want those converted to
>
> 25.010           36.5     20
> 22.3               19        35

From your sample output, you do not appear to want to convery 25.010 into
25.01 therefore I think you want this:

    s/(\.0*)(?!\d)/' ' x length $1/eg;

I am guessing also that you want to maintain the column structure,
therefore I'm replacing the removed characters with the same amount of
spaces. If that is not important, then it's

    s/(\.0*)(?!\d)//g;




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

Date: Tue, 07 Dec 2004 11:58:21 -0800
From: BigDaDDY <ihatespam@hotmail.com>
Subject: Re: RegExp Help
Message-Id: <10raohbk026ve5b@corp.supernews.com>

Andrew,

My bad..I did want 25.010 to be converted to 25.01.  Nice catch.

How does this change the regexp you provided?


Andrew Hamm wrote:

> Indigo5 wrote:
>> This may be a simple question, but how would I use a regular
>> expression to convert reals to integers whenever possible.  For
>> example, if I had the following lines
>>
>> 25.010      36.5     20.00
>> 22.3          19.       35.
>>
>>
>> I would want those converted to
>>
>> 25.010           36.5     20
>> 22.3               19        35
> 
> From your sample output, you do not appear to want to convery 25.010 into
> 25.01 therefore I think you want this:
> 
>     s/(\.0*)(?!\d)/' ' x length $1/eg;
> 
> I am guessing also that you want to maintain the column structure,
> therefore I'm replacing the removed characters with the same amount of
> spaces. If that is not important, then it's
> 
>     s/(\.0*)(?!\d)//g;



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

Date: Tue, 07 Dec 2004 00:41:02 -0600
From: brian d foy <comdog@panix.com>
Subject: The Perl Review, with cheaper subscription options
Message-Id: <071220040041020648%comdog@panix.com>


A lot of people have asked about an online-only edition of TPR,
so I created one.  International customers can pay the same
price as US subscribers ($US16), although they won't get the print
edition.  Those subscribers still have full access to the 
PDF versions.

   https://www.theperlreview.com/cgi-bin/subscribe.cgi

We are, however, working on a European edition.  If we get
enough European subscribers, the online-only edition will
convert to a print subscription at no additional cost.  
Online-only subscribers can also get the print versions
for the price of shipping if they change their minds later.

We've also reduced the price to $US20 for Canada and Mexico, 
since the shipping is a bit cheaper than overseas.  Anyone
who recently subscribed from either of those countries can
contant me if they want to get the lower rate (or something
else for the extra money).


-------

The second print issue of The Perl Review is coming off the presses
and will be mailed this week, so you have time to get your name 
on the subscriber list.  TPR is the only print magazine devoted
to Perl.

   http://www.theperlreview.com/

In this issue ( 1.1, Winter 2004 )

   * Down Translating XML -- Alberto Manuel Simes

   * Module::Release and Beyond -- brian d foy

   * Functional Perl Programming -- Frank Antonsen

   * Faking Stored Procedures -- Zach Thompson
   
   plus Perl News, Perl Mongers and Perl Foundation reports, book
   reviews, and short notes.
   

The first print issue ( 1.0 ) is still available to subscribers online
as a PDF file, and some back issues are available.

   * Test Driven Development -- Denis Kosykh

   * Just do{} it -- brian d foy

   * Extending XML::XPath -- Michel Rodriguez

   * Test::More in 20 Seconds -- brian d foy

   * Magick Tile Puzzles -- Grant McLean


Before that, The Perl Review was a digital only version with
eight issues which are still available for free download as
PDF files.

   http://www.theperlreview.com/Issues/


RSS Feeds are available too.

   Subscriber only (current) issues
      http://www.theperlreview.com/RSS/tpr-subscribers.rdf
      
   Free Issues and articles
      http://www.theperlreview.com/RSS/tpr-free.rdf
      
   The Perl Review news
      http://www.livejournal.com/users/perl_review/data/rss
   
   The Perl Review public discussion
      http://www.livejournal.com/community/the_perl_review/data/rss
      

Want to write for TPR? Send us a note, or submit an idea online

   http://www.theperlreview.com/Authors/submit.html

Prices: $16 in the US, $20 for Canada and Mexico, and $30 outside the
US.  If we can get enough subscribers in the European Union, we'll
start printing there too and lower the cost.  For online access only,
you can pay $16, and if we start printing in your part of the world,
you can convert to a print subscription without paying more.

TPR accepts MasterCard, Visa, American Express, PayPal, Amazon.com
Honors System, and check or money order in US dollars.  Sorry, but we
can only accept advance payment since we're too small to do handle
individual billing.

Samples to Perl user groups, Perl instructors, and other worthy causes
are available.

-- 
brian d foy, comdog@panix.com
Subscribe to The Perl Review: http://www.theperlreview.com


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

Date: 6 Dec 2004 15:41:11 -0800
From: "TB" <truesail@yahoo.com>
Subject: Re: Using Perl to align text in an HTML page
Message-Id: <1102376471.923682.30820@c13g2000cwb.googlegroups.com>

Hmm...in my experience, tabs and HTML don't really get along.  I think
your problem could be solved at least two ways.  The simplest would be
to insert a <pre> tag to align things in a courier type font (not
pretty).  Secondly, write you a <table> tag out.  Next maybe write a
header row like this:

<th>Last Name</th>
<th>First Name</th>
<th>First Name 2</th>

 ...then as you loop through the rows in the database, start with
<tr>
 ...loop through each column in the table..
<td>lastname</td>
<td>firstname</td>
<td>firstname2</td>
 ...close out the html table row,
</tr>
 ...continue looping through table until all rows are processed.
Then close the table: </table>
Not elegant, but it might get you through.  

HTH -TB



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

Date: Tue, 07 Dec 2004 02:11:10 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: Using Perl to align text in an HTML page
Message-Id: <2j8td.29724$Rf1.9513@newssvr19.news.prodigy.com>

TB wrote:
> Hmm...in my experience, tabs and HTML don't really get along.  I think
> your problem could be solved at least two ways.  The simplest would be
> to insert a <pre> tag to align things in a courier type font (not
> pretty).  Secondly, write you a <table> tag out.  Next maybe write a
> header row like this:
> 
> <th>Last Name</th>
> <th>First Name</th>
> <th>First Name 2</th>
> 
> ...then as you loop through the rows in the database, start with
> <tr>
> ...loop through each column in the table..
> <td>lastname</td>
> <td>firstname</td>
> <td>firstname2</td>
> ...close out the html table row,
> </tr>
> ...continue looping through table until all rows are processed.
> Then close the table: </table>
> Not elegant, but it might get you through.  
> 
> HTH -TB
> 

The OP said *no tables*.  Your entry into the contest is disqualified.

-ceo


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

Date: Tue, 07 Dec 2004 02:20:31 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: Using Perl to align text in an HTML page
Message-Id: <Pr8td.29782$Rf1.10300@newssvr19.news.prodigy.com>

Rob wrote:

> Hi,
> 
> My final objective is to create a Word doc (formatted the way I want
> it) that is a collection of names contained in a MySQL database. My
> approach has been to output the information to a web page, then copy &
> paste it into my Word doc (basically because all the info is getting
> inputted by a web page and web pages are easy to deal with...I'm not
> married to this approach).
> 
> I have a situation where I want to print:
> 
> Lastname   Firstname
> Firstname2
> 
> Where the names are names of people in a family. These names reside in
> my database. I want them aligned nicely, as I've shown. I repeat this
> process for many families. I'm using a Perl script to go get the info
> from the database and send it to a web page. The problem I'm having is
> the two firstnames don't align nicely. I can't simply place Firstname2
> over a certain number of spaces since Lastname varies in length,
> especially since it is in bold (and firstnames are not).
> 
> I don't want to use a table since if I paste that into a Word doc the
> table shows up in Word, which I don't want.
> 
> I tried using:
> 
> <SCRIPT LANGUAGE='Javascript'>
> document.write("<XMP>")
> document.write("100 Meter\t400 Meter\t1500 Meter\r")
> document.write("110 Hurdles\tHigh Jump\tlong Jump\r")
> document.write("Javelin\t\tPole Vault\tShot Put\r")
> document.write("Discus")
> document.write("</XMP>")
> </SCRIPT>
> 
> Which I found on the web. In a "normal" web page it works great. I
> added it to my Perl script:
> 
> #!C:/Perl/bin/Perl.exe
> 
> print qq(
> <html>
> <SCRIPT LANGUAGE='Javascript'>
> document.write("<PRE>")
> document.write("100 Meter\t400 Meter\t1500 Meter\r")
> document.write("110 Hurdles\tHigh Jump\tlong Jump\r")
> document.write("Javelin\t\tPole Vault\tShot Put\r")
> document.write("Discus")
> document.write("</PRE>")
> </SCRIPT>
> </html>);
> exit;
> 
> and it seems like the web page simply ignores it - it doesn't print
> *anything*, let alone the tabs.
> 
> Any thoughts?

Your Perl worked for me under AS Perl v5.8.3 and Cygwin Perl alike on 
Windows XP...?  You JavaScript however needs to end with semicolons on 
each line (for the JS you output).  Also, your \t tab characters aren't 
going to do what you want them to do in this output.  You need \\t so 
that it shows up as \t in the JavaScript output.

If you are going to continue pursuing a MySQL -> HTML -> Word 
"conversion", and you don't want HTML tables, you may want to try using 
a CSS style sheet with absolute position for "columns".  I have NO IDEA 
how that will carry over into Word when you cut and paste.  It's just a 
thought I had.  Trying to get stuff to align in HTML without using 
tables is problematic at best, but if you stretch, it can be done.

Personally, I would probably consider a Win32::OLE approach and take my 
data directly from MySQL and place it into a Word document being created 
with Win32::OLE directly.  I don't think it's THAT hard.

-ceo


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

Date: Tue, 07 Dec 2004 05:56:29 GMT
From: "VBSome" <not@home.net>
Subject: Re: vbscript or perl
Message-Id: <hCbtd.27659$fC4.24203@newssvr11.news.prodigy.com>

>The real question is .... which do you know better.  If you can honestly
>answer that question, then you'll already have an answer :-)

GOOD ANSWER!

>This isn't true. Microsoft have a tool called Windows Script Host, that
>allows VB- (and Java-) scripts to run independently of any browser, or
>anything like that. It is the official M$-recommended way of scripting
>windows (they've finally admitted .bat files are useless).

YUP! VBScript can run independant of any browser. That is why scripts (read 
virus) written in VBS are so dangerous.

Perl is really easy to install on Win32 machines so if you already know 
Perl, have at it. If you don't know Perl, and have little experience with 
VBS then the latter might be easier to learn. Just remember that VBS is just 
a subset of the "real" language (VB) so you might get stuck.

I am a VB programmer (sure go ahead and laugh) and do most applications in 
VB but when I need a good scripting language I go for Perl, because, 
although not as easy, I can get things done quicker in Perl.





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

Date: Tue, 07 Dec 2004 08:25:11 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: vbscript or perl
Message-Id: <cp3loq$te0$1@nntp.fujitsu-siemens.com>

VBSome wrote:

> Perl is really easy to install on Win32 machines so if you already know=
=20
> Perl, have at it. If you don't know Perl, and have little experience wi=
th=20
> VBS then the latter might be easier to learn. Just remember that VBS is=
 just=20
> a subset of the "real" language (VB) so you might get stuck.

Also, if you ever want your script to run on anything but Windows, you=20
might get stuck if you used VBScript.
Perl is pretty wide spread.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

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


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