[15846] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3259 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 5 21:06:15 2000

Date: Mon, 5 Jun 2000 18:05:16 -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: <960253516-v9-i3259@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 5 Jun 2000     Volume: 9 Number: 3259

Today's topics:
        Active Directory and Perl theowood@my-deja.com
        Active Directory and Perl theowood@my-deja.com
    Re: Array Help <makarand_kulkarni@My-Deja.com>
    Re: Array Help (Tad McClellan)
        Can't Write Binary File <grichards@flashcom.net>
    Re: Convert reference to array into an array of referen twolfmaier@acm.org
        CRON + system <joeb@jagas.demon.co.uk>
    Re: CRON + system (John Gehman)
    Re: Daylight savings time? <flavell@mail.cern.ch>
    Re: Daylight savings time? <red_orc@my-deja.com>
    Re: DBM or flat file? <jeff@vpservices.com>
    Re: easy reference question <lr@hpl.hp.com>
    Re: easy reference question (Tad McClellan)
    Re: embedded macros <makarand_kulkarni@My-Deja.com>
    Re: embedded macros <gnari@simnet.is>
    Re: Extracting an area from web page <memmett@fraser.sfu.ca>
        ftp client - PERL (Brian A)
    Re: Gtk/Glade usage <atrus@atrustrivalie.eu.org>
    Re: Help: OOPS Inheritance... <Tbone@pimpdaddy.com>
    Re: Help: OOPS Inheritance... (Ala Qumsieh)
        list array contains perl functionality invinfo@my-deja.com
    Re: list array contains perl functionality <sariq@texas.net>
    Re: list array contains perl functionality <jeff@vpservices.com>
    Re: multiple foreach - logic question (John Gehman)
    Re: Newbie needs help with search and replace <gnari@simnet.is>
    Re: Parsing Email from Europe <webmaster@ostas.lu.se>
        Perl and Active Directory? theowood@my-deja.com
    Re: persistent connection with Apache::DBI (mod_perl) <makarand_kulkarni@My-Deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 05 Jun 2000 23:10:37 GMT
From: theowood@my-deja.com
Subject: Active Directory and Perl
Message-Id: <8hhc1f$olj$1@nnrp2.deja.com>

Does anyone have sample Perl code for accessing
objects (ie. users, groups) in Microsoft's Active
Directory?  We need to be able to call the COM
functions in Microsoft's Active Directory
Services Interface.


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


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

Date: Mon, 05 Jun 2000 23:13:00 GMT
From: theowood@my-deja.com
Subject: Active Directory and Perl
Message-Id: <8hhc5g$qud$1@nnrp1.deja.com>

Does anyone have sample code for querying and modifying objects (ie.
users and groups) in Microsoft's Active Directory?


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


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

Date: Mon, 05 Jun 2000 15:54:17 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Array Help
Message-Id: <393C2F99.847F932C@My-Deja.com>



Lee wrote:

> I am trying to populate a drop down list on a HTML Page with a "LOCATION"
> field from a database. I can get the field contents  easily enough and
> populate the list, but if the field contents are the same, I want it to be
> disregarded, the continue looping.
>
> The only thing I could come up with was to read the field first put that
> into the drop down menu (<option>), then push it onto an @array. Then when
> the next field contants are read, it checks to see if it already in the
> list, if not adds it to the drop down as an option, if it is, just
> disregards it, so I don't get duplicate drop down items. This is when I hit
> the problem, I have no idea how to string match within @arrays, only within
> $strings, using the m// pattern matching.
>
> After all that ranting: I would like to know if you can add new words onto
> $strings (string concatenation) or if someone could tell me how to pattern
> match within an @array.
>
> Thanks in advance...
>
> Lee

use a hash to makes items unique.
eg.
my @list =  qw/a b c c d d e e e f f f x x x z/;
my %list ;
@list { @list } = () ;
@list = sort keys %list ; # voila ! we now have unique items
 print join ( ":", @list ) , "\n";
--



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

Date: Mon, 5 Jun 2000 17:47:28 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Array Help
Message-Id: <slrn8jobg0.us.tadmc@maxim.metronet.com>

On Mon, 05 Jun 2000 14:24:46 GMT, Lee <lee.stoddart@wcl.fi> wrote:

>it checks to see if it already in the
>list, 


Perl FAQ, part 4:

   "How can I remove duplicate elements from a list or array?"

   "How can I tell whether a list or array contains a certain element?"


>, I have no idea how to string match within @arrays, only within
>$strings, using the m// pattern matching.


Because you cannot pattern match against arrays.

You _can_, however, pattern match against array _elements_, which
are scalars just like any other scalar. Just loop over the array:

   foreach ( @array ) {
      if ( /something/ ) {
         print "matched: $_\n";
       }
    }

But you don't need to do that now, because you are going to do it as
suggested in the FAQ  :-)

And you should be using a test for equality rather than a pattern
match anyway (unless you are searching for patterns rather than
strings).


>After all that ranting: 
                 ^^^

There's your problem!

You have three characters wrong:

   s/ant/ead/;

You should be "reading", not "ranting". 

:-)


The answer is already on your hard disk!

So what are you doing asking it here?


>I would like to know if you can add new words onto
>$strings (string concatenation) or if someone could tell me how to pattern
>match within an @array.


You don't want/need pattern matching:

   foreach ( @array ) {
      if ( $_ eq 'something' ) {
         print "found: $_\n";
       }
    }


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 5 Jun 2000 16:31:12 -0700
From: "Gabe" <grichards@flashcom.net>
Subject: Can't Write Binary File
Message-Id: <sjodstqs2t5137@corp.supernews.com>

The following results in a file name $picname being created but with zero
bytes, i.e. no data is written to it. I can't figure it out. I've used this
algorithm in other programs and it's worked...I think. Please help.

#This code doesn't work;
use CGI;
use File::Basename;
fileparse_set_fstype('MSWin32');
my $file = $cgi->param('image');
my $picname = basename($cgi->param('image'));
no strict;
open (PIC, ">/home/cremeco/www/images/$picname") or die &error;
while (my $bytesread = read($file,my $buffer,1024)) {
print PIC $buffer;
}
close PIC;

The next snippet, from a different program, writes to the same server, but
this one works, what's the difference! They're virtually the same program
right?

#This code works.
my $picname = $cgi->param('prodid');
$picname = "$picname.jpg";
my $filename = $cgi->param('pic');
no strict;
open (PIC, ">>/home/cremeco/www/images/catalog/$picname") or die &error;
while (my $bytesread = read($filename,my $buffer,1024)) {
print PIC $buffer;
}
close PIC;

Gabe




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

Date: Mon, 05 Jun 2000 23:21:31 GMT
From: twolfmaier@acm.org
Subject: Re: Convert reference to array into an array of references
Message-Id: <8hhcld$rbi$1@nnrp1.deja.com>

Hi Abigail,

> But, what's the point? It's an obscure, inefficient way to print with
> newlines or spaces between the elements.
>
>     {local $" = $separated ? "\n" : " "; print "@$arrayref\n";}

Nice. I would have never thought of that. :-)

Of course, you are absolutely right. I have to apologize. In my attempt
to focus on my particular question, I omitted any background
information.

I am writing a little subroutine for sending email using the Net::SMTP
module. One of the parameters passed to the subroutine is a reference to
an array of recipients. Sometimes I would like to send one email to all
recipients in the array, at other times I would like to send a separate
email to each recipient (so that the other recipients don't appear in
the To: line of the email). In the latter case, calling the
subroutine for each recipient would be inefficient. Here are some clips:


#!perl -w

use strict;

use Net::SMTP;

my $SMTP_SERVER = 'smtp.somewhere.com';
my $SMTP_HOSTNAME = 'someone@somewhere.com';

&send_email($SMTP_HOSTNAME, ['recipient1@somewhere.com',
'recipient2@somewhere.com'], undef, 'Subject', 'This is the message.',
{SendSeparate => 1});

# $to and $cc are references to an array
sub send_email {
    my ($from, $to, $cc, $subject, $message, $attributes) = @_;

    # lines deleted

    foreach ($$attributes{'SendSeparate'} ? map {[$_]} @$to : $to) {
        my $failed_attempts = 0;
        do {
            eval {
                $smtp->mail($from) or die('smtp->mail() failed');
                $smtp->to(@$_, @$cc) or die('smtp->to() failed');

                $smtp->data() or die('smtp->data() failed');
                $smtp->datasend('To: ' . join(', ', @$_) . "\n") or
die('smtp->datasend(To:) failed');
                $smtp->datasend("From: $from\n") or
die('smtp->datasend(From:) failed');

                #lines deleted
             };

            if ($@) {
                # lines deleted
                if (++$failed_attempts >= 3) { return ''; }
            }
        } while ($@);
    }

    return 1;
}


I am still in debug mode, so there might be one or two bugs in there. If
you can think of any better ways of doing what I attempt to achieve,
don't hesitate to let me know.

Thomas

-----------------------------------------------------
Thomas Wolfmaier
Human-Computer Interaction Resource Network (HCIRN)
25 Bucks Green Road, Thornhill, ON, Canada, L3T 4G1
Tel: +1-905-881-7095
Email: twolfmaier@acm.org
Web: www.hcirn.com
-----------------------------------------------------



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


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

Date: Mon, 05 Jun 2000 23:25:17 +0100
From: JoeB <joeb@jagas.demon.co.uk>
Subject: CRON + system
Message-Id: <393C28CC.446660F0@jagas.demon.co.uk>

Hello All,

Can anyone tell me if I can call the "system" function in a cron job?
My script runs fine from the command line. Hoewver, as a cron job
it doesn't. I have managed to narrow it down to "system" function call.
Any Help will be appreciated.



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

Date: 5 Jun 2000 22:39:05 GMT
From: jdg28@pantheon.yale.edu (John Gehman)
Subject: Re: CRON + system
Message-Id: <8hha69$j6j$2@news.ycc.yale.edu>

I have used system calls in programs run from my crontab, so I think
there's nothing inherently wrong with doing so.

Perhaps what you're running from the command line is dependent on the
directory that you're in? That is, some path that you've defined for use
with the system("...","...") is defined in terms relative to the location
of the executable? If so, specify the path with absolute referencing
(that is /home/user/Directory/subdirectory/file )

j.


JoeB (joeb@jagas.demon.co.uk) wrote:
: Hello All,

: Can anyone tell me if I can call the "system" function in a cron job?
: My script runs fine from the command line. Hoewver, as a cron job
: it doesn't. I have managed to narrow it down to "system" function call.
: Any Help will be appreciated.



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

Date: Tue, 6 Jun 2000 00:13:10 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Daylight savings time?
Message-Id: <Pine.GHP.4.21.0006060011210.2487-100000@hpplus01.cern.ch>

On Mon, 5 Jun 2000, Rodney Engdahl wrote:

> > Has the World suddenly agreed on changeover dates while I wasn't
> > looking?
> 
> intended context was US.

Alright, point taken.

But you know, I can't help thinking that a better solution for the
stated problem could be achieved by _removing_ that simplification ;-)

cheers



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

Date: Mon, 05 Jun 2000 23:05:12 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Daylight savings time?
Message-Id: <8hhbmv$qpm$1@nnrp1.deja.com>

In article <Pine.GHP.4.21.0006060011210.2487-100000@hpplus01.cern.ch>,
  "Alan J. Flavell" <flavell@mail.cern.ch> wrote:
> On Mon, 5 Jun 2000, Rodney Engdahl wrote:
>
> > > Has the World suddenly agreed on changeover dates while I wasn't
> > > looking?
> >
> > intended context was US.
>
> Alright, point taken.
>
> But you know, I can't help thinking that a better solution for the
> stated problem could be achieved by _removing_ that simplification ;-)
>
> cheers
>
>


You are certainly correct in that thought.


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


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

Date: Mon, 05 Jun 2000 18:58:11 -0400
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DBM or flat file?
Message-Id: <393C3083.ED492BA6@vpservices.com>

William Herrera wrote:
> 
> On Mon, 05 Jun 2000 03:59:55 GMT, juump@my-deja.com wrote:
> 
> >I'm working with data in a flat file, one record per line. There are
> >between 20K and 150K records per file. I need to compare a
> >substring to each record, and return any records that contain the
> >substring.
> 
> Yes, use a flat file and a fast hard disk with good buffers.
> 
> >What about cases where
> >there are several substrings to compare, using both AND and OR?
> 
> Compile the regular expression using & and | in that regular expression, then
> use the (dynamically?) compiled regex in the flat file search. This is the sort
> of thing that perl really handles well IMO.

Since they are substring comparisons, you can use index() instead of a
regex, or you can use one of the DBI modules that supports flat files
(DBD::CSV or DBD::RAM, for example) and use LIKE or CLIKE in your SQL
selection.  Those modules will use the C search libraries that are part
of Statement.pm to make the selection.  If you try all the methods
(regex,index,module) and benchmark them, please let us know the results.

-- 
Jeff


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

Date: Mon, 5 Jun 2000 15:45:52 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: easy reference question
Message-Id: <MPG.13a5cd7b2623102398ab25@nntp.hpl.hp.com>

In article <393c7988.0@news.isholf.is> on Mon, 5 Jun 2000 21:05:29 -
0000, Ragnar Hafstað <gnari@simnet.is> says...

 ...

> seriously, you are probably thinking of:
> $xref=[param('xArray')];
> 
> this should work, but note that param() has the wonderful ability
> of returning either a scalar or a list depending on context, and the
> line above happens to put it in a scalar context, fortunately.

I'm quite sure you mean 'list context', not 'scalar context'.  And it is 
by intent, not by fortune.

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


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

Date: Mon, 5 Jun 2000 17:59:53 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: easy reference question
Message-Id: <slrn8joc79.us.tadmc@maxim.metronet.com>

On Mon, 5 Jun 2000 21:05:29 -0000, Ragnar Hafstað <gnari@simnet.is> wrote:
>"steveFarris" <nlymbo@mindspring.com> wrote in message
>news:393C23E2.1A34CF83@mindspring.com...
>>
>> Is there anyway to shorten the following to one line:
>>
>> use CGI;
>>
>> @x = param('xArray');
>> $xref = \@x;
>
>seriously, you are probably thinking of:
>$xref=[param('xArray')];
>
>this should work, 


This does work. No "should" about it...


>but note that param() has the wonderful ability
>of returning either a scalar or a list depending on context, and the
>line above happens to put it in a scalar context, 
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^


No it doesn't.

Anonymous arrays impose _list_ context.

Perhaps you were thinking of square brackets when used for
_indexing_ an array, which gives scalar context?


>fortunately.

It would be *mis*fortunate indeed if it was as you describe. 

We've dodged a bullet  :-)


>so where you are not sure about context, 


where you are not sure about context, go read the docs to find
out what context it is (or write a subroutine using wantarray()
to find out the context).


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 05 Jun 2000 16:12:22 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: embedded macros
Message-Id: <393C33D6.67A4C800@My-Deja.com>

> I try solve the following problem:
> I have a text file. Inside this
> text files I want to embed perl macros:

Module HTML::mason was written for this reason
http://www.masonhq.com/docs/faq/
--




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

Date: Mon, 5 Jun 2000 23:21:21 -0000
From: "Gnari" <gnari@simnet.is>
Subject: Re: embedded macros
Message-Id: <393c9960.0@news.isholf.is>

$frame=~ s/%(.+?)%/&peval($1)/ge;

or even better, get rid of your peval sub altogether, and use:
$frame=~ s/%(.+?)%/$1/gee;

I dont know what you expect the for loop in your macro to return.
a print is a print, even inside an eval. maybe you wanted something like:
%do {my $x='';for ($ii=0;$ii<10;$ii++){$x.=$ii};$x}%

a % is not a good delimiter if you want to be able to use hashes
in your macros

read the docs, please
perldoc perlre


gnari


"Daniel Heiserer" <daniel.heiserer@bmw.de> wrote in message
news:393B802F.9C91A123@bmw.de...
> Hi,
> I try solve the following problem:
> I have a text file. Inside this
> text files I want to embed perl macros:
> --------- my file-----------------
> $This should  not be a variable for perl!!!!!
> hello every body.
> now I try to run a perl macro.
> My name is %$ENV{USER}% and
> I want to embed some macros here:
> %for ($ii=0;$ii<10;$ii++){print $ii};%
> ----------end of my file---------
>
> So the idea is I split the file using the '%'
> then I take every 2nd element and put
> it into an %TOEVAL hash.
> Then I evaluate each key in the toeval hash
> and print $_ and put the result back as the value
> of the hash and then I substitute each key of the
> hash inside myfile with its value.
>
> Unfortunately I fail at some points:
> I faile for example at points like
> $r='$ENV{USER}' because (I think)
> perl sees in the substitute
> s,$r,whoIam,;
> the value of $r which itself is a variable
> and therefore is going to be substituted right?
> How can I fix this or is there a better way to mix
> perl code and simple text and keeping the simple text
> still readable (no printf-crap for all the text lines)?
> Remind the amount of perl commands inside the text
> should be quite small.
>
>
> my code:
> sub parse{
>         @Tmp=split('\%',$frame);
>         for ($jk=1;$jk<=$#Tmp;$jk=$jk+2){
>                 $TOEVAL{$Tmp[$jk]}=peval($Tmp[$jk]);
>         }
>         foreach $r (keys %TOEVAL){
>                 print "evaluating: $r ==> $TOEVAL{$r}";
>                 $frame=~s,\%$r\%,$TOEVAL{$r},;
>         };
>         print $frame;
> }
> #------------------------------------------------------------------------
> sub peval{
>         $\="\n";
>         my $toeval=shift @_;
> #       print "1.$toeval";
>         $toeval='$_='.$toeval;
> #       print "2.$toeval";
>         eval($toeval);
>         s/\n*$//g;
> #        print;
>         return $_;
> };
> #------------------------------------------------------------------------
>
>
> Thanks Daniel




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

Date: 05 Jun 2000 15:16:09 -0700
From: Matthew Wilson Emmett <memmett@fraser.sfu.ca>
Subject: Re: Extracting an area from web page
Message-Id: <yvw91z2b93km.fsf@fraser.sfu.ca>

"Gnari" <gnari@simnet.is> writes:

> > Please forgive me, as I said, I'm pretty new to this.  What are you
> > suggesting i do to make this suggestion work.  Because if I execute the
> > script as is, it does not capture the region specified, I get the whole
> page
> > returned.  Any help is much appreciated!

> > > : $page =~ /\<!-- START HERE --\>.*?\<!-- END HERE --\>/;
> > > :
> > > : $region_of_interest = $1;
> > >
> > > Not without capturing parens in the regex it won't.
> 
> what he means is that is cruel to post wrong code in reply to a question
> as yours.
> 
> the capturing parens are used to specify what parts of the match are to
> be returned or put into $1, $2 ...
> in the example above they should surround the '.*?', giving us:
> $page =~ /\<!-- START HERE --\>(.*?)\<!-- END HERE --\>/;
> $region_of_interest = $1;

Whoops!  Sorry about that!

Matt


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

Date: Mon, 05 Jun 2000 23:35:34 GMT
From: nospam_bca1000@hotmail.com (Brian A)
Subject: ftp client - PERL
Message-Id: <393c375b.6838585@news.ezesurf.co.uk>

I want to allow others to upload to my site using standard ftp
software on their computers. I want to be able to restrict access as
necessary to each individual user.
I have already written a browser based uploader but this is rather
basic. I need to allow uploads of lots of files at one go with the
ease normally afforded with ftp software - mine only allows 5 files at
once :-).
I would prefer Perl software at the site to take care of the
uploading. Any scripts out there ?
Brian A.

Miss off the 'no_spam' in the address if sending an email.
Surf the Net and get 31p + per hour for it!!
http://www.site44.com/surfpay4u/index.html


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

Date: Mon, 05 Jun 2000 16:38:07 -0700
From: Yann Ramin <atrus@atrustrivalie.eu.org>
Subject: Re: Gtk/Glade usage
Message-Id: <393C39DF.DBB92262@atrustrivalie.eu.org>

Ok, I was a complete idiot here... :)


Each pre-made signal doohickey has a member $form.  If you need to get
another form, use:

$form->{'widget'}->member();

Have fun,

Yann

Yann Ramin wrote:
> 
> Hi,
> 
> I've been dwelving into using GTK+ and Glade (as an interface builder).
> I have glade2perl working, and everything is peachy, until I write my
> own signal handlers.  My question is:
> 
> How do I access another widget/form from my  package?  I can't figure
> out how to do it :)
> I.e., I have a text entry called name and an entry called passwd.  When
> name changes (I have the signal handler in place), I want to put that
> text into passwd (its only an example).  I've figured out I need to use
> get_text and set_text, but how would I go about doing this?
> 
> Yann
> --
> 
> --------------------------------------------------------------------
> Yann Ramin                      atrus@atrustrivalie.eu.org
> Atrus Trivalie Productions      www.atrustrivalie.eu.org
>                                 irm.it.montereyhigh.com
> Monterey High IT                www.montereyhigh.com
> ICQ                             46805627
> AIM                             oddatrus
> Marina, CA
> 
> "All cats die.  Socrates is dead.  Therefore Socrates is a cat."
>         - The Logician
> 
>         # fortune
> "To be responsive at this time, though I will simply say, and therefore
> this is a repeat of what I said previously, that which I am unable to
> offer in response is based on information available to make no such
> statement."
> --------------------------------------------------------------------

-- 

--------------------------------------------------------------------
Yann Ramin			atrus@atrustrivalie.eu.org
Atrus Trivalie Productions	www.atrustrivalie.eu.org
				irm.it.montereyhigh.com
Monterey High IT		www.montereyhigh.com
ICQ 				46805627
AIM				oddatrus
Marina, CA	

"All cats die.  Socrates is dead.  Therefore Socrates is a cat."
	- The Logician
	
	# fortune
"To be responsive at this time, though I will simply say, and therefore
this is a repeat of what I said previously, that which I am unable to
offer in response is based on information available to make no such
statement."
--------------------------------------------------------------------


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

Date: 5 Jun 2000 22:46:12 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: Help: OOPS Inheritance...
Message-Id: <8hhajk$1doe$1@news.enteract.com>

echao@interaccess.com writes:
>
>   package HTMLStrip;
>   require Exporter;
>   @ISA         = qw( Exporter HTML::Parser );

You haven't required or used HTML::Parser. Simply inheriting
from it is not enough.



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

Date: Mon, 05 Jun 2000 23:08:43 GMT
From: aqumsieh@hyperchip.com (Ala Qumsieh)
Subject: Re: Help: OOPS Inheritance...
Message-Id: <8F4ACE993aqumsiehhyperchipcom@198.235.216.4>

bart.lateur@skynet.be (Bart Lateur) wrote in 
<393bff80.414628@news.skynet.be>:

>Ala Qumsieh wrote:
>
>>>   $p = new HTMLStrip;
>>         ^^^
>>This calls the method new() in the HTMLStrip module. Looking at the 
>>module above, you don't have a method called 'new'. Unlike C++, the 
>>word 'new' is not special with Perl.
>
>No, but looking at the @ISA thing, he expected the call to be
>transferred to the HTML::Parser module. Which is not an unreasonable
>thing to expect. But hey, I never use Perl's OO stuff, so I don't know
>why it doesn't work.

Good point. I am not familiar with HTML::Parser, so I don't know 
whether or not it supplies a new() method. If not, then there's the 
problem. Else, there is something fishy going on!

--Ala



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

Date: Mon, 05 Jun 2000 22:13:59 GMT
From: invinfo@my-deja.com
Subject: list array contains perl functionality
Message-Id: <8hh8mo$ojn$1@nnrp1.deja.com>



I am looking for a perl solution akin to java's hashtable.contains()

I would like to be able to use it on a list - preferably.

grep EXPR, LIST
  would be ideal if I could use a scalar in EXPR.

Is there a better solution than the following ?

$bool = 0;
for ( @mylist )
{
    $bool = 1 	if ( $_ == $srch4 );
}

btw, I'm working on a WinNT system.


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


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

Date: Mon, 05 Jun 2000 17:32:44 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: list array contains perl functionality
Message-Id: <393C2A8C.3D97A182@texas.net>

invinfo@my-deja.com wrote:
> 
> I am looking for a perl solution akin to java's hashtable.contains()
> 
> I would like to be able to use it on a list - preferably.
> 
> grep EXPR, LIST
>   would be ideal if I could use a scalar in EXPR.
> 
> Is there a better solution than the following ?
> 
> $bool = 0;
> for ( @mylist )
> {
>     $bool = 1   if ( $_ == $srch4 );
> }

Perl comes with exhaustive documentation.  Use it.  Always.  Without
fail.

perldoc -q contains

Then, read:

perldoc perldoc
perldoc perl

- Tom


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

Date: Mon, 05 Jun 2000 18:45:33 -0400
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: list array contains perl functionality
Message-Id: <393C2D8D.C5033F74@vpservices.com>

invinfo@my-deja.com wrote:
> 
> grep EXPR, LIST
>   would be ideal if I could use a scalar in EXPR.
> 
> Is there a better solution than the following ?
> 
> $bool = 0;
> for ( @mylist )
> {
>     $bool = 1   if ( $_ == $srch4 );
> }


Map the list onto a hash in which the keys of the hash are the array
members and the value of all keys is 1 (i.e. true), then test to see if
a given hash key is true.

my $srch4 = 3;
my @list = (1,2,3);
my %hash = map {$_=>1} @list;
print "TRUE" if $hash{$srch4};


-- 
Jeff


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

Date: 5 Jun 2000 22:28:58 GMT
From: jdg28@pantheon.yale.edu (John Gehman)
Subject: Re: multiple foreach - logic question
Message-Id: <8hh9ja$j6j$1@news.ycc.yale.edu>

#!/usr/bin/perl
use strict;

my $string_ein = 'ugly wet smelly bad mean gnarly dog';
my $string_zwei = 'nice well-groomed dog with no bad breath but a wet
tongue';

my @array_ein = split /\s+/, $string_ein;
my @array_zwei = split /\s+/, $string_zwei;
my @matches;
foreach my $w (@array_zwei) {
        my @match = grep { $_ eq $w } @array_ein;
        push @matches, @match;
}

print "@matches\n";

# ALternately, use { $w =~ $_ } if you want to allow some slack in the
# matches (i.e. dog <-> dogs still matches
#
# You could avoid looping at all if you left the flat list as a string
# and matched $_ to the string:


my $string_ein = 'ugly wet smelly bad mean gnarly dog';
my $string_zwei = 'nice well-groomed dog with no bad breath but a wet
tongue';

my @array_ein = split /\s+/, $string_ein;
my @matches = grep { $string_zwei =~ $_ } @array_ein;

print "@matches\n";


Jeremiah Adams (adams1015@worldnet.att.net) wrote:
: Hi I've got this logic problem maybe someone can help me out with it.

: I need to take user submitted data and split it at white space. Then I need
: to search a flat file with each piece of the split data from the user. The
: problem is that I also need to split the flat file data at white space as
: well and look for mathes at each split. For example - the user data: ugly
: dog and the flat file data : nice dog

: I need to check for a match with ugly and nice and ugly and dog, then a
: match for dog and nice and dog and dog. Dog and dog will return a hit. Here
: is what I have so far:

: open (FH, $standard_db_path ) || die "Cannot open file[$standard_db_path] :
: $!";

: while( defined( $line = <FH> ) ) {

:     chomp $line;

:     ( $site_name, $site_url, $site_email) = split( /\|/ , $line );

:     my (@site_names) = split(/\b([A-Za-z]+)\b/, $site_name);

:     # check each member of the $term array for match agains $site_name
:     # if there is a match stuff it into the matched hash

: foreach $term(@terms) {
:      if ( lc( $term ) eq lc( $site_name ) ) {
:     # do a bunch of stuff with data split from $line
:      }
: }

: The logic problem lies with the if statement above. Originally the script
: just looked for a match between the two terms $term and $site_name. But,
: that doen't allow for hits with partial matches against either the site name
: or the user submitted search term and I want to be able to do that. I want
: to be able to search each member of the @site_names array. Thanks






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

Date: Mon, 5 Jun 2000 22:27:02 -0000
From: "Gnari" <gnari@simnet.is>
Subject: Re: Newbie needs help with search and replace
Message-Id: <393c8ca3.0@news.isholf.is>

your problem might be the 2 '\s' that should be '\s+' or something

gnari


"Neil Watson" <neilwSPAMTHIS@idirect.com> wrote in message
news:393bcad7.17046812@bigmomma.idirect.com...
> I have a file that has lines similar to (each line is spaced the
> same):
>
> PSteel8804      A  10000000000000000A0
> PSteel8805      A  10000000000000000A0
> PSteel8812      A  10000000000000000A0
> PSteel8814S     A  10000000000000000A0
> PSteel18814S    A  10000000000000000A0
> Pl8812          A  10000000000000000A0
> Pl8814S         A  10000000000000000A0
> P128814S        A  10000000000000000A0
>
> I want to replace the 0A0 at the end of the line with 0S0 on any line
> that begins with PSteel.
>
> I wrote this script:
>
> perl -p -i rp AINVPIR
>
> where rp is:
>
> #/usr/local/bin/perl -w -p
> s/(PSteel[0-9]{4,5}[A-Z]?\sA\s[0-9]{16})0A0\n/\10S0\n/g
>
> I receive no errors yet no replacements are made.  I'm assuming that
> my regex does not match the line correctly but I can't firgure out
> what is wrong.  Can anyone help me?
>
> Thanks
> Neil Watson
> webhome.idirect.com/~neilw




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

Date: Sun, 04 Jun 2000 14:12:08 +0200
From: Jimmy Lantz <webmaster@ostas.lu.se>
Subject: Re: Parsing Email from Europe
Message-Id: <393A4798.BA069B7D@ostas.lu.se>

Hi, Thanks for the short code Abigail.
However when someone says there's no need for enoding the åäö and such
into &auml; and the likes that's wrong.
I do need to do that since I work with three different fonts in two
languages (swedish and chinese).
For this to be displayed properly I can't have it in charset, I define
classes in css. 
So, if your working with pages in several languages and with visitors
from Chine you need to encode them.
BTW the code isn't working still.
I'm working on a G4 MAc with MacPerl. (if someone has anyideas how to
get a pora link or a tip.table module for charconvertions, for Mac
please be my guest and  post a link or a tip)
// Jimmy Lantz
Sweden

"Alan J. Flavell" wrote:
> 
> On 1 Jun 2000, Abigail wrote:
> 
> > Note that Å and such are perfectly valid in HTML,
> 
> They are, if they're in the repertoire of the current character
> coding ("charset"), yes.  Quick check of Abigail's posting headers:
> 
>   Content-Type: text/plain; charset=iso-8859-1
> 
> Yup, you're OK there.
> 
> > so there isn't much need to encode them.
> 
> If you were using (say) iso-8859-7, or koi8-r, as your charset, there
> sure would be a need     ;-)
> 
> Both of these character codings are used "in Europe", after all.
> 
> (Do I need to cite RFC2070 at this point?  Surely not...)
> 
> all the best


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

Date: Mon, 05 Jun 2000 23:10:37 GMT
From: theowood@my-deja.com
Subject: Perl and Active Directory?
Message-Id: <8hhc1e$oli$1@nnrp2.deja.com>

Does anyone have sample code using Perl to access
Microsoft's Active Directory?   I have installed
the Active Directory SDK (ADSI), but I can't seem
to access the objects from within Perl using the
Win32::OLE functions.


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


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

Date: Mon, 05 Jun 2000 16:13:49 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: persistent connection with Apache::DBI (mod_perl)
Message-Id: <393C342D.56F3A814@My-Deja.com>

> I am trying to have a persistent access  to my database (mysql)
> via Apache::DBI bat i can't find any example of tow script using a same
> connection
> please help

In a CGI script you would close the connection before exiting.
In a Apache::DBI you will not close it. That is all. Or else
there is no other difference.

--



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 3259
**************************************


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