[22867] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5088 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 7 14:05:53 2003

Date: Sat, 7 Jun 2003 11:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 7 Jun 2003     Volume: 10 Number: 5088

Today's topics:
    Re: and if I killed this programmer *I'd* go to jail.. (Bhaskar Kurapati)
    Re: Building Threaded List of Newsgroup Headers <cpryce@pryce.nospam.net>
    Re: Changing form output <drumspoorly@reachone.net>
    Re: Converting numerical character references to Unicod <apollock11@hotmail.com>
    Re: Converting numerical character references to Unicod <noreply@gunnar.cc>
    Re: Converting numerical character references to Unicod <flavell@mail.cern.ch>
        extracting text in <TABLE> <Snygg@gmx.net>
    Re: extracting text in <TABLE> <Snygg@gmx.net>
    Re: extracting text in <TABLE> (Graham Smith)
    Re: Help with XML::Simple (Graham Smith)
        how to find no of elements in array/hash/array passed t (Bhaskar Kurapati)
    Re: how to find no of elements in array/hash/array pass <bigj@kamelfreund.de>
    Re: how to find no of elements in array/hash/array pass <grazz@pobox.com>
    Re: how to find no of elements in array/hash/array pass <jurgenex@hotmail.com>
    Re: how to find no of elements in array/hash/array pass (Tad McClellan)
    Re: how to find no of elements in array/hash/array pass <bob@nowhere.com>
    Re: how to find no of elements in array/hash/array pass <noreply@gunnar.cc>
    Re: how to find no of elements in array/hash/array pass <noreply@gunnar.cc>
        Newbie: Looking for MP3 script to trucate/fade my mp3 c <hurrells@tbaytel.net>
    Re: redirect location prints to screen <flavell@mail.cern.ch>
        Safe.pm doesn't catch match? <bob@nowhere.com>
    Re: Safe.pm doesn't catch match? <bob@nowhere.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Jun 2003 00:44:11 -0700
From: bhas_kurapati@yahoo.com (Bhaskar Kurapati)
Subject: Re: and if I killed this programmer *I'd* go to jail..
Message-Id: <3c0c6539.0306062344.7d02e6c4@posting.google.com>

Ummmm ... ,

I think he was not paid well !!!

Bhaskar


genericax@hotmail.com (Sara) wrote in message news:<776e0325.0306050958.319bfc19@posting.google.com>...
> This is one of the less ugly examples what I've inherited from my
> "ancestral" programmers here. I think he must have had a C-to-Perl
> script he ran to produce his Perl Code..
> 
> 805:       for($i=0;$i<=$#g_INFO;$i++){
> 806:          if($g_INFO[$i][$x_ID] ne $id){  next; }
> 807:          @tmp1 = split(/;/,$g_INFO[$i][$_TEXT]);
> 808:          for($j=0;$j<=$#tmp1;$j++){
> 809:             $tmp1[$j] =~ s/^(\s)*//g;
> 810:             @tmp2 = split(/,/,$tmp1[$j]);
> 811:             if($tmp2[0] == $level){  return "$tmp2[1]";     } 
> 
> I'll be in rehab before this project is though.. ACK....
> 
> Gx


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

Date: Sat, 07 Jun 2003 14:21:55 GMT
From: cp <cpryce@pryce.nospam.net>
Subject: Re: Building Threaded List of Newsgroup Headers
Message-Id: <070620030921551507%cpryce@pryce.nospam.net>

In article <060620030904299472%cpryce@pryce.net>, cp <cpryce@pryce.net>
wrote:

[ snip pprevious message with sample data ]

My solution follows ( 94 lines of code) follows. Most error checking is
removed to keep the code example short . I'd appreciate feedback, or
some advice as to whether this is the right approach.

Thanks 

#!/usr/bin/perl 

use warnings;
use strict; 

use Net::NNTP; 
use CGI qw(:standard *table); 
# config 
my $NNTP    = "news.viecon.com";    # news-server
my $MAX     = '50';                 # max post to fetch with an xover

# Grab some user input
my $group   = param('group') || 'bentley.testposts'; 
my $cur     = param('current'); 

my $nntp = Net::NNTP->new($NNTP);
printError( "News Server Connection Failed" ) unless $nntp; 
$nntp->reader if $nntp;

my ( $total, $first, $last, undef) = $nntp->group( $group ); 
$cur ||= $first; 

my $max = $cur + $MAX; 
$max = $total if $max > $total; 

my $msg = $nntp->xover( [ $cur, $max ] ); 
my $msg_list = {};

foreach (sort keys %$msg ) { 
    my( $id, $message, @moms ) = prep_message( $msg->{ $_ } ); 
    # @moms hold the references to previous messages
    if ( @moms ) { 
        # if there are moms, we walk the message list 
        my $child = $msg_list->{ shift @moms }{kids}; 
        while ( @moms ) { 
            $child = $child-> { shift @moms }{kids} 
        } 
        $child->{ $id } = $message; 
    }
    else { 
        # We are the mom if there are no other mothers
        $msg_list->{ $id } = $message; 
    }
}

my $code; # global to store the list of messages
my $indent = 0; 
make_list( $msg_list ); 

print header(), start_html('message list'), h1( $group ),
    "<ul>", $code, "</ul>", end_html();
exit;

sub prep_message { 
    my ($array_ref, $art) = @_; 
    # my $date = user_pref_datefmt( $array_ref->[2] ); 
    
    my $message = { subject =>  $array_ref->[0],
                    from    =>  $array_ref->[1],
                    date    =>  $array_ref->[2],
                    number  =>  $art,
                    kids    => {}
                }; 
    my @moms = split/ /, $array_ref->[4]; 
    return ($array_ref->[3], $message, @moms); 
} 

sub make_list { 
    my $self = shift; 
    my $s = script_name(); # the url of the script
    return unless ref $self eq 'HASH';

    foreach my $kid ( keys %$self ) { 
        my $list = $self->{ $kid }; 
        # store a row of data
        $code .= qq(
        <li style="text-indent: ${indent}em"><a href="$s?$kid">
            $list->{subject}</a></li> 
        ); 
        
        if ( keys %{ $list->{kids} } ) { 
            $indent ++; # begin recursing 
            make_list( $list->{kids} ) ; 
        } 
    }
    $indent --;
}

printError { 
    my $msg = shift; 
    print header(), start_html('error'), p( $msg ), end_html;
    die $msg;
    exit;
}


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

Date: Sat, 07 Jun 2003 00:21:39 -0700
From: Steve May <drumspoorly@reachone.net>
Subject: Re: Changing form output
Message-Id: <ve346jmo985t0b@corp.supernews.com>

Steve wrote:

<snip>

> 
> 
> Please excuse if I have offended anyone,
>  

Offense? I think exasperation might be closer.


> I am still at a loss as to where the idea that my question was
> 'DEMANDING' comes from. I have re-read it and I simply asked a
> question not unlike any other question in this forum. In return I
> hoped that some one would assist me?
> 

Ah.... no.

You posted a mail sending routine.  Presumably you were looking for a
way to format '$message' prior to calling the routine, though that's not
absolutely certain since you did *not* post any code dealing with the
format issue as far as I can see.

Folks here are incredibly patient with boneheaded mistakes and errors in
thinking IF it's clear the poster is at least trying..... I have
personal experience on that one, trust me.  True, you will often only
get a reference to the pertinent documentation, but getting a handle
on the docs is 90% of learning any programming language IMHO.

But when someone seems to be asking for a whole-cloth answer,
well, that does tend to rile the natives. :-)


> As for your reference as to being burnt out from answering other
> peoples questions, why do you answer so negativley? would it be better
> to just not answer at all.
> 

A number of regulars often lose patience with posters who don't seem
to have done their homework.

Your post qualified in Gunnar's judgement...... and I'm not so sure
he was wrong.

Anyway, you now have two choices:

1. Get angry and refuse to learn from this little exchange.
2. On your next post ask for a hand-up instead of a hand-out.

Up to you, though the long term results of No. 2 should be much
more beneficial....


s.





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

Date: Sat, 07 Jun 2003 09:44:52 -0700
From: Arvin Portlock <apollock11@hotmail.com>
Subject: Re: Converting numerical character references to Unicode
Message-Id: <bbt4q7$s07$1@agate.berkeley.edu>

Gunnar Hjalmarsson wrote:

> Arvin Portlock wrote:
>
> > Say I'm given a hexadecimal numerical character reference:
> > "©". How can I turn this into the equivalent unicode
> > character: "©"?
>
> One idea:
>
>     my $string = '&#x00A9;';
>     print chr oct $1 if $string =~ /&#(\w+);/;
>
> / Gunnar

Nah, doesn't work. It just prints out © and not ©.



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

Date: Sat, 07 Jun 2003 19:21:19 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Converting numerical character references to Unicode
Message-Id: <bbt6vf$ch9bg$1@ID-184292.news.dfncis.de>

Arvin Portlock wrote:
> Gunnar Hjalmarsson wrote:
>>Arvin Portlock wrote:
>>> Say I'm given a hexadecimal numerical character reference:
>>> "©". How can I turn this into the equivalent unicode
>>> character: "©"?
>>
>> One idea:
>>
>>     my $string = '&#x00A9;';
>>     print chr oct $1 if $string =~ /&#(\w+);/;
> 
> Nah, doesn't work. It just prints out © and not ©.

That may be because the Unicode value 'x00A9' represents just the 
character ©. Unicode for  is 'x00C2'. I thought that the occurrence 
of the  character in your question was a typo. ;-)

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 7 Jun 2003 19:28:07 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Converting numerical character references to Unicode
Message-Id: <Pine.LNX.4.53.0306071902360.11037@lxplus081.cern.ch>

On Fri, Jun 6, Arvin Portlock inscribed on the eternal scroll:

| Content-Type: text/plain; charset=ISO-8859-1; format=flowed

> Say I'm given a hexadecimal numerical character reference:
> "&#x00A9;". How can I turn this into the equivalent unicode
> character: "©"?

I'm afraid we already have some evidence here that you're confused.
That's OK: it's a common enough condition, but I'd suggest you need
a bit of reading-around the topic first.

What you posted there was a pair of octets (bytes) which, due to the
posting's MIME header, allegedly represented a pair of iso-8859-1
8-bit characters.

What I suspect you _intended_ to post was a single Unicode character
represented in utf-8 encoding (this particular character needs two
octets in utf-8 coding: utf-8 characters can require one, two or more
octets, theoretically up to a maximum of six).

You need to know that a "unicode character" is a theoretical concept,
that can exist in various embodiments.

Current versions of Perl work internally with unicode characters, when
necessary.  When you want to express such a character externally, you
need to make it clear just how you want it coded.

I'd recommend starting with perluniintro,
http://www.perldoc.com/perl5.8.0/pod/perluniintro.html
and if the answer to your question isn't then obvious,
you might want to dip into
http://www.perldoc.com/perl5.8.0/pod/perlunicode.html

Even if you don't want to struggle that far - at least you'd be in a
better position to describe what you want to achieve (I was only
guessing when I surmised that you wanted utf-8-coded output).

> Something like print "\x{00A9}"; only works
> at compile time, it doesn't take a variable as an argument.
> I couldn't figure out how to do it using chr() as the
> documentation suggests.

Now, here you have me confused.  I think you owe us a short test
program which runs without errors or warnings, and demonstrates what
you were asserting.

Both of them should produce the same internal representation.  If you
output them in a situation where the Perl system thinks you want
iso-8859-1 coding as output, then you should get a single octet of
value hex A9, but this, you say, is not what you want.  If you tell
the Perl system that you want utf-8 coded output, then you should get
utf-8-coded output.

Code snippet:

my $foo = chr(169);
print "|\x{00A9}|$foo|\n";

binmode STDOUT, ":utf8";
print "|\x{00A9}|$foo|\n";

Output (here I'm pasting raw octets into my iso-8859-1-coded
posting, just what I was complaining about before, but it's to
make a point):

|©|©|
|©|©|

But I urge you, don't just paste this into your solution: take a
moment to understand what you're doing - it'll stand you in good stead
later.

cheers



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

Date: Sat, 07 Jun 2003 09:31:41 +0200
From: Stefan Glimne <Snygg@gmx.net>
Subject: extracting text in <TABLE>
Message-Id: <3ee1953f$0$6799$9b4e6d93@newsread4.arcor-online.net>

Hi there,

I'm quite new when it comes to handling Modules (Can't really understand 
sometimes what they write on the pages at http://www.cpan.org ). So my 
question is:

Can someone provide a very simple example on how to extract text that 
are within a TABLE in a html-document? Or perhaps more general for any 
tag. I know it's possible, but sometime I can't read obviously ... ;)

Thank U in advance

Stefan



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

Date: Sat, 07 Jun 2003 14:07:36 +0200
From: Stefan Glimne <Snygg@gmx.net>
Subject: Re: extracting text in <TABLE>
Message-Id: <3ee1d5ea$0$6797$9b4e6d93@newsread4.arcor-online.net>

Here is a solution I found:

use lib qw( ..);
use HTML::TableExtract;
use LWP::Simple;

my $te  = new HTML::TableExtract( subtables );

my $content = get("http://??.com/page.html");

$te->parse($content);

# Examine all matching tables
foreach $ts ($te->table_states) {
   foreach $row ($ts->rows) {
     $count = -1;
     foreach $key (@$row) {
       $count += 1;
       print "$count: $key\n";
     }
   }
}

> Hi there,
> 
> I'm quite new when it comes to handling Modules (Can't really understand 
> sometimes what they write on the pages at http://www.cpan.org ). So my 
> question is:
> 
> Can someone provide a very simple example on how to extract text that 
> are within a TABLE in a html-document? Or perhaps more general for any 
> tag. I know it's possible, but sometime I can't read obviously ... ;)
> 
> Thank U in advance
> 
> Stefan
> 



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

Date: 7 Jun 2003 07:39:58 -0700
From: grehom@ntlworld.com (Graham Smith)
Subject: Re: extracting text in <TABLE>
Message-Id: <98eb7f13.0306070639.274a4a19@posting.google.com>

use HTML::TokeParser;

have a look at the examples contained within: 
   
   perldoc html::tokeparser


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

Date: 7 Jun 2003 07:27:36 -0700
From: grehom@ntlworld.com (Graham Smith)
Subject: Re: Help with XML::Simple
Message-Id: <98eb7f13.0306070627.6523aa45@posting.google.com>

Much as I like nested arrays and hashes of references to same I'd be
tempted to argue that XML::Simple isn't all that simple - contrast it
with:

	use strict;
	use warnings;

	use XML::Twig;

	my $twig= new XML::Twig;

	$twig->parsefile("doc.xml");    # build the twig

	my $root= $twig->root;          # get the root of the twig 
	
	my $developers = $root->first_child('developers');
	
	my @personel= $developers->children; # get the developer list

	foreach my $person (@personel) {
		my $id = $person->att('id');
		my $phone = $person->first_child('phone')->text;
		print "ID: $id, Phone: $phone\n";
	}

added to this the caveats regarding XML::Simple and I think XML::Twig
would
be a much better solution.


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

Date: 7 Jun 2003 00:28:10 -0700
From: bhas_kurapati@yahoo.com (Bhaskar Kurapati)
Subject: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <3c0c6539.0306062328.f9fb969@posting.google.com>

Hi all,

I googled for above question but could not find required answer. Well
I have two arrays @arr1, @arr2 and one hash %hash. These three will be
passed to a subroutine/function. Since the sub routine *modifies* the
content of @arr1, @arr2 and %hash ... i can not pass them with
reference.

$arr1[0] = "zero";
$arr1[1] = "one";
$arr1[2] = "two";

$arr2[0] = "A";
$arr2[1] = "B";

$hash{'a'} = "AA";
$hash{'b'} = "BB";

mysubroutine(@arr1, %hash, @arr2);

sub mysubroutine
{
    # How to find no of elements in @arr1, @arr2 and %hash here !!
} 

I know how to find number of elements in @arr1, @arr2 and %hash if
subroutine is called like this ...

mysubroutine(\@arr1, \%hash, \@arr2);

thanks in advance,
Bhaskar


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

Date: Sat, 07 Jun 2003 09:02:35 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <pan.2003.06.07.07.02.34.181783@kamelfreund.de>

Bhaskar Kurapati wrote at Sat, 07 Jun 2003 00:28:10 -0700:

> I googled for above question but could not find required answer. Well I
> have two arrays @arr1, @arr2 and one hash %hash. These three will be
> passed to a subroutine/function. Since the sub routine *modifies* the
> content of @arr1, @arr2 and %hash ... i can not pass them with reference.

?!

If a reference of anything is passed to a subroutine, the subroutine can
change the anything that is referenced on.
What do you really mean ?


Greetings,
Janek


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

Date: Sat, 07 Jun 2003 08:49:32 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <wGhEa.42454$ca5.6074@nwrdny02.gnilink.net>

Bhaskar Kurapati <bhas_kurapati@yahoo.com> wrote:
> 
> I googled for above question but could not find required 
> answer.  Well I have two arrays @arr1, @arr2 and one hash 
> %hash. These three will be passed to a subroutine/function. 
> Since the sub routine *modifies* the content of @arr1, 
> @arr2 and %hash ... i can not pass them with reference.

It sounds like all you really want is:

    (a) to pass more than one hash/array to a subroutine, and
    (b) to be able to modify a local copy of each

And you know how to do (a) by passing references -- so the 
remaining question is:

   "How can I make a copy of a hash/array?"

Much simpler... :-)

    my @copy = @original;
    my %copy = %$ref_to_original;

    sub foo {
        my @a = @{ shift() };
        my %h = %{ shift() };
    }

    foo(\@array, \%hash);

-- 
Steve


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

Date: Sat, 07 Jun 2003 13:28:05 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <FLlEa.61760$Pb.7497@nwrddc01.gnilink.net>

Bhaskar Kurapati wrote:
> I googled for above question but could not find required answer. Well
> I have two arrays @arr1, @arr2 and one hash %hash. These three will be
> passed to a subroutine/function. Since the sub routine *modifies* the
> content of @arr1, @arr2 and %hash ... i can not pass them with
> reference.

It took me a while to understand what you mean with that sentence. I guess
what you mean is the sub modifies them internally but you don't want the
original data changed.

Well, trivial: make a local copy and work on that data.
It's just the same as passing by value, only now your are creating the copy
explicitely while with passing by value the interpreter creates the copy for
you.


> sub mysubroutine
> {
my @arr1 = @{$_[0]};
my %hash = %{$_[1]};
my @arr2 = @{$_[2]};
}

And la voila, you got local copies of your argument data.

>     # How to find no of elements in @arr1, @arr2 and %hash here !!
> }
>
> I know how to find number of elements in @arr1, @arr2 and %hash if
> subroutine is called like this ...
>
> mysubroutine(\@arr1, \%hash, \@arr2);
>
> thanks in advance,
> Bhaskar




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

Date: Sat, 7 Jun 2003 09:02:48 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <slrnbe3s48.4d4.tadmc@magna.augustmail.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:

> Are you sure you really want to _pass_ them? Maybe you want:
> 
> mysubroutine();
> 
> sub mysubroutine
> {
>      print scalar @arr1, " elements in \@arr1\n",


> In other words, 


"use global variables to communicate with the subroutine instead of
subroutine arguments".


> provided that the variables are either package
> globals or 'my' declared on 'the package level' (i.e. not in some
> other subroutine, for instance), you can well access them from inside
> your subroutine.


Bad idea. Bad design. Bad programming.

Global variables should be used _very_ sparingly.

Action-at-a-distance leads to hard to debug programs, 
global variables lead to action-at-a-distance.


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


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

Date: Sat, 07 Jun 2003 13:03:26 -0500
From: bob <bob@nowhere.com>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <3ee228e3_1@127.0.0.1>

On Sat, 07 Jun 2003 02:28:10 -0500, Bhaskar Kurapati wrote:

If you mean that the subroutine makes changes that you DO want to persist
after the sub returns, passing by reference is exactly what you WANT to
do.

If you mean the subroutine makes changes that you DON'T want happening,
you're already out of luck:

#!/usr/bin/perl -w

use Data::Dumper;

@arr1 = qw( zero  );
@arr2 = qw( A  );
%hash = ( a => 'Aa', );

print "Before:\n";
dumpr(\@arr1, \%hash,  \@arr2);

mysubroutine(@arr1, %hash, @arr2);

print "After:\n";
dumpr(\@arr1, \%hash,  \@arr2);

sub mysubroutine
{
	tr/a-z/A-Z/ for ( @_ );
} 


sub dumpr
{
	print Dumper $_ for (@_);
}

__END__

Results:

Before:
$VAR1 = [
          'zero'
        ];
$VAR1 = {
          'a' => 'Aa'
        };
$VAR1 = [
          'A'
        ];
After:
$VAR1 = [
          'ZERO'
        ];
$VAR1 = {
          'a' => 'AA'
        };
$VAR1 = [
          'A'
        ];


If you change the subroutine to 

sub mysubroutine
{
	my @a = @_;
	tr/a-z/A-Z/ for ( @a );
}

Results are:
Before:
$VAR1 = [
          'zero'
        ];
$VAR1 = {
          'a' => 'Aa'
        };
$VAR1 = [
          'A'
        ];
After:
$VAR1 = [
          'zero'
        ];
$VAR1 = {
          'a' => 'Aa'
        };
$VAR1 = [
          'A'
        ];


But this ONLY works for hasshes and arrays one level deep.  Any deeper
and you;re using references in the structures and copyiong those for @_
to 'my @a' doesn't protect them.

In that case, use Storable.pm.


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


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

Date: Sat, 07 Jun 2003 14:10:42 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <bbskov$ctnbs$1@ID-184292.news.dfncis.de>

Bhaskar Kurapati wrote:
> I googled for above question but could not find required answer.
> Well I have two arrays @arr1, @arr2 and one hash %hash. These three
> will be passed to a subroutine/function.

Are you sure you really want to _pass_ them? Maybe you want:

mysubroutine();

sub mysubroutine
{
     print scalar @arr1, " elements in \@arr1\n",
           scalar values %hash, " elements in \%hash\n",
           scalar @arr2, " elements in \@arr2\n";

     # Maybe do something else ...
}

In other words, provided that the variables are either package
globals or 'my' declared on 'the package level' (i.e. not in some
other subroutine, for instance), you can well access them from inside
your subroutine.

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 07 Jun 2003 18:35:22 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <bbt49a$d6k2e$1@ID-184292.news.dfncis.de>

Tad McClellan wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>>Are you sure you really want to _pass_ them? Maybe you want:
>>
>>mysubroutine();
>>
>>sub mysubroutine
>>{
>>     print scalar @arr1, " elements in \@arr1\n",

<snip>

>>In other words, 
> 
> "use global variables to communicate with the subroutine instead of
> subroutine arguments".
> 
>>provided that the variables are either package
>>globals or 'my' declared on 'the package level' (i.e. not in some
>>other subroutine, for instance), you can well access them from inside
>>your subroutine.
> 
> Bad idea. Bad design. Bad programming.

If done in a routine fashion: Yes. In this case, considering the 
background OP has given: I'm not able to tell. Are you?

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 07 Jun 2003 10:56:07 -0400
From: Stephen Hurrell <hurrells@tbaytel.net>
Subject: Newbie: Looking for MP3 script to trucate/fade my mp3 collection to 20sec ea.
Message-Id: <ve3v88gnh8ki7a@corp.supernews.com>

Hello.

I'm not a perl newbie but a Audio::MPEG (seems to be the right tool?) 
newbie.

I'm looking for a tool that will allow me to make "thumbnails" of my 
music collection. I just want the mp3-info and a short sample of the
start of the song left in place of each full length mp3. Reason: I am
making a multi-media database for a collection but cannot store the 
entire song due to the size of the radio station's collection.

I am looking for a perl shell script (or ideas, suggestions) about how 
to write a perl script that can be run from a cronjob to go through a
growing directory of MP3's and truncate, and possibly fade, them to 
perhaps about 20 secs each (adjustable). Yes there would also be many 
already "adjusted" mp3's in there. This program would only work on the 
larger/newer mp3 files obviously.

So any ideas about how to write the mp3 "chopper" would be appreciated.
FYI: This is the same idea as what you see on Amazon, CDnow, etc. when 
you listen to short segments of each song on a album.

Thank You
Stephen



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

Date: Sat, 7 Jun 2003 13:07:07 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: redirect location prints to screen
Message-Id: <Pine.LNX.4.53.0306071259090.939@lxplus012.cern.ch>

On Sat, Jun 6, Harvey Siegelman inscribed on the eternal scroll:

> Thanks for all of the suggestions, but so far none of them have worked
> on my site.

I've already seen the answer posted.  Either you didn't read it, or
you failed to recognise it as the answer.

> The mechanics of website may be responsible for the problem.

The fact that you're using SSI makes it impossible to achieve what you
intend.

> Those subfolders are password protected and the username for each is
> the name of their folder.  Within the client folder is also an
> index.shtml page that contains the call to the CGI script.

So don't do that.  And this has nothing specific to do with Perl.

What persuaded you to add the extra complication and difficulty of
putting an SSI in front of your CGI?

> BTW I am running this on a unix box.

Irrelevant.  The chief benefit of CGI is that it's designed to be
portable.

And whoever suggested that your browser might be an issue, didn't
understand the principles either.  If you send the right response,
then all client agents will understand it correctly.  If you send the
wrong response (and you did), then fiddling around with the client
agent is no solution.

cheers

-- 

      ISO-8859-1 is one of two charsets appropriate for use in
      Western Europe (the other is ISO-8859-15).  The US has not
      been politically part of Europe for nearly 227 years.  - Mark Crispin


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

Date: Sat, 07 Jun 2003 11:35:31 -0500
From: bob <bob@nowhere.com>
Subject: Safe.pm doesn't catch match?
Message-Id: <3ee21447$1_1@127.0.0.1>

Playing around with Safe.pm to write a prog that would safely allow users
to enter test strings and regexes and test matching.

Found the following:

#!/usr/bin/perl -w

use Safe;
$c = new Safe;

$c->permit_only( 
	qw(
		leaveeval
		const
	));

$result = $c->reval('"A" =~ m/a/i') ? 'YES' : 'NO';

die "$@\n" if $@;

print "\$result = $result\n";

__END__

This works, even though I didn't permit 'match'.

Current output is "$result = YES".

Changing regex to delete the i causes "$result = NO"

eliminating either OP in the permit_only() cause the $c->reval to fail
compilation with "<OP> item trapped by operation mask at (eval 2) line
1" as expected.

Shouldn't I need to permit 'match' for this to pass reval()?


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


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

Date: Sat, 07 Jun 2003 11:37:14 -0500
From: bob <bob@nowhere.com>
Subject: Re: Safe.pm doesn't catch match?
Message-Id: <3ee214ae$1_1@127.0.0.1>

Ooops.  perl 5.005_03 and 5.6.0 on Linux, perl 5.6.1 form Activestate on WinNT.

On Sat, 07 Jun 2003 11:35:31 -0500, bob wrote:

> Playing around with Safe.pm to write a prog that would safely allow
> users to enter test strings and regexes and test matching.
> 
> Found the following:
>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


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

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


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