[24178] in Perl-Users-Digest
Perl-Users Digest, Issue: 6370 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 7 06:05:40 2004
Date: Wed, 7 Apr 2004 03:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 7 Apr 2004 Volume: 10 Number: 6370
Today's topics:
Re: add blank lines after word MAC (sed/awk or perl??) (rakesh sharma)
Re: change meta tag description in all htm documents in <gnari@simnet.is>
Re: command line <lv@aol.com>
Re: command line <Joe.Smith@inwap.com>
Re: Help me with my form please. <gnari@simnet.is>
how 2 convert mime to txt or extract words from mime <jcharth@hotmail.com>
I cann't scale gif with correctly with perlmagick. (kenny)
Re: I cann't scale gif with correctly with perlmagick. <tore@aursand.no>
Looking ahead in a split operation. <mr@sandman.net>
Re: Looking ahead in a split operation. (Anno Siegel)
Re: Looking ahead in a split operation. <noreply@gunnar.cc>
Re: Mime::Lite and smtp authentification <jgibson@mail.arc.nasa.gov>
Re: Mime::Lite and smtp authentification <dreamer@cox.net>
Re: Mime::Lite and smtp authentification <Joe.Smith@inwap.com>
Re: More NET::LDAP questions <pkent77tea@yahoo.com.tea>
Re: Net::Time <pkent77tea@yahoo.com.tea>
Object oriented gui with Perl/Tk ... how can I make thi (Nataku)
Re: Object oriented gui with Perl/Tk ... how can I make <uri@stemsystems.com>
Re: Perl Version Issue? <Joe.Smith@inwap.com>
Re: print given character range. <cenxnfu@rpr.nevmban.rqh>
problem with HangUP <aolblowz@yahoo.com>
Re: problem with HangUP (Anno Siegel)
Question about Perl and Expect (Markus Kemp)
Re: Question about Perl and Expect <Joe.Smith@inwap.com>
Re: real, simple sample OOP intro text??!! <uri@stemsystems.com>
Regular expression question (Kapil Khosla)
Re: Regular expression question <tore@aursand.no>
scoping, sig handlers, and labels ctcgag@hotmail.com
Re: scoping, sig handlers, and labels <wherrera@lynxview.com>
Re: scoping, sig handlers, and labels (Anno Siegel)
Re: Tough (for me) regex case <brian@knowdotnet.nospam.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Apr 2004 23:04:37 -0700
From: sharma__r@hotmail.com (rakesh sharma)
Subject: Re: add blank lines after word MAC (sed/awk or perl??)
Message-Id: <ed24e4cf.0404062204.585c13@posting.google.com>
news8080@yahoo.com (NNTP) wrote in message
>
> I have a file with the following data
>
> 192.168.60.161 DOMAINNAME-POWER 03U
> 192.168.60.161 DOMAINNAME-TEMP 1eU
> 192.168.60.161 MAC 00-xy-zz-07-bd-8a
> 192.168.60.179 DOMAINNAME-abacdf 00U
> 192.168.60.179 DOMAINNAME 00U
> 192.168.60.179 DOMAINNAME-abacdf 20U
> 192.168.60.179 DOMAINNAME 1eU
> 192.168.60.179 MAC 00-xy-8b-1c-08-c7
> 192.168.60.198 DOMAINNAME-abcd 00U
> 192.168.60.198 DOMAINNAME 1cU
> 192.168.60.198 DOMAINNAME 00U
> 192.168.60.198 DOMAINNAME-abcd 20U
> 192.168.60.198 DOMAINNAME 1bU
> 192.168.60.198 DOMAINNAME 1eU
> 192.168.60.198 DOMAINNAME 1dU
> 192.168.60.198 MAC 00-zz-aa-bb-8f-35
>
>
> what I want to do is add blank line after MAC entry for each IP. I am
> confortable with awk/sed but can't seem to fig. this out.
>
> do I need perl? or can sed/awk do this?
>
sed -e '/MAC/G' yourfile
------------------------------
Date: Tue, 6 Apr 2004 21:59:55 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: change meta tag description in all htm documents including all files in subdirectories
Message-Id: <c4v968$vqq$1@news.simnet.is>
"Tamara" <tamara@agencija.com> wrote in message
news:c4v3ve$2es$1@ls219.htnet.hr...
> How can I change meta tag description in all htm documents including all
> files in subdirectories, with using perl on Windows XP?
> E.g. new meta tag is "New meta tag", and I want change it in all htm file
> including htm files in subdirectories.
>
use File::Find;
gnari
------------------------------
Date: Tue, 06 Apr 2004 21:17:18 -0500
From: l v <lv@aol.com>
Subject: Re: command line
Message-Id: <EwJcc.472$Fo.13777@dfw-read.news.verio.net>
luc wrote:
> "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> schreef in
> bericht news:Xns94C3978013BECelhber1lidotechnet@62.89.127.66...
>
>>"luc" <anonymous@disneyland.com> wrote:
>>
>>
>>>I am trying to understand perls command line in dos(xp). I would
>>>simple want to send hello to the screen. I've tried things like:
>>>perl -ew "print \"hello\";"
>>>perl -ew "print 'hello';"
>>>What are perls rules here in the dos command line? Is there any
>>>site/tutorial on this subject?
>>
>>
>>Change -ew to -we in both examples. For more information:
>>
>>
>> perldoc perlrun
>>
>>
>>--
>>Cheers,
>>Bernard
>
>
> Thanks Bernard.
> So if you would like to rename a list of files with a .txt extension to a
> .pl extension, you could use the following command: print -we "rename
> '*.txt','*.pl';"? This however doesn't work. How can you rename a series of
> files(without using the default variable!) in a one liner?
>
>
The dos for command may be of interest to you. If you are on NT and
above the dos command ren *.txt *.pl should work, or perl -we "`ren
*.txt *.pl`". If looking for a Perl solution, although not the
prettiest and *may not* be what you are looking for:
dir /b|perl -nlwe "($n = $_) =~ s/\.txt$/\.pl/i; `ren $_ $n`"
Len
------------------------------
Date: Wed, 07 Apr 2004 09:30:04 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: command line
Message-Id: <wSPcc.81879$gA5.1028642@attbi_s03>
luc wrote:
> So if you would like to rename a list of files with a .txt extension to a
> .pl extension, you could use the following command: print -we "rename
> '*.txt','*.pl';"? This however doesn't work. How can you rename a series of
> files(without using the default variable!) in a one liner?
It is possible to do it in less than 80 characters, but you will need to
use variables.
C:>perl -le "for(<*.txt>){$f=$_;s/txt$/pl/;print $f,'=',(rename $f,$_)?$_:$!}"
-Joe
------------------------------
Date: Tue, 6 Apr 2004 21:56:38 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Help me with my form please.
Message-Id: <c4v903$vqe$1@news.simnet.is>
"David Baker" <davidbaker@canoemail.com> wrote in message
news:279d0b35.0404061056.13a64c2a@posting.google.com...
in addition to what Paul said, let me add:
> open (LOG, ">>../LOG.txt");
you do not check if the open() fails
you assume that ../ has a meaning
do you realize that you might want to lock the file ?
gnari
------------------------------
Date: Wed, 07 Apr 2004 00:34:53 GMT
From: joe <jcharth@hotmail.com>
Subject: how 2 convert mime to txt or extract words from mime
Message-Id: <Xns94C3D10AE3AEBjosephthecianet@207.69.154.202>
I am trying to convert a mime file to text to put all the words in
databasse. the email are store as .msg files. i was using the command
stripmime -h but now i am trying to do it from a module. Any
recomendations? thanks in advanced.
------------------------------
Date: 7 Apr 2004 00:41:33 -0700
From: kennyjohn00001@yahoo.com (kenny)
Subject: I cann't scale gif with correctly with perlmagick.
Message-Id: <2eebf9a.0404062341.1ed36d50@posting.google.com>
i face a problem when i scaling the dynamic gif image.
after scale the image, the image have appear incorrectly.
my code is like below:
###########################
!/usr/local/bin/perl
use strict;
use Image::Magick;
my $image = new Image::Magick;
$image->Read('sample.gif');
my $Width = $image->Get('Width');
my $Height = $image->Get('Height');
$Width = $Width * 0.7;
$Height = $Height * 0.7;
$image->Scale(Height=>$Width, $Height);
$image->Write('gif:scale.gif');
########################################
so someone have know solution not or any extra methd use to scale the gif image?
------------------------------
Date: Wed, 07 Apr 2004 10:02:20 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: I cann't scale gif with correctly with perlmagick.
Message-Id: <pan.2004.04.07.07.52.26.490773@aursand.no>
On Wed, 07 Apr 2004 00:41:33 -0700, kenny wrote:
> $image->Scale(Height=>$Width, $Height);
Never used Image::Magick, actually, but are you sure this line is correct?
It doesn't _look_ correct to me, as it would have made more sense to write
something like this:
$image->Scale(Width => $Width,
Height => $Height);
Maybe I'm wrong.
--
Tore Aursand <tore@aursand.no>
"The pure and simple truth is rarely pure and never simple." -- Oscar
Wilde
------------------------------
Date: Wed, 07 Apr 2004 10:57:41 +0200
From: Sandman <mr@sandman.net>
Subject: Looking ahead in a split operation.
Message-Id: <mr-111370.10574107042004@news.fu-berlin.de>
I am doing a tv listing kind of thing, and parsing a string that looks
something like this:
"12.00 Simpsons 12.30 Fresh prince 14.00 Superbowl"
Some of you might remember me asking for how to split that on the time yet keep
the delimiter. That worked out just fine. I am doing something like this now:
----
#!/usr/bin/perl
use strict;
use warnings;
my $string = "12.00 Simpsons 12.30 Fresh prince 14.00 Superbowl";
my @list = split / ?(?=\d\d\.\d\d)/, $string;
foreach (@list){
print "$_\n";
}
__END__
12.00 Simpsons
12.30 Fresh prince
14.00 Superbowl
----
Now, I realised that I wanted to display how long Simpsons would be on, so that
I would display "12.00-12.30 Simpsons".
Is there a way to do this without saving the individual starttimes and iterate
the data again, this time fetching the data from the saved times?
Basically, I would want to know, in iteration 1 what the delimiter was between
array item 1 and 2. I'm sure you understand what I am trying to do.
Thanks in advance!
--
Sandman[.net]
------------------------------
Date: 7 Apr 2004 09:51:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Looking ahead in a split operation.
Message-Id: <c50iul$rof$1@mamenchi.zrz.TU-Berlin.DE>
Sandman <mr@sandman.net> wrote in comp.lang.perl.misc:
> I am doing a tv listing kind of thing, and parsing a string that looks
> something like this:
>
> "12.00 Simpsons 12.30 Fresh prince 14.00 Superbowl"
>
> Some of you might remember me asking for how to split that on the time yet keep
> the delimiter. That worked out just fine. I am doing something like this now:
>
> ----
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $string = "12.00 Simpsons 12.30 Fresh prince 14.00 Superbowl";
>
> my @list = split / ?(?=\d\d\.\d\d)/, $string;
>
> foreach (@list){
> print "$_\n";
> }
> __END__
> 12.00 Simpsons
> 12.30 Fresh prince
> 14.00 Superbowl
>
> ----
>
> Now, I realised that I wanted to display how long Simpsons would be on, so that
> I would display "12.00-12.30 Simpsons".
$string =~ s/(\d\d\.\d\d) (.*?) (?=(\d\d\.\d\d))/$1-$3 $2\n/g;
And your lines are still too long.
Anno
------------------------------
Date: Wed, 07 Apr 2004 12:00:50 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Looking ahead in a split operation.
Message-Id: <c50jo2$2np3il$1@ID-184292.news.uni-berlin.de>
Sandman wrote:
> I am doing a tv listing kind of thing, and parsing a string that
> looks something like this:
>
> "12.00 Simpsons 12.30 Fresh prince 14.00 Superbowl"
>
> Some of you might remember me asking for how to split that on the
> time yet keep the delimiter. That worked out just fine.
<snip>
> 12.00 Simpsons
> 12.30 Fresh prince
> 14.00 Superbowl
>
> Now, I realised that I wanted to display how long Simpsons would be
> on, so that I would display "12.00-12.30 Simpsons".
>
> Is there a way to do this without saving the individual starttimes
> and iterate the data again, this time fetching the data from the
> saved times?
Why would you need to parse the data again, when all the info is in
the array?
Anyway, I think I'd drop the split() function and do something like
this instead:
my $string = '12.00 Simpsons 12.30 Fresh prince 14.00 Superbowl';
my ($elem, @list) = 0;
while ( $string =~ /(\d\d\.\d\d)\s+(.*?)\s*(?=\d\d\.\d\d|$)/g ) {
$list[$elem]{time} = $1;
$list[$elem]{title} = $2;
$elem ++;
}
for (0..$#list-1) {
print "$list[$_]{time}-$list[$_+1]{time} ",
"$list[$_]{title}\n";
}
print "$list[-1]{time}- $list[-1]{title}\n";
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 06 Apr 2004 16:20:58 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Mime::Lite and smtp authentification
Message-Id: <060420041620589160%jgibson@mail.arc.nasa.gov>
In article <LoydnZ8mcv4gie7dRVn2ig@giganews.com>, Fred
<dreamer@cox.net> wrote:
> I have been using a sendmail script based on Mime::Lite for years. Now I
> have to switch to a server which requires smtp authentification, and I
> cannot find any information about how to do that.
> If smtp.mail authorisation is not possible with Mime::Lite, which other
> module can be used instead?
>
> -- Fred
I have (or had) no idea, but when I entered "SMTP authentication" in
the search box at search.cpan.org, Net::SMTP_auth popped out at the top
of the list!
------------------------------
Date: Wed, 07 Apr 2004 09:36:01 +0200
From: Fred <dreamer@cox.net>
Subject: Re: Mime::Lite and smtp authentification
Message-Id: <fNOdnbxHZYb5Mu7dRVn2iQ@giganews.com>
Jim Gibson wrote:
> In article <LoydnZ8mcv4gie7dRVn2ig@giganews.com>, Fred
> <dreamer@cox.net> wrote:
>
>
>>I have been using a sendmail script based on Mime::Lite for years. Now I
>>have to switch to a server which requires smtp authentification, and I
>>cannot find any information about how to do that.
>>If smtp.mail authorisation is not possible with Mime::Lite, which other
>>module can be used instead?
>>
>>-- Fred
>
>
> I have (or had) no idea, but when I entered "SMTP authentication" in
> the search box at search.cpan.org, Net::SMTP_auth popped out at the top
> of the list!
Correct. And it contains a nice sample which I can use. I wonder why I
did not find that with Google -> mime+lite+auth
Thank you Jim,
-- Fred
------------------------------
Date: Wed, 07 Apr 2004 09:49:37 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Mime::Lite and smtp authentification
Message-Id: <R8Qcc.88551$JO3.44333@attbi_s04>
Fred wrote:
> Correct. And it contains a nice sample which I can use. I wonder why I
> did not find that with Google -> mime+lite+auth
Google does not know everything there is to know about perl modules.
http://search.cpan.org/ does.
-Joe
------------------------------
Date: Tue, 06 Apr 2004 23:53:26 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: More NET::LDAP questions
Message-Id: <pkent77tea-F73626.23532606042004@pth-usenet-01.plus.net>
In article <863f122c.0404061212.208cbb@posting.google.com>,
slkleine@hotmail.com (Steve The Geek) wrote:
> According to MS, an LDAP query of
> (useraccountcontrol:1.2.840.113556.1.4.803:=2) should pull up all
> expired accounts. From the LDP utility in the Windows 2000 resource
> kit, it works.
...
> Any thoughts of why the easier 1.2.840.113556.1.4.803:=2 won't work?
Our LDAP books are all in the office technical library and, given it's
23:38, I'm nowhere near work :-) but I do think that Net::LDAP _can_
handle these strings-of-numbers. A quick look at the docs reveals the
'CONTROLS' section near the bottom where you can specify an OID. No idea
if that's any help though...
Actually, the example code download at:
http://www.winnetmag.com/Articles/ArticleID/38058/pg/3/3.html
gives me a hint. Listing 3 has these lines:
...
sub LDAP_CONTROL_TREE_DELETE () { "1.2.840.113556.1.4.805" }
...
my $treedelc = Net::LDAP::Control->new( LDAP_CONTROL_TREE_DELETE );
$rc = $ldap->delete($dn_to_delete, control => [ $treedelc ]);
...
so maybe you can create your own control with that OID that you have and
use that in the search() call.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Tue, 06 Apr 2004 23:20:50 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Net::Time
Message-Id: <pkent77tea-5F8A13.23205006042004@pth-usenet-01.plus.net>
In article <hr867052bq4jnqdq2i8ob3vr9i6l6g0ffc@4ax.com>,
Paul <Paul@nospam.com> wrote:
> I am having a problem getting Net::Time to return a value.
> both of the folling examples return blank lines when run. I was
> expecting it to return the number of seconds from Jan. 1970.
>
> Just to test I have running these lines by themselves in a 2 line
> script.
>
> The docs from active state have not been too much help. I have tried
> w/ both tcp and udp.
>
> Can anyone point me in the right direction
The docs say that inet_time() is "...using the protocol as defined in
RFC868" which is:
http://www.faqs.org/rfcs/rfc868.html
i.e. that's the service running on port 37.
The inet_daytime() routine uses RFC867, which is the one that sits on
port 13 by default.
So, you must be able to connect to port 37 (or 13 for the 'daytime'
service) on the target machine and that port must be running a 'time'
(or 'daytime') server. Note that these are often implemented as part of
inetd, not as a separate program, so check the /etc/inetd.conf if
relevant.
In any case you need to check that the host is running the relevant
services - in my experience some systems ship with these turned OFF by
default, and some administrators turn off those services.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: 6 Apr 2004 21:30:10 -0700
From: Crapnut566@yahoo.com (Nataku)
Subject: Object oriented gui with Perl/Tk ... how can I make this work?
Message-Id: <7e48fc99.0404062030.16d0566b@posting.google.com>
Got a question for all you fellow Perl programmers out there.
Sometime recently I really got into Java because of an OOP class I was
taking at the university, and I have been attempting to apply what I
have learned to a Perl project I have been working on.
Everything seems to go pretty smoothly, and perl takes relatively well
to most OO stuff - but when I get to the GUI part of the program I hit
a rather annoying roadblock that I can't really seem to find a good
solution to. Basically I am attempting to create a class that will
contain a BrowseEntry widget along with a Listbox. When the user
selects a kind of category from the BrowseEntry, the Listbox should
update with all the entries from that particular category.
My problem arises when I get to assigning the command to the
BrowseEntry widget using the browsecmd hashkey/variable. I can only
assign a package function call to it, and as such - it kind of defeats
the whole OO aspect of it, since I cant keep multiple instances of it
around. The piece of code that follows should help to illustrate my
plight.
***************
sub Populate {
my ($self, $args) = @_;
$self->SUPER::Populate($args);
my $browseEntry = $cardLabFrame->BrowseEntry( -variable =>
\$currentSet,
-browsecmd =>
\&refreshList )->pack( -side => 'top' );
}
sub refreshList{
my $self = shift;
#This doesnt work because the $self that gets shifted in here
# is actually the browseEntry widget, and I have no way that
# I know of to reliably get back to my parent object since
# there is no THIS operator in perl.
}
****************
So hopefully with this visual aid you can see my quandry. Never mind
the fact that I havent actually added the Listbox yet ... I havent
gotten that far because of this issue I stumbled upon. I did think of
a hack to get back to the parent object, by storing a reference to the
actual $self I want within an unused hashkey inside of the BrowseEntry
widget, but that seems way to hacky for me.
So I appeal to the community at large. Can any of you think of a way
out of this without hacking the language?
Ben
------------------------------
Date: Wed, 07 Apr 2004 05:00:05 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Object oriented gui with Perl/Tk ... how can I make this work?
Message-Id: <x7lll8o017.fsf@mail.sysarch.com>
>>>>> "N" == Nataku <Crapnut566@yahoo.com> writes:
N> Sometime recently I really got into Java because of an OOP class I
N> was taking at the university, and I have been attempting to apply
N> what I have learned to a Perl project I have been working on.
glad you realize that perl has better OO than java! :)
N> My problem arises when I get to assigning the command to the
N> BrowseEntry widget using the browsecmd hashkey/variable. I can only
N> assign a package function call to it, and as such - it kind of defeats
N> the whole OO aspect of it, since I cant keep multiple instances of it
N> around. The piece of code that follows should help to illustrate my
N> plight.
N> ***************
N> sub Populate {
N> my ($self, $args) = @_;
N> $self->SUPER::Populate($args);
N> my $browseEntry = $cardLabFrame->BrowseEntry( -variable =>
N> \$currentSet,
N> -browsecmd =>
N> \&refreshList )->pack( -side => 'top' );
N> }
use a closure for the callback and close on $self.
<untested>
my $callback = sub { my $widget = shift ;
$self->whatever(
$widget ) } ;
do that inside Populate and use it for the -browsecmd value. then call
whatever method you want in the same class as Populate. it has both the
widget passed in @_ and the Populate object closed on $self.
note: this could creates a data loop (the closure has $self which could
have $browseEntry which has $self!). so you need to be careful or you
may leak memory. you have explicitly break that loop to properly garbage
collect it. you can do that by clearing the values in $browseEntry
(maybe some tk destroy method?) and then deleting $browseEntry.
N> So I appeal to the community at large. Can any of you think of a way
N> out of this without hacking the language?
get the book object oriented perl which covers using closures with
objects for callbacks.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 07 Apr 2004 09:41:36 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Perl Version Issue?
Message-Id: <j1Qcc.86119$w54.509791@attbi_s01>
Kirk Strauser wrote:
> You forgot the "-w" and "use strict;". Add those and see if it gives you
> additional warnings.
Absolutely no change.
Fails with 5.8.0, works with 5.8.3; bug fixed.
-Joe
------------------------------
Date: Tue, 6 Apr 2004 15:56:47 -0700
From: Cognition Peon <cenxnfu@rpr.nevmban.rqh>
Subject: Re: print given character range.
Message-Id: <Pine.GSO.4.50.0404061551250.25635-100000@ece2.ece.arizona.edu>
Yesterday, IP packets from Andre Majorel delivered:
> On 2004-04-05, Jayaprakash Rudraraju <prakash@ece.arizona.edu> wrote:
>
> > Most of the files in bioinformatics save their sequences in fasta
> > format. Fasta format files contain header lines followed by dna
> > sequence. I have been using the following short-cut to get sequence
> > given the range in the sequence.
> >
> > perl -ne 'chomp; next if />/; print' FASTA.TXT | cut -c3450-3470
> >
> > Is there is a better and convinient way to do it.
>
> Other ways to do it would be:
>
> grep -v '>' FASTA.TXT | tr -d '\n' | cut -c3450-3470
Thanks for the solution.. wanted a simpler way to get the range of
sequence from a fasta file. The headers in fasta files always start
with '>' but I was not looking for a faster solution. will use a script
if fasta file is too long.
>
> perl -ne '
> chomp;
> next if />/;
> $result .= $_;
> if (length ($result) >= 3470)
> {
> print substr ($result, 3449, 21), "\n";
> exit 0
> }'
>
> Whether they're faster or more convenient than the above, I
> don't know. But the solutions involving cut(1) may not do what
> you want if FASTA.TXT is too big to be swallowed in one line.
>
>
--
echo cenxnfu@rpr.nevmban.rqh | perl -pe 'y/a-z/n-za-m/'
If you want to make God laugh, tell him your future plans.
-------------------------------------
Printed using 100% recycled electrons
------------------------------
Date: Tue, 06 Apr 2004 21:38:37 -0400
From: lucas <aolblowz@yahoo.com>
Subject: problem with HangUP
Message-Id: <Te2dnTzmcPYAxu7dRVn-uQ@golden.net>
$SIG{HUP} = sub { print STDERR "$$: HUP Caught\n";
LoadFiles($adfilterfile); }; #Catch HanUPs, and reread all loaded files
All I want this to do is catch a HangUP signal, run the LoadFiles() routine
and return to what it was doing. However this exits the program. It
doesn't die, it just exits. Any idea on how I can stop this from exiting?
thx
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
------------------------------
Date: 7 Apr 2004 08:18:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: problem with HangUP
Message-Id: <c50dg4$ni9$1@mamenchi.zrz.TU-Berlin.DE>
lucas <aolblowz@yahoo.com> wrote in comp.lang.perl.misc:
> $SIG{HUP} = sub { print STDERR "$$: HUP Caught\n";
> LoadFiles($adfilterfile); }; #Catch HanUPs, and reread all loaded files
>
> All I want this to do is catch a HangUP signal, run the LoadFiles() routine
> and return to what it was doing. However this exits the program. It
> doesn't die, it just exits. Any idea on how I can stop this from exiting?
No.
The code you show doesn't exit. If it exits for you, that happens in the
code you don't show. We can't correct code we don't get to see.
Anno
------------------------------
Date: 7 Apr 2004 01:15:27 -0700
From: markus.kemp@erlf.siemens.de (Markus Kemp)
Subject: Question about Perl and Expect
Message-Id: <7807f68a.0404070015.4b4524ff@posting.google.com>
Hi all,
I'm doing some programming with the tool Expect. So far I've been
doing this in Tcl, but I'd like to migrate to Perl. I've gone to the
Expect homepage http://expect.nist.gov/ to find out whether Expect is
available for Perl as well, but I couldn't find any such information.
On the contrary, on the site it is said that "Note: Expect requires
Tcl. If you don't already have Tcl, you can download it as source from
[...]". Suprisingly when I went googling using the search term
"Expect for Perl" I found a page that seems to have just what I'm
looking for. The thing is, I'm a little puzzled by the fact that I
found page offering Expect for Perl when the Expect homepage seems to
think that there is no such thing. Is the Perl version somehow
restricted or otherwise flawed that it would not be mentioned on the
Expect homepage? I need Expect for a project at work, so I need to be
sure that I have a stable and 100% functioning Expect. Can someone in
the know please shed some light on this for me? Thanks in advance.
Regards,
Markus
------------------------------
Date: Wed, 07 Apr 2004 09:59:44 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Question about Perl and Expect
Message-Id: <kiQcc.208850$Cb.1811640@attbi_s51>
Markus Kemp wrote:
> I'm doing some programming with the tool Expect. So far I've been
> doing this in Tcl, but I'd like to migrate to Perl. I've gone to the
> Expect homepage http://expect.nist.gov/ to find out whether Expect is
> available for Perl as well, but I couldn't find any such information.
That is not the appropriate page to find out if Expect is available
for Perl. Go to http://search.cpan.org and you will find Expect.pm.
> looking for. The thing is, I'm a little puzzled by the fact that I
> found page offering Expect for Perl when the Expect homepage seems to
> think that there is no such thing.
Not surprising. There are a lot of perl modules that act as wrappers
for other software, doing things that the author never considered.
Said author may or may not mention the perl enhancement; it is not required.
-Joe
------------------------------
Date: Tue, 06 Apr 2004 23:44:16 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: real, simple sample OOP intro text??!!
Message-Id: <x71xn0pt7z.fsf@mail.sysarch.com>
>>>>> "DHA" == David H Adler <dha@panix.com> writes:
DHA> In article <x77jwvh08q.fsf@mail.sysarch.com>, Uri Guttman wrote:
>>>>>>> "TvP" == Tassilo v Parseval <tassilo.parseval@rwth-aachen.de> writes:
>>
TvP> Also sprach Uri Guttman:
DHA> [snip]
TvP> I'd rather suggest he has a look at Randal's "Learning Perl
TvP> Objects, References & Modules. And unlike Damian's book, this
TvP> one comes with excercises for the reader.
>>
>> i would expect that to be good too. i haven't snarfed a copy yet :)
DHA> Aha. Well, if you can push damian's book as a tech reviewer of it, I
DHA> can help out here. :-) Yes, it's a good book.
DHA> Damian's book, although wonderful, is very much an in-depth look
DHA> at OOP, whereas Randal's book feels a bit more like an
DHA> introduction - not wholly surprising, as it's intended to act
DHA> sort of as a follow up to Learning Perl.
the chapter of perl review in OOP is a classic. and the chapter on the 3
points that make perl into OO is also great. the rest of the book as you
say is in depth and not for beginners.
DHA> Also, if examples featuring characters from Gilligan's Island appeals,
DHA> Randal's book wins on that score. :-)
yeah, OOP uses boring cd catalog examples.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 6 Apr 2004 22:05:32 -0700
From: khoslakapil@yahoo.com (Kapil Khosla)
Subject: Regular expression question
Message-Id: <919aa2da.0404062105.16d45296@posting.google.com>
Hi,
I am trying to match the expression
#brace.txt
int main()
{
return main();
}
in a file but am getting stuck somewhere. This is the code I could write till now.
open I, "E:\\mycode\\perl\\brace.txt";
while($line = <I>)
{
$line =~ s/int main\(\)\s*\{return\s*main\(\)\;\s*\}/matched/ ;
print $line;
}
close I;
Where am I going wrong? Please help,
Thanks,
Kapil
------------------------------
Date: Wed, 07 Apr 2004 07:53:43 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Regular expression question
Message-Id: <pan.2004.04.07.05.16.23.198926@aursand.no>
On Tue, 06 Apr 2004 22:05:32 -0700, Kapil Khosla wrote:
> I am trying to match the expression
>
> #brace.txt
> int main()
> {
> return main();
> }
>
> in a file but am getting stuck somewhere. This is the code I could write
> till now.
>
> open I, "E:\\mycode\\perl\\brace.txt";
Always (!) check if open() succeeds, and drop the double quotes; they're
not necessary here;
open(I, '<', 'e:\mycode\perl\brace.txt') or die "$!\n";
> while($line = <I>)
> {
> $line =~ s/int main\(\)\s*\{return\s*main\(\)\;\s*\}/matched/;
> print $line;
> }
You're trying to match multiple lines. The code above will try to match
only one line at a time. You should consider reading your whole file into
one string and _then_ do the matching.
--
Tore Aursand <tore@aursand.no>
"Scientists are complaining that the new "Dinosaur" movie shows
dinosaurs with lemurs, who didn't evolve for another million years.
They're afraid the movie will give kids a mistaken impression. What
about the fact that the dinosaurs are singing and dancing?" -- Jay
Leno
------------------------------
Date: 06 Apr 2004 22:17:30 GMT
From: ctcgag@hotmail.com
Subject: scoping, sig handlers, and labels
Message-Id: <20040406181730.956$ML@newsreader.com>
I expect the program below to go into an infinite loop after print 9,
but instead it errors out. Why can't it find the label REDO?
I plead guilty to leaving a sub through redo, but the rest of it
I swear I'm innocent.
#perl -w
use strict;
REDO:foreach(1..1000) {
$SIG{ALRM}=sub {redo REDO};
alarm 10;
system "sleep $_"; # don't use builtin sleep, just in case.
alarm 0;
print "$_\n";
};
__END__
1
2
3
4
5
6
7
8
9
Exiting subroutine via redo at - line 3.
Exiting eval via redo at - line 3.
Label not found for "redo REDO" at - line 3.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 06 Apr 2004 21:41:25 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: scoping, sig handlers, and labels
Message-Id: <DYGdnUXU-4Ue5e7dRVn-sA@adelphia.com>
ctcgag@hotmail.com wrote:
> I expect the program below to go into an infinite loop after print 9,
>
> #perl -w
> use strict;
> REDO:foreach(1..1000) {
> $SIG{ALRM}=sub {redo REDO};
> alarm 10;
> system "sleep $_"; # don't use builtin sleep, just in case.
> alarm 0;
> print "$_\n";
> };
from perlfunc:
===
It is usually a mistake to intermix alarm and sleep calls. (sleep may be
internally implemented in your system with alarm)
------------------------------
Date: 7 Apr 2004 09:13:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: scoping, sig handlers, and labels
Message-Id: <c50gmv$q94$1@mamenchi.zrz.TU-Berlin.DE>
<ctcgag@hotmail.com> wrote in comp.lang.perl.misc:
> I expect the program below to go into an infinite loop after print 9,
> but instead it errors out. Why can't it find the label REDO?
>
> I plead guilty to leaving a sub through redo, but the rest of it
> I swear I'm innocent.
>
> #perl -w
> use strict;
> REDO:foreach(1..1000) {
> $SIG{ALRM}=sub {redo REDO};
> alarm 10;
> system "sleep $_"; # don't use builtin sleep, just in case.
> alarm 0;
> print "$_\n";
> };
> __END__
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> Exiting subroutine via redo at - line 3.
> Exiting eval via redo at - line 3.
> Label not found for "redo REDO" at - line 3.
I'm not sure what's happening, but in a similar vein I noticed you can't
leave a SIG handler via "goto" back to the main program. Like in your
case, the label isn't found.
Anno
------------------------------
Date: Tue, 6 Apr 2004 22:33:10 -0400
From: "Brian Davis" <brian@knowdotnet.nospam.com>
Subject: Re: Tough (for me) regex case
Message-Id: <#56LviEHEHA.1240@TK2MSFTNGP12.phx.gbl>
The match itself contains the quotes, but the named group 'no_quotes'
contains only the text within the quotes.
As I mentioned in the reply, the match should consume the quotes so they
will not be re-used in other matches (the " brown" problem). You can then
use a named group to extract only a portion of the actual match.
Brian Davis
http://www.knowdotnet.com
"mortb" <moggadah@hotmail.com> wrote in message
news:OQZC9i8GEHA.3164@TK2MSFTNGP11.phx.gbl...
> Sorry Brian,
> I tested your expression "(?<no_quotes>(""|[^"])*)" and it also rendered
>
> (1) "quick"
> (2) "fox jumped ""over"" the"
>
> thus still leaving the initial and ending quotes in the strings.
>
> cheers,
> mortb
>
> "Rob Perkins" <rob_perkins@hotmail.com> wrote in message
> news:4nmr60h82vnto36j69knmmtnspjd1fia85@4ax.com...
> > "Brian Davis" <@> wrote:
> >
> > >
> > >Does my earlier suggestion about using a named group not work?
> >
> >
>
>
------------------------------
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 6370
***************************************