[16710] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4122 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 18:10:38 2000

Date: Thu, 24 Aug 2000 15:10:24 -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: <967155024-v9-i4122@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 24 Aug 2000     Volume: 9 Number: 4122

Today's topics:
    Re: How to sort time? <panderse@us.ibm.com>
    Re: How to sort time? <lr@hpl.hp.com>
    Re: How to sort time? <lr@hpl.hp.com>
    Re: Implicit passing of arrays with prototypes <katz@underlevel.net>
    Re: Implicit passing of arrays with prototypes (Greg Bacon)
    Re: MIME Mail help on NT - no sendmail! <g.chapman0749@home.com>
        Never Mind, I got it working <perrin@lacis.com>
    Re: newbie question - dont flame me (Soren Andersen)
    Re: newbie question about "uninitialized variables" (Jon S.)
    Re: newbie:? string sub through an array <sariq@texas.net>
        ODBC, MS Access and Unicode problems <tomw@convergentarts.com>
    Re: Perl vs. other scripting languages (Charlie Watts)
    Re: Perl vs. other scripting languages <godzilla@stomp.stomp.tokyo>
    Re: Perl vs. other scripting languages <russ_jones@rac.ray.com>
    Re: Please help, 1024 char limit writing to DB's? perlnewbie@my-deja.com
    Re: Please wait... [was: Perl - Blinking Text] (Abigail)
    Re: Please wait... [was: Perl - Blinking Text] <iltzu@sci.invalid>
        PROBLEM: using REDIRCTS within IF statements boopfm523@my-deja.com
    Re: PROBLEM: using REDIRCTS within IF statements (Andrew J. Perrin)
    Re: Quick way to determine if a method is implemented i <tim@ipac.caltech.edu>
        REDIRECT PROBLEM boopfm523@my-deja.com
    Re: REDIRECT PROBLEM (Randal L. Schwartz)
    Re: RegEx <dietmar.staab@t-online.de>
    Re: RegEx <care227@attglobal.net>
    Re: RegEx <lr@hpl.hp.com>
    Re: RegEx <care227@attglobal.net>
    Re: RegEx (Steven M. O'Neill)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Aug 2000 13:07:51 -0500
From: "Paul R. Andersen" <panderse@us.ibm.com>
Subject: Re: How to sort time?
Message-Id: <39A56477.714AC900@us.ibm.com>

zbernie@my-deja.com wrote:
> 
> How can you sort a time in the format hh:mm:ss?
> For example, here's a code fragment that obtains the
> time from the 8th column after the split, then gets
> a running total.  What I need to do is print out the
> times in decending order.

I'm gonna be a bit bad and offer the following which is untested, I am
snipping it out of a larger routine I have and removing stuff you don't
need on the fly.  Use it as a starting point.
 
sub by_Time
{
  my($aHour, $bHour, $aMin, $bMin, $aSec, $bSec);

  ($aHour, $aMin, $bSec) = split (/:/, $tTime);
  ($bHour, $bMin, $bSec) = split (/:/, $tTime);
  # Now, compare the two and return a -1, 0, or 1
  return  $aHour <=> $bHour ||
          $aMin  <=> $bMin  ||
           $aSec <=> $bSec;
}


-- 
Paul Andersen
+++++++++++++
The difference between theory and practice is that in theory there is no
difference between theory and practice; but in practice there is.


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

Date: Thu, 24 Aug 2000 11:46:14 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to sort time?
Message-Id: <MPG.140f0d52855ce1fa98acd8@nntp.hpl.hp.com>

In article <8o3ld5$184$1@nnrp1.deja.com> on Thu, 24 Aug 2000 17:18:51 
GMT, zbernie@my-deja.com <zbernie@my-deja.com> says...
> How can you sort a time in the format hh:mm:ss?
> For example, here's a code fragment that obtains the
> time from the 8th column after the split, then gets
> a running total.  What I need to do is print out the
> times in decending order.
> 
> -Thanks!
> 
> 
>   open(HFILE, $ARGV[0]) || die "Can't open file: $!\n";

Well done, but it might be nice to interpolate the filename into the 
diagnostic, also.

>     while (<HFILE>) {
> 
>       ($col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8, $col9,
> $col10) = split(/\t/, $_);
> 
>       ($hr, $min, $sec) = split(/:/, $col8);

This does the same as the previous two statements, only nicer.

        my ($hr, $min, $sec) = split /:/ => (split /\t/)[7];

Use 'my' to limit the scope of the temporary variables.

perldoc -f my

>       $rtotal += $sec + ($min * 60) + ($hr * 3600);
> 
>     }#end while
> 
>   close(HFILE);

Good code, which deals with your data one line at a time, which is 
usually best.  But to sort the data, all must be in memory at the same 
time, so slurping the entire file into an array is best.  Then you can 
loop over the array to do your summing as you show above.

As for the sorting, you can sort directly by the eighth field, using the 
default lexicographic sort.  But for efficiency, you must do the split 
once per element, not for each comparison.

You will find useful information about this in perlfaq4: How do I sort 
an array by (anything)?" or in this paper:

    http://www.hpl.hp.com/personal/Larry_Rosler/sort/

Here, for the sake of propaganda, is the sort using the Guttman-Rosler 
Transform described in the paper:

Simplest:

    my @sorted = map substr($_, 8) => sort map
                    (split /\t/)[7] . $_ => <DATA>;

Slightly better:

    my @sorted = map substr($_, 6) => sort map {
                    (my $time = (split /\t/)[7]) =~ tr/://d;
                    $time . $_ } <HFILE>;

Removing the colons shortens the sortkeys by two bytes, which might 
matter a bit for efficiency.  If you really cared, you could shorten 
that further, to three bytes, by packing each of the three numerical 
fields into one character.

    my @sorted = map substr($_, 3) => sort map
        pack(C3 => (split /\t/)[7] =~ /(\d\d):(\d\d):(\d\d)/) . $_ =>
           <DATA>;

But all that seems hardly worth the trouble.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 24 Aug 2000 12:00:45 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to sort time?
Message-Id: <MPG.140f10b7d382aea498acda@nntp.hpl.hp.com>

In article <39A56477.714AC900@us.ibm.com> on Thu, 24 Aug 2000 13:07:51 -
0500, Paul R. Andersen <panderse@us.ibm.com> says...
+ zbernie@my-deja.com wrote:
+ > 
+ > How can you sort a time in the format hh:mm:ss?
+ > For example, here's a code fragment that obtains the
+ > time from the 8th column after the split, then gets
+ > a running total.  What I need to do is print out the
+ > times in decending order.
+ 
+ I'm gonna be a bit bad and offer the following which is untested, I am
+ snipping it out of a larger routine I have and removing stuff you
+ don't need on the fly.  Use it as a starting point.
+  
+ sub by_Time
+ {
+   my($aHour, $bHour, $aMin, $bMin, $aSec, $bSec);
+ 
+   ($aHour, $aMin, $bSec) = split (/:/, $tTime);
+   ($bHour, $bMin, $bSec) = split (/:/, $tTime);
+   # Now, compare the two and return a -1, 0, or 1
+   return  $aHour <=> $bHour ||
+           $aMin  <=> $bMin  ||
+            $aSec <=> $bSec;
+ }

Posting this code is irresponsible.  'A bit bad' indeed!  Not only is it 
quite incorrect, it would be grossly inefficient were it correct.

You haven't shown how to extract $tTime from each of the two comparands.  
Using $tTime for both of them leads to no sorting at all.

Once the two values are extracted, why split them up?  Just compare them 
as strings.  But the extraction should be done once per input element, 
not for every comparison, as discussed in my post.

BTW, in looking again at this simple exercise, I see that in my post I 
overlooked the 'descending order' requirement.  Just sticking 'reverse' 
ahead of the lexicographic sorting code is by far the best solution.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 24 Aug 2000 14:35:50 -0400
From: Jordan Katz <katz@underlevel.net>
Subject: Re: Implicit passing of arrays with prototypes
Message-Id: <m3og2iwlq1.fsf@underlevel.underlevel.net>

"John J. Lee" <phrxy@csv.warwick.ac.uk> writes:

> Why does this:
> 
> #!/usr/bin/perl -w
> 
> @list = (1, 2, 3);
> foo(@list);
      ^^ You're passing a plain array.

> sub foo(\@) {
          ^^ function `foo' expects a reference to an array, not just
             an array.

> #    my @list = @{shift()};
>     my @list = @_;

Perl will let above line slide, because @_ contains *all* parameters
passed to `foo', in our case (1, 2, 3), which will be assigned to
@list.  However, shift simply gets a single value off of @_ in this
case, which is supposed to be a reference -- but, you're not passing a
reference, you're passing an array.  To solve this, simply change:

  foo(@list);

to:

  foo(\@list);

>     print join ', ', @list;
> }
> 
> output this:
> 1, 2, 3
> 
> whereas moving the # one line down to comment the second 'my' outputs
> nothing at all?
> 
> In other words, why doesn't the prototype appear to work - isn't the \@
> prototype supposed to give you a reference when you pass an array?

The prototype says function `foo' takes a reference and expects a reference,
but you didn't pass one, you passed an array.

I hope that helps,
-- 
Jordan Katz <katz@underlevel.net>


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

Date: Thu, 24 Aug 2000 19:11:28 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Implicit passing of arrays with prototypes
Message-Id: <sqasr0fbt91159@corp.supernews.com>

In article <m3og2iwlq1.fsf@underlevel.underlevel.net>,
    Jordan Katz  <katz@underlevel.net> wrote:

: "John J. Lee" <phrxy@csv.warwick.ac.uk> writes:
: 
: > foo(@list);
:       ^^ You're passing a plain array.
: 
: > sub foo(\@) {
:           ^^ function `foo' expects a reference to an array, not just
:              an array.

Please go back and read the Prototypes section in the perlsub manpage.
You're dreadfully misinformed on the matter.

Greg
-- 
If a group of N persons implements a COBOL compiler, there will be N-1
passes.  Someone in the group has to be the manager.
    -- T. Cheatham


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

Date: Thu, 24 Aug 2000 21:51:13 GMT
From: "Graham Chapman" <g.chapman0749@home.com>
Subject: Re: MIME Mail help on NT - no sendmail!
Message-Id: <lNgp5.109619$c5.2407092@news2.rdc1.on.home.com>

Why not try the MIME::Lite module. I've got this working sending e-mails
(with attachments) OK on NT. There's an example in the associated
documentation about sending without sendmail.


Tracy Terrell <tracyterrell@entersysgroup.com> wrote in message
news:pD%o5.14250$C5.180407@typhoon.austin.rr.com...
> Hey folks, here is an easy one (I bet) ...
>
> I am trying to use MIME-Tools and MailTools to send mail w/ attachment
from
> an NT machine (Perl - ActiveState 5.6).  I am starting by trying to get
the
> example code from MIME::Entity to work, but as you can see it uses
sendmail
> to actually send the mail.  Can someone help me understand what I need to
do
> differently to send this MIME Entity using functionality offered by the
> MailTools module (which I think ultimately uses
> Net::SMTP)?
>
> Thanks for your time!
> Tracy
>
>
> use MIME::Entity;
>
> $top = build MIME::Entity Type    =>"text/plain",
>                           From    => "me@domain.com",
>                           To      => "you@domain.com",
>                           Subject => "Test Mime";
>
> attach $top  Path=>"./short.txt";
>
>
> # I'm looking for a "MailTools" replacement for this block.....
> open MAIL, "| /usr/lib/sendmail -t -i" or die "open: $!";
> $top->print(\*MAIL);
> close MAIL;
>
>
>
>
>
>




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

Date: Thu, 24 Aug 2000 14:41:52 -0700
From: Perrin Kliot <perrin@lacis.com>
Subject: Never Mind, I got it working
Message-Id: <39A596A0.6E523BE1@lacis.com>

Thanks for the help, this works perfect.

Perrin Kliot wrote:

> Thanks for the tip on Text::Wrap, unfortunatly I can't figure out how to get
> it to work. I found several examples online such as the one below but I can't
> get them to wrap the text. Is there something special I should know about
> using the module??
>
> use Text::Wrap;
>
> $Text::Wrap::columns = 20;
> $pre1 = "\t";
> $pre2 = "";
>
> print wrap( $pre1, $pre2, "Hello, world, it's a nice day, isn't it?\n" );
>
> Greg Bacon wrote:
>
> > In article <39A56E8C.912E839F@lacis.com>,
> >     Perrin Kliot  <perrin@lacis.com> wrote:
> >
> > : I have a long string that is taken from a <textarea> field and I want to
> > : insert a carriage return every 60 to 70 characters where there is a " ",
> > : I want to do this so when the string is printed is will wordwrap instead
> > : of being one long string. How can I do this.
> >
> > The standard Text::Wrap module can help you.
> >
> > Greg
> > --
> > The balance of power is the scale of peace.  The same balance would be
> > preserved were all the world destitute of arms, for all would be alike;
> > but since some will not, others dare not lay them aside . . .
> >     -- Thomas Paine, "Thoughts on Defensive War"



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

Date: 24 Aug 2000 19:19:06 GMT
From: soren@spmfoiler.removethat.wonderstorm.com (Soren Andersen)
Subject: Re: newbie question - dont flame me
Message-Id: <8o3sfb$n15$1@slb1.atl.mindspring.net>

filosmith@my-deja.com wrote in <8o35tr$dm4$1@nnrp1.deja.com>:

>I'm going to get a book or something.
>
>Thanks again,
>Filo

Yeah, that was an awesome piece of communal debugging. A joy to read.
-book(s)?
 the Camel (Programming Perl, auth. Wall, Christianson & Schwartz, publ. 
O'Reilly & Assoc), and Object Oriented Perl (auth. Damian Conway, publ. 
Manning).

   soren andersen
-- 
Using PNG-format images as Web BACKGROUNDs without
"breaking your Site" for silly older browsers:
http://www.wonderstorm.com/techstuff/
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Thu, 24 Aug 2000 20:31:08 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: newbie question about "uninitialized variables"
Message-Id: <39a5859e.9862423@news.earthlink.net>

On 23 Aug 2000 21:46:17 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:
>However, as CGI::Carp needs no
>special installation, you could also just extract the file from the
>archive and copy it to /home/username/perlmod/CGI/Carp.pm .
>
>In your script, you'd simply write:
>
>  use lib '/home/username/perlmod';
>  use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

I figured I could do something like this, but didn't want to take up
too much of people's time with follow questiosn.  Thanks Ilmari for
the module and the help.

Jon


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

Date: Thu, 24 Aug 2000 13:11:46 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: newbie:? string sub through an array
Message-Id: <39A56562.8DCE0842@texas.net>

Teodor Zlatanov wrote:
> 
> <8o0uof$s04$1@nnrp1.deja.com>:coughlan@gothaminteractive.com:comp.lang.perl.misc:Wed, 23 Aug 2000 16:39:46 GMT:quote:
> : What's the easiest way to do a string subtritution of "A" for "B"
> : throughout an array @myarray?
> 
> I like both
> map { s/A/B/ } @myarray;
> and
> s/A/B/ foreach @myarray;
> 
> depending on the context they can both be useful.

Both of those are *much* slower than Larry Rosler's previously posted
solution, which uses the 'tr' operator.

- Tom


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

Date: Thu, 24 Aug 2000 15:04:26 -0600
From: "tom" <tomw@convergentarts.com>
Subject: ODBC, MS Access and Unicode problems
Message-Id: <c4gp5.485$hb5.171288@news.uswest.net>

Hi All,

I have some data in Access 2000 which I need to display in a web page. It is
Japanese text, and stored as Unicode (Access default). I am using DBI:ODBC
to get the data, but it's getting mangled in the process. Here are the
relavant lines:

$dbh = DBI->connect('dbi:ODBC:catalog', { RaiseError => 1, AutoCommit =>
1 });

    snip

while ( @row = $StH->fetchrow_array ) {

    snip

And here is the html encoding portion:

print "<META HTTP-EQUIV='Content-Type' CONTENT='text/html;
charset=UTF-8'>\n";
print "<meta http-equiv='Content-language' content='jp'>";

All I'm getting is question marks. I've tried changing the encoding on my
browser and I can see Japanese on other pages. There don't seem to be any
settings for the Access driver. The system is NT 4, US/English. Any
suggestions greatly appreciated!

Thanks,
Tom




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

Date: 24 Aug 2000 20:26:09 GMT
From: cewatts@animas.frontier.net (Charlie Watts)
Subject: Re: Perl vs. other scripting languages
Message-Id: <slrn8qb170.kpl.cewatts@animas.frontier.net>

<godzilla@stomp.stomp.tokyo> wrote:
>Only flashing light our Makos have, is this red one which, not too
>often, appears in a rear view mirror, back there with the Mercedes.
>Ever drive at one-eighty across a deserted desert highway, T-tops
>down, tank top down, listening to Steppenwolf at five-hundred watts
>while eating frozen yogurt? A thrill I'll say.

I have nothing useful to add. I would just like to say that:

There is no way in hell that even a Mako Shark can do 180mph.

I don't care if you think it has 400hp.

Unless you meant kph.

I think this sort of absurdist exaggeration nicely sums up godzilla.

"I have a fun car, but I am not in touch with reality."

-- 
Charlie Watts                 Quidquid latine dictum sit, altum viditur.
cewatts@frontier.net         (Whatever is said in Latin sounds profound.)


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

Date: Thu, 24 Aug 2000 14:12:48 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Perl vs. other scripting languages
Message-Id: <39A58FD0.676267F0@stomp.stomp.tokyo>

Charlie Watts wrote:
 
> <godzilla@stomp.stomp.tokyo> wrote:
> >Only flashing light our Makos have, is this red one which, not too
> >often, appears in a rear view mirror, back there with the Mercedes.
> >Ever drive at one-eighty across a deserted desert highway, T-tops
> >down, tank top down, listening to Steppenwolf at five-hundred watts
> >while eating frozen yogurt? A thrill I'll say.

 
> I have nothing useful to add.

Boy, I'll say! * laughs *


> There is no way in hell that even a Mako Shark can do 180mph.

$his_comment =~ s/that//;
$his_comment =~ s/0m/0 m/;
 
Actually, this Mako Shark tops out around 200 miles per hour
well into red line 7 grand on my tachy meter. Hard to tell 
because the speedy meter stops at 160 miles per hour. Have
to guesstimate additional gradients beyond its marked limit.
I figure three-quarters of inch beyond 160 qualifies for
somewhere near 200 miles per hour, certainly 180.

You are a Hugo driver, right?

Godzilla!

--
"Give me 2 miles of open road, I'll give you 200."


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

Date: Thu, 24 Aug 2000 16:20:44 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Perl vs. other scripting languages
Message-Id: <39A591AC.ACE3132A@rac.ray.com>

Charlie Watts wrote:
> 
> <godzilla@stomp.stomp.tokyo> wrote:
> >Only flashing light our Makos have, is this red one which, not too
> >often, appears in a rear view mirror, back there with the Mercedes.
> >Ever drive at one-eighty across a deserted desert highway, T-tops
> >down, tank top down, listening to Steppenwolf at five-hundred watts
> >while eating frozen yogurt? A thrill I'll say.
> 
> I have nothing useful to add. I would just like to say that:


You don't hear watts (okay, you hear Charlie Watts), you hear
decibels. And if you come through my neighborhood playing anything
that loud on your cracked speakers and it DOESN'T have Charlie Watts
on it, I will shoot you. Heavy metal thunder my ass.


-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

But he can't be a man 'cause he doesn't use
the same release of Perl as me. - Mick Jagger - Perl-faq-tion


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

Date: Thu, 24 Aug 2000 19:34:36 GMT
From: perlnewbie@my-deja.com
Subject: Re: Please help, 1024 char limit writing to DB's?
Message-Id: <8o3tca$bb4$1@nnrp1.deja.com>



Thanks Eric and Paul I have downloaded and compiled Berkley Db and now
just have to install it on the server.  I will then look at how to use
DB_File to interact with Berkley DB.  I believe it I would use "tie".
Anyway I'll let you know how it works out thanks again for the input.


In article <8o17t1$81m$1@slb6.atl.mindspring.net>,
  ebohlman@netcom.com (Eric Bohlman) wrote:
> perlnewbie@my-deja.com wrote:
> : I am encountering an error when I try and write to a DB file in
WinNT
> : using Active Perl. Here is the error message I receive:
> :
> : "Tue Aug 22 09:54:07 2000: sdbm store returned -1, errno 22,
> : key "92"..."
> :
> : It seems that I am only allowed to write a maximum of 1024
characters.
>
> That's an inherent limit of SDBM.  Grab a copy of DB_File from
> ActiveState; it doesn't have this limit.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 24 Aug 2000 20:16:46 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Please wait... [was: Perl - Blinking Text]
Message-Id: <slrn8qb0k2.tj3.abigail@alexandra.foad.org>

Greg Bacon (gbacon@HiWAAY.net) wrote on MMDL September MCMXCIII in
<URL:news:sqadh2gut91134@corp.supernews.com>:
@@ 
@@ How about this?
@@ 
@@     sub bubbles {
@@         my @bubble = (' ', '.', 'o', 'O');
@@         my $len = 10;
@@         my $tank = join '',
@@                    map $bubble[rand @bubble],
@@                    1 .. $len;
@@ 
@@         my $tmp;
@@         while (1) {
@@             print "\rPlease wait $tank";
@@ 
@@             $tank =~ s/(OO+)/$tmp = ' ' x length $1;
@@                              substr($tmp, rand length $1, 1) = 'O';
@@                              $tmp/eg;
@@ 
@@             $tank =~ s/oo/     rand() < 0.5 ? 'O ' : ' O'/eg;
@@             $tank =~ s/\.\./   rand() < 0.5 ? 'o ' : ' o'/eg;
@@             $tank =~ s/Oo/     rand() < 0.5 ? 'O ' : ' O'/egi;
@@             $tank =~ s/\.o|o\./rand() < 0.5 ? 'o ' : ' o'/eg;
@@             $tank =~ s/\.O|O\./rand() < 0.5 ? 'oO' : 'Oo'/eg;
@@ 
@@             while (rand() < 0.6) {
@@                 substr($tank, rand $len, 1) = $bubble[rand @bubble];
@@             }
@@ 
@@             select undef, undef, undef, 0.2;
@@         }
@@     }


That seems to need a $| = 1.



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-


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

Date: 24 Aug 2000 20:44:16 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Please wait... [was: Perl - Blinking Text]
Message-Id: <967148459.17411@itz.pp.sci.fi>

In article <slrn8qaaf0.fkn.tjla@thislove.dyndns.org>, Gwyn Judd wrote:
>I was shocked! How could Ilmari Karonen <iltzu@sci.invalid>
>say such a terrible thing:
>>
>>  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
>>	   => pack "v" => $i while ++$i and sleep 1'
>>
>>  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
>>	   => pack "v" => $i^$i/2 while ++$i and sleep 1'
>
>rand $i makes a nice effect too :)

A bit too, well, random for my taste.  $i^$i/4 looks somewhat less
repetitive than the above two, yet sufficiently ordered that one could
probably stare at it quite some time trying to figure out the pattern.

Another somewhat simpler looking animation I came up with is:

  perl -e '$i=$|=1; print "\rPlease wait", grep tr/01/ ./ =>
           unpack "b*" => pack "V" => $i^=$i<<1 while sleep 1'

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"True, but the user receiving the e-mailed password might think
 'Strange, I don't remember choosing "&\xe7?\x9b\x3f\t\xef\xb7"
 as my password, and how do I type it?'"  -- Keith C. Ivey



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

Date: Thu, 24 Aug 2000 18:09:34 GMT
From: boopfm523@my-deja.com
Subject: PROBLEM: using REDIRCTS within IF statements
Message-Id: <8o3ocb$555$1@nnrp1.deja.com>

While learning Perl I have become stuck on one problem for a while and
can't find the answer anywhere (I can't give up..It haunts me).  Within
a IF-ELSIF-ELSE condition I am putting code to redirect the browser to
another perl script (I am not outputting any thing to the browser with
this perl script just redirecting to another perl script).  What I am
doing is passing in a variable that can only have two values 1 or 2.
Depending what the value is, it will direct me to a different perl
script which will then create an html page.  I included an ELSE
statement which will direct me to an special error page I made incase
the value passed in is not 1 or 2.  The perl script that the redirect
calls is the same for each redirect.  The only difference is this perl
script accepts a text document and will display an html page depending
on the contents of the text file.  The text file is basically used as a
filler for the body.

My problem is that no matter what the value is passed in, the brower is
always redirected to the ELSE error page.  I know it is not the syntax,
because if I comment out the redirect statements and write code to
output the value of the variable passed in, it goes to the correct IF
or ELSIF statement and works properly.  It will never go to the ELSE
error page.  I cannot figure out why.  I change it back and it goes
right back to the error page.I have looked in several books and asked
several employees who know Perl and they don't know why either.  In the
error log I get this:

[Thu Aug 24 13:04:36 2000] [error] [client 127.0.0.1] Premature end of
script headers: d:/program files/apache group/apache/cgi-bin/getjoke1.pl



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 24 Aug 2000 14:27:40 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: PROBLEM: using REDIRCTS within IF statements
Message-Id: <uitsqikf7.fsf@demog.berkeley.edu>


It is absolutely impossible to help you if you don't post code.

-- 
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
       aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------


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

Date: Thu, 24 Aug 2000 13:53:36 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Quick way to determine if a method is implemented in OO module
Message-Id: <39A58B50.39AF293E@ipac.caltech.edu>

Jeffrey Horn wrote:
> 
> Given an OO module, what is the fastest (best?) way to determine if the module
> implements a given method?
> 
> The specific case I have in mind is determining whether or not a DBD module
> implements the 'reauthenticate' method.  Is there a way to check the internal
> symbol table to look for given subroutines?

perldoc UNIVERSAL
perldoc perltootc

You're looking for the 'can' method.

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Thu, 24 Aug 2000 18:26:50 GMT
From: boopfm523@my-deja.com
Subject: REDIRECT PROBLEM
Message-Id: <8o3pcf$6dq$1@nnrp1.deja.com>

Why does this not work for the redirects (It always sends me to the
else).  But, if I comment out the redirects and uncomment the
print "$name...blah"; it works correctly.  Any ideas. I know it is not
the syntax.  Here is the shorted version of the perl code.

if ($value == 1)
{
   	print $out->redirect(url goes here);
	#print "$name went to value $value -- should be in value 1;
}
elsif ($value == 2)
{
   	print $out->redirect(url goes here);
	#print "$name went to value $value -- should be in value 2";
}
else
{
   	print $out->redirect(url goes here);
   	#print "$name went to ERROR";
}


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 24 Aug 2000 12:18:28 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: REDIRECT PROBLEM
Message-Id: <m18ztmxybf.fsf@halfdome.holdit.com>

>>>>> "boopfm523" == boopfm523  <boopfm523@my-deja.com> writes:

boopfm523> Why does this not work for the redirects (It always sends me to the
boopfm523> else).  But, if I comment out the redirects and uncomment the
boopfm523> print "$name...blah"; it works correctly.  Any ideas. I know it is not
boopfm523> the syntax.  Here is the shorted version of the perl code.

Too short.  How does $value get its value?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 24 Aug 2000 20:58:32 -0500
From: "Dietmar Staab" <dietmar.staab@t-online.de>
Subject: Re: RegEx
Message-Id: <8o3r9b$1d7$12$1@news.t-online.com>

In article <39A546D9.A50F4CB7@attglobal.net>, Drew Simonis
<care227@attglobal.net> wrote:
> zejames@my-deja.com wrote:

> where the regex is:
> 
> 	/(.*)
> 
> which says "match a leading slash followed by anything or nothing."
> There is no substitution, and the whole string obviously matches, so 
> that is what is assigned to $test.  What about this don't you
> understand?

Didn't understood the former question but I've another question:

$name = "/usr/local/bin/perl";
($test) = ( $name =~ m#/usr(/local)(.*)# );
print "$test\n";

If I leave $test without the parenthesis (scalar context) I got the number
of matches. But with ($test) I got the first backreference as result. Is
this a feature of perl's regexp or useless?

greetings, D.



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

Date: Thu, 24 Aug 2000 15:55:40 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: RegEx
Message-Id: <39A57DBC.94DDF723@attglobal.net>

Dietmar Staab wrote:
> 
> 
> Didn't understood the former question but I've another question:
> 
> $name = "/usr/local/bin/perl";
> ($test) = ( $name =~ m#/usr(/local)(.*)# );
> print "$test\n";
> 
> If I leave $test without the parenthesis (scalar context) I got the number
> of matches. But with ($test) I got the first backreference as result. Is
> this a feature of perl's regexp or useless?
> 

This behaviour is discussed (although not very completely IMO) in
the perlop manpage.

http://www.perl.com/pub/doc/manual/html/pod/perlop.html#Regexp_Quote_Like_Operators


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

Date: Thu, 24 Aug 2000 13:01:56 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: RegEx
Message-Id: <MPG.140f1f11b9e4483198acdc@nntp.hpl.hp.com>

In article <8o3r9b$1d7$12$1@news.t-online.com> on Thu, 24 Aug 2000 
20:58:32 -0500, Dietmar Staab <dietmar.staab@t-online.de> says...

 ...

> $name = "/usr/local/bin/perl";
> ($test) = ( $name =~ m#/usr(/local)(.*)# );
> print "$test\n";
> 
> If I leave $test without the parenthesis (scalar context) I got the number
> of matches. But with ($test) I got the first backreference as result. Is
> this a feature of perl's regexp or useless?

Of course it is a feature, and quite valuable too.  You will find it 
documented in perlop:

If the /g option is not used, m// in list context returns a list 
consisting of the subexpressions matched by the parentheses in the 
pattern, i.e., ($1, $2, $3...). 

> greetings, D.

Grüß!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 24 Aug 2000 16:26:59 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: RegEx
Message-Id: <39A58513.375280D3@attglobal.net>

Larry Rosler wrote:
> 
> Grüß!
> 

There's no reason to call someone a grub, is there?


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

Date: 24 Aug 2000 16:33:39 -0400
From: steveo@panix.com (Steven M. O'Neill)
Subject: Re: RegEx
Message-Id: <8o40r3$ie4$1@panix6.panix.com>

Drew Simonis  <care227@attglobal.net> wrote:
>Larry Rosler wrote:
>> 
>> Grüß!
>> 
>
>There's no reason to call someone a grub, is there?

Yeah!  That's groß!
-- 
Steven O'Neill                                         steveo@panix.com


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

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


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