[19391] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1586 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 22 09:29:17 2001

Date: Wed, 22 Aug 2001 06: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)
Message-Id: <998485509-v10-i1586@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 22 Aug 2001     Volume: 10 Number: 1586

Today's topics:
         error handling question ;O) <nmudie@chello.com>
        'filtering' a hash <A.S.Janse@azu.nl>
    Re: 'filtering' a hash (Eric Bohlman)
    Re: Alternative to use URI::Escape; <iltzu@sci.invalid>
        arrays question <CalinG@cfgroup.ca>
    Re: arrays question (Tad McClellan)
    Re: Calling several '.bat' files from ActivePerl <Thomas@Baetzler.de>
    Re: error handling question ;O) <ilya@martynov.org>
        flocking a r/w file <i.b.kerr@adm.leeds.ac.uk>
    Re: flocking a r/w file <i.b.kerr@adm.leeds.ac.uk>
    Re: For loop iterator variable not working correctly?? (Tad McClellan)
    Re: HTTP::Request::Common file upload <pdumarchie@goldenbytes.com>
    Re: HTTP::Request::Common file upload <pdumarchie@goldenbytes.com>
        Insert elements into an array <wayne.marrison@consignia.com>
    Re: Insert elements into an array <ilya@martynov.org>
    Re: Is element in array (Anno Siegel)
    Re: Last index of array referenced in a scalar?? (Anno Siegel)
    Re: Last index of array referenced in a scalar?? (Anno Siegel)
    Re: Last index of array referenced in a scalar?? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Last index of array referenced in a scalar?? (Anno Siegel)
    Re: Microsoft Perl (Phil Hibbs)
    Re: Microsoft Perl (Tad McClellan)
    Re: mod_perl problems - core dump using Socket or IO:So <Thomas@Baetzler.de>
        Not sure how best to do this. <hafatel@netpci.com>
    Re: Not sure how best to do this. <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Not sure how best to do this. <ilya@martynov.org>
    Re: This is not a question ... call me slow if you like <josef.moellers@fujitsu-siemens.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 22 Aug 2001 10:19:13 GMT
From: "nick" <nmudie@chello.com>
Subject:  error handling question ;O)
Message-Id: <BGLg7.140832$z11.2790152@amsnews02.chello.com>

Hi people, I'm sure this is a VERY easy one which I'm finding a pain in the
arse to figure out. (excuse the french)

I am using cgi scripts to call information from an oracle database.

I have a couple of dropdown lists (Month and Year) which the user can choose
from the html frontend.

If he/she chooses February and 2001 then the @tablename array you see in the
code below becomes network_m_200102. This table doesn't exist so the cgi
fails. If he/she chooses July 2001 then it works because that does exist
(network_m_200107).

Basically, I need to find out how to put in error control for when the table
DOESN'T exist by using die/else/$error or any other means. CAN YOU HELP????
:o)

Here is the code I am using:

if ($csv ne "checked")
 {
 $getbilling = $dbh->prepare(qq{SELECT customer_id, pkg, p_domain, network,
country, bytes, trunc(factor,2) from @tablename where cu
stomer_id like '$billingid%' and pkg like '%$sqlpkg%' and p_domain like
'%$sqldom%' and network like '%$network%' and rownum < '$row
num' order by bytes desc});

  &html_start;
  $getbilling->execute || die "is this where it fails?";   # it executes the
above sql statement here so I'm guessing this is where its failing. yes?
    my @data;
  while (@data = $getbilling->fetchrow_array())
{
  my $custid = $data[0];
  my $package = $data[1];
  my $p_domain = $data[2];
  my $network = $data[3];
  my $country = $data[4];
  my $bytes = $data[5];
  my $factor = $data[6];

print
"<tr><td>$custid<td>$package<td>$p_domain<td>$network<td>$country<td>$bytes<
td>$factor</td></tr>\n";
  }
   &html_end;
   $getbilling->finish;
 }


Thanks,
Nicky Mudie
Apps engineer chello broadband,
amsterdam




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

Date: Wed, 22 Aug 2001 13:36:20 +0200
From: Anne Janse <A.S.Janse@azu.nl>
Subject: 'filtering' a hash
Message-Id: <Pine.GSO.4.30.0108221304320.14748-100000@dizzy.azu.nl>

Hi all,

I've got a hash %hash and an array @array
and I'd like to make a new hash %newhash that contains only those
$key-$value pairs from %hash of which there is no $key in @array.

In other words, I'd like to throw away all $key-$value pairs
from %hash of which $key is in @array.

How can I do this? The problem doesn't look too hard, but my perl
experience is quite limited..

Thanks in advance,

Anne



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

Date: 22 Aug 2001 11:53:52 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: 'filtering' a hash
Message-Id: <9m06gg$anu$1@bob.news.rcn.net>

Anne Janse <A.S.Janse@azu.nl> wrote:
> I've got a hash %hash and an array @array
> and I'd like to make a new hash %newhash that contains only those
> $key-$value pairs from %hash of which there is no $key in @array.

> In other words, I'd like to throw away all $key-$value pairs
> from %hash of which $key is in @array.

> How can I do this? The problem doesn't look too hard, but my perl
> experience is quite limited..

In recent perls, you can delete a hash slice:

delete @hash{@array};

I'm not sure when delete was extended to allow slices; if your perl 
doesn't allow it, then

delete $hash{$_} for (@array);

will do it.



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

Date: 22 Aug 2001 12:55:42 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Alternative to use URI::Escape;
Message-Id: <998484767.3440@itz.pp.sci.fi>

In article <3B819873.53A2D794@wgn.net>, $Bill Luebkert wrote:
>Martin Vorlaender wrote:
>> 
>> jtjohnston (jtjohnston@courrier.usherb.ca) wrote:
>> > >>use URI::Escape;
>> > >>$in{'P1OC2Q1'} = uri_escape($in{'P1OC2Q1'}, "^A-Za-z");
>> >
>> > A luck would have it, when I tried my script on the University server,
>> > URI.pm was not installed in the last installation of libnet. Rather than
>> > wait 6 months, can anyone come up with an alternative to URI.pm. I have
>> > found this line of code, but does it escape everything?
>> >
>> > $in{'blah'} =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>> 
>> No. This *de*codes. To (simplistically) encode:
>> 
>> $in{'blah'} =~ s/([^A-Za-z])/sprintf '%%%02X', ord $1/eg;
>> 
>> This, however, escapes way too many characters. OTOH, you could even use
>> (.) instead of ([^A-Za-z]).
>> 
>> And it assumes you do this in an ISO8859-1 environment.
>
>Maybe more like:
>
>$string =~ s/([^;\/?:@&=+\$,A-Za-z0-9\-_.!~*'() ])/sprintf("%%%02X",ord($1))/eg;
>$string =~ tr/ /+/;

*Hopefully* more like:

  $string =~ s/([^A-Za-z0-9\-_.!~*'() ])/sprintf("%%%02X",ord($1))/eg;
  $string =~ tr/ /+/;

But in any case, escaping too many characters (like Martin's solution
did) is not a problem.  Escaping too few, like yours did, is.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



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

Date: Wed, 22 Aug 2001 08:44:24 -0400
From: "Calin Guga" <CalinG@cfgroup.ca>
Subject: arrays question
Message-Id: <AGNg7.14739$Z2.173600@nnrp1.uunet.ca>

Hello,

    How could I place 2(for ex. @numbers and @dates) or more arrays together
in a file, array 1 items would go on first row, array 2 items would go on
second, etc. separated by comma, consecutively?
Thanks a lot,
Calin



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

Date: Wed, 22 Aug 2001 08:08:18 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: arrays question
Message-Id: <slrn9o785i.2nc.tadmc@tadmc26.august.net>

Calin Guga <CalinG@cfgroup.ca> wrote:
>
>    How could I place 2(for ex. @numbers and @dates) or more arrays together
>in a file, array 1 items would go on first row, array 2 items would go on
>second, etc. separated by comma, consecutively?


   { local $" = ',';
     die "Barf! Commas in the data fields!\n" if grep /,/, @numbers, @dates;
     print FILE "@numbers\n";
     print FILE "@dates\n";
   }


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


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

Date: Wed, 22 Aug 2001 12:25:40 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Calling several '.bat' files from ActivePerl
Message-Id: <6r17otc6jfdj0sqttshgm69iiu8j19ufel@4ax.com>

Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr> wrote:

>70262.1046@compuserve.com wrote:
>> I'm trying to call several '.bat' files from a perl script. Most of
>> the '.bat' files run conginuously (they never end until ctrl-c). How
>> can I call a series of '.bat' files, some of which end and some
>> of which do not end?

>Not really an answer, but... why using .bat files and not perl scripts ?

Just a guess - they do what they should do, so it's probably not
feasible to recode them in Perl?

Besides, if these files were written in Perl, there would still be the
same problem - you have to detach your external programs somehow if
they run continuously.

From personal experience I'd say that right now, calling "start" via
system (as recommended by a previous poster) is a much better idea
than using fork() on Win32 systems.

Cheers,
-- 
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.


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

Date: 22 Aug 2001 16:11:54 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: error handling question ;O)
Message-Id: <878zgcmgz9.fsf@abra.ru>


n> Hi people, I'm sure this is a VERY easy one which I'm finding a pain in the
n> arse to figure out. (excuse the french)

n> I am using cgi scripts to call information from an oracle database.

n> I have a couple of dropdown lists (Month and Year) which the user can choose
n> from the html frontend.

n> If he/she chooses February and 2001 then the @tablename array you see in the
n> code below becomes network_m_200102. This table doesn't exist so the cgi
n> fails. If he/she chooses July 2001 then it works because that does exist
n> (network_m_200107).

n> Basically, I need to find out how to put in error control for when the table
n> DOESN'T exist by using die/else/$error or any other means. CAN YOU HELP????
n> :o)

Set RaiseError option for database handler:

    $dbh->{RaiseError} = 1;

And catch exceptions with eval.

See 'perldoc DBI' and 'perldoc -tf eval'

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Wed, 22 Aug 2001 00:44:29 +0100
From: "IKerr." <i.b.kerr@adm.leeds.ac.uk>
Subject: flocking a r/w file
Message-Id: <9lursk$bkr$1@news6.svr.pol.co.uk>

Hi,

I haven't found much information (that I have understood - newbie ;-) on
file locking.

I have some code, something like this:

#!/pathtoperl5 -Tw

use strict;
use MIME::Base64 qw(encode_base64);

# blah blah define vars al the rest of the script (cgi)

open(FILE1, "+<$file/$name") or die "$!";
# flock(FILE1, 2); tried this - didn't work
open (MAIL, "|$mailprogram -t -oi") or die "$!";
print MAIL "TO: $address\n";
print MAIL "RETURN-PATH: $return\n";
print MAIL "FROM: $fromaddress\n";
print MAIL "SUBJECT: Blah blah \n";
print MAIL "MIME-Version: 1.0\n"
# print blah blah MIME headers for a multipart message #
while (read(FILE1, $buf, 60*57)) {
print MAIL encode_base64($buf);
   }
# print end of email stuff
close(MAIL);

# clear contents of file, but leave on disk & permissions intact
truncate("$upl_path/$filename", 0) or die "$!";
close(FILE1);

I found somewhere that the first open needed a +'s.

What happens is that the encoded contents of MAIL are non existant if I put
the flock there.  What am I doing wrong ?

One more question, perlsec says you need to clean ENV's when using -T, but
what should $ENV{'PATH'} = ""; be set to - the location of the perl
executable, the path of the perl script (this is a cgi), the location of
something else ?

Hope someone can help,

cheers

Iain




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

Date: Wed, 22 Aug 2001 00:47:14 +0100
From: "IKerr." <i.b.kerr@adm.leeds.ac.uk>
Subject: Re: flocking a r/w file
Message-Id: <9lus1p$q53$1@news8.svr.pol.co.uk>

correction

> # clear contents of file, but leave on disk & permissions intact
> truncate("$upl_path/$filename", 0) or die "$!";

this last bit is
truncate("$file/$name", 0) or die "$!";

Iain





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

Date: Wed, 22 Aug 2001 07:18:03 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: For loop iterator variable not working correctly??
Message-Id: <slrn9o757b.2hs.tadmc@tadmc26.august.net>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>According to Carlos C. Gonzalez  <miscellaneousemail@yahoo.com>:
>> Eric Bohlman at ebohlman@omsdev.com said...
>
>> > You want $$new here, not @$new.  I'd actually write it as $new->[0], but 
>> > that's a matter of personal preference.
>> 
>> @$new seems to work fine Eric. ...
>
>More evidence that the DWIMmer is a corrupter of innocent minds.


For any folks out there that don't see where the corruption is:

------------------
#!/usr/bin/perl -w
use strict;

my @new = qw/harry@tiger.net undef undef Russia undef undef/;
my $new = \@new;

@$new[0] = report_context();
$$new[0] = report_context();

sub report_context
{
  if ( wantarray )
      {print "list context\n"}
   elsif ( defined wantarray )
      {print "scalar context\n"}
   else
      {print "void context\n"}
}
------------------

Now consider the difference in behavior:

   @$new[0] = <DATA>;   # read all lines up to EOF, put first line
                        # in the array, discard all the rest of the lines

   $$new[0] = <DATA>;   # read a single line.


Using a one-element slice instead of a scalar will bite you
if the construct is used to determine context.


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


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

Date: Wed, 22 Aug 2001 12:51:11 +0200
From: "Peter du Marchie" <pdumarchie@goldenbytes.com>
Subject: Re: HTTP::Request::Common file upload
Message-Id: <998477422.349606@newsreader1.wirehub.nl>

"gnari" <gnarinn@hotmail.com> wrote in message
news:998420765.0150068118236959.gnarinn@hotmail.com...

> i do not know, but the documentation also says:
>     A header key called 'Content' is special and when seen the value will
>     initialize the content part of the request instead of setting a
header.
>
> did you try that?

I did not (see|interpret) that part of the documentation( as a key to the
solution)?

Thanks




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

Date: Wed, 22 Aug 2001 12:52:32 +0200
From: "Peter du Marchie" <pdumarchie@goldenbytes.com>
Subject: Re: HTTP::Request::Common file upload
Message-Id: <998477503.539579@newsreader1.wirehub.nl>

And thank you very much for the example!




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

Date: Wed, 22 Aug 2001 09:42:25 +0100
From: "Wayne Marrison" <wayne.marrison@consignia.com>
Subject: Insert elements into an array
Message-Id: <998469694.561023@igateway.postoffice.co.uk>

Hi peeps,

I have another question for you all.

How do I insert an element at  a given point within an array?

For example, I have an array of about 100 elements, and need to insert
elements at various positions along it.  When the element is inserted, I
would like the rest of the array to be shuffled to the right (or down
whichever way you look at it), giving me 101 elements.

I have checked the FAQ and looked through this newsgroup, but cannot find
anything about this.  I have also checked several books on Perl, all to no
avail.

This may be a simple question, and I know I can code it manually, but given
Perls excellent array handling, a function to do this kind of thing must be
present ...???

Thanks

Wayne





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

Date: 22 Aug 2001 16:20:27 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Insert elements into an array
Message-Id: <87y9ocl20k.fsf@abra.ru>


WM> Hi peeps,
WM> I have another question for you all.

WM> How do I insert an element at  a given point within an array?

WM> For example, I have an array of about 100 elements, and need to insert
WM> elements at various positions along it.  When the element is inserted, I
WM> would like the rest of the array to be shuffled to the right (or down
WM> whichever way you look at it), giving me 101 elements.

WM> I have checked the FAQ and looked through this newsgroup, but cannot find
WM> anything about this.  I have also checked several books on Perl, all to no
WM> avail.

You should look at 'perldoc perlfunc'. In its beging you will find
list of all functions by category. For example:

       Functions for real @ARRAYs
           "pop", "push", "shift", "splice", "unshift"

WM> This may be a simple question, and I know I can code it manually, but given
WM> Perls excellent array handling, a function to do this kind of thing must be
WM> present ...???

You can do it with splice()

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: 22 Aug 2001 10:14:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is element in array
Message-Id: <9m00m6$b43$3@mamenchi.zrz.TU-Berlin.DE>

According to Tassilo von Parseval  <Tassilo.Parseval@post.rwth-aachen.de>:
> Pascal Jolin wrote:
> > Happy GREP!!!
> > 
> > my @bla=("one","two","three");
> > 
> > if ( grep {/two/}@bla){ 
> >   print "true";
> > } else {
> >   print "False";
> > }
> 
> I think it is a bad habit to check a contain with grep. Imagine you have 
> an array of 10.000 elements and the first element already contains the 
> value. Then you still "Happy[ly] GREP!!!" through another 9.999 elements.
 
That sounds bad, but in many practical cases the hit will be in the
middle of the list on average, so grep inspects twice as many elements
as strictly necessary.  This may well be acceptable.

Anno


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

Date: 22 Aug 2001 10:50:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <9m02p5$h80$1@mamenchi.zrz.TU-Berlin.DE>

According to Ren Maddox  <ren@tivoli.com>:
 
[...]

> "$#" belongs in the same group as "$", "@" and "%".

In what sense?  In most respects "$#" is fundamentally different from
"$", "@" and "%": It doesn't correspond to a data type, or a slot in
a stash entry.  You can't declare a variable that begins with "$#"
while you can with the others.  "$#" makes only sense in conjunction
with a corresponding array variable, the others are independent of
other variables.  Where is the similarity?

Anno


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

Date: 22 Aug 2001 11:08:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <9m03rn$i6i$1@mamenchi.zrz.TU-Berlin.DE>

According to Tassilo von Parseval  <Tassilo.Parseval@post.rwth-aachen.de>:
> Carlos C. Gonzalez wrote:
> 
> > Can you clarify for me how to use the $new->[-1] method to get the last 
> > index value?  I have tried "$#new->[-1]", "$#{$new->[-1]}" and some 
> > others without any success.  
> 
> Ah, sorry, my fault. I did not read carefully. Indeed, for retrieving 
> the last index-value you have to use either $#$ref or, if you like it 
> perhaps slightly clearer, "scalar @{$ref} - 1".
> If you often work with array-refs, you could always set up a 
> sub-routine, that does the job:
> 
> sub lidx {
> 	return $#_       if @_ > 1; # called with an array
> 	return $#{$_[0]} if @_ == 1 && ref $_[0] eq 'ARRAY';
> 			            # called with an array-ref
> }
> 
> Not sure whether the above catches all possible cases, but if you either 
> call it with an array or an array-ref as the only parameters, this 
> should work.

If @x is an array whose single element is an arrayref (@x = ( [])), there
is no way for lidx( @x) to tell what the user has meant.

Anno


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

Date: Wed, 22 Aug 2001 13:21:53 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <3B8395D1.606@post.rwth-aachen.de>

Anno Siegel wrote:

>>sub lidx {
>>	return $#_       if @_ > 1; # called with an array
>>	return $#{$_[0]} if @_ == 1 && ref $_[0] eq 'ARRAY';
>>			            # called with an array-ref
>>}
>>
>>Not sure whether the above catches all possible cases, but if you either 
>>call it with an array or an array-ref as the only parameters, this 
>>should work.
>>
> 
> If @x is an array whose single element is an arrayref (@x = ( [])), there
> is no way for lidx( @x) to tell what the user has meant.

Yes, I expected contradition. :-)
That's why I said that it might not cover all eventualities.

When thinking about your examples it is probably impossible to write 
this lidx so that it always works since the function would not know 
whether it has been lidx ( ([ ]) ) or lidx ( [ ] ). I wouldn't know how 
to differentiate between these two cases.

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 22 Aug 2001 12:04:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <9m074i$kkg$1@mamenchi.zrz.TU-Berlin.DE>

According to Tassilo von Parseval  <Tassilo.Parseval@post.rwth-aachen.de>:
> Anno Siegel wrote:
> 
> >>sub lidx {
> >>	return $#_       if @_ > 1; # called with an array
> >>	return $#{$_[0]} if @_ == 1 && ref $_[0] eq 'ARRAY';
> >>			            # called with an array-ref
> >>}
> >>
> >>Not sure whether the above catches all possible cases, but if you either 
> >>call it with an array or an array-ref as the only parameters, this 
> >>should work.
> >>
> > 
> > If @x is an array whose single element is an arrayref (@x = ( [])), there
> > is no way for lidx( @x) to tell what the user has meant.
> 
> Yes, I expected contradition. :-)
> That's why I said that it might not cover all eventualities.
> 
> When thinking about your examples it is probably impossible to write 
> this lidx so that it always works since the function would not know 
> whether it has been lidx ( ([ ]) ) or lidx ( [ ] ). I wouldn't know how 
> to differentiate between these two cases.

You can't, in the sub @_ is the same in both cases.  If you do this,
your program must decide which it prefers and it must be documented.

Anno


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

Date: 22 Aug 2001 03:58:42 -0700
From: phil.hibbs@capgemini.co.uk (Phil Hibbs)
Subject: Re: Microsoft Perl
Message-Id: <153e25f0.0108220258.204b034e@posting.google.com>

"William Alexander Segraves" <wsegrave@mindspring.com> wrote:
> BTW, I noted yesterday that IndigoStar, www.indigostar.com, distributes 
> what appears to be the same Perl v. 5.001 as part of the shareware version 
> of MicroWeb.

It seems unlikely that there will be a 5.005 version of this port
around, then. Ho hum.

Can anyone point me in the direction of a decent overview of the
problems with 5.001 so that I can be aware of them?

Phil.


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

Date: Wed, 22 Aug 2001 07:50:58 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Microsoft Perl
Message-Id: <slrn9o7752.2hs.tadmc@tadmc26.august.net>

Phil Hibbs <phil.hibbs@capgemini.co.uk> wrote:
>"William Alexander Segraves" <wsegrave@mindspring.com> wrote:
>> BTW, I noted yesterday that IndigoStar, www.indigostar.com, distributes 
>> what appears to be the same Perl v. 5.001 as part of the shareware version 
>> of MicroWeb.
>
>Can anyone point me in the direction of a decent overview of the
>problems with 5.001 so that I can be aware of them?


Start with a huge, gaping, well-publicized security hole:

   http://www.cert.org/advisories/CA-1997-17.html

The phrase "buffer overflow" really gets a cracker's juices flowing...


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


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

Date: Wed, 22 Aug 2001 12:19:13 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: mod_perl problems - core dump using Socket or IO:Socket in startup.pl
Message-Id: <ea07ot0mrui3ujt0bc8rio4s6obncn2ktq@4ax.com>

Hi,

On Wed, 22 Aug 20010, "Stephen Wylie" <stephen.wylie@xko.co.uk> wrote:
[...]
>What controls the
>actual perl binary used by mod_perl? Any ideas?

mod_perl does not use an external Perl binary - it basically is a Perl
core. Thus, it picks up all the defaults from the Perl source it was
compiled from. You really should build your own matching Perl, Apache
and mod_perl yourself - mix'n'match is not a good approach for
building a stable Apache with mod_perl.

HTH,
-- 
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.


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

Date: Wed, 22 Aug 2001 21:20:51 +1000
From: "Michael McPherson Pierotti" <hafatel@netpci.com>
Subject: Not sure how best to do this.
Message-Id: <9m04iv01vt6@enews1.newsguy.com>

I need to convert from YYYYMMDDhhmmss to YYYY:MM:DD:hh:mm:ss

example: 20010101000001 to 2001:01:01:00:00:01


this should work correct???

my $date = "20010101000001";
$date = join(':', split (/\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}/));

TYIA

Mike




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

Date: Wed, 22 Aug 2001 14:07:40 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Not sure how best to do this.
Message-Id: <3B83A08C.7030504@post.rwth-aachen.de>

Michael McPherson Pierotti wrote:

> I need to convert from YYYYMMDDhhmmss to YYYY:MM:DD:hh:mm:ss
> 
> example: 20010101000001 to 2001:01:01:00:00:01
> 
> 
> this should work correct???

What happens when you try?

For splitting fields with fixed length I often use unpack:
my $n = "20010101000001";
$date = join ":", unpack "A4 A2 A2 A2 A2 A2", $n;

See: 'perldoc -f pack' for what a template is ("A4..."). unpack just 
does the opposite to pack but uses the same templates.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 22 Aug 2001 16:16:29 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Not sure how best to do this.
Message-Id: <874rr0mgrm.fsf@abra.ru>


MMP> I need to convert from YYYYMMDDhhmmss to YYYY:MM:DD:hh:mm:ss
MMP> example: 20010101000001 to 2001:01:01:00:00:01


MMP> this should work correct???

MMP> my $date = "20010101000001";
MMP> $date = join(':', split (/\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}/));

It should be

    $date = join(':', $date =~ /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/);

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Wed, 22 Aug 2001 12:18:57 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: This is not a question ... call me slow if you like...
Message-Id: <3B838711.E8D1A5C5@fujitsu-siemens.com>

David Combs wrote:

>s''n4|9|21|3|n1\2||2|(_-<2_|4_`1|3\3_1\2_|3\3-_)2_|n\__/\_,_|___/\__|2\_=
_,_|_|
> >1_|\___/\__|_|1_|\___|_|nn4_1\9|3|14|n4__/1-_)2_|1|5\3_`1|2_|1!1/2-_)2=
_|n3_|1\
> >___|_|2_|2_|1_|\__,_|\__|_i_\\\___|_|1)n45/n',y/n\n/\n/d,s/\d+/$"x$&/e=
g,print;
> >
> =

> Now, just what do we have to do to turn
> those three lines into a perl program?
> =

> (especially great would be the exact command line or
> lines we must type in.)

Works fine with perl, version 5.005_03.

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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


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