[25555] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7799 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 18 14:05:35 2005

Date: Fri, 18 Feb 2005 11:05:19 -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           Fri, 18 Feb 2005     Volume: 10 Number: 7799

Today's topics:
    Re: Archive::Zip - _isSeekable a bit bodgy (Anno Siegel)
    Re: forking & (mysql)sockets (Anno Siegel)
    Re: How can I get the exit status? <nobull@mail.com>
    Re: How can I get the exit status? <jgibson@mail.arc.nasa.gov>
    Re: How can I get the exit status? <nobull@mail.com>
    Re: how to set time <1usa@llenroc.ude.invalid>
    Re: how to set time <nospam@bigpond.com>
    Re: how to set time <info@skynet.be>
    Re: how to set time <noreply@gunnar.cc>
        How to validate date and time? yashgt@yahoo.com
    Re: Low level data manipulation in Perl <nobull@mail.com>
    Re: Modify keys in a %hash using tr/// or s/// <dreamer@cox.net>
    Re: Need help with an advanced? regular expression <nospam@nospam.net>
    Re: Need help with an advanced? regular expression <do-not-use@invalid.net>
    Re: Need help with an advanced? regular expression <jl_post@hotmail.com>
    Re: Need help with an advanced? regular expression <noreply@gunnar.cc>
        Newbie question sorting mdfoster44@netscape.net
    Re: Question? Alternative to loading modules!!! nospam@geniegate.com
    Re: simple map query <mritty@gmail.com>
    Re: use strict; and O_WRONLY <tassilo.von.parseval@rwth-aachen.de>
        variation on 'calling subroutine via reference'? <alisonNO@SPAMhorison-research.com>
    Re: Why aren't 'warnings' on by default? <tassilo.von.parseval@rwth-aachen.de>
    Re: Why aren't 'warnings' on by default? (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 18 Feb 2005 16:32:04 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Archive::Zip - _isSeekable a bit bodgy
Message-Id: <cv55a4$kre$1@mamenchi.zrz.TU-Berlin.DE>

Matthew Braid  <not@invalid.invalid> wrote in comp.lang.perl.misc:
> Hi all,
> 
> I've just found a rather annoying problem with Archive::Zip.
> 
> I'm using temp files (via File::Temp's tempfile function) to store 
> zipped data from a database. Unfortunately it seems there was a change 
> in the last version that makes Archive::Zip want a seekable handle for 
> the readFromFileHandle, and Archive::Zip doesn't want to believe that 
> temp files are seekable.
> 
> I checked the _isSeekable function in Archive::Zip:
> 
> sub _isSeekable    # Archive::Zip
> {
>          my $fh = shift;
> 
>          if ( UNIVERSAL::isa( $fh, 'IO::Scalar' ) )
>          {
>                  return 0;
>          }
>          elsif ( UNIVERSAL::isa( $fh, 'IO::String' ) )
>          {
>                  return 1;
>          }
>          elsif ( UNIVERSAL::can( $fh, 'stat' ) )
>          {
>                  return -f $fh;
>          }
>          return UNIVERSAL::can( $fh, 'seek' );
> }
> 
> The problem is that the -f $fh is wrapped in a UNIVERSAL::can(). I've 
> never had much luck with UNIVERSAL::can(), and sure enough it's failing 
> here. A quick demo shows this:

It is true that ->can has problems (in particular in combination with
AUTOLOAD), but in this case it's right.  tempfile() returns an unblessed
globref, which indeed doesn't have a ->stat method.  That the Perl function
stat() knows how to deal with it is outside ->can's responsibility.

The bug is in Archive::Zip.  It should probably add a test "ref( $fh) eq
'GLOB'" in _is_seekable to catch this.

For a quick fix try blessing the temp fh into IO::File before using it.
That should repair the behavior of Archive::Zip without hurting the file
handle as such.  Untested.

Anno


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

Date: 18 Feb 2005 17:25:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: forking & (mysql)sockets
Message-Id: <cv58en$kre$2@mamenchi.zrz.TU-Berlin.DE>

 <arnevt@sloeber.office.xs4all.be> wrote in comp.lang.perl.misc:
> 
> > 
> > I don't know what a "getcounter" script is, and have no experience with
> > Net::SNMP, but I do know that for general databse work, mysql connections
> > should be opened after the fork(s), not before.
> 
> a "getcounter" script is a script that gets counters :D

This is either a tasteless joke at the expense of people who are trying
to help you, or you are childishly assuming that everybody lives inside
your head.  Immature either way.

Anno


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

Date: Fri, 18 Feb 2005 17:25:07 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How can I get the exit status?
Message-Id: <cv583d$p2h$1@sun3.bham.ac.uk>



laredotornado@zipmail.com wrote:
> Hello,
>    I have a perl script that launches a Unix process that calls another
> Perl script:
> 
> `perl /myscripts/gen_ecom_xml.pl $ckit_file > $xml_file`;
> 
> 
> and I am wondering how I can get the exit status value and any
> potential error messages? 

Rather than passively "wondering" could I suggest you should have taken 
a look  section of the reference manual that describes the behaviour of 
the backquotes.

Anyhow, look at the documentation of the $? special variable and the FAQ 
   "How can I capture STDERR from an external command?".



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

Date: Fri, 18 Feb 2005 09:35:49 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: How can I get the exit status?
Message-Id: <180220050935499742%jgibson@mail.arc.nasa.gov>

In article <1108739727.195814.98050@o13g2000cwo.googlegroups.com>,
<laredotornado@zipmail.com> wrote:

> Hello,
>    I have a perl script that launches a Unix process that calls another
> Perl script:
> 
> `perl /myscripts/gen_ecom_xml.pl $ckit_file > $xml_file`;
> 
> 
> and I am wondering how I can get the exit status value and any
> potential error messages? 

perldoc -f system

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


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

Date: Fri, 18 Feb 2005 17:52:56 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How can I get the exit status?
Message-Id: <cv59nj$pio$2@sun3.bham.ac.uk>



Brian McCauley wrote:

> laredotornado@zipmail.com wrote:
> 
>> `perl /myscripts/gen_ecom_xml.pl $ckit_file > $xml_file`;
>>
>> and I am wondering how I can get the exit status value and any
>> potential error messages? 

> Anyhow, look at the documentation of the $? special variable and the FAQ 
>   "How can I capture STDERR from an external command?".

I forgot to mention the FAQ "What's wrong with using backticks in a void 
context?".



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

Date: 18 Feb 2005 17:28:45 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: how to set time
Message-Id: <Xns96017EF248EBasu1cornelledu@132.236.56.8>

"Peter" <info@skynet.be> wrote in
news:J1oRd.22643$EH5.22636@blueberry.telenet-ops.be: 

> I'm a newbie and busy with a mailform.
> 
> This mailform sent autoresponse mail.
> My question is if it possible to sent the autoresponse mail one or two
> days later after receiving the mail. 

Yes, but that has nothing to do with the code you posted below.

> I think it has to be change in this piece of code ?

Is that a question or statement?

><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Please post plain text only.

Sinan


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

Date: Sat, 19 Feb 2005 03:49:25 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: how to set time
Message-Id: <37mo56F5esehmU1@individual.net>

Peter wrote:

>
> I think it has to be change in this piece of code ?

Do it then. Why tell us?

gtoomey


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

Date: Fri, 18 Feb 2005 19:06:42 +0100
From: "Peter" <info@skynet.be>
Subject: Re: how to set time
Message-Id: <Q8qRd.30088$aE3.17209@biebel.telenet-ops.be>


Hello Sinan,

Yes it is a question because I really don't know how to change it.
I want to sent the autoresponse 1 or 2 days later.

Hereby I sent the send mail script.



sub sdsmail {


                if ($send_email_results eq "1") {

  open(MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
 print MAIL "To: $MAIN_mail_send\n";
if ($mail_ccto){
      print MAIL "Cc: $mail_ccto\n";
}
 print MAIL "From: $formdata{'email'}\n";
 print MAIL "Subject: $formdata{'subject'}\n";
 print MAIL "The form below was submited by $formdata{'email'} form Ip 
address: $ENV{'REMOTE_ADDR'} on $monthnameactual $dayofmonth, $year at 
$newhour:$newmin $nightday \n";
 print MAIL 
"-------------------------------------------------------------------------\n\n";


if (! $formdata{'sort'}) {


  for ($indexval = 0; $indexval < @formvalue; $indexval++) {
  ${'myname'} = $formname[$indexval];
  ${'myvalue'} = $formvalue[$indexval];


 if (${'myname'} eq "reply_subject"|| ${'myname'} eq "subject" || 
${'myname'} eq "sendreply" || ${'myname'} eq "required" || ${'myname'} eq 
"success_page" || ${'myname'} eq "message_format" || ${'myname'} eq 
"text_qualifier" || ${'myname'} eq "datafile" || ${'myname'} eq "outputfile" 
|| ${'myname'} eq "sort" || ${'myname'} eq "data_format" || ${'myname'} eq 
"cc_to" || ${'myname'} eq "send_to" || ${'myname'} eq "plain_mesfile" || 
${'myname'} eq "html_mesfile" || ${'myname'} eq "error_page" || ${'myname'} 
eq "required_desc"){
 $dontrun = "1";
 }else{
 $dontrun = "";
 }

  ## CHECK PRINT BLANK FIELDS ##
  if ($PRNT_blankfields eq "2" && ! ${'myvalue'}) {
  $dontrun = "1";
  }

 if (! $dontrun){
 print MAIL "${'myname'}:   ${'myvalue'} \n\n";
 }
  }

}else{  ##ELSE IF NO SORT FIELD ##

 for ($numsort = 0; $numsort < @sortfields; $numsort++) {
 $sfield = $sortfields[$numsort];
 ${'sfieldvalue'} = $formdata{"$sfield"};
 ${'sfield'} = "$sfield";

 ## CHECK PRINT BLANK FIELDS ##
 if ($PRNT_blankfields eq "2" && ! ${'myvalue'}) {
 }else{

 print MAIL "${'sfield'}:   ${'sfieldvalue'} \n\n";

 } ## END CHECK PRINT BLANK FIELDS ##

 }

} ## END ELSE IF SORT FIELD ##

 close MAIL;

                 }  ## END IF SEND_EMAIL_RESULTS##

if ($formdata{'sendreply'} eq "1"){



use MIME::Lite;
    MIME::Lite->send("sendmail", "$mailprog -t -oi -oem");



    $msg = MIME::Lite->new(
           From    => $mail_sendto,
           To      => $formdata{'email'},
           Subject => $reply_subject,
           Type    => $email_format,
           Data    => $mime_body,
           "X-Arpidentifier:" => 12345

    );

########################################
## USE ATTACHEMENT                    ##
########################################

if ($send_attachement eq "1"){

                    $msg->attach(Type => $att_content_type,
                                 Encoding => $att_format->[1],
                                 Path => $att_path,
                                 Filename => $attachment_nm
                    );

}


######################################
$msg->send;
}

}

return 1;



"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message 
news:Xns96017EF248EBasu1cornelledu@132.236.56.8...
> "Peter" <info@skynet.be> wrote in
> news:J1oRd.22643$EH5.22636@blueberry.telenet-ops.be:
>
>> I'm a newbie and busy with a mailform.
>>
>> This mailform sent autoresponse mail.
>> My question is if it possible to sent the autoresponse mail one or two
>> days later after receiving the mail.
>
> Yes, but that has nothing to do with the code you posted below.
>
>> I think it has to be change in this piece of code ?
>
> Is that a question or statement?
>
>><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>
> Please post plain text only.
>
> Sinan 




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

Date: Fri, 18 Feb 2005 19:20:57 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to set time
Message-Id: <37mpt8F5gj4a5U1@individual.net>

Peter wrote:
>  
> This mailform sent autoresponse mail.
> My question is if it possible to sent the autoresponse mail one or two 
> days later after receiving the mail.

Yes.

> I think it has to be change in this piece of code ?

<code snipped>

No.

To schedule the execution of code to a point of time in the future, you 
need a daemon. Check out

     perldoc -q daemon

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


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

Date: 18 Feb 2005 10:01:10 -0800
From: yashgt@yahoo.com
Subject: How to validate date and time?
Message-Id: <1108749670.332411.256190@z14g2000cwz.googlegroups.com>

I have a program that deals with files with names such as
SA_2005-01-03_01-00-00_sqf1974_1.0.0_Iub_Iu_CT.csv
The format is SA_<date>_<time>_....
Befor processing a file, I would like the program to validate the
filename by checking whether the date and time parts are correct.
I tried using mktime, hoping for perl to return an error value if the
date and time are wrong. But for some reason even if I give plain text
in the time part, mktime does not return an error. I use
ActivePerl 5.8.2 on Windows 2000. This does not have the Date module.
Can someone suggest a way to do the validation?

Thanks
Yash



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

Date: Fri, 18 Feb 2005 17:39:06 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Low level data manipulation in Perl
Message-Id: <cv58tn$pio$1@sun3.bham.ac.uk>

In a thread that has been inactive for a month nospam@geniegate.com wrote:

> In: <csdo6v$60e$1@newsg2.svr.pol.co.uk>, "Leonard Challis" <perl@lennychallis.co.uk> wrote:
 >
>>What I have noticed from my searches so far is things like pack(), unpack(), 
>>binmode() and some other stuff, but not really what I'm looking for, AFAIK.
> 
> 
> Actually, you're in the right direction...

[snip valid comment ]

But this thread is a month dead and all that was discussed then!

This isn't the only old thread you've posted to.  If you are seening 
these as new posts rather than the start of exisitng (and indeed 
complete) threads then there may be something wrong with your Usenet 
reader (or your understanding of it).



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

Date: Fri, 18 Feb 2005 09:16:51 -0800
From: Fred Hare <dreamer@cox.net>
Subject: Re: Modify keys in a %hash using tr/// or s///
Message-Id: <ioGdndCY1aybvovfRVnyjg@giganews.com>

Bart Lateur wrote:
> Fred Hare wrote:
> 
> 
>>I have a script for comparing a dir of MP3-files to a DB-file. It works 
>>OK unless there are files with high-ascii characters in the dir or in 
>>the DB. I tried to add a conversion but I get errors like "uninitialized 
>>value in pattern-match..."
>>Is there a way to alter the hash-keys using tr/// or s/// ?
> 
> 
> No, you have to do the conversion before you put the stuff in the hash.
> A hash key is a read-only property.
> 
> You can use 
> 
> 	$hash{$new} = delete $hash{$old};
> 
> but preferably only after you make sure that $new ne $old, so you know
> this step is required.
> 

I agree with that. My "subjet-line" was incorrect: Since I use

	$hash1{ lc convert ($infile) } = $value;

both commands (lc and the convert-sub) are executed *before* the %hash 
is created and I do not have to alter hash-keys.
-- 
Fred


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

Date: Fri, 18 Feb 2005 16:05:56 +0000
From: Martin Gill <nospam@nospam.net>
Subject: Re: Need help with an advanced? regular expression
Message-Id: <421610ac$1_1@baen1673807.greenlnk.net>

Thanks for the quick reply,

Bernard El-Hagin wrote:
> Martin Gill <nospam@nospam.net> wrote:
> 
> 
>>Hi,
>>
>>I'm trying to write a regular expression which parses the
>>following string: 
>>
>>blah blah items 1234, 4567, 4345, and 3245 blah blah blah
>>
>>I want to be able to pick up the numbers following the "items"
>>label. 
>>
>>I thought the following might work, but it doesn't seem to
>>
>>/ORs (\b(\d+)\b)+/
> 
>    ^^^
> 

replace ORs with items. I'm trying to use the regex in different places, 
and I picked the other example.

> 
> What is that supposed to do?
> 
>  
> 
>>i want it to match:
>>1234
>>4567
>>4345
>>3245
> 
> 
> 
> With the input and specification you've provided this will work for 
> you:
> 
> 
>   print "$_\n" for m/(\d+)/g;
> 
> 

The problem I have is that the target string could be something like this:

Over the next 10 days i'll deliver 4 items 1234, 1234, 5321 and 2345.

I want to use items as the key phrase to identify the list of times.
The example you gave will also find 10 and 4 which i don't want.

In english, the regex i need is: Find all numbers after "items".


-- 
--
Martin Gill


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

Date: 18 Feb 2005 17:21:40 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Need help with an advanced? regular expression
Message-Id: <yzdfyzt260b.fsf@invalid.net>


Martin Gill <nospam@nospam.net> writes:
> The problem I have is that the target string could be something like this:
> 
> Over the next 10 days i'll deliver 4 items 1234, 1234, 5321 and 2345.
> 
> I want to use items as the key phrase to identify the list of times.
> The example you gave will also find 10 and 4 which i don't want.
> 
> In english, the regex i need is: Find all numbers after "items".

I would first extract the substring beginning with "items" and then
apply the regexp to find the numbers.

Maybe it can be done in one single regexp (I don't think it can), but
even if so, would it be worth the effort?


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

Date: 18 Feb 2005 08:22:24 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Need help with an advanced? regular expression
Message-Id: <1108743744.271567.255600@c13g2000cwb.googlegroups.com>

Martin Gill wrote:
>
> I'm trying to write a regular expression which parses the following
> string:
>
> blah blah items 1234, 4567, 4345, and 3245 blah blah blah
>
> I want to be able to pick up the numbers following the "items" label.
>
> I thought the following might work, but it doesn't seem to
>
> /ORs (\b(\d+)\b)+/
>
> i want it to match:
> 1234
> 4567
> 4345
> 3245


   Well, for one thing, you want to pick up the numbers following the
"items" string, but in your regular expression you are searching for
"ORs" instead (which doesn't appear in your string at all).

   If you have a $string variable:

$string = "blah blah items 1234, 4567, 4345, and 3245 blah blah blah";

you can print out all the numbers by first matching "items" and then by
matching all the numbers in the postmatch (the $' variable), like this:

      if ($string =~ /items/)
      {
         # Everything after "items" (the postmatch) is now in $'
         #    so extract all the numbers in $' :
         print "$_\n"  foreach $' =~ m/\d+/g;
      }

But be warned!  Use of $' carries a performance penalty, making many of
Perl programmers avoid it.  If this performace penalty bothers you, you
can avoid it with the following similar code:

      if ($string =~ /items(.*)/)
      {
         # Everything after "items" is now in $1
         #    so extract all the numbers in $1 :
         print "$_\n"  foreach $1 =~ m/\d+/g;
      }

   If this is the only regular expression in your program, or if the
other regular expressions operate on relatively small strings, then
using $' should be nothing to worry about.  In such cases, I think you
should use whatever method is more readable to you.

   I hope this helps.

   -- Jean-Luc



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

Date: Fri, 18 Feb 2005 17:14:10 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Need help with an advanced? regular expression
Message-Id: <37mjftF5ebj5eU1@individual.net>

Martin Gill wrote:
> The problem I have is that the target string could be something like this:
> 
> Over the next 10 days i'll deliver 4 items 1234, 1234, 5321 and 2345.
> 
> I want to use items as the key phrase to identify the list of times.
> The example you gave will also find 10 and 4 which i don't want.
> 
> In english, the regex i need is: Find all numbers after "items".

You don't necessarily need a pure regex, do you?

     print "$_\n" for substr($_, index $_, 'items') =~ /\d+/g;

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


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

Date: 18 Feb 2005 10:47:41 -0800
From: mdfoster44@netscape.net
Subject: Newbie question sorting
Message-Id: <1108752461.443860.42760@o13g2000cwo.googlegroups.com>

Hi

Could someone please point me to some documentation on how to sort
arrays such as these?

a[0][0]= ANA a[0][1]= 1
a[1][0]= MFI a[1][1]= 12
a[2][0]= ABW a[2][1]= 1
a[3][0]= LTL a[3][1]= 2
a[4][0]= APD a[4][1]= 2

I would like to sort the first column after sorting the second column
numerically.
So the sort of the above data should give back.

ABW 1
ANA 1
APD 2
LTL 2
MFI 12

Thanks



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

Date: Fri, 18 Feb 2005 16:37:02 GMT
From: nospam@geniegate.com
Subject: Re: Question? Alternative to loading modules!!!
Message-Id: <Lucy1108742055137890xf3b6b8@air.tunestar.net>

In: <1106230069.951809.280200@c13g2000cwb.googlegroups.com>, "ChicksHateMe" <chicks_hate_me@hotmail.com> wrote:
>I consider myself still a newbie so I am looking for help, not flaming.
>Thanks in advance.
>
>I have written a few Perl programs, and I enjoy it. I like it more than
>doing stuff in PHP. I don't want to start the whole PHP - Perl thing,
>but I like the power and ease of Perl, and who's faster doesn't matter
>to me.

Perl is more creative, I'll have to agree. (I use both)

>1. Where I am doing this for my own specific sites, what I am wondering
>is, if there are any issues I may run into?

Yes. As someone pointed out, binary dependancies will be a nightmare.

You might also run into problems with the import() method that is called
automatically by 'use'

use lib qw(/your/module/path); 

Is probably what you want.



Write a throw-away CGI/shell script:

#!/bin/sh
echo "Content-Type: text/plain"
echo ""

perl Makefile.PL 2>&1
make 2>&1
make install 2>&1

# set parameters and such for make, password protect directory first! (Or
# at least remove the temp cgi when done)


>2. Would installed modules run faster than using the modules as a
>simple include where possible and needed??

It depends.. in NON mod_perl CGI environments, the thing to keep in mind
is that only a small portion of your program will ever be run in the same
request. AUTOLOAD can really speed this up, (But become a HUGE nightmare
when you get into OO perl)

Either way, the strategy is to only load the portions of your program
via 'require' when they are actually needed. Literally including perl
code in one monolithic program can slow down a program considerably 
in this environment.

In mod_perl environments, it's almost exactly the opposite.

>3 Is there an EASY way to convert a module to a simple include, or will
>I OFTEN run into issues?? Things like assigned vars, etc??

use lib qw(/path) can really go a long way here. (Or in some other
way modify @INC before any other 'use' statements are evaluated, a hack
when lib isn't available/won't work is to wrap @INC in a BEGIN { ... } 
block, but don't do that unless 'use lib' won't work... it's ugly.)

>Again, the reason I ask, Is I LOVE perl and want to learn more, but in
>some cases it is REALLY difficult to get the hosts to load Perl
>modules, packages, bundles, etc...  So, in that way, it's hard to
>actually run some software on sites ( i.e. pre-written CMS packages).
>I Think this is a MAJOR reason why PHP based CMS's  are far more
>popular and supported than Perl Based ones.

Yea, PHP has sort of taken over, Used to be the other way around. There
are a lot of reasons for this. mod_perl is still quite popular in 
larger scale operations. (With mod_perl, most everything you learn
about CGI optimization needs to be turned upside-down.) 


Jamie
--
http://www.geniegate.com                    Custom web programming
guhzo_42@lnubb.pbz (rot13)                User Management Solutions


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

Date: Fri, 18 Feb 2005 16:47:05 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: simple map query
Message-Id: <d_oRd.31363$f%5.1523@trndny03>

"John H" <john1976@hotmail.com> wrote in message
news:R8oRd.38032$k4.741027@news1.nokia.com...
> i have been trying to write very simple statement using map,
> what it should do check the condition if it fails don't push it in to
> result
> @Myarray= map {if($_!~/echo/),@fromarray
>
> i have totaly confused now , I have tried all the damm combination of
> brackets , it does not work,
> its pathatic now ,

You're confusing the purpose of 'map' and 'grep'.  map() returns a list
of all results of some block of code applied to each element of a list.
grep() returns a list of all elements of a list for which some condition
is true.  You want to do the second one.

my @Myarray = grep {! /echo/} @fromarray;

read more about each of these functions in
perldoc -f map
and
perldoc -f grep

Paul Lalli



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

Date: Fri, 18 Feb 2005 17:50:17 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: use strict; and O_WRONLY
Message-Id: <slrnd1c769.13a.tassilo.von.parseval@localhost.localdomain>

Also sprach Sherm Pendley:

> Tassilo v. Parseval wrote:
>
>> const-xs.inc is the XS implementation of the 'constant' function as
>> available from AUTOLOAD. 'XS_constant' then calls the C function
>> 'constant' (defined in const-c.inc).
>
> When I was dealing with constants in my XS code, I managed to follow things
> up to this point...
>
>> This one then works a bit like a
>> finite state machine that does pattern matching on the name of the
>> requested constant.
>
> But this is where I got lost. When I created a new XS module with h2xs, it
> had skeletons of both *.inc files, but I couldn't figure out how those were
> generated, nor how to update them. I suppose there's a discussion about it
> to be found in the p5p archives, but I didn't want to dive into Perl's
> guts, all I wanted to do is export some constants.

It's done from Makefile.PL with the help of ExtUtils::Constants. The
relevant code in Makefile.PL looks like this:

    if  (eval {require ExtUtils::Constant; 1}) {
	my @names = qw/CONSTANT1 CONSTANT2 .../;
	ExtUtils::Constant::WriteConstants(
	    NAME         => 'Module',
	    NAMES        => \@names,
	    DEFAULT_TYPE => 'IV',
	    C_FILE       => 'const-c.inc',
	    XS_FILE      => 'const-xs.inc',
	);
    }

@names' content is determined by h2xs' flimsy C-header parser which will
ever so often miss important #defines or enums or find some that
actually don't exist in the header.

It's also possible to provide one's own set of symbols for @names.

In pre-ExtUtils::Constants times h2xs would create even messier C-code
for the constant exportation and inline it into the XS file. The code
thusly generated was often buggy and you were forced to debug this
machine-generated code. For an anecdote on this, see

    <http://use.perl.org/~ethan/journal/9230>

and the comment by Nicholas Clark who's responsible for
ExtUtils::Constants. In his comment you'll find a few explanations on
how the constant-handling in XS works.

> Eventually, I gave up - I wrote a simple text file with the names of the
> constants I wanted to export to Perl. For each name in it I call a short C
> function that uses dlsym() to check for the existence and location of that
> symbol. If it exists, I pass its value to newCONSTSUB() to create the
> constant in Perl.

I wonder about the necessity of dlsym(). Public symbols somehow need to
be mentioned in the header which has to be included in the XS file.
Under these premises, a simple '#ifdef' should be enough. Non-existing
symbols would then yield an error at compile-time already.

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: Fri, 18 Feb 2005 13:41:00 -0500
From: "Alison Bowes" <alisonNO@SPAMhorison-research.com>
Subject: variation on 'calling subroutine via reference'?
Message-Id: <e2aaa$421636a3$4200e6a2$26212@ispnews.usenetserver.com>

I posted this on comp.lang.perl then ran across another post saying that 
that newsgroup is "defunct" and posts should be made here instead.  Sorry if 
you're seeing this twice!

I know that if $subname contains the name of the subroutine I want to call, 
I can call that subroutine via

&$subname;

However, my subroutine names are in an array, so if I want to call 
$subname[3] I've tried

&$subname[3];

But, that doesn't work, and I'm not having much luck finding such an
example.  If I'm doing something truly numbskulled, I do apologize!

I do realize I could go this route:
$this_sub = $subname[3];
&$this_sub;

But, that just seems so clunky and unnecessary, no?

TIA,
Alison





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

Date: Fri, 18 Feb 2005 18:09:50 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <slrnd1c8au.13a.tassilo.von.parseval@localhost.localdomain>

Also sprach Anno Siegel:

> <nospam@geniegate.com> wrote in comp.lang.perl.misc:
>
>> Thats actually one of the reasons I don't care for the -w switch. (*EXCEPT* in
>> debugging) I don't know if it's still the case or not, but this used to
>> generate a warning:
>> 
>> sub something {
>> 	my($i);
>> 	{
>> 		my($i)
>> 		.. use inner $i ...
>> 	}
>> 	... use outer $i ..
>> }
>
> It doesn't warn (why didn't you test it?) and it never did.  That is
> no reason not to use warnings.

There is a problem with warnings on a larger scale, namely in the
context of published code, most notably modules. It's most annoying and
fairly useless to read things such as 

    Use of uninitialized value in string eq at
    /opt/perl5.8.6-db/lib/5.8.6/Foo/Bar/Baz.pm line 4242

Does it mean there's a bug in the module, or maybe in my program using
this module? Or maybe it's a potential bug that could occur under
certain rare circumstances. It could just as easily mean nothing of that
kind and only expose the module's author's sloppyness.

If warnings in module context really and rightly suggest there's a bug,
then the bug itself will sooner or later manifest in some other way,
wont it? Otherwise it wouldn't be one. The point being that warnings
rarely provide information useful to people not in charge of the code.

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: 18 Feb 2005 17:57:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <cv5a9s$o6q$1@mamenchi.zrz.TU-Berlin.DE>

Tassilo v. Parseval <tassilo.von.parseval@rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach Anno Siegel:
> > <nospam@geniegate.com> wrote in comp.lang.perl.misc:

> >> sub something {
> >> 	my($i);
> >> 	{
> >> 		my($i)
> >> 		.. use inner $i ...
> >> 	}
> >> 	... use outer $i ..
> >> }
> >
> > It doesn't warn (why didn't you test it?) and it never did.  That is
> > no reason not to use warnings.
> 
> There is a problem with warnings on a larger scale, namely in the
> context of published code, most notably modules. It's most annoying and
> fairly useless to read things such as 
> 
>     Use of uninitialized value in string eq at
>     /opt/perl5.8.6-db/lib/5.8.6/Foo/Bar/Baz.pm line 4242

Okay, but that happens only with global -w, not with lexical "use warnings".

> Does it mean there's a bug in the module,

Yes.  See below.

> or maybe in my program using
> this module? Or maybe it's a potential bug that could occur under
> certain rare circumstances. It could just as easily mean nothing of that
> kind and only expose the module's author's sloppyness.

If a module issues warnings the author didn't intend the user to see,
that's a bug.  Most of the time it is trivially fixed.

If the module author has "use warnings" early in each file as a matter of
course, these problems are caught during development.  Unfortunately, h2xs
issues a module template without warnings.  That may be a reason why the
practice isn't more common.

> If warnings in module context really and rightly suggest there's a bug,
> then the bug itself will sooner or later manifest in some other way,
> wont it? Otherwise it wouldn't be one.

What about silently delivering wrong results?

> The point being that warnings
> rarely provide information useful to people not in charge of the code.

Really?  I'd understand "(not) useful to the people running the program",
but as a developer I'm just as interested in warnings as I am in errors.

Anno


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

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


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

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

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


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


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