RE: easy way to add element to array

2004-10-29 Thread Jeff 'japhy' Pinyan
On Oct 29, Bob Showalter said: >[EMAIL PROTECTED] wrote: >> Though about using a hash but I don't have a need for a Key/Value >> combination. I just need a list without duplicates. I suppose I can >> define the hash keys if they don't already exists and export the keys >> into an array with the ke

Re: Extracting Directories and Sub Directories and Counting

2004-10-29 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote: for my $dir ( sort keys %HoA ) { print "$dir\n"; my @basenames = @{ $HoA{$dir} }; my %count; for my $frames ( @basenames ) { $count{$frames} += 1; } for ( sort keys %count ) { printf "%30s\t%04d\n"

Re: Newbie: Perl Vs Shell

2004-10-29 Thread Chris Devers
On Fri, 29 Oct 2004, Lawrence Statton N1GAK/XE2 wrote: > [EMAIL PROTECTED] (Chris Devers) writes: > > > On Fri, 29 Oct 2004, Jenda Krynicky wrote: > > > > > Actually no. They are generaly not very fast. The reason is that > > > the shell interpreter needs to create a new process for each and >

Re: Extracting Directories and Sub Directories and Counting

2004-10-29 Thread Gunnar Hjalmarsson
Ron Smith wrote: The following is the re-worked script: snip- #!/usr/bin/perl -w use strict; my %HoA; for ( `dir /b/s` ) { push @{ $HoA{$1} }, $2 if /(.+)\\(\w+)\.(\d+)\.(\w+)$/; } The two last pairs of parentheses are redundant. my %count; for my $dir (

Re: Printing to a file

2004-10-29 Thread Zeus Odin
my $hero = 'John Krahn'; $hero =~ s/John Krahn/Jenda Krynicky/; >:-) I can't believe I wrote what I thought was a thoughtful post that would hopefully make perl.beginners a better place to frequent (good luck!) and all I get is: Dude, Randal is spelled with one L not two. Pay attention. I'm John

Re: Extracting Directories and Sub Directories and Counting

2004-10-29 Thread Ron Smith
Well I've moved this along a little further, but it looks like I'm stuck on one last thing. I'm getting; C:\Perl\scripts\dir\dir\dir basename 0001 basename 0002 basename 0003 basename 0004

Re: Append on top

2004-10-29 Thread John W. Krahn
Jenda Krynicky wrote: From: [EMAIL PROTECTED] This is the way I would do it, however my code has been subject to criticism more that once in the past :) open (FILE, "; close (FILE); $new_data = "This is my new line that I am going to put at the top\n"; unshift (@file, $new_data);

Re: regex matching in a nested loop

2004-10-29 Thread Zeus Odin
Jason, You state your question, and practically give the answer in the solution. :-) You have a for loop inside a while loop. Both loops set $_. You state that you can not properly do your match within the for loop because you need the $_ value set by the while loop. Well ... why don't you just "

Re: easy way to add element to array

2004-10-29 Thread Zeus Odin
Also look at perldoc -q duplicate and Perl Cookbook 4.6. Extracting Unique Elements from a List "Brian Barto" <[EMAIL PROTECTED]> wrote in message ... > Though about using a hash but I don't have a need for a Key/Value > combination. I just need a list without duplicates. I suppose I can def

Re: each character in a string

2004-10-29 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi All, Hello, I have to write a code wherein I have to access each character in a string and compare it with '-' $_ = $seq1[0]; while(/./g) { if($1 eq '-') { $res1[0] .= '-'; ^^ } else { $res1[0] = "A"; ^ Is that supposed to be '.='

Interpreting Benchmark test

2004-10-29 Thread Owen
My first foray into Benchmark with the code below produced these results; The file is 22000 lines, and there are 2 matches in the file. [EMAIL PROTECTED] PerlScripts]$ perl benchmark.pl Regex with modifer YES YES timethis 100: 5 wallclock secs ( 4.84 usr + 0.50 sys = 5.34 CPU) @ 187265.9

Re: Newbie: Perl Vs Shell

2004-10-29 Thread Lawrence Statton N1GAK/XE2
[EMAIL PROTECTED] (Chris Devers) writes: > On Fri, 29 Oct 2004, Jenda Krynicky wrote: > > > Actually no. They are generaly not very fast. The reason is that the > > shell interpreter needs to create a new process for each and every > > commend you specify in the script [...] > > Is this true

Re: each character in a string

2004-10-29 Thread Ajey Kulkarni
Also, "Mastering Regular EXpressions" - Orielly book gives real nice insight about this. I'm still learning PERL...Sigh! ~A On Fri, 29 Oct 2004, Gunnar Hjalmarsson wrote: > [EMAIL PROTECTED] wrote: > > I have to write a code wherein I have to access each character in a > > string and compare i

RE: Append on top

2004-10-29 Thread Rajesh Dorairajan
Title: RE: Append on top I looked at the archives and found a mail by NYMI Jose where the code was pretty neat. It was actually for inserting in the middle of the file. However, I could not get it to append on top. I am enclosing the mail containing his code as attachment if someone likes to c

RE: how summarise results from 2 hashes?

2004-10-29 Thread Charles K. Clarkson
Maxipoint Rep Office <[EMAIL PROTECTED]> wrote: : Charles K. Clarkson [mailto:[EMAIL PROTECTED] wrote: : : : Maxipoint Rep Office <[EMAIL PROTECTED]> top-posted: : : : : : Additional: $hasfromform1 have as result only 1 key : : : $hasfromform2 can have multiple keys (ever key by : : : $hasfromform

Re: Newbie: Perl Vs Shell

2004-10-29 Thread daggerquill unknown
On Fri, 29 Oct 2004 13:36:00 -0400 (EDT), Chris Devers <[EMAIL PROTECTED]> wrote: > On Fri, 29 Oct 2004, Jenda Krynicky wrote: > > > Actually no. They are generaly not very fast. The reason is that the > > shell interpreter needs to create a new process for each and every > > commend you specify

Re: Newbie: Perl Vs Shell

2004-10-29 Thread Thomas Bätzler
"Chris Devers" <[EMAIL PROTECTED]> wrote: On Fri, 29 Oct 2004, Thomas Bätzler wrote: Chris Devers <[EMAIL PROTECTED]> claimed: [...] > well written shell scripts don't need Perl and well written Perl > scripts don't need external shell commands. I think that's the "ivory tower" point of view. Down

RE: easy way to add element to array

2004-10-29 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > Though about using a hash but I don't have a need for a Key/Value > combination. I just need a list without duplicates. I suppose I can > define the hash keys if they don't already exists and export the keys > into an array with the keys function. Is that what you are hin

RE: each character in a string

2004-10-29 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > Hi All, > I have to write a code wherein I have to access each character in a > string and compare it with '-' > > $_ = $seq1[0]; > while(/./g) { > if($1 eq '-') { > $res1[0] .= '-'; > } > else { > $res1[0] = "A"; Do you mean .= here? > } > } Are you tryin

RE: easy way to add element to array

2004-10-29 Thread brian . barto
Though about using a hash but I don't have a need for a Key/Value combination. I just need a list without duplicates. I suppose I can define the hash keys if they don't already exists and export the keys into an array with the keys function. Is that what you are hinting towards? Thanks, Brian ---

Re: each character in a string

2004-10-29 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote: I have to write a code wherein I have to access each character in a string and compare it with '-' $_ = $seq1[0]; while(/./g) { if($1 eq '-') { $res1[0] .= '-'; } else { $res1[0] = "A"; } } I have initialised $_ with the string in which I have to search. Now I k

RE: easy way to add element to array

2004-10-29 Thread Bob Showalter
Bob Showalter wrote: > If you still want to use an array, the Tie::File::Array module will > do the trick. Duh, that should be "Tie::Array::Unique". Sorry 'bout that. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: easy way to add element to array

2004-10-29 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > Hi. I'm working with an array that i'm pushing values on to, but I > don't want there to be any duplicates. Is there a perl function of an > easy way to check if an array already contains a value before I push > that value on to it? First consider whether you should be u

Re: each character in a string

2004-10-29 Thread Ajey Kulkarni
It will... #!/usr/bin/perl my $var = "-- hellohowareyou-"; $_ = $var; while (/(.)/g) { # . is never a newline here # do something with $1 if($1 eq '-') { printf "HELLO"; } else { printf "HI"; } } On Fri, 29 Oct 2004

easy way to add element to array

2004-10-29 Thread brian . barto
Hi. I'm working with an array that i'm pushing values on to, but I don't want there to be any duplicates. Is there a perl function of an easy way to check if an array already contains a value before I push that value on to it? Thanks, Brian

each character in a string

2004-10-29 Thread mk76
Hi All, I have to write a code wherein I have to access each character in a string and compare it with '-' $_ = $seq1[0]; while(/./g) { if($1 eq '-') { $res1[0] .= '-'; } else { $res1[0] = "A"; } } I have initialised $_ with the string in which I have to search. Now I know that the wh

Re: Get all mail addresses from a domain

2004-10-29 Thread Chasecreek Systemhouse
On Fri, 29 Oct 2004 08:42:14 -0400, Bob Showalter <[EMAIL PROTECTED]> wrote: > Eva Perales Laguna wrote: > > But I would like to get all the addresses in that domain. > > Lots of folks turn off VRFY and EXPN, for obvious reasons. Besides, VRFY and EXPN do not prove that an e-mail exists at any p

RE: Append on top

2004-10-29 Thread Ajey Kulkarni
>>> while (read OLDFILE, $buff, 8*1024); A quick qn. :) Y is 8*1024 being mentioned here? Are you just word-aligning or something else? regards -Ajey On Fri, 29 Oct 2004, Jenda Krynicky wrote: > From: [EMAIL PROTECTED] > > This is the way I would do it, however my code has be

Re: Why is not "sub" necessary? What is the difference: block and expression?

2004-10-29 Thread Gunnar Hjalmarsson
Siegfried Heintze wrote: I'm trying to understand the map function in perl and have been studying David's response to my earlier query. When David calls his iterate function, why does he not need to use the keyword "sub"? Because he used prototypes instead. Also, can someone elaborate on his use of

RE: Newbie: Perl Vs Shell

2004-10-29 Thread Chris Devers
On Fri, 29 Oct 2004, Jenda Krynicky wrote: > Actually no. They are generaly not very fast. The reason is that the > shell interpreter needs to create a new process for each and every > commend you specify in the script [...] Is this true even for built in shell commands? For example, commands

Why is not "sub" necessary? What is the difference: block and expression?

2004-10-29 Thread Siegfried Heintze
I'm trying to understand the map function in perl and have been studying David's response to my earlier query. When David calls his iterate function, why does he not need to use the keyword "sub"? Apparently he is passing a function by reference. Is this a block or an expression? The camel book sa

Re: using file before and after when in foreach loop

2004-10-29 Thread Roberto Alamos
or better you can do for(0.$#files) { $prev = $files[$_-1]; $next = $files[$_+1]; } where $#files is the array's length - 1. Bye On Fri, 29 Oct 2004 09:14:25 -0600, Jeff Eggen <[EMAIL PROTECTED]> wrote: > >>> "Murphy, Ged (Bolton)" <[EMAIL PROTECTED]> 29/10/2004 > 9:02:56 am >>> >

Re: using file before and after when in foreach loop

2004-10-29 Thread Jeff Eggen
>>> "Murphy, Ged (Bolton)" <[EMAIL PROTECTED]> 29/10/2004 9:02:56 am >>> >The previous item is simple to do, but I'm struggling to think of a way of >getting the next item. You could just change your foreach line to a standard for loop: for ( my $index = 0; $index <= $#files; $index++ ) { } And

using file before and after when in foreach loop

2004-10-29 Thread Murphy, Ged (Bolton)
Hi all. I'm using a foreach loop to iterate through an array and print out HTML code related to each value. However in my HTML code I would also like to make links to the previous array item and next array item. The previous item is simple to do, but I'm struggling to think of a way of getting th

RE: Newbie: Perl Vs Shell

2004-10-29 Thread Chris Devers
On Fri, 29 Oct 2004, Thomas Bätzler wrote: > Chris Devers <[EMAIL PROTECTED]> claimed: > [...] > > well written shell scripts don't need Perl and well written Perl > > scripts don't need external shell commands. > > I think that's the "ivory tower" point of view. Down here in the > trenches, it

RE: Append on top

2004-10-29 Thread Jenda Krynicky
From: [EMAIL PROTECTED] > This is the way I would do it, however my code has been subject to > criticism more that once in the past :) > > open (FILE, " @file = ; > close (FILE); > $new_data = "This is my new line that I am going to put at the top\n"; > unshift (@file, $new_data)

RE: Newbie: Perl Vs Shell

2004-10-29 Thread Jenda Krynicky
From: <[EMAIL PROTECTED]> > Shell scripting is native to the shell in which u right them and are > not portable more imp is difficult to implement even simple logic > ..but are very fast as they are native to OS. Actually no. They are generaly not very fast. The reason is that the shell interpre

regex matching in a nested loop

2004-10-29 Thread Jason Wozniak
I wrote the following as a quick script to find all files on the system that contain any hard coded passwords for our database. For testing purposes I used a file called testing123 in my find string, so as not to search the entire directory tree for each test. The problem I'm having lies in the w

RE: Append on top

2004-10-29 Thread brian . barto
This is the way I would do it, however my code has been subject to criticism more that once in the past :) open (FILE, "; close (FILE); $new_data = "This is my new line that I am going to put at the top\n"; unshift (@file, $new_data); open (FILE, ">myfile.dat") or die; print FILE @file; close (FIL

Re: Printing to a file

2004-10-29 Thread John W. Krahn
Zeus Odin wrote: Charles Clarkson, Randall Schwartz, and John Krahn (I'm only naming three. You probably meant Randal Schwartz (one "l".) :-) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Append on top

2004-10-29 Thread NYIMI Jose \(BMB\)
> -Original Message- > From: Mandar Rahurkar [mailto:[EMAIL PROTECTED] > Sent: Friday, October 29, 2004 3:18 PM > To: Rajesh Dorairajan; Perl-Beginners ([EMAIL PROTECTED]) > Subject: Re: Append on top > > > read the file. Rewrite ur data into the file followed by > original data. easy

RE: Newbie: Perl Vs Shell

2004-10-29 Thread Thomas Bätzler
Chris Devers <[EMAIL PROTECTED]> claimed: [...] > well > written shell scripts don't need Perl and well written Perl > scripts don't need external shell commands. I think that's the "ivory tower" point of view. Down here in the trenches, it's more like "a well-written Perl script uses shell com

Re: Append on top

2004-10-29 Thread Mandar Rahurkar
read the file. Rewrite ur data into the file followed by original data. easy way.. Mandar Original message >Date: Thu, 28 Oct 2004 18:11:54 -0700 >From: "Rajesh Dorairajan" <[EMAIL PROTECTED]> >Subject: Append on top >To: "Perl-Beginners ([EMAIL PROTECTED])" <[EMAIL PROTECTED]> >Cc:

Re: Printing to a file

2004-10-29 Thread Zeus Odin
I could see this thread coming 2 months ago. Does anyone have any pent-up frustrations? :-) I think this list is the BEST list I have ever read ... not that I have read many lists. However, any list can be improved. The improvements I would suggest have to do with editorializing and patience: Fir

Re: Assigning regexpression to a variable

2004-10-29 Thread John W. Krahn
Prabahar Mosas wrote: On Fri, 29 Oct 2004 John W.Krahn wrote : Prabahar Mosas wrote: specimen coding ** $value = 2422; $reg = '/\d/'; The slashes (/) are the delimiters for the match operator, they are not a part of the regular expression, just like the quotes (') delimit the string bu

RE: Get all mail addresses from a domain

2004-10-29 Thread Bob Showalter
Eva Perales Laguna wrote: > Hello, > > I use the Net::SMTP module to check if a mail address is present > in a domain. I do something like this: > >my $smtp = new Net::SMTP($domain); > my $matches = $smtp->verify($usermane); > > But I would like to get all the addresses in that domain.

RE: Append on top

2004-10-29 Thread Bob Showalter
Rajesh Dorairajan wrote: > Does anyone know of a way to open a file in append mode and append on > top of the file? No, because that's not what "append mode" means. To insert data anywhere but at the end, you have to rewrite the file contents from the point of insertion forward. Or, you need to wr

Re: Newbie: Perl Vs Shell

2004-10-29 Thread Chris Devers
On Fri, 29 Oct 2004, Durai raj wrote: > Anyone can explain the difference between Perl and Shell scripts? They're completely separate languages. On Unix systems, a "shell" is a program that receives input and sends results down to the kernel to be executed, thus the name "shell" -- it's an e

re parse xml to Franklin

2004-10-29 Thread E.Horn
Ok! So Franklin, how does your parser look like? Is this really the same homepage you parse? Where do you come from ;-) perhaps you sit in the room next door? joking...?! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: parse xml

2004-10-29 Thread Traeder, Philipp
On Friday 29 October 2004 10:44, E.Horn wrote: > geben Sie ein gtpprotein ein > ras > > "http://www.ncbi.nlm.nih.gov/entrez/query/DTD/egquery.dtd";> > > > > > > > ras > > > > > pubmed > PubMed > 27832 >

Get all mail addresses from a domain

2004-10-29 Thread Eva Perales Laguna
Hello, I use the Net::SMTP module to check if a mail address is present in a domain. I do something like this: my $smtp = new Net::SMTP($domain); my $matches = $smtp->verify($usermane); But I would like to get all the addresses in that domain. Someone can help me? Thanks! Eva --

RE: Append on top

2004-10-29 Thread NYIMI Jose \(BMB\)
> -Original Message- > From: Ing. Branislav Gerzo [mailto:[EMAIL PROTECTED] > Sent: Friday, October 29, 2004 11:36 AM > To: [EMAIL PROTECTED] > Subject: Re: Append on top > > > Rajesh Dorairajan [RD], on Thursday, October 28, 2004 at > 18:11 (-0700) thoughtfully wrote the following: >

RE: Newbie: Perl Vs Shell

2004-10-29 Thread arjun.mallik
Shell scripting is native to the shell in which u right them and are not portable more imp is difficult to implement even simple logic ..but are very fast as they are native to OS. ,where as Perl scripts are inter operable and a bit easy to write and debug] compared to shell scripts. This as p

Re: Append on top

2004-10-29 Thread Ing. Branislav Gerzo
Rajesh Dorairajan [RD], on Thursday, October 28, 2004 at 18:11 (-0700) thoughtfully wrote the following: RD> Does anyone know of a way to open a file in append mode and append on top of RD> the file? I don't think it is possible. You have to read source file, and after print your results to new f

Newbie: Perl Vs Shell

2004-10-29 Thread Durai raj
Hello All, Anyone can explain the difference between Perl and Shell scripts? Regards, Durai. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.783 / Virus Database: 529 - Release Date: 10/27/2004 ---

RE: Append on top

2004-10-29 Thread arjun.mallik
This mode will append text at the bottom not at the top. Arjun -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, October 29, 2004 2:45 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Append on top open(MYNAME,">>a.txt"); -Original Messag

RE: Append on top

2004-10-29 Thread Sreedhar . Kalkunte-Venkatachala
open(MYNAME,">>a.txt"); -Original Message- From: Rajesh Dorairajan [mailto:[EMAIL PROTECTED] Sent: 29 October 2004 02:12 To: Perl-Beginners ([EMAIL PROTECTED]) Cc: Rajesh Dorairajan Subject: Append on top Does anyone know of a way to open a file in append mode and append on top of the f

Append on top

2004-10-29 Thread Rajesh Dorairajan
Does anyone know of a way to open a file in append mode and append on top of the file? Thanks in Advance, --Rajesh

parse xml

2004-10-29 Thread E.Horn
geben Sie ein gtpprotein ein ras http://www.ncbi.nlm.nih.gov/entrez/query/DTD/egquery.dtd";> ras pubmed PubMed 27832 Ok pmc

Re: xml parsing

2004-10-29 Thread Philipp Traeder
On Thursday 28 October 2004 10:56, E.Horn wrote: Good morning, > this gives me a DTD as output. DTD? As in the kind of document that describes XML files? If yes, an XML Parser might be the wrong tool for parsing this kind of file. Could you give us an example? > My problem is I want to parse th

Re: Antwort: Re: """Wallbanger@t-online.de""" aus Eurer Verteiung nehmen!!!!!

2004-10-29 Thread Gunnar Hjalmarsson
Manfred Beilfuss wrote: Hi Gunnar , I just tried to translate you. Schönen Dank! :) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Antwort: Re: """Wallbanger@t-online.de""" aus Eurer Verteiung nehmen!!!!!

2004-10-29 Thread Manfred . Beilfuss
Hello Everybody, Hallo Sonja, auch von mir mein herzlichstes Beileid zum Tode Deines Mannes. Ich uebersetze Dir kurz was Gunnar schon geschrieben hat. Er spricht Dir auch sein Beileid aus und war so freundlich Deinen Wunsch zu erfüllen, Deinen leider verstorbenen Mann aus der Email-Liste auszu

RE: Preventing shell redirection from creating empty file

2004-10-29 Thread Jim
> > On Tue, 26 Oct 2004, Dan Fish wrote: > > > system("myscript.pl arg1 arg2 > myfile.txt"); > > > > What is the easiest way to prevent "myfile.txt" from being > created if > > the script dies or produces no output? (It seems the shell > will always > > create myfile.txt, regardless) > >

Re: """Wallbanger@t-online.de""" aus Eurer Verteiung nehmen!!!!!

2004-10-29 Thread Gunnar Hjalmarsson
FYI I just sent this message: Original Message Subject: Re: Bitte schreibe mir in Deutsch !! Date: Fri, 29 Oct 2004 09:09:42 +0200 From: Gunnar Hjalmarsson To: Spikema (Sonja Klenner) Dear Sonja, Thanks for your note. I did understand most of what you wrote (studied some German on