[27083] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8974 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 20 09:05:50 2006

Date: Mon, 20 Feb 2006 06:05:05 -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           Mon, 20 Feb 2006     Volume: 10 Number: 8974

Today's topics:
        ANNOUNCE: AFS Perl API 2.4.0 released <nog@MPA-Garching.MPG.DE>
        Looking for a trick with strings <january.weiner@gmail.com>
    Re: Looking for a trick with strings <rwxr-xr-x@gmx.de>
    Re: Looking for a trick with strings (Anno Siegel)
    Re: Pattern Matching on Case <someone@example.com>
    Re: Pattern Matching on Case <samwyse@gmail.com>
    Re: Pattern Matching on Case <matthew.garrish@sympatico.ca>
        perl/expect.pm manual user input <noreply@noreply.com>
    Re: Puzzled over rgexp <whoever@whereever.com>
    Re: XS - Variable creation <bol@adv.magwien.gv.at>
    Re: XS - Variable creation (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 20 Feb 2006 12:20:09 GMT
From: Norbert Gruener <nog@MPA-Garching.MPG.DE>
Subject: ANNOUNCE: AFS Perl API 2.4.0 released
Message-Id: <Iuzn5H.15KL@zorch.sf-bay.org>


AFS Perl API Version 2.4.0
    I am pleased to announce the AFS Perl API 2.4.0 release

    The AFS module bundle is a dynamically loadable extension to
    Perl. It gives the AFS user and administrator access to many of
    the AFS programming APIs, allowing you to make these calls
    directly from Perl, rather then processing the output of a
    command. The AFS module bundle is a thin layer above the low-level
    AFS APIs.

Where To Get It
    The version 2.4.0 is now available at

        http://www.MPA-Garching.MPG.de/~nog/perl/AFS-2.4.0.tar.gz
        http://www.cpan.org/authors/id/N/NO/NOG/AFS-2.4.0.tar.gz

    This release should work on all UNIX/Linux platforms which have
    AFS API interfaces and the appropriate C compilation environment.

MD5SUM
    cad4a2921be02930f2234a6f08c43258  AFS-2.4.0.tar.gz


User Visible Changes in this Release
    - New module BOS which implements most commands of the BOS command suite.
    - compiles now with OpenAFS 1.4 system libraries
    - improved test drivers


For more information about the current state of the AFS Perl API,
check my "AFS Perl API Kwiki" site at:

        http://www.mpa-garching.mpg.de/kwiki/nog/afsperl/


Share and Enjoy!

Norbert
-- 




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

Date: Mon, 20 Feb 2006 13:54:45 +0100 (CET)
From: January Weiner <january.weiner@gmail.com>
Subject: Looking for a trick with strings
Message-Id: <dtce6l$r40$1@sagnix.uni-muenster.de>

Hi, 

here is the problem.

I have strings (protein sequences, to be precise) that contain letters +
'-':

  my $s = 'Y---ERI-TTKDIV----EIKRHLDYLQAPRITNNDLE' ; # for example
  my $s_nogaps = $s ;
  $s_nogaps =~ s/-//g ;

Then I get two numbers:

  my ($from, $length) = (0, 5) ;

These are the indices of a substring within $s_nogaps (and not $s).  The
above indices correspond to a string 'YERIT'.

Now I would like to have fragments of $s corresponding to this substring.
For example, given the above indices, I should get 'Y--ERI-T'.

The best that I can come up with is looping over each character separately,
and incrementing a counter only if it is:


  sub get_subseq {
    my ($s, $f, $l) = @_ ;
    my $i = 0 ;
    my $ret ;
    my $within = 0 ;
  
    for(split //, $s) {
      last if($i >= $f + $l) ;
      if($_ ne '-') { $i++ ; }
      next unless($i > $f) ;
      $ret .= $_ ;
    }
  
    return $ret ;
  }

any better ideas?

j.

-- 


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

Date: Mon, 20 Feb 2006 14:24:19 +0100
From: "Lukas Mai" <rwxr-xr-x@gmx.de>
Subject: Re: Looking for a trick with strings
Message-Id: <dtcfu3$4ap$00$1@news.t-online.com>

January Weiner <january.weiner@gmail.com> schrob:
> I have strings (protein sequences, to be precise) that contain letters +
> '-':
> 
>  my $s = 'Y---ERI-TTKDIV----EIKRHLDYLQAPRITNNDLE' ; # for example
>  my $s_nogaps = $s ;
>  $s_nogaps =~ s/-//g ;
> 
> Then I get two numbers:
> 
>  my ($from, $length) = (0, 5) ;
> 
> These are the indices of a substring within $s_nogaps (and not $s).  The
> above indices correspond to a string 'YERIT'.
> 
> Now I would like to have fragments of $s corresponding to this substring.
> For example, given the above indices, I should get 'Y--ERI-T'.

Hmm, you could define a gappy letter as [A-Z], followed by 0 or more
dashes. Then you need to match a prefix of $from gappy letters, followed
by $length gappy letter, which you extract.

sub get_subseq {
    my ($str, $from, $len) = @_;
    return ($str =~ /(?:[A-Z]-*){$from}((?:[A-Z]-*){$len})/)[0];
}

The only problem with this approach is that it will return all trailing
dashes, i.e. get_subseq('Y--ERI-TT', 0, 1) eq 'Y--'.

HTH, Lukas


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

Date: 20 Feb 2006 13:55:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Looking for a trick with strings
Message-Id: <dtchnu$k92$1@mamenchi.zrz.TU-Berlin.DE>

January Weiner  <january.weiner@gmail.com> wrote in comp.lang.perl.misc:
> Hi, 
> 
> here is the problem.
> 
> I have strings (protein sequences, to be precise) that contain letters +
> '-':
> 
>   my $s = 'Y---ERI-TTKDIV----EIKRHLDYLQAPRITNNDLE' ; # for example
>   my $s_nogaps = $s ;
>   $s_nogaps =~ s/-//g ;
> 
> Then I get two numbers:
> 
>   my ($from, $length) = (0, 5) ;
> 
> These are the indices of a substring within $s_nogaps (and not $s).  The
> above indices correspond to a string 'YERIT'.
> 
> Now I would like to have fragments of $s corresponding to this substring.
> For example, given the above indices, I should get 'Y--ERI-T'.
> 
> The best that I can come up with is looping over each character separately,
> and incrementing a counter only if it is:
> 
> 
>   sub get_subseq {
>     my ($s, $f, $l) = @_ ;
>     my $i = 0 ;
>     my $ret ;
>     my $within = 0 ;
>   
>     for(split //, $s) {
>       last if($i >= $f + $l) ;
>       if($_ ne '-') { $i++ ; }
>       next unless($i > $f) ;
>       $ret .= $_ ;
>     }
>   
>     return $ret ;
>   }

Create an offset table @offset that points, for every character position
in $s_nogaps, to the corresponding character in $s.  That is, the array
would start out ( 0, 4, 5, 6, 8, ...).  Use that table to calculate
the character positions in $s, given character positions in $s_nogap.

    my $s = 'Y---ERI-TTKDIV----EIKRHLDYLQAPRITNNDLE' ; # for example

    my @offset = do {
        my @char = split //, $s;
        grep $char[ $_] ne '-', 0 .. $#char;
    };

    (my $s_nogaps = $s) =~ tr/-//d;

    my ($from, $length) = ( 0, 5);
    my $ret = do {
        my $to = $from + $length;
        substr( $s, $offset[ $from], $offset[ $to] - $offset[ $from]);
    };

    print "$ret\n";

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Mon, 20 Feb 2006 00:32:54 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Pattern Matching on Case
Message-Id: <W68Kf.5642$_62.3908@edtnps90>

DANIEL BURCH wrote:
> I have a file that apparently had html tags stripped out of it, or
> something, but no space characters added to replace the tags so it ended up
> with a lot of words run together like "ExplosionThis".  In almost all cases
> there is a lower case letter followed by an upper case letter.  I am trying
> to figure out a substitution statement that would separate them, but I'm not
> sure what would work.  Maybe something like
> 
> s/*[a-z][A-Z]*/*[a-z] [A-Z]*/g;
> 
> but I don't have a clue if that is even close to working or if it will give
> me an "a" at the end and beginning of the words.  Any help would be greatly
> appreciated.

$ perl -le'$_ = "ThisIsATest"; print; s/(?<=.)(?=[[:upper:]])/ /g; print'
ThisIsATest
This Is A Test


John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 20 Feb 2006 05:17:09 GMT
From: Samwyse <samwyse@gmail.com>
Subject: Re: Pattern Matching on Case
Message-Id: <phcKf.34787$F_3.23009@newssvr29.news.prodigy.net>

DANIEL BURCH wrote:
> I have a file that apparently had html tags stripped out of it, or
> something, but no space characters added to replace the tags so it ended up
> with a lot of words run together like "ExplosionThis".

This is a bit off-topic, and definitely not related to Perl, but your 
file didn't have HTML tags stripped from it.  When stripping HTML tags, 
you aren't supposed to replace them with whitespace.  For example, 
consider the following HTML, which italicizes some of the alphabet:

a<i>bcd</i>e<i>fgh</i>i<i>jklmn</i>o<i>pqrst</i>u<i>vwx</i>y<i>z</i>

Introducing spaces for the tags would mess everything up.


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

Date: Mon, 20 Feb 2006 07:18:38 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Pattern Matching on Case
Message-Id: <vsiKf.3254$%14.157095@news20.bellglobal.com>


"Samwyse" <samwyse@gmail.com> wrote in message 
news:phcKf.34787$F_3.23009@newssvr29.news.prodigy.net...
> DANIEL BURCH wrote:
>> I have a file that apparently had html tags stripped out of it, or
>> something, but no space characters added to replace the tags so it ended 
>> up
>> with a lot of words run together like "ExplosionThis".
>
> This is a bit off-topic, and definitely not related to Perl, but your file 
> didn't have HTML tags stripped from it.  When stripping HTML tags, you 
> aren't supposed to replace them with whitespace.  For example, consider 
> the following HTML, which italicizes some of the alphabet:
>
> a<i>bcd</i>e<i>fgh</i>i<i>jklmn</i>o<i>pqrst</i>u<i>vwx</i>y<i>z</i>
>
> Introducing spaces for the tags would mess everything up.

But then consider:

<td>I like to</td><td>Format everything</td><td>Inside cells</td><td>On one 
line</td>

Never underestimate a bad html parsing job... : )

Matt 




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

Date: Sun, 19 Feb 2006 19:33:43 -0500
From: "R. Craw" <noreply@noreply.com>
Subject: perl/expect.pm manual user input
Message-Id: <11vi3jace0rcgbd@corp.supernews.com>

I have a script that I am automating where occasionally the script requires 
manual user input. If I simply tell expect.pm to send default values (\n), 
the scripts work fine. However, when I remove one of the checks and wish the 
user running the expected automated script to be allowed to manually enter 
one of the script queries, the perl/expect script just sits there after the 
user has entered the values. I expect (sorry) that I need to be using a 
manual tty function within the expect call, but am unsure. Looking for 
guidance on how to allow a manual user input value within an expect 
automated input call.

Sample code follows, the commented section is the field I wish to allow the 
user running the script to be able to manually enter the code:

$exp->expect($timeout,
        [ qr/ENTER to continue/ =>
          sub {
            my $exp = shift;
            sleep 1;
            $exp->send("\n");
            exp_continue;
          }
        ],
        [ qr/\[\/usr\/local\] / =>
          sub {
            my $exp = shift;
            sleep 1;
            $exp->send("\n");
            exp_continue;
          }
        ],
#       [ qr/Activation code \:/ =>
#          sub {
#            my $exp = shift;
#            sleep 1;
#            $exp->send("\n");
#            exp_continue;
#          }
#        ],
        [ qr/ENTER to quit/ =>
          sub {
            my $exp = shift;
            sleep 1;
            $exp->send("\n");
            exp_continue;
          }
        ],
);
$exp->soft_close(); 




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

Date: Mon, 20 Feb 2006 10:56:56 -0000
From: "IanW" <whoever@whereever.com>
Subject: Re: Puzzled over rgexp
Message-Id: <dtc79o$d8f$1@blackmamba.itd.rl.ac.uk>


"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message 
news:45m8ebF7e4o2U1@individual.net...
> IanW wrote:
>> Gunnar Hjalmarsson wrote:
>>>Btw, which standard are you referring to?
>>
>> RFC2822, according to wikipedia
>
> There are certainly RFC 2822 compliant addresses that won't match your 
> regex. Quoted strings and domain literals come to mind. There are probably 
> others.

Well, quoted strings are discouraged according to RFC 2821 and so I'm quite 
happy to ignore such addresses.

Ian 




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

Date: Mon, 20 Feb 2006 13:34:29 +0100
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: XS - Variable creation
Message-Id: <1140438870.621665@proxy.dienste.wien.at>

Sisyphus:

> Perhaps this simple Inline::C demo helps:

Unfortunately, there's no Inline module available on my system
(and no supported CPAN version for OpenVMS).

Anno Siegel:

> Then copy the value into the SV associated with the variable.

Yeah, that's exactly what I do now:

/* rtscalar is the sv set previously */

SV* perlsv = get_sv("Cosmos::RtScalar",0);     /* Create named SV entry */
sv_setsv(perlsv,rtscalar);                                   /* Copy
existing SV to named SV */

BTW can someone explain me the difference in marking a SV as "not longer
needed" by doing a

sv_2mortal(mysv)         and
SvREFCNT_dec(mysv)?

I also found code like this:

HV* stash1 = GvHV(gv_fetchpv("ZoneG::",GV_ADDMULTI,Svt_PVHV));
AV* arrdb = GvAV(gv_fetchpv("ZoneG::AdptOn",GV_ADDMULTI,Svt_PVAV));

Can someone tell we what's going on here?

Ilya Zakharevich:

> I would do it like this: return a reference from XS.  Do the
> assignment in Perl code wrapper (via *name = reference).  (Not hard to
> do from XS, but somebody spent some time to make it *especially
> simple* from Perl code; why not use it?)

Sorry, I can't understand what you mean. Could you post an example, please?

Many thanks for all answers I got, and kind greetings from Vienna,

Ferry

-- 
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at








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

Date: 20 Feb 2006 13:16:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: XS - Variable creation
Message-Id: <dtcffo$icp$1@mamenchi.zrz.TU-Berlin.DE>

Ferry Bolhar <bol@adv.magwien.gv.at> wrote in comp.lang.perl.misc:
> Sisyphus:
> 
> > Perhaps this simple Inline::C demo helps:
> 
> Unfortunately, there's no Inline module available on my system
> (and no supported CPAN version for OpenVMS).

Inline is only a shortcut.  Anything you can do with Inline you can
do in XS directly.

> BTW can someone explain me the difference in marking a SV as "not longer
> needed" by doing a
> 
> sv_2mortal(mysv)         and
> SvREFCNT_dec(mysv)?

SvREFCNT_dec counts the refcount down immediately.  If the sv had
a refcount of 1, it will be gone after the operation.

sv_2mortal arranges for a delayed SvREFCNT_dec.  The sv will continue
to exist until the next call to FREETMPS.  FREETMPS is usually called
implicitly at statement boundaries.

> I also found code like this:
> 
> HV* stash1 = GvHV(gv_fetchpv("ZoneG::",GV_ADDMULTI,Svt_PVHV));
> AV* arrdb = GvAV(gv_fetchpv("ZoneG::AdptOn",GV_ADDMULTI,Svt_PVAV));
> 
> Can someone tell we what's going on here?

Interpreting code without context is like filling out a crossword
puzzle without the questions.  You may succeed eventually, but the
result may or may not match the original.

It looks like someone is fetching the stash for the package ZoneG
(first line) and fetching the array @ZoneG::AdptON (second line).

If you don't know what a function/variable/macro/flag does, look
it up in

    1. perldoc perlapi
    2. perldoc perlguts
    3. the Perl source:
       grep xyz *.h  # macros, flags
       grep xyz *.c  # functions, variables

Yes, it's a tedious process.

Anno


-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

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


Administrivia:

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

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

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

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

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


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


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