[19387] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1582 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 21 21:22:43 2001

Date: Tue, 21 Aug 2001 18:05:08 -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: <998442308-v10-i1582@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 21 Aug 2001     Volume: 10 Number: 1582

Today's topics:
    Re: Baiting Gozilla to obtain quality code for nothing! <matthew.garrish@sympatico.ca>
        Calling several '.bat' files from ActivePerl 70262.1046@compuserve.com
    Re: capturing command line error or output from `<comma <jagman@h80.c960693-a.plano1.tx.home.com>
    Re: CGI FAQ beta =) (was Re: CGI) <flavell@mail.cern.ch>
    Re: Custom Perl Script for Scanning IP's and Resources? <tumpen@fez.dk>
    Re: Good old regexp teaser <bart.lateur@skynet.be>
        grep 5th word in a text-file <trinks@prolink.de>
    Re: grep 5th word in a text-file <Tassilo.Parseval@post.rwth-aachen.de>
        Hash Question <mark.riehl@agilecommunications.com>
        Invoking '.bat' files from perl script 70262.1046@compuserve.com
    Re: Invoking '.bat' files from perl script <wyzelli@yahoo.com>
    Re: Invoking '.bat' files from perl script <bart.lateur@skynet.be>
    Re: Last index of array referenced in a scalar?? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Last index of array referenced in a scalar?? <miscellaneousemail@yahoo.com>
    Re: Last index of array referenced in a scalar?? <ren@tivoli.com>
    Re: Last index of array referenced in a scalar?? (Tad McClellan)
    Re: need to reformat file from variable to fixed length <mjcarman@home.com>
    Re: Net::NNTP <bigusAT@btinternetDOT.com>
    Re: new modules - looking for (sort-of-)pre-release inp <sean@quinlan.org>
        Passing code pieces to program (Chas Friedman)
    Re: regex to edit config variable <wyzelli@yahoo.com>
        Strange Problem with Win32::Console (Lyle Goldman)
    Re: String extraction <davidhilseenews@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 21 Aug 2001 18:14:29 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Baiting Gozilla to obtain quality code for nothing!!
Message-Id: <K%Ag7.17093$Nc3.2087136@news20.bellglobal.com>


"Steffen Müller" <tsee@gmx.net> wrote in message
news:9lui9u$1tv$07$1@news.t-online.com...
> "John J. Trammell" <trammell@haqq.hypersloth.invalid> schrieb im
Newsbeitrag
> news:slrn9o5qa2.3qv.trammell@haqq.hypersloth.net...
> > On Tue, 21 Aug 2001 18:08:13 GMT, Jay Flaherty <fty@mediapulse.com>
wrote:
> > > Godzilla! has always come across to me as Ignatius J. Reilly from John
> > > Kennedy Toole's "A Confederacy of Dunces".
> >
> > http://www.winternet.com/~mikelr/flame63.html
>
> http://www.winternet.com/~mikelr/flame67.html
>
> ;P
>

And all this time I thought he was Don King's hideous love child...




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

Date: Tue, 21 Aug 2001 22:51:40 GMT
From: 70262.1046@compuserve.com
Subject: Calling several '.bat' files from ActivePerl
Message-Id: <3b82e508.24750349@news.compuserve.com>

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

If fork() is the answer, please provide a simple example, since I've
never used fork() before.

Many thanks...Vic


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

Date: Wed, 22 Aug 2001 00:26:40 GMT
From: "Jag Man" <jagman@h80.c960693-a.plano1.tx.home.com>
Subject: Re: capturing command line error or output from `<command>`
Message-Id: <20010821.192916.601385644.1549@h80.plano1.tx.home.com>

I needs to capture the output in variable, so I guess I needs to capture
in file and then read from file to variable.

TIA!
JM

In article <20010819.094933.76065818.8629@h80.plano1.tx.home.com>,
"JagMan" <jagman@h80.c960693-a.plano1.tx.home.com> wrote:


> I needs to capture both error and/or output generated by a command line
> using ``.
> Example:
> @snmpget = `snmpget <ip> <comm> OID`;  This does not capture errors. 
> How can I capture errors from a command line.
> TIA!
> JM


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

Date: Wed, 22 Aug 2001 01:03:24 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI FAQ beta =) (was Re: CGI)
Message-Id: <Pine.LNX.4.30.0108220059100.4505-100000@lxplus023.cern.ch>

On Aug 21, Tim Hammerquist inscribed on the eternal scroll:

>  The latter was only found on MS-DOS
>     (the oldest but still most stable software ever to be produces by
>     Microsoft),

OK, so I know it's way OT, but I can't help asking: you reckon they
_produced_ DOS?  I thought they got it from somewhere else, and only
marketed it.



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

Date: Wed, 22 Aug 2001 01:43:45 +0200
From: "Nezar Nielsen" <tumpen@fez.dk>
Subject: Re: Custom Perl Script for Scanning IP's and Resources?
Message-Id: <2nCg7.9548$3q.290524@news010.worldonline.dk>

"Belphegor" <globalpunk@hotmail.com> wrote in message
news:isyg7.31951$vG4.1593277@weber.videotron.net...
> Okay, here's the issue
>
> I need to get a perl script that will scan ips, (ping them) with a given
> set.
> 1. I say "192.1.1 -100" and it'll ping  from "192.1.1.1" to "192.1.1.255",
> with the exception of "192.1.1.100".
> 2. Then it asks for Samba Share name.
> 3. Then it asks for the SHARES it enters ALL Share data, and EVERY Last
file
> into a given database......

Take a look at the following modules available from CPAN:

Net::Ping,
Filesys::SmbClient &
Filesys::SmbClientParser

If you're using Win32, also take a look at the Win32::* modules available
from http://www.roth.net/perl/

and for db-stuff: DBI and DBD::whatever_kind_of_db_you_want_to_use.

If you want a working script, pay up, otherwise, read the modules'
documentation and at least give it a try yourself.

XFUT: comp.lang.perl.misc,comp.lang.perl.modules,dk.edb.programmering.perl
FUT: comp.lang.perl.misc

--
Mvh. Nezar Nielsen
http://fez.dk/





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

Date: Tue, 21 Aug 2001 23:04:13 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Good old regexp teaser
Message-Id: <o2q5otoq8kf8j713sfsk8r6qujm6eutv20@4ax.com>

Paul Fortescue wrote:

>$line = "subscription= by owner ack= yes sir confidential= yes";
>
>print "$1 \n" while $line =~ /(\S+=.+?)(?=\S+= |$)/g;
>
>Will give you the pairs, which you can then split. Note the ?=

Another solution: note that each value, which may not contain a "=",
must be followed by a space or end of string; keys don't contain
spaces..

	$line = "subscription= by owner ack= yes sir confidential= yes";
	print "$1 = '$2'\n"  while $line =~ /(\S+)=\s*([^=]+)(?= |$)/g;
-->
	subscription = 'by owner'
	ack = 'yes sir'
	confidential = 'yes'

-- 
	Bart.


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

Date: Tue, 21 Aug 2001 22:30:27 GMT
From: Timo Trinks <trinks@prolink.de>
Subject: grep 5th word in a text-file
Message-Id: <7iBg7.86707$B37.2004948@news1.rdc1.bc.home.com>


hi.

i'm trying to code a script that reads the 5th word of a line and writes
it to stdout:

radius log report for: foo

so foo is the word to be extracted from a logfile and to be written to
stdout or to another file.

i tried sth like my $word =3D (split ' ', $1)[4]; but unsuccessfully...
so any ideas ?

tia,

Timo
-- =

aka t=B2 .oO http://www.trinks.net/cv.php Oo.
}


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

Date: Wed, 22 Aug 2001 00:38:42 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: grep 5th word in a text-file
Message-Id: <3B82E2F2.8010607@post.rwth-aachen.de>

Timo Trinks wrote:

> hi.
> 
> i'm trying to code a script that reads the 5th word of a line and writes
> it to stdout:
> 
> radius log report for: foo
> 
> so foo is the word to be extracted from a logfile and to be written to
> stdout or to another file.
> 
> i tried sth like my $word = (split ' ', $1)[4]; but unsuccessfully...

This should work. If it doesn't, I assume that you split the wrong 
string. What is $1 here? It seems to come from a regex. Have you made 
sure that it contains at least five words seperated by whitespaces?

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



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

Date: Wed, 22 Aug 2001 00:45:34 GMT
From: "Mark Riehl" <mark.riehl@agilecommunications.com>
Subject: Hash Question
Message-Id: <OgDg7.530$nV4.190080@typhoon1.gnilink.net>

All - I'm trying to use the complex hash.  The script below runs, and I can
loop through each of the sub elements w/o a problem.

Question is, how do I access individual elements to update the values?  For
example, I want to change the last_tx_time property in the all_transmitters
array of hashes for the first element (urn=4) to a new value.

I thought that I use something similar to the following, but haven't had any
luck:

$HashName{$key}{all_transmitters}[0][0]

Also, same question for a delete.  I'm assuming that once I figure out the
syntax to access the element, then deleting an element would use the same
syntax.  Is this correct?

Any suggestions?

Thanks,
Mark


****************************************************************************
*********
#!perl -w

use strict;

my ($who, $key, %RxTxData);

%RxTxData = (
      1000=> {
       current_transmitters => [
           { urn=>"1", time=>"8456823",  lat=>"35.311",
long=>"-116.4101", },
           { urn=>"2", time=>"8456824",  lat=>"35.312",
long=>"-116.4201", },
           { urn=>"3", time=>"8456825",  lat=>"35.313",
long=>"-116.4301", },
          ],
       all_transmitters => [
       { urn=>"4", last_tx_time=>"8451234",},
       { urn=>"5", last_tx_time=>"8451234",},
       { urn=>"6", last_tx_time=>"8451234",},
      ],
       statistics => [
        { time=>"8456823",  visibility=>"123", accuracy=>"456", },
        { time=>"8456823",  visibility=>"123", accuracy=>"456", },
        { time=>"8456823",  visibility=>"123", accuracy=>"456", },
       ],
       last_sa_time=>"1000",
       last_lat=>"35.1000",
       last_long=>"-116.5",
      },
     );

for $key (keys %RxTxData) {
  print "Table key = $key\n";

  for $who ( @{ $RxTxData{$key}{current_transmitters} } ) {
    print "$who->{urn},$who->{time},$who->{lat},$who->{long}\n";
  }

  for $who ( @{ $RxTxData{$key}{all_transmitters} } ) {
    print "$who->{urn}\t$who->{last_tx_time}\n";
  }
  for $who ( @{ $RxTxData{$key}{statistics} } ) {
    print "$who->{time},$who->{visibility},$who->{accuracy}\n";
  }

  print "$RxTxData{$key}{last_sa_time}\n";
  print "$RxTxData{$key}{last_lat}\n";
  print "$RxTxData{$key}{last_long}\n";
}





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

Date: Tue, 21 Aug 2001 22:59:14 GMT
From: 70262.1046@compuserve.com
Subject: Invoking '.bat' files from perl script
Message-Id: <3b82e70a.25264238@news.compuserve.com>

I'm trying to invoke a series of '.bat' files from within a Perl
script. Some of the '.bat' files exit upon completion, and some simply
continue running indefinitely. How can I call each '.bat' file without
having to wait for it to finish/exit?

If fork() is the answer, please provide a simple example, since I've
never used it'

Many thanks....Vic


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

Date: Wed, 22 Aug 2001 09:46:08 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Invoking '.bat' files from perl script
Message-Id: <3MCg7.11$Sh2.4943@wa.nnrp.telstra.net>

<70262.1046@compuserve.com> wrote in message
news:3b82e70a.25264238@news.compuserve.com...
> I'm trying to invoke a series of '.bat' files from within a Perl
> script. Some of the '.bat' files exit upon completion, and some simply
> continue running indefinitely. How can I call each '.bat' file without
> having to wait for it to finish/exit?
>
> If fork() is the answer, please provide a simple example, since I've
> never used it'

'fork' is unlikely to be the answer.  It works in an emulated mode on WinNT
and Win2K after v 5.6 but I have never tried it.

'exec' is likely to be your answer.

perldoc -f exec

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";





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

Date: Wed, 22 Aug 2001 00:17:37 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Invoking '.bat' files from perl script
Message-Id: <aiu5otckqc2c35kn0dfpr9nnb3nqmk8ufm@4ax.com>

70262.1046@compuserve.com wrote:

>I'm trying to invoke a series of '.bat' files from within a Perl
>script. Some of the '.bat' files exit upon completion, and some simply
>continue running indefinitely. How can I call each '.bat' file without
>having to wait for it to finish/exit?

	system 'start', 'batchfile.bat';

You have no control over the appearance of the window. If that matters,
use the API call ShellExecute, through the module Win32::API. That way
you can minimize, or even hide, the window of the batch file.

-- 
	Bart.


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

Date: Wed, 22 Aug 2001 00:23:55 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <3B82DF7B.7090003@post.rwth-aachen.de>

Carlos C. Gonzalez wrote:

> print "Last element index: [ $#$new ]\n";
> 
> Is there a way to rewrite [ $#$new ] so that it doesn't look like so much 
> gibberish?  Also although this code is producing the right output is it 
> doing what I want it to do or is the 1 index produced a byproduct of 
> something else?  
> 
> I just spent fifteen minutes trying different combinations of squiggly 
> things =:) until I found one that worked. Can someone correct or check my 
> understanding of what I did?  

I personally prefer the $ref->[$n] syntax since I think it is more 
intuitive. In your case: $new->[0] retrieves the first element of the 
array referenced to by $new. Subsequenelty, getting the last one:
$new->[-1]. Read "->" as a dereference in this context....that is, 
something that is getting away from the original reference and thus 
producing the original value.

Did you know that you can do a backwards walk through an array?
$a->[-1]; # last element
$a->[-2]; # second last one etc...

This dereferencing thing works similarily for hashes:
my $ref = %hash;
$ref->{key}


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



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

Date: Tue, 21 Aug 2001 23:01:09 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <MPG.15ec95fd2cf91c70989788@news.edmonton.telusplanet.net>

Tassilo von Parseval at Tassilo.Parseval@post.rwth-aachen.de said...

> [snipped] Subsequenelty, getting the last one:
> $new->[-1]. Read "->" as a dereference in this context....that is, 
> something that is getting away from the original reference and thus 
> producing the original value.

Thanks Tassilo but....

#!/usr/bin/perl -W
use diagnostics;
use strict;
my @data = (
  'jack@ardvark.com,Jack,020010812 18:34,Canada,Kissimee,Yes',
  'tammy@kangaroo.com,Tammy,20010812 18:34,United States,Chicago,Yes',);
my $new = \@data;
print "Last element index: $new->[-1]\n";

displays the *values* of the last element in @data not the number of the 
last element index. 

Can you clarify for me how to use the $new->[-1] method to get the last 
index value?  I have tried "$#new->[-1]", "$#{$new->[-1]}" and some 
others without any success.  

Thanks.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so please don't 
subscribe.  Thanks.


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

Date: 21 Aug 2001 17:16:40 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <m3pu9pukhj.fsf@dhcp9-161.support.tivoli.com>

On Tue, 21 Aug 2001, miscellaneousemail@yahoo.com wrote:

> Hi everyone,
> 
> Is this the right way to obtain the last index of the @data array 
> referenced by $new?  Seems to work okay....
> 
> The code:
> 
> #!/usr/bin/perl -W
> 
> use diagnostics;
> use strict;
> 
> my @data = ("jack\@ardvark.com,Jack,020010812 18:34,Canada,Kissimee,Yes",
>   "tammy\@kangaroo.com,Tammy,20010812 18:34,United States,Chicago,Yes",);
> 
> my $new = \@data;
> 
> print "Last element index: [ $#$new ]\n";

I think you're looking for $#data.

> Is there a way to rewrite [ $#$new ] so that it doesn't look like so
> much gibberish?  Also although this code is producing the right
> output is it doing what I want it to do or is the 1 index produced a
> byproduct of something else?

Other than $#data, the common answer is to rethink what you are
doing.  In Perl, you seldom actually need to refer to the index of an
array.

For example, instead of:

for(my $i=0; $i <= $#data; $i++) {  # or $i < @data
  # do something with $data[$i]
}

you would normally just use:

for (@data) {
  # do something with $_
}

> I just spent fifteen minutes trying different combinations of
> squiggly things =:) until I found one that worked. Can someone
> correct or check my understanding of what I did?
> 
> I think "[ $#$new ]" means something like.....
> 
> Return the last element "$#" of the array referenced by $new.  
> 
> If the "[]" were not there it would mean...return the last element
> "$#" of the reference value.  Which would just produce an error or
> invalid index value.

The square brackets within quotes have no special meaning.

"$#array" is a fairly strange beast.  Basically, any time you could
refer to an array with "@", you can refer to the index of the last
element with "$#".

So:

@array                          $#array
@$ref                           $#$ref
@{$hash_of_arrays{key}}         $#{$hash_of_arrays{key}}
@{ code returning array ref }   $#{ code returning array ref}

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

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 21 Aug 2001 19:41:07 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <slrn9o5scj.kp.tadmc@tadmc26.august.net>

Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:

>my @data = ("jack\@ardvark.com,Jack,020010812 18:34,Canada,Kissimee,Yes",
>  "tammy\@kangaroo.com,Tammy,20010812 18:34,United States,Chicago,Yes",);


You should consider using a LoL instead of simulating the 2nd
level with split/join:

my @data = (
 ['jack@ardvark.com', 'Jack', '020010812 18:34', 
     'Canada', 'Kissimee', 'Yes'],
 ['tammy@kangaroo.com', 'Tammy', '20010812 18:34', 
     'United States', 'Chicago', 'Yes'],
);


Or, better yet, a LoH:

my @data = (
 { address => 'jack@ardvark.com', 
   name    => 'Jack',
   date    => '020010812 18:34', 
   country => 'Canada', 
   city    => 'Kissimee', 
   wanna   =>'Yes'},
 { ... },
);


Now you don't need to hold in your head that "index 0 means address",
"index 4 means city"...


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


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

Date: Tue, 21 Aug 2001 16:49:08 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: need to reformat file from variable to fixed length is Perl the best  way
Message-Id: <3B82D754.197B7AEF@home.com>

johnthan wrote:
> 
> We need to convert a file from a variable lenght delimted format
> to a fixed length format.
> 
> we have a 24 gig file in 12 pieces.  Currently the file is variable
> length delimited by |  with fields enclosed with ^

Can ^ appear within the data? If so, what is the escape character?

> we need to convert this to a fixed lenght format with each field
> taking a certain predined lenght.

How long?

> I am sure that this can be done in Perl

Trivially.
 
> 1 - would this involved just using reading and then fprint to format.

Basically, yes.

> How to handle the delimiters and ^.

Split each line on the delimeters and then remove the quoting.

>  Would every single character need to be processed and examined?

No, this isn't C. :)

> 2 - is Perl able to do this very quickly?  i am looking at around
> 20-25 mins per 2 gig file.

Perl can do it about as quickly as anything else. Just how long it takes
will depend on your hardware and how heavily it's loaded (if it's a
multiuser system).

Assuming that your data is all as in your example (no embedded
quote-chars):

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

while (<DATA>) {
    chomp;
    my @fields = map{s/\^//g; $_} split(/\|/, $_);
    printf("%11s  %10s %26s  %10s\n", @fields);

}

__DATA__
^717764002^|^71776401.^|^2000-09-11-19.23.00.000000^|^2000-05-25^
^300102^|^30011.^|^2000-06-28-19.57.29.670634^|^2000-05-30^

If you can have embedded quotes, it's better to use the Text::CSV_XS
module. (Which isn't part of the standard distro.)

#!/usr/bin/perl -w
use strict;
use Text::CSV_XS;
my $obj = Text::CSV_XS->new({
    sep_char    => '|',
    quote_char  => '^',
    escape_char => '\', # your escape char goes here...
});

while (<DATA>) {
    warn "Couldn't parse line $." unless $obj->parse($_);
    printf("%11s  %10s %26s  %10s\n", $obj->fields);
}

__DATA__
^717764002^|^71776401.^|^2000-09-11-19.23.00.000000^|^2000-05-25^
^300102^|^30011.^|^2000-06-28-19.57.29.670634^|^2000-05-30^

-mjc


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

Date: Wed, 22 Aug 2001 01:53:19 +0100
From: "S Warhurst" <bigusAT@btinternetDOT.com>
Subject: Re: Net::NNTP
Message-Id: <9luvit$jhp$1@plutonium.btinternet.com>

"Gerard Lanois" <gerard@NOSPAMlanois.com> wrote in message
news:u66bhxml6.fsf@NOSPAMlanois.com...

> Did you try it without the \015\012?

Yeah I tried that.. however, I didn't try it with "\n" and it works v.nicely
:-)

Thanks guys

Spencer




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

Date: Wed, 22 Aug 2001 00:41:52 GMT
From: Sean Quinlan <sean@quinlan.org>
Subject: Re: new modules - looking for (sort-of-)pre-release input
Message-Id: <3B830158.D5E1805B@quinlan.org>

OK, let's try this again, hopefully a little more readable!

Simon Andrews wrote:

> [cc'd to original poster]
>
> Sean Quinlan wrote:
> >
> > Thanks in advance to anyone who takes the time to look this over!
> >
> > I'm in the process of  'creating' a few modules that I will be or have
> > uploaded to CPAN and hope to have listed in the modules list. They are
> > currently developed under the CompBio namespace.
>
> [snip]
>
> > I also welcome any suggestions for appropriate additions to these
> > modules, modules that would fit well in this group, and/or if interested
> > in collaborating on this project. Please feel free to e-mail me at
> > seanq@darwin.bu.edu.
>
> Sean,
>
> You asked for suggestions for what to do with these modules, you seem to
> have done quite a bit already! If you are interested, my suggestion
> would be to integrate some of the stuff you are doing into the existing
> bioperl project (www.bioperl.org).  They already have modules to perform
> some of the tasks that yours do, as well as many you may be considering
> writing.  They are always keen to get more people involved, and you may
> find that many of the tools you would find useful are already available
> (there is already a Bioperl DB module for instance).  If nothing else,
> then their code is free, so you can save yourself some development!
>
> Bioperl is a pretty big project, and is the backend for large projects
> such as www.ensembl.org.  You can look through their latest release
> either by getting from their site, or from CPAN
>
> (http://search.cpan.org/search?mode=module&query=bioperl)
>
> I hope this is of interest
>
>         TTFN
>
>         Simon.

Thanks Simon!

Although I would be flattered if the bioperl maintainers thought they could
make use of some of my code, truth be told it exists mostly _because_
bioperl is so big.  Which is also why I state in the docs (perhaps not
clearly enough?), that the CompBio modules are in no way a replacement
for the excellent effors of the bioperl project. I certainly expect that there

will be some functions, perhaps most, in CompBio that are also provided
by bioperl. My goal is just to provide a, hopefully,  simpler way to do be
able to do a small subset of the tasks I, and others I've talked to, have
found to be very commonly needed.

As for the DB module, as I understand it, and I may well be wrong,
bioperl uses a _very_ OO approach to it's design, and it's DB modules
are set up to interact with the database sequence 'objects' that are used
in all of bioperls suite of code. And although it does appear to fetch
outside data through many different websites, it does not _appear_ to
have ways to connect to a local RDBMS. The DB module I have is
designed to interact with relational databases in a fairly straightforward
(again, I hope) manner.

Those are some of the reasons for the existance of this as a seperate
project. All that being said, I do agree I should probably make more of an
effort to contact the bioperl maintainers. Although I believe there are
_very_ good reasons for something like the module set I have made
available, there is no reason why it should be considered an either/or match
against bioperl; I _certainly_ don't want it to be.  If, as the modules I've
released mature, I get the nod to extract code from bioperls existing work
to fill them out, and people working on bioperl projects find some of the
code I've released useful, GREAT!

Again, thank you very much for your input. I hope my explination of why I'm
not simply submitting this code to bioperl and instead releasing it as a
seperate set makes sense to you. If not, I'd be happy to continue this
discusion.

--------------------------
Sean Quinlan
mailto:seanq@darwin.bu.edu
http://bmerc-www.bu.edu/

"You can discover more about a person in an hour of play than in a year of
conversation" - Plato



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

Date: Tue, 21 Aug 2001 23:30:12 GMT
From: friedman@math.utexas.edu (Chas Friedman)
Subject: Passing code pieces to program
Message-Id: <3b82ed5c.13792869@news.itouch.net>

 Is there a way to pass pieces of code to a script as arguments? For
example, I have a  script that uses File::Find, and contains the
expression:  if (-M $_<1)....  
I would like to be able to pass the "-M$_<1" to the script when it is
run (so I could also pass in other conditions.)   I suppose I could
use an eval on some string made up partly of the passed in arg,
but I wondered if there is any other way. Thanks for any comments.
                                                chas friedman


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

Date: Wed, 22 Aug 2001 09:51:30 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: regex to edit config variable
Message-Id: <5RCg7.12$Sh2.5469@wa.nnrp.telstra.net>

"Dale Henderson" <projectobjects@earthlink.net> wrote in message
news:YBzg7.908$OG4.81926@newsread1.prod.itd.earthlink.net...
> I know that App::Config can retrieve values from perl config variables. Is
> there a known function that can change the value of the config variable in
a
> flat text file in the following format
>
> $var = "value1";
>
> or could someone post a regex that can do the replace for the value1.
> Obviously, I am a novice with regex.

Your question is unclear.  Does the text file contain '$var = "value1"; or
does $var contain 'value1'?

If the latter, simply change the value:

$var = 'value2';

if the former:

$_ = '$var = "value1"';

s/"[^"]+"/"value2"/;

HTH

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;





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

Date: 21 Aug 2001 15:27:35 -0700
From: Lyle_Goldman@ibi.com (Lyle Goldman)
Subject: Strange Problem with Win32::Console
Message-Id: <ed639144.0108211427.5b1d0f71@posting.google.com>

-
	Hello. I have been using the Win32::Console package to turn off echoing
while a user enters a password. It works well. However, after the password is
entered and the console echo is turned back on, the Perl program will no longer
accept standard input! Why is this happening and what can I do to fix it?

	Here is the code, stripped of error checking.

use Win32::Console;

sub getpass
{
	my ($password, $term);
	$term = new Win32::Console STD_INPUT_HANDLE;
	my $echo = ENABLE_ECHO_INPUT;
	$term->Mode($term->Mode & ~$echo);
	$password = <STDIN>;
	print "\n";
	$term->Mode($term->Mode | $echo);
	return $password;
}

	Thank you for any help you can give me.

						- Lyle Goldman


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

Date: Tue, 21 Aug 2001 22:07:48 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: String extraction
Message-Id: <UYAg7.2649$hT4.399156@news1.rdc1.md.home.com>


"shaz" <ssa1701@yahoo.co.uk> wrote in message
news:23e71812.0108210811.1bbd822b@posting.google.com...
> You once explained how to write a script which found the keyword in a
> text file.
>
> I was wondering if it would be possible if you could give me little
> more help.
>
> The code below is what you said I should use.
>
> #!/usr/bin/perl -w
> use strict;
> my @tags = ('<NN>', '<VBZ>', '<DET>');
> my $search = join('|',@tags);
> my %taglist;
>
> while (<DATA>) {
>         while (/(\w+)\s($search)/og) {
>         #       print "$1 -> $2\n";
>                 $taglist{$2}{$1}++;
>         }
> }
>
> This finds a SINGLE keyword. I have tried to modify it to find words
> that appear next to each other based on their tags.
>
> I tried this using
>
> while (/(\w+)\s($search)\s(\w+)\s($search)/og)
>
> instead of     while (/(\w+)\s($search)/og)
>
> but it does not work.
>
>
> An example text file is
>
> My <NN> Perl <NN> is <CD> not <VBZ> very <ADJ> good <ADJ>, so <NN>
> please <NN> help <CD> me<NN>.
>
> The new code should find My Perl
>
> Any help would be grately appriciated.
>
> Thanks

I _think_ you want something like this.  I didn't see your last post and
don't feel like digging it up right now.  I used \2 to match the same string
again in the regex.  Note that you have to worry about matches not extending
across multiple lines.  I assume you can organize the data as you see fit
once it is extracted.

#!/usr/bin/perl
use strict;

my @tags = qw/<NN> <CD> <VBZ> <ADJ>/;

my $search = join "|", @tags;
my %taglist;

while ( <DATA> )
{
    # $1 is first word, $2 is tag, $3 is second word
    while ( /(\w+)\s($search)\s(\w+)\s\2/og )
    {
        $taglist{$2}{$1}++;
        $taglist{$2}{$3}++;
    }
}
my ($k, $kinner, $v, $vinner);
while ( ($k, $v) = each %taglist )
{
    print "tag: $k\n";
    while ( ($kinner, $vinner) = each %$v )
    {
        print "$kinner => $vinner\n";
    }
    print "\n";
}
__DATA__
My <NN> Perl <NN> is <CD> not <VBZ> very <ADJ> good <ADJ>,
so <NN> please <NN> help <CD> me<NN>.


David Hilsee




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

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


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