[22503] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4724 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 18 11:05:41 2003

Date: Tue, 18 Mar 2003 08:05:08 -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           Tue, 18 Mar 2003     Volume: 10 Number: 4724

Today's topics:
    Re: Determining String Membership <noreply@gunnar.cc>
    Re: Determining String Membership (Anno Siegel)
    Re: Determining String Membership (Tad McClellan)
    Re: Determining String Membership (Tad McClellan)
    Re: Determining String Membership <does.not@exist.de>
    Re: Determining String Membership <noreply@gunnar.cc>
    Re: Determining String Membership (Anno Siegel)
        disable pattern metacharacters? <bing-du@tamu.edu>
    Re: disable pattern metacharacters? <bing-du@tamu.edu>
    Re: frames without files ? <ericosman@rcn.com>
    Re: IO::Socket::SSL usage of SSL_reuse_ctx option <thomas.haselberger@ucpmorgen.com>
    Re: IO::Socket::SSL usage of SSL_reuse_ctx option <ndronen@io.frii.com>
    Re: Out of memory ctcgag@hotmail.com
        perl ssh background process (Omega)
        remote control with perl <user@someserver123abc.com>
    Re: remote control with perl <palladium@spinn.net>
    Re: return value of 'accept' in PF_UNIX sockets <mzawadzk@man.poznan.pl>
    Re: splitting an array into two arrays <usenet@dwall.fastmail.fm>
        text filter <user@someserver123abc.com>
    Re: text filter (Helgi Briem)
    Re: text filter <REMOVEsdnCAPS@comcast.net>
    Re: text filter <josef.moellers@fujitsu-siemens.com>
    Re: text filter <user@someserver123abc.com>
    Re: use of uninitialized value (david)
    Re: use of uninitialized value (Anno Siegel)
    Re: What's wrong with the Perl docs <h.m.brand@hccnet.nl>
        why can't I last? <user@someserver123abc.com>
    Re: why can't I last? ctcgag@hotmail.com
    Re: Win32 Perl newsgroup? (Helgi Briem)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 18 Mar 2003 12:09:16 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Determining String Membership
Message-Id: <b56v4b$25drp7$1@ID-184292.news.dfncis.de>

Anno Siegel wrote:
> Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
>>I'd be interested in comments on which of regexp patterns and the
>>index() function is the most efficient approach in this particular case.
> 
> I suspect neither, once you allow the hash approach to the contest.

Please explain. :)

/ Gunnar

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



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

Date: 18 Mar 2003 12:03:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Determining String Membership
Message-Id: <b571u0$9u1$3@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> >>I'd be interested in comments on which of regexp patterns and the
> >>index() function is the most efficient approach in this particular case.
> > 
> > I suspect neither, once you allow the hash approach to the contest.
> 
> Please explain. :)

Sorry, I spoke too soon.  I guess I assumed there was a way to extract
the (possible) server name from each line (split or something).  Then
you could just check the name for existence in a hash.  Since no such
method was indicated, the "hash approach" remains a fantasy.  There
is none, as far as we know.

Anno


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

Date: Tue, 18 Mar 2003 07:03:39 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Determining String Membership
Message-Id: <slrnb7e69b.6h6.tadmc@magna.augustmail.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote in comp.lang.perl.misc:
>> In article <2653596.1047941479@dbforums.com>,
>> rymoore  <member26707@dbforums.com> wrote:

>> :I have an array of server names that is read in from a config file.

>> :I then need to search through a file and keep any lines that have these
>> :server names in them.

>> $pattern = join '|', @SERVERS;
> 
> Make that
> 
>     $pattern = join '|', map quotemeta, @SERVERS;


>     /$pattern/o and print while <FILE>;


Make _that_

      /\b($pattern)\b/o and print while <FILE>;


So that it will work with something like:

   my @SERVERS = qw/ fred frederick /;

and not match lines containing "freda".

:-)


(this also illustrates why index() is perhaps not the Right Tool.)


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


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

Date: Tue, 18 Mar 2003 07:16:22 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Determining String Membership
Message-Id: <slrnb7e716.6jj.tadmc@magna.augustmail.com>

Tad McClellan <tadmc@augustmail.com> wrote:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote in comp.lang.perl.misc:
>>> In article <2653596.1047941479@dbforums.com>,
>>> rymoore  <member26707@dbforums.com> wrote:
> 
>>> :I have an array of server names that is read in from a config file.
> 
>>> :I then need to search through a file and keep any lines that have these
>>> :server names in them.
> 
>>> $pattern = join '|', @SERVERS;
>> 
>> Make that
>> 
>>     $pattern = join '|', map quotemeta, @SERVERS;
> 
> 
>>     /$pattern/o and print while <FILE>;
> 
> 
> Make _that_
> 
>       /\b($pattern)\b/o and print while <FILE>;
> 
> 
> So that it will work with something like:
> 
>    my @SERVERS = qw/ fred frederick /;
> 
> and not match lines containing "freda".
> 
>:-)


And even that will fail (false positive) in the face of:

   my @SERVERS = qw/ fred- frederick /;

and a line containing something like "fred-erick"...


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


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

Date: Tue, 18 Mar 2003 14:20:17 +0100
From: Carsten Rau <does.not@exist.de>
Subject: Re: Determining String Membership
Message-Id: <b576ei$6uk$1@newssrv.hl.siemens.de>

Anno Siegel wrote:
> Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> 
>>Anno Siegel wrote:
>>
>>>Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
>>>
>>>>I'd be interested in comments on which of regexp patterns and the
>>>>index() function is the most efficient approach in this particular case.
>>>
>>>I suspect neither, once you allow the hash approach to the contest.
>>
>>Please explain. :)
> 
> 
> Sorry, I spoke too soon.  I guess I assumed there was a way to extract
> the (possible) server name from each line (split or something).  Then
> you could just check the name for existence in a hash.  Since no such
> method was indicated, the "hash approach" remains a fantasy.  There
> is none, as far as we know.
> 
> Anno

Hello,

Now I would like to know if a loop or a '|' regexp is more efficient to 
match multiple expressions?

Annos Post:

 >    $pattern = join '|', map quotemeta, @SERVERS;
 >    /$pattern/o and print while <FILE>;


Loop Version ( adapted from FAQ):

     @SERVERS   = map { qr/\b$_\b/i } @SERVERS;
     while ($line = <FILE>) {
	for $pattern (@SERVERS) {
	    if ($line =~ /$pattern/o) {
		print $line;
	    	last;		
	    }
	}	
     }

Loop looks slower to me, but is it?

Just Curious

Best Regards
Carsten



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

Date: Tue, 18 Mar 2003 15:06:03 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Determining String Membership
Message-Id: <b579gh$25abib$1@ID-184292.news.dfncis.de>

Carsten Rau wrote:
> Now I would like to know if a loop or a '|' regexp is more efficient to 
> match multiple expressions?
> 
> Annos Post:
> 
>  >    $pattern = join '|', map quotemeta, @SERVERS;
>  >    /$pattern/o and print while <FILE>;
> 
> Loop Version ( adapted from FAQ):
> 
>     @SERVERS   = map { qr/\b$_\b/i } @SERVERS;
>     while ($line = <FILE>) {
>     for $pattern (@SERVERS) {
>         if ($line =~ /$pattern/o) {
>         print $line;
>             last;       
>         }
>     }   
>     }

A third option is a loop without regexp patterns:

     while (<FILE>) {
         for my $server (@SERVERS) {
             if ((index $_, $server) >= 0) {
                 print;
                 last;
             }
         }
     }

> Loop looks slower to me, but is it?

And is there a difference between the two loop variants above?

/ Gunnar

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



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

Date: 18 Mar 2003 14:20:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Determining String Membership
Message-Id: <b579vm$l2l$2@mamenchi.zrz.TU-Berlin.DE>

Carsten Rau  <does.not@exist.de> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> >>Anno Siegel wrote:
> >>>Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:

[...]

> Hello,
> 
> Now I would like to know if a loop or a '|' regexp is more efficient to 
> match multiple expressions?
> 
> Annos Post:
> 
>  >    $pattern = join '|', map quotemeta, @SERVERS;
>  >    /$pattern/o and print while <FILE>;
> 
> 
> Loop Version ( adapted from FAQ):
> 
>      @SERVERS   = map { qr/\b$_\b/i } @SERVERS;
>      while ($line = <FILE>) {
> 	for $pattern (@SERVERS) {
> 	    if ($line =~ /$pattern/o) {
> 		print $line;
> 	    	last;		
> 	    }
> 	}	
>      }
> 
> Loop looks slower to me, but is it?

The best way to find out is to benchmark it (use Benchmark).  Everything
else is guesswork.

Anno


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

Date: Tue, 18 Mar 2003 09:50:09 -0600
From: Bing Du Test <bing-du@tamu.edu>
Subject: disable pattern metacharacters?
Message-Id: <3E774031.563A9A8B@tamu.edu>

I think it is because of '+' in $foo that the following script returns
'foo is not in bar' even though foo is really in bar.

===========
$foo = 'a+b';
@bar = ('a+b','c+d');

if (!grep(/^$foo$/i,@bar))
{
 print "foo is not in bar\n";
} else {
            print "foo is in bar\n";
          }
===========

I have some vague memory that \Q may help get around.  But can not
remember clearly how and that simple example about \Q in perlre manual
does not make much sense to me.  Anybody want to help?

Thanks,

Bing



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

Date: Tue, 18 Mar 2003 09:59:26 -0600
From: Bing Du Test <bing-du@tamu.edu>
Subject: Re: disable pattern metacharacters?
Message-Id: <3E77425E.A70C4933@tamu.edu>

By the way, I want an exact match.  That is if @bar is changed to "@bar =
('a+b+e','c+d')", $foo should not be in @bar.

From my testing, seems grep(/\Q$foo/i,@bar) says 'foo is in bar' for both
@bar cases.  But grep(/^\Q$foo$/i,@bar) which is really what I want does
not.

So help is still needed.

Bing


Bing Du Test wrote:

> I think it is because of '+' in $foo that the following script returns
> 'foo is not in bar' even though foo is really in bar.
>
> ===========
> $foo = 'a+b';
> @bar = ('a+b','c+d');
>
> if (!grep(/^$foo$/i,@bar))
> {
>  print "foo is not in bar\n";
> } else {
>             print "foo is in bar\n";
>           }
> ===========
>
> I have some vague memory that \Q may help get around.  But can not
> remember clearly how and that simple example about \Q in perlre manual
> does not make much sense to me.  Anybody want to help?
>
> Thanks,
>
> Bing



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

Date: Tue, 18 Mar 2003 10:02:37 -0500
From: Eric Osman <ericosman@rcn.com>
Subject: Re: frames without files ?
Message-Id: <3E77350D.9060507@rcn.com>



> you can have perl output your page as 
> normal, but include in it some javascript code that populates the 
> secondary "table of contents" frame from the main "content" frame.
> 


I don't understand the above yet.

YES, I know how to generate javascript from perl to fill in some
of the blanks on the (existing) TOC (table of contents) page.

But my main thing I don't see clearly yet is how to make my perl
output THREE html pages (the frame set, the TOC, and the body text).

I can use "print" in the perl script to generate ONE html page, but
how to get the other two ?

Am I forced to implement something more complicated as mentioned, such
as making my perl script fork into three separate ones ?

By the way, the contents for the body page can be up to about 200K
(0.2 meg) of text.  If you're suggesting I pass that around in some sort
of CGI-html "&name=value" construct, will such a large amount of text be
ok ?  That is, suppose MYPERL.pl attempts to use "print" to
generate the following sort of frameset:

<html>
<frameset rows="30%,*">
<frame src="MYPERL.pl &data=the-200k-of-text" name=toc>
<frame name=body src="MYPERL.pl &data=the-200k-of-text" name=body>
</frameset>
</html>

Will browsers and perl and servers tend to allow this much text in-line  ???

Thanks for all your help so far, I appreciate it.

/Eric



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

Date: Tue, 18 Mar 2003 13:31:59 +0100
From: Thomas Haselberger <thomas.haselberger@ucpmorgen.com>
Subject: Re: IO::Socket::SSL usage of SSL_reuse_ctx option
Message-Id: <ud6kokg8w.fsf@ucpmorgen.com>

Nicholas Dronen <ndronen@io.frii.com> writes:

> Thomas Haselberger <thomas.haselberger@ucpmorgen.com> wrote:
> TH> Started using IO::Socket::SSL these days and am at a loss with 
> TH> the *SSL_reuse_ctx* option.
>
> TH> Any hints on the usage of that option would be appreciated - 
> TH> I just don't get what I should pass as the value for it 
> TH> (the perldoc and examples show no usage).
>
> Once you've created an IO::Socket::SSL object with a "full" context,
> you can simply provide that object as the SSL_resuse_ctx argument
> to new().
>
> That an IO::Socket::SSL object has a context implies that you've
> provided values for all of the following arguments to new():
>
> 	SSL_use_cert SSL_key_file
> 	SSL_cert_file
> 	SSL_passwd_cb
> 	SSL_ca_file
> 	SSL_ca_path
> 	SSL_verify_mode
>
> You should only need to care about SSL_reuse_ctx in the case that
> you're creating more than one object.  If you're just creating one,
> I think the argument should be undef.

thanks, nicholas.

to be sure I understand that right - would that be used like so ?:
--------------
my $sock = IO::Socket::SSL->new(
#   ...set host, port 
#   ...set above arguments
   );
# create a new socket with existing context
my $anothersock = IO::Socket::SSL->new(
#  ...set host, port
#  ...and reuse context:
   SSL_reuse_ctx => $sock
);
--------------

my interest in this option started because I looked for a possibility 
for session id reuse and thought that this option would possibly 
provide that - now it seems that this is not the case.

I lookes over most ssl related perl modules for that - didn't find 
anything else possibly related to the ssl session id.

thx,
        tom


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

Date: 18 Mar 2003 13:20:34 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: IO::Socket::SSL usage of SSL_reuse_ctx option
Message-Id: <3e771d22$0$198$75868355@news.frii.net>

Thomas Haselberger <thomas.haselberger@ucpmorgen.com> wrote:
TH> Nicholas Dronen <ndronen@io.frii.com> writes:

>> Thomas Haselberger <thomas.haselberger@ucpmorgen.com> wrote:
>> TH> Started using IO::Socket::SSL these days and am at a loss with 
>> TH> the *SSL_reuse_ctx* option.
>>
>> TH> Any hints on the usage of that option would be appreciated - 
>> TH> I just don't get what I should pass as the value for it 
>> TH> (the perldoc and examples show no usage).
>>
>> Once you've created an IO::Socket::SSL object with a "full" context,
>> you can simply provide that object as the SSL_resuse_ctx argument
>> to new().
>>
>> That an IO::Socket::SSL object has a context implies that you've
>> provided values for all of the following arguments to new():
>>
>>       SSL_use_cert SSL_key_file
>>       SSL_cert_file
>>       SSL_passwd_cb
>>       SSL_ca_file
>>       SSL_ca_path
>>       SSL_verify_mode
>>
>> You should only need to care about SSL_reuse_ctx in the case that
>> you're creating more than one object.  If you're just creating one,
>> I think the argument should be undef.

TH> thanks, nicholas.

TH> to be sure I understand that right - would that be used like so ?:
TH> --------------
TH> my $sock = IO::Socket::SSL->new(
TH> #   ...set host, port 
TH> #   ...set above arguments
TH>    );
TH> # create a new socket with existing context
TH> my $anothersock = IO::Socket::SSL->new(
TH> #  ...set host, port
TH> #  ...and reuse context:
TH>    SSL_reuse_ctx => $sock
TH> );
TH> --------------

That looks about right to me.  Caveat: I only answered your post
because I've used an SSL C APIs in the past and remember enough
about it ti respond after looking at the man page for the module.

-- 
"Why shouldn't I top-post?"    http://www.aglami.com/tpfaq.html
"Meanings are another story."  http://www.ifas.org/wa/glossolalia.html


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

Date: 18 Mar 2003 15:42:41 GMT
From: ctcgag@hotmail.com
Subject: Re: Out of memory
Message-Id: <20030318104241.156$KG@newsreader.com>

ritesh_shah2000@yahoo.com (Ritesh Shah) wrote:

> Is there a way to tell perl to
> free the buffers after a certain checkpoint so that they can be used
> again to store file contents until the next checkpoint. This is the
> psuedocode of my perl script.

It's best to make your psuedocode be real code.

>
> #declare hashes, arrays

(Probably) don't declare hashes and arrays here.

> #open input file
>
> while(not end of file) {
>
>         #initialize all arrays hashes

Declare the arrays and hashes here, instead of initializing them.

>
>         while( checkpoint does not occur) {
>
>                 #read one line from the file
>                 #parse line to obtain data and
>                 #store them in arrays, hashes
>
>         }
>
>         #perform calculation on obtained data
>
>         #print the result ##These results actually get printed until out
>         of
>                           ##memory message
>
> }


Almost always it is not necessary to re-initialize variables within a loop.
If you need to do something like that, you can usually put the
"my" inside the loop in place of the re-initialization.  This can prevent a
host of bugs.  (you are using strict, right?).  My guess is that one of
your variables isn't really getting re-initialized to empty after a
checkpoint.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 18 Mar 2003 07:11:44 -0800
From: omega28@rediffmail.com (Omega)
Subject: perl ssh background process
Message-Id: <83acb7b.0303180711.3bf5bb23@posting.google.com>

Respected Group,

I have a problem while executing remote perl script. I use ssh from
machine A. My perl script reside on Machine B.
Machine A> ssh -l user machineB 'cd /home/user/cron; ./foo.pl
1>/dev/null 2>/dev/null' < /tmp/bar

The script "foo.pl" on MachineB is as following.

#!/usr/bin/perl
my $infile;
while (<STDIN>) {
  $infile .= $_;
}

close STDIN;
close STDOUT;
close STDERR;

open (FOO, ">./foo.file");
print FOO $infile;
close FOO;

unless ($pid = fork) {
  sleep (100);
}

exit 0;

While running this script on MachineB it works in background as
written. but when running from MachineA the script as following
Machine A> ssh -l user machineB 'cd /home/user/cron; ./foo.pl
1>/dev/null 2>/dev/null' < /tmp/bar

It wait till sleep statement finished. 

Any help appritiated.

Regards,

Dilip


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

Date: Tue, 18 Mar 2003 10:28:24 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: remote control with perl
Message-Id: <3E773B18.C9D5959@someserver123abc.com>

anyone tried remote control with perl?

I guess someway to make a perl script daemon on a server.
and maybe access it with a web browser?


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: Tue, 18 Mar 2003 05:13:58 -0700
From: "Rod" <palladium@spinn.net>
Subject: Re: remote control with perl
Message-Id: <v7egp9s8008o21@corp.supernews.com>

"stinkbomb" <user@someserver123abc.com> wrote in message
news:3E773B18.C9D5959@someserver123abc.com...
> anyone tried remote control with perl?
>
> I guess someway to make a perl script daemon on a server.
> and maybe access it with a web browser?
>
>
> -----------== Posted via Newsfeed.Com - Uncensored Usenet News
==----------
>    http://www.newsfeed.com       The #1 Newsgroup Service in the World!
> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers
=-----

Ok Easy Enough.. Whats the real question?






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

Date: Tue, 18 Mar 2003 12:11:12 +0100
From: Marek Zawadzki <mzawadzk@man.poznan.pl>
Subject: Re: return value of 'accept' in PF_UNIX sockets
Message-Id: <Pine.GSO.4.44.0303181154210.14226-100000@rose.man.poznan.pl>

On Mon, 17 Mar 2003, Benjamin Goldberg wrote:

> Marek Zawadzki wrote:
> > I'd like to send credentials of a process or a file descriptor (see FAQ
> > reference below) from one process to another via Unix-domain socket.
> >
> > In another post, Ilja Tabachnik directed me to this resource:
> >         Secure UNIX Programming FAQ
> >         (http://www.whitefang.com/sup/secure-faq.html),
> >         section "4.4) How do I authenticate a non-parent process?"

I've just come up with an idea, which uses the above concept, but is 100%
portable:

How to make sure the client process is run by the user it claims to be
(PF_UNIX sockets):

-> Client claims via the protocol she is being run by user 'Alice'.
<- Server generates an unique filename under Alice's home dir and asks
   client to create this file (eg. /home/alice/.authAJKSJKK23K).
-> Alice creates the given file and sends confirmation to the server.
<- Server checks if Alice's home is non-world-writeable and then if the
   file exists it authenticates the client as being run by Alice.

Since this adds maybe 0.003 cents to Perl's being more portable, I'd like
to ask you for your opinion about my scheme.

-marek



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

Date: Tue, 18 Mar 2003 14:37:53 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: splitting an array into two arrays
Message-Id: <Xns934261F9A9A60dkwwashere@216.168.3.30>

Bill Smith <wksmith@optonline.net> wrote on 17 Mar 2003:

> Sorry for the criticism, I must have read the document for int with
> my eyeballs out of calibration.  I still prefer ceil because it does
> exactly what you want in any numerical representation without the bias 
> term.

Not a problem.  I used int() because I had it in my head.  I would have 
had to look up ceil(), because it and the POSIX module are not things I 
often have a need for.  

If only all *my* mistakes were so trivial.  :-)

Anyway, I got what I wanted: several ways of looking at the same simple 
problem.  

-- 
David K. Wall - usenet@dwall.fastmail.fm
WWJD? JWRTFM.


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

Date: Tue, 18 Mar 2003 09:50:15 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: text filter
Message-Id: <3E773227.255000DA@someserver123abc.com>

I have "3iji3j4ij34+_=,,//[]24" and I only want alpha numeric and commas
and slash (a..z 1..9 , /)

I can do this:

$str="3iji3j4ij34+_=,,//[]24";

go thru every character in a for loop perhaps.

but is there a "perl" way to do this in one line?


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: Tue, 18 Mar 2003 14:55:52 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: text filter
Message-Id: <3e773364.3380960504@news.cis.dfn.de>

On Tue, 18 Mar 2003 09:50:15 -0500, stinkbomb
<user@someserver123abc.com> wrote:

>I have "3iji3j4ij34+_=,,//[]24" and I only want alpha numeric 
>and commas and slash (a..z 1..9 , /)

$str =~ s/[^\/,a-z0-9]//g;
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Tue, 18 Mar 2003 09:17:21 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: text filter
Message-Id: <Xns934268AA0924Esdn.comcast@216.166.71.239>

stinkbomb <user@someserver123abc.com> wrote in
news:3E773227.255000DA@someserver123abc.com: 

> I have "3iji3j4ij34+_=,,//[]24" and I only want alpha numeric and
> commas and slash (a..z 1..9 , /)
> 
> I can do this:
> 
> $str="3iji3j4ij34+_=,,//[]24";
> 
> go thru every character in a for loop perhaps.
> 
> but is there a "perl" way to do this in one line?

$str =~ tr|a-zA-Z0-9,/||cd;

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


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

Date: Tue, 18 Mar 2003 16:25:19 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: text filter
Message-Id: <3E773A5F.CAA420F0@fujitsu-siemens.com>

Helgi Briem wrote:
> =

> On Tue, 18 Mar 2003 09:50:15 -0500, stinkbomb
> <user@someserver123abc.com> wrote:
> =

> >I have "3iji3j4ij34+_=3D,,//[]24" and I only want alpha numeric
> >and commas and slash (a..z 1..9 , /)
> =

> $str =3D~ s/[^\/,a-z0-9]//g;

TMTOWTDI

$str =3D~ tr/\/,a-z0-9//cd;

It's even one character shorter B-{)
One can even do it with less:
$str =3D~ y|/,a-z\d||;

-- =

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


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

Date: Tue, 18 Mar 2003 10:44:35 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: Re: text filter
Message-Id: <3E773EE3.C0998DDA@someserver123abc.com>


and if the string is 300BogoByes long, which is quickest?


Josef Möllers wrote:
> 
> Helgi Briem wrote:
> >
> > On Tue, 18 Mar 2003 09:50:15 -0500, stinkbomb
> > <user@someserver123abc.com> wrote:
> >
> > >I have "3iji3j4ij34+_=,,//[]24" and I only want alpha numeric
> > >and commas and slash (a..z 1..9 , /)
> >
> > $str =~ s/[^\/,a-z0-9]//g;
> 
> TMTOWTDI
> 
> $str =~ tr/\/,a-z0-9//cd;
> 
> It's even one character shorter B-{)
> One can even do it with less:
> $str =~ y|/,a-z\d||;
> 
> --
> Josef Möllers (Pinguinpfleger bei FSC)
>         If failure had no penalty success would not be a prize
>                                                 -- T.  Pratchett


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: 18 Mar 2003 05:35:53 -0800
From: dwlepage@yahoo.com (david)
Subject: Re: use of uninitialized value
Message-Id: <b09a22ae.0303180535.5169c422@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b56nek$6h5$1@mamenchi.zrz.TU-Berlin.DE>...
> david <dwlepage@yahoo.com> wrote in comp.lang.perl.misc:
> > I am continuously getting a message "Use of uninitialized value in
> > pattern match (m//) at test.pl line 15, <FILE> line 2130." This
> 
> Line s 13-15 are
> 
>            my @fields = split ( /,/ );
>          # Grab token serial number from Comments field if exists
>                  if (!($fields[8] =~ m/S\/N:\s(\w+)/ )) {
> 
> You would have done us all a favor if you had identified the critical
> line instead of letting everyone count.
> 
> Obviously, $fields[8] is undefined because some input lines don't
> have enough comma-delimited fields.
> 
> > happens for every line parsed by my script. I have tried this on
> > several deffernt data files and the strange this is that it doesn't
> > happen when I parse against all of them, only some.
> 
> Some have eight or more fields per line, others don't.
> 
> >                                                      I have looked at
> > older postings and searched around and it appears it must have
> 
> You should have looked at the error message and your script.
> 
> [...]
> 
> Anno

Sorry - I didnt realize counting to line 14 was going to be a problem.
And I did look at the error message which I indicated in the original
post, That is why I asked the question.. I wasnt sure why... Thanks
for your time.


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

Date: 18 Mar 2003 14:04:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: use of uninitialized value
Message-Id: <b5791k$l2l$1@mamenchi.zrz.TU-Berlin.DE>

david <dwlepage@yahoo.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<b56nek$6h5$1@mamenchi.zrz.TU-Berlin.DE>...
> > david <dwlepage@yahoo.com> wrote in comp.lang.perl.misc:
> > > I am continuously getting a message "Use of uninitialized value in
> > > pattern match (m//) at test.pl line 15, <FILE> line 2130." This
> > 
> > Line s 13-15 are
> > 
> >            my @fields = split ( /,/ );
> >          # Grab token serial number from Comments field if exists
> >                  if (!($fields[8] =~ m/S\/N:\s(\w+)/ )) {
> > 
> > You would have done us all a favor if you had identified the critical
> > line instead of letting everyone count.
> > 
> > Obviously, $fields[8] is undefined because some input lines don't
> > have enough comma-delimited fields.
> > 
> > > happens for every line parsed by my script. I have tried this on
> > > several deffernt data files and the strange this is that it doesn't
> > > happen when I parse against all of them, only some.
> > 
> > Some have eight or more fields per line, others don't.
> > 
> > >                                                      I have looked at
> > > older postings and searched around and it appears it must have
> > 
> > You should have looked at the error message and your script.
> > 
> > [...]
> > 
> > Anno
> 
> Sorry - I didnt realize counting to line 14 was going to be a problem.

Then why didn't you?

Every effort you save yourself in preparing a posting must be compensated
by *every one* of your readers.  That is inefficient and annoying.

> And I did look at the error message which I indicated in the original
> post, That is why I asked the question.. I wasnt sure why... Thanks
> for your time.

Well, there is only one variable ($fields[8]) in the line that could be
undefined.  There isn't much room for interpretation or doubt, is there?  
From your posting, one could get the impression you hadn't even bothered
to identify the offending line.  That's another reason why it would
have been wise to mark it.

Anno


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

Date: Tue, 18 Mar 2003 14:40:03 +0100
From: "H. Merijn Brand" <h.m.brand@hccnet.nl>
To: comp.lang.perl.misc
Subject: Re: What's wrong with the Perl docs
Message-Id: <Xns93429534EEF48Merijn@192.0.1.90>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in news:3E727CCF.E73CD426
@earthlink.net:

> Andras Malatinszky wrote:
>> Abigail wrote:
>> > Tintin wrote on MMMCDLXXXI September MCMXCIII:
>> > ..  Anyone seen http://clueless.justsomeguy.com/
>> > ..
>> > ..  Anyone agree with any of his points?
> [snip]
>> > ++  * Some functions documented by saying "works like it does in C"
>> >
>> > Yes, and? Some functions are delegated to the C library. They will
>> > work the same way as in C. Consult your systems manual page; it will
>> > be your best resort, as such functions may not behave the same on
>> > all platforms Perl runs on. Perl is at the mercy of your system, not
>> > only for the working of the function, but also for its documenation.
>> 
>> That's another example of the same Unix-centric view. The implicit
>> promise is that Perl  will run on other platforms, so it's not
>> unreasonable to expect that the docs be comprehensible without access
>> to a Unix box or some form of C documentation.
> 
> It's not just that perl will *run* on other platforms, it's that perl
> will *compile and run* on other platforms.  If you can compile perl,
> then you have a C compiler.  And that C compiler should come with

Worse. It should be an ANSI C compiler.

> documentation for the C runtime library.  If the compiler doesn't come
> with docs, then you didn't getting your money's worth when you bought
> it.
> 
> So, it's not an example of a Unix-centric view, it's an example of a
> "you've compiled your own perl"-centric view.
> 
> The only reason you might not have the documentation is if someone has
> given you a precompiled perl, and has chosen to omit the documentation
> for the C runtime with which it was compiled.  That's not perl's fault;
> it's the fault of the person who gave you the precompiled perl.
> 
> Outside of the Windows world, how many perl programmers download
> precompiled perls?

Anyone not having, or not able to get hold of, or unable to install a 
decent ANSI C compiler, or have to pay huge amounts of M^H$ to get one
just in order to compile Perl (which is free).

> An inside of the Windows world, how many perl programmers don't have
> internet connections, or otherwise can't connect to
>     http://msdn.microsoft.com/library/
> ?

-- 
H.Merijn Brand    Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl-5.6.1, 5.8.0 & 633 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
     WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.024 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/


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

Date: Tue, 18 Mar 2003 10:25:11 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: why can't I last?
Message-Id: <3E773A57.1AD2AA11@someserver123abc.com>

foreach $rec (@db){
    @dates_boxes=split /$splitDates_Boxes/, $rec;
    $dates_boxes[0]=~ s/[^\/,a-z0-9]//g;
    @dates=split /$splitDates/,$dates_boxes[0];
    foreach $date (@dates){
	if ($date eq $today){
	    print "$date = $today<br>";
	    last;
	}
    }
    print "<br>oooooo<br>"; #decoration
}


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: 18 Mar 2003 15:59:56 GMT
From: ctcgag@hotmail.com
Subject: Re: why can't I last?
Message-Id: <20030318105956.142$gg@newsreader.com>

stinkbomb <user@someserver123abc.com> wrote:
> foreach $rec (@db){
>     @dates_boxes=split /$splitDates_Boxes/, $rec;
>     $dates_boxes[0]=~ s/[^\/,a-z0-9]//g;
>     @dates=split /$splitDates/,$dates_boxes[0];
>     foreach $date (@dates){
>         if ($date eq $today){
>             print "$date = $today<br>";
>             last;
>         }
>     }
>     print "<br>oooooo<br>"; #decoration
> }


What makes you think you can't last?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Tue, 18 Mar 2003 11:12:24 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Win32 Perl newsgroup?
Message-Id: <3e76fd33.3367086464@news.cis.dfn.de>

On Mon, 17 Mar 2003 12:39:59 -0500, AK <aknntp@yahoo.com>
wrote:

>Is there a newsgroup dedicated to Perl on Win32?

No.  Perl is Perl.  It's as close to being a platform
independent language as possible.

>In any case, can I get some recommended sites where online 
>discussion about Perl on Win32?

No, but Activestate.com has lots of mailing lists to
deal with the Windows specificc issues.  Pretty trivial.

>At the moment, my main issue is trying to send out email through an
>authenticated SMTP server (eg: smtp.mail.yahoo.com) on Windows 2000.

Any number of modules will do that just fine, whatever
the platform, Windows or Unix doesn't matter.

I use MIME::Lite. 
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

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


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