[22446] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4667 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 5 14:06:03 2003

Date: Wed, 5 Mar 2003 11:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 5 Mar 2003     Volume: 10 Number: 4667

Today's topics:
        A problem about the time function <mlho@pc89132.cse.cuhk.edu.hk>
    Re: A problem about the time function <goldbb2@earthlink.net>
    Re: CGI query string help <wsegrave@mindspring.com>
    Re: CGI query string help <mothra@nowhereatall.com>
    Re: CGI query string help <REMOVEsdnCAPS@comcast.net>
    Re: CGI query string help <mothra@nowhereatall.com>
    Re: Counting matches in a regular expression <goldbb2@earthlink.net>
    Re: Counting matches in a regular expression <goldbb2@earthlink.net>
    Re: Early Perl source <newsfeed2@boog.co.uk>
        File::Tail problem <branco@markdata.pt>
    Re: Greedy regexps <somewhere@nowhere.com>
    Re: memory testing with Perl <Juha.Laiho@iki.fi>
    Re: memory testing with Perl <tzz@lifelogs.com>
    Re: memory testing with Perl <goldbb2@earthlink.net>
        Phonetic Module <jmcada@hotmail.com>
    Re: Playing a .wav file <zentara@highstream.net>
    Re: Playing a .wav file <ian@WINDOZEdigiserv.net>
    Re: Retrieving a Perl variable from a MySQL database <tzz@lifelogs.com>
    Re: Retrieving a Perl variable from a MySQL database (Tad McClellan)
    Re: Stolen! <newsfeed2@boog.co.uk>
    Re: XML to HTML <spam-block-@-SEE-MY-SIG.com>
    Re: XML to HTML (Tad McClellan)
    Re: XML to HTML <newsfeed2@boog.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 5 Mar 2003 17:56:44 GMT
From: Ho Man Lam <mlho@pc89132.cse.cuhk.edu.hk>
Subject: A problem about the time function
Message-Id: <b45dos$iel$1@eng-ser1.erg.cuhk.edu.hk>

In Unix/Linux, I can get the time since the Epoch (00:00:00 UTC, January 
1, 1970), measured in seconds by the command "date".

For example:

date -d "20030305 11:22:36" +%s

the command gives:
1046834556

I know there is a fuction "time" give current time when the function is 
called. But I want to get the seconds since the Epoch for a specific time.

Please help!

Ho Man Lam


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

Date: Wed, 05 Mar 2003 13:23:03 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: A problem about the time function
Message-Id: <3E664087.7D7D216A@earthlink.net>

Ho Man Lam wrote:
> 
> In Unix/Linux, I can get the time since the Epoch (00:00:00 UTC,
> January 1, 1970), measured in seconds by the command "date".
> 
> For example:
> 
> date -d "20030305 11:22:36" +%s
> 
> the command gives:
> 1046834556
> 
> I know there is a fuction "time" give current time when the function
> is called. But I want to get the seconds since the Epoch for a
> specific time.

Use the Time::Local module, and it's timelocal() function.

Or, Date::Manip or Date::Parse from CPAN.


-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print


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

Date: Wed, 5 Mar 2003 10:00:03 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: CGI query string help
Message-Id: <b457a4$rmb$1@slb0.atl.mindspring.net>

"Blnukem" <blnukem@hotmail.com> wrote in message
news:EUn9a.2612$gf7.924287@news4.srv.hcvlny.cv.net...
> Hi All
>
> When I use CGI and try to pass variables from a query string like this
> "www.mysite.com/script.pl.?name=jon&age= 43" they return empty. What am I
> doing wrong?
>
> #!/usr/local/bin/perl
>
> use strict;
> use CGI qw(:standard);
>
> $user_name = $query->param('name');
> $user_age = $query->param('age');

You are apparently not doing

perl -c script.pl

before trying to use the script. You must fix the errors before running the
script.

Your script, corrected:

From: "Blnukem" <blnukem@hotmail.com>
Subject: CGI query string help
Date: Wednesday, 05 March, 2003 8:33 AM

Hi All

When I use CGI and try to pass variables from a query string like this
"www.mysite.com/script.pl.?name=jon&age= 43" they return empty. What am I
doing wrong?

#!/usr/local/bin/perl -w
#  added -w

use strict;
use CGI qw(-no_xhtml :standard);
# added -no_xhtml prama

my $user_name = param('name');
my $user_age = param('age');
# removed undefined CGI object $query

print header, start_html, "$user_name is ", "$user_age years old.",
end_html;
# added something to do with the data

ISTM that, right after not reading the posting guidelines, the next
incorrect thing was failing to read the CGI.pm documentation, where you
would have found everything you needed to answer your own question.

1. Pick an approach, object-oriented or functional; and then use it
consistently, e.g., you attempted to employ a query object, $query, without
defining it.
2. Test from the command line, fixing errors until the script compiles and
executes correctly.

Good luck!

Bill Segraves




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

Date: Wed, 5 Mar 2003 09:10:53 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: CGI query string help
Message-Id: <3e662e32@usenet.ugs.com>


"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:b457a4$rmb$1@slb0.atl.mindspring.net...
> "Blnukem" <blnukem@hotmail.com> wrote in message
> news:EUn9a.2612$gf7.924287@news4.srv.hcvlny.cv.net...
[snipped]
> Your script, corrected:
>
> #!/usr/local/bin/perl -w
> #  added -w
>
> use strict;
> use CGI qw(-no_xhtml :standard);
> # added -no_xhtml prama
>
> my $user_name = param('name');
> my $user_age = param('age');
                             ^^^^^
should'nt that be url_param?
The params are in the url not the posted form

> # removed undefined CGI object $query
I missed that in my prev. response. Good catch :-)
>
> print header, start_html, "$user_name is ", "$user_age years old.",
> end_html;
> # added something to do with the data
>
> Good luck!
>
> Bill Segraves


Mothra




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

Date: Wed, 05 Mar 2003 11:23:27 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: CGI query string help
Message-Id: <Xns93357DF17AB6sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Mothra" <mothra@nowhereatall.com> wrote in news:3e662e32@usenet.ugs.com:

> 
> "William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
> news:b457a4$rmb$1@slb0.atl.mindspring.net...
>>
>> my $user_name = param('name');
>> my $user_age = param('age');
>                              ^^^^^
> should'nt that be url_param?
> The params are in the url not the posted form

url_param is only needed if parameters are given on the URL *and* the CGI 
is invoked via POST method, a questionable practice.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPmYyZ2PeouIeTNHoEQKGhACg1qBuRa+VQBUCHJXLNK9tWftJj/4An2Ha
M0FVkpDZWK+MR/vP8yMN668n
=Ow8s
-----END PGP SIGNATURE-----


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

Date: Wed, 5 Mar 2003 09:32:01 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: CGI query string help
Message-Id: <3e663326$1@usenet.ugs.com>

Hi Eric,

"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
news:Xns93357DF17AB6sdn.comcast@216.166.71.239...
>
> "Mothra" <mothra@nowhereatall.com> wrote in news:3e662e32@usenet.ugs.com:
>
> >
> > "William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
> > news:b457a4$rmb$1@slb0.atl.mindspring.net...
> >>
> >> my $user_name = param('name');
> >> my $user_age = param('age');
> >                              ^^^^^
> > should'nt that be url_param?
> > The params are in the url not the posted form
>
> url_param is only needed if parameters are given on the URL *and* the CGI
> is invoked via POST method, a questionable practice.

Thanks!! I did not know that!!

Mothra


>
> - --
> Eric




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

Date: Wed, 05 Mar 2003 11:54:07 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Counting matches in a regular expression
Message-Id: <3E662BAF.A8A98EFC@earthlink.net>

John W. Krahn wrote:
[snip]

Your code is significantly slower than it could be -- with a bit of
trimming, I was able to make it run in under a minute, and produce the
same information that yours does.  (Note that this information is not
quite what the OP asked for, but it's a start).

use strict;
use warnings;
use integer;

print localtime() . " Marking possible 3 digit combos.\n";

my $bitvec = "";
{
   # set a 1 for all 3-digit combos.
   for my $a ( 0 .. 46 ) { for my $b ( $a+1 .. 47 ) {
      vec( $bitvec, $a * 2401 + $b * 49 + $_, 1 ) = 1
         for $b+1 .. 48;
   }  }
}

print localtime() . " Unmarking winning 3 digit combos.\n";

open my $csv, '649.csv' or die "Cannot open 649.csv: $!";

# clear the 1 from those 3-digit combos
# which have ever won anything.
while ( <$csv> ) {
   # Discard ("649", row-id, date) from front.
   my (undef, undef, undef, @d) = split /,/;
   --$_ for @d; # scale 1..49 down to 0..48
   # sort put into canonical order.
   @d = sort {$a <=> $b} @d;
   for my $a ( 0 .. 4 ) { for my $b ( $a+1 .. 5 ) {
      vec( $bitvec, $d[$a] * 2401 + $d[$b] * 49 + $d[$_], 1 ) = 0
         for $b+1 .. 6;
   }  }
}

close $csv;

print localtime() . " Printing losing 3 digit combos.\n";

my $losers = 0;

# Print out those which haven't ever won anything.
while( $bitvec =~ m/[^\0]+/g ) {
   for my $i ( grep vec( $bitvec, $_, 1 ),  $-[0] * 8 .. $+[0] * 8 ) {
      ++$losers;
      print( 1 + ($i % 49), " " ), $i /= 49 for 1..3;
      print "\n";
   }
}
print localtime() . " There are $losers losers.\n";
__END__

Yes, this is a bit like your program, however:
  1/ I sort the data coming in from the csv.  If it's not in canonical
order, the results will be wrong.
  2/ Since the combinations are *always* of three elements, it's far
simpler to just use three nested for() loops than a combinations()
function.
  3/ Since there're 49 numbers, I use base 49.  This results in less
memory usage, which is something which *usually* speeds up programs, but
I'm not sure how that speedup compares to the cost of --$_ for @d;
  5/ I 'use integer' for a speedup.

The result is pretty damn fast:
Wed Mar  5 11:42:37 2003 Marking possible 3 digit combos.
Wed Mar  5 11:42:37 2003 Unmarking winning 3 digit combos.
Wed Mar  5 11:42:42 2003 Printing losing 3 digit combos.
 .... lots of lines ....
Wed Mar  5 11:42:42 2003 There are 414 losers.

-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print


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

Date: Wed, 05 Mar 2003 13:14:11 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Counting matches in a regular expression
Message-Id: <3E663E73.CD9E66B6@earthlink.net>

This is a multi-part message in MIME format.
--------------B2495D980355E86B657BF971
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Barty wrote:
[snip]
> 
> It's running now..  Looks like it will take around two hours (on my
> athlon 1400) which is better than I though it would be!  If anyone
> would like to play with it, here's my code:
>    http://www.ianbishop.ca/649.zip

I've attached my own code, and the output of one run.

There couldn't *really* have only been 24 six-digit-combos which didn't
get at least 3 digits in common with a winning draw, could there?

And the whole thing finishes in 4 seconds -- is that possible?

If my algorithm is wrong, does anyone have a guess as to the problem?

And if it's right -- nyah nyah, my code's faster than yours is :P

-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
--------------B2495D980355E86B657BF971
Content-Type: application/x-perl;
 name="bar.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="bar.pl"

use strict;
use warnings;
use integer;

print localtime() . " Marking winning combos.\n";

my $bitvec = "";

open my $csv, '649.csv' or die "Cannot open 649.csv: $!";

while ( <$csv> ) {
   # Discard ("649", row-id, date) from front.
   my (undef, undef, undef, @d) = split /,/;
   --$_ for @d; # scale 1..49 down to 0..48
   # sort into canonical order.
   @d = sort {$a <=> $b} @d;
   for my $a ( 0 .. 3 ) { for my $b ( $a+1 .. 4 ) {
      vec( $bitvec, $d[$a] * 2401 + $d[$b] * 49 + $d[$_], 1 ) = 1
         for $b+1 .. 5;
   }  }
}

close $csv;

# Generate some code.

my $code = "";

my @subsets;
for my $a ( 0 .. 3 ) { for my $b ( $a + 1 .. 4 ) {
   push @subsets, [$a, $b, $_] for $b + 1 .. 5;
} }

for my $index ( 0 .. 5 ) {
   my $p = $index - 1;
   $code .= sprintf qq[for my \$i%s ( %s .. %d ) {\n],
      $index, ($index ? "\$i$p + 1" : 0), 48 - 5 + $index;
   $code .= "   " . join(" ||\n   ", map sprintf(
       q[vec( $bitvec, $i%d * 2401 + $i%d * 49 + $i%d, 1 )],
       @$_ ), grep $index == $_->[2], @subsets ) . " and next;\n"
       if $index >= 2;
}
$code .= q{
   print "$i0, $i1, $i2, $i3, $i4, $i5\n";
};
$code .= "}}}}}}\n";

print localtime() . " Printing losing combos.\n";

eval "$code; 1" or die $@;

print localtime() . " Done.\n";
__END__


--------------B2495D980355E86B657BF971
Content-Type: text/plain; charset=us-ascii;
 name="bar.out.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="bar.out.txt"

Wed Mar  5 13:00:15 2003 Marking winning combos.
Wed Mar  5 13:00:19 2003 Printing losing combos.
1, 25, 29, 46, 47, 48
1, 25, 39, 46, 47, 48
1, 27, 34, 42, 47, 48
4, 6, 43, 44, 47, 48
5, 21, 39, 44, 47, 48
5, 24, 28, 44, 45, 48
5, 24, 28, 44, 46, 48
5, 24, 28, 46, 47, 48
5, 25, 43, 44, 46, 48
7, 28, 37, 43, 46, 48
8, 18, 42, 46, 47, 48
8, 29, 42, 46, 47, 48
9, 24, 27, 45, 47, 48
10, 14, 16, 46, 47, 48
10, 16, 20, 46, 47, 48
10, 16, 38, 46, 47, 48
10, 20, 37, 46, 47, 48
10, 26, 37, 46, 47, 48
11, 16, 26, 46, 47, 48
17, 31, 39, 45, 47, 48
18, 24, 27, 42, 47, 48
18, 24, 27, 46, 47, 48
18, 24, 42, 46, 47, 48
18, 27, 43, 46, 47, 48
Wed Mar  5 13:00:19 2003 Done.

--------------B2495D980355E86B657BF971--



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

Date: Wed, 5 Mar 2003 18:53:40 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: Early Perl source
Message-Id: <2Ir9a.13630$EN3.109345@newsfep4-glfd.server.ntli.net>

John Krahn wrote:
> http://www.etla.org/retroperl/

I just wanted to thank you guys for the URLs, I've checked them all out and
found some classic files to get :-)

Cheers,
Pete




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

Date: Wed, 05 Mar 2003 17:43:35 +0000
From: Nuno Branco <branco@markdata.pt>
Subject: File::Tail problem
Message-Id: <bHq9a.4764$ZG4.2789446@newsserver.ip.pt>


I am writing an application to monitor log files and i am using FILE::Tail
to help me with that.

My problem is that randomly (sometimes is once a day, other times is once a
week) all the file that I am "tailing" gets dumped on my screen since it
was opened.

I have nothing (or at least i think so) on my cronjobs that could be
trigering this. I tought maybe logrotate could be doing it but it's not the
case.

Does someone else had similar problems with file::tail ? The manpage i read
says nothing about it.

-- 
Best Regards,
Nuno Branco




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

Date: Wed, 5 Mar 2003 16:09:00 -0000
From: "Bigus" <somewhere@nowhere.com>
Subject: Re: Greedy regexps
Message-Id: <b457et$paa@newton.cc.rl.ac.uk>

David K. Wall wrote:
> Bigus <somewhere@nowhere.com> wrote on 05 Mar 2003:
>
>> Abigail wrote:
>>> People should stop thinking it's easy to parse HTML with a single
>>> regexp. It's not. Parsing is far, far easier.
>
>> I do understand that parsing HTML isn't easy if you are to take
>> into account all the possible complications as identified in the
>> CPAN FAQ, however, I think for my purposes half a dozen lines of
>> regexps will work nicely to preprocess the HTML pages ready for
>> keyword searching. Covering "all likely possibilities" is enough..
>> if I do spot something at a later date that I've not taken into
>> account then I can make the necessary correction.
>
> Unless it's HTML you've written yourself, you may be tweaking your
> program for a long time, depending on the whim of the person or
> program writing the HTML.
>
> On the other hand, I use regexes on HTML myself, but always with HTML
> *I* wrote and (usually) pre-processed with HTML Tidy
> <http://tidy.sourceforge.net/> to get it into a predictable format.

Yes, they're all my pages, so it should be OK.. and in all the pages I've
marked the searchable area of the page with comments and the area within is
all straight forward HTML, so it should be fine.

Spencer




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

Date: Wed, 05 Mar 2003 16:32:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: memory testing with Perl
Message-Id: <b458i8$l96$1@ichaos.ichaos-int>

"Dick Penny" <penny1482@attbi.com> said:
>> Ted Zlatanov <tzz@lifelogs.com> wrote:
>> On linux, I do $size = (split ' ', `ps -p $$ -o rss `)[1] ;
>
>Am sort of a newbie on a Win2K platform,  I do recognize $$, it is in Perl
>docs, but
>what is ps
>what is -p
>what is -o
>what is rss
>and what does this whole string represent?

As such it's meaningless on Windows side; with Unix (and like) systems
it'll return the "resident set size" of the calling process. So, how much
of its overall address space does this process have mapped in real memory
at this moment (real memory as opposed to the paging area).
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Wed, 05 Mar 2003 12:13:47 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: memory testing with Perl
Message-Id: <4n7kbdbut0.fsf@lockgroove.bwh.harvard.edu>

On 04 Mar 2003, ctcgag@hotmail.com wrote:
> Ted Zlatanov <tzz@lifelogs.com> wrote:
>> The key feature is that I'd like to know when the script
>> has reached, let's say, 512MB of memory usage.
> 
> On linux, I do $size = (split ' ', `ps -p $$ -o rss `)[1] ;
> to get the approximate memory size in kilobytes.  I don't know what
> you use on windows.

Hmm, yes, I was hoping to grab the amount of memory Perl itself knows
it's using - it must track the amount of memory allocated, since it
has a garbage collector.

>> I've assumed so far
>> that every element is just a little larger than its contents
> 
> Very bad assumption.  I've brought our server to it's knees on that
> assumption before.  (Tie::Cache can underestimate memory consumption
> by a factor of 6 or more, if you have deep data structures with
> small contents.)

You are right in general, but in my particular case I was doing

push @array, "0123456789ABCDEF";

without any deep structures, so this doesn't apply so strongly.

Thanks
Ted


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

Date: Wed, 05 Mar 2003 13:33:23 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: memory testing with Perl
Message-Id: <3E6642F3.F57AAAB8@earthlink.net>

Ted Zlatanov wrote:
[discussion of size of data]
> You are right in general, but in my particular case I was doing
> 
> push @array, "0123456789ABCDEF";
> 
> without any deep structures, so this doesn't apply so strongly.

Your 16-character string is 17 bytes (perl always keeps strings '\0'
terminated, to make it easier to pass them to C library functions which
expect cstrings... even if it doesn't use this '\0' itself), plus some
extra due to malloc going to (IIRC) 16 byte boundaries, so that the
char-pointer part of the scalar is 32 bytes.

Plus an additional overhead of 24 bytes.

That's a total of 56 bytes, for a string that's 16 letters long.

True, this is much less than the 'factor of 6' that I snipped, but it's
still quite a bit.


-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print


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

Date: Wed, 05 Mar 2003 17:15:23 GMT
From: "Josh McAdams" <jmcada@hotmail.com>
Subject: Phonetic Module
Message-Id: <Lgq9a.937$kP1.493474932@newssvr12.news.prodigy.com>

Does anyone know of a word/text recognition module that handles multiple
languages.  All that I've found so far is Text::SoundEx and Text::Metaphone,
but they seem to be limited to English sounds.

Thanks in advance,
Josh




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

Date: Wed, 05 Mar 2003 11:33:14 -0500
From: zentara <zentara@highstream.net>
Subject: Re: Playing a .wav file
Message-Id: <8k9c6vsfi2o14nosrc3ho5284ep6cln3pk@4ax.com>

On Tue, 04 Mar 2003 13:06:08 GMT, "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
wrote:

>
>Does anyone know of a method/function that'll enable a wav file to be
>played on a certain event?

Check out SDL. http://libsdl.org

Here is a simple wav player.  The sleep statement
is a hack to simulate a event loop like in Tk or an SDL app.
It's a nice module, you can run it from Tk, and play sounds
or music based on events like mouse clicks.


#!/usr/bin/perl -w
use SDL::Mixer;
use SDL::Music;

$mixer = eval { SDL::Mixer->new(-frequency => 44100, -channels => 2,
-size => 1024); };

$mixer->music_volume(100);
$music = new SDL::Music './1bb.wav' or die $!;
$mixer->play_music($music,2);  # 0 for single play

while(1){
if( $mixer->playing_music() ){sleep(1)}else{ last}
}







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

Date: Wed, 05 Mar 2003 16:43:12 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: Playing a .wav file
Message-Id: <47ac6v0lq96alv7tghdnh90mlunsc4rlu3@4ax.com>
Keywords: Remove WINDOZE to reply

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on Wed, 05 Mar 2003 11:33:14 -0500, zentara
<zentara@highstream.net> managed to scribble:

> On Tue, 04 Mar 2003 13:06:08 GMT, "Ian.H [dS]"
> <ian@WINDOZEdigiserv.net> wrote:
> 
> >
> >Does anyone know of a method/function that'll enable a wav file to
> >be played on a certain event?
> 
> Check out SDL. http://libsdl.org
> 
> Here is a simple wav player.  The sleep statement
> is a hack to simulate a event loop like in Tk or an SDL app.
> It's a nice module, you can run it from Tk, and play sounds
> or music based on events like mouse clicks.
> 
> 
> #!/usr/bin/perl -w
> use SDL::Mixer;
> use SDL::Music;
> 
> $mixer = eval { SDL::Mixer->new(-frequency => 44100, -channels =>
> 2, -size => 1024); };
> 
> $mixer->music_volume(100);
> $music = new SDL::Music './1bb.wav' or die $!;
> $mixer->play_music($music,2);  # 0 for single play
> 
> while(1){
> if( $mixer->playing_music() ){sleep(1)}else{ last}
> }
> 


This looks great zentara.. simple and compact too.

Much appreciated =)



Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPmYpHmfqtj251CDhEQK0RwCdGvC+p9eOPj2tU4EjiP46W5Zo/2YAnjR8
z04F07DDtNB7q9S7F9xOBb4R
=qC/g
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.


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

Date: Wed, 05 Mar 2003 12:17:17 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Retrieving a Perl variable from a MySQL database
Message-Id: <4n4r6hbun6.fsf@lockgroove.bwh.harvard.edu>

On Wed, 5 Mar 2003, nospam@nospam.org wrote:
> I have a MySQL database that contains a string like this:
> 
> "Hello, $username"
> 
> If I define $username in my code and then retrieve the string from
> the database, when I print it, it prints:
> 
> "Hello, $username"
> 
> but I would want:
> 
> "Hello, somename" (because $username can be assigned to any names).
> 
> I tried to eval the string before printing it, but it still displays
> "$username" instead of "somename".

It's much safer to use %s and sprintf, imagine what happens if someone
accesses your database - they could put arbitrary code to be executed
in there!

[say, $database_string is "Hello, %s"]

my $output = sprintf ($database_string, $username);

Also, look at the Class::DBI module, it may work better for you than
direct DBI access for what you're doing.

Ted


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

Date: Wed, 5 Mar 2003 12:05:52 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Retrieving a Perl variable from a MySQL database
Message-Id: <slrnb6cf40.4f8.tadmc@magna.augustmail.com>

Christian Caron <nospam@nospam.org> wrote:

> I have a MySQL database that contains a string like this:
> 
> "Hello, $username"


> I tried to eval the string before printing it, but it still displays
> "$username" instead of "somename".


> Anyone have an idea?


   perldoc -q variable

      "How can I expand variables in text strings?"


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


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

Date: Wed, 5 Mar 2003 18:51:55 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: Stolen!
Message-Id: <1Ir9a.13629$EN3.109345@newsfep4-glfd.server.ntli.net>

> > Anyone got any really up to date benchmarks?
>
> I'd hope to see a benchmark showing mod_perl 2.0 and mod_php 4, on the
> same hardware and OS.

If someone thinks they can write a suitable, small, program for both systems,
I'm sure quite a few of us here would be willing to run tests on our own servers
to check it out.

Of course, it'd be of the essence to make sure both scripts use the same
methods, or do the same task (say, get a row from a MySQL table and repeat 1000
times or something). I don't know PHP at all, so I couldn't write such a script
myself.

It'd be interesting to have some real benchmarks on this.

Cheers,
Pete




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

Date: Wed, 5 Mar 2003 17:56:05 +0000
From: James Taylor <spam-block-@-SEE-MY-SIG.com>
Subject: Re: XML to HTML
Message-Id: <ant0517051cbfNdQ@oakseed.demon.co.uk>

In article <uTf9a.37222$V42.11374@nwrddc03.gnilink.net>,
Jürgen Exner <jurgenex@hotmail.com> wrote:
> 
> Peter Cooper wrote:
> > 
> > Tore Aursand wrote:
> > > 
> > > Why don't you just (...) write a stylesheet for the XML file?
> >
> > Varying browser support and various browser inconsistencies might be
> > the problem with that method.
> 
> Why? You can apply the XSL locally, just like you would run the
> Perl script locally.

Forgive my ignorance but I don't follow this. What tool
would you use to "apply" the XSL locally? And why would that
help with the basic problem of converting XML to HTML?

My HTML3.2 vintage browser predates XML/XSL so could not do this
unaided. Surely, I would need a program to perform the conversion.

-- 
James Taylor, Cheltenham, Gloucestershire, UK.       PGP key: 3FBE1BF9
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use james at oakseed demon co uk.



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

Date: Wed, 5 Mar 2003 12:08:59 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: XML to HTML
Message-Id: <slrnb6cf9r.4f8.tadmc@magna.augustmail.com>

James Taylor <spam-block-@-SEE-MY-SIG.com> wrote:
> In article <uTf9a.37222$V42.11374@nwrddc03.gnilink.net>,
> Jürgen Exner <jurgenex@hotmail.com> wrote:
>> 
>> Peter Cooper wrote:
>> > 
>> > Tore Aursand wrote:
>> > > 
>> > > Why don't you just (...) write a stylesheet for the XML file?
>> >
>> > Varying browser support and various browser inconsistencies might be
>> > the problem with that method.
>> 
>> Why? You can apply the XSL locally, just like you would run the
>> Perl script locally.
> 
> Forgive my ignorance but I don't follow this. What tool
> would you use to "apply" the XSL locally? 


He meant "on the server side".


> And why would that
> help with the basic problem of converting XML to HTML?


That is not the problem that doing it server-side helps with.

The "Varying browser support" problem is the problem it helps
with, as it the data is plain-old-HTML by the time it gets
to the browser.



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


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

Date: Wed, 5 Mar 2003 18:49:33 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: XML to HTML
Message-Id: <0Ir9a.13628$EN3.109345@newsfep4-glfd.server.ntli.net>


"Tad McClellan" <tadmc@augustmail.com> wrote:
> >> Why? You can apply the XSL locally, just like you would run the
> >> Perl script locally.
> >
> > Forgive my ignorance but I don't follow this. What tool
> > would you use to "apply" the XSL locally?
>
> He meant "on the server side".
<snip>
> The "Varying browser support" problem is the problem it helps
> with, as it the data is plain-old-HTML by the time it gets
> to the browser.

And this brings us straight back to the original poster's request.. << I have a
2.5 MB XML file I'd like to convert to HTML to be viewed in a browser >> to
which Tore said << just (...) write a stylesheet for the XML file >>.

Or, are you saying that there's an Apache module, or such, that can do this
translation without user interaction?

Pete




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 4667
***************************************


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