Re: Newbie: Perl reg. expression
this should work open FILE, test.txt or die Can't open file!: $!; while( FILE ) { my @parts = split(/\s+/); foreach (@parts){ print if /(\d+\.\d+\.\d+\.\d)/; } } close FILE; Rakhitha Karunarathne Web Master www.Ad-Man.tk - Free Unlimited Banner Rotators - Original Message - From: Durai [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:54 AM Subject: Newbie: Perl reg. expression Hello All, open FILE, test.txt or die Can't open file!: $!; while( FILE ) { print if /(\d+\.\d+\.\d+\.\d)/; } close FILE; It gives the following output: # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) #Listen 12.34.56.78:80 # e.g., www.apache.org (on) or 204.62.129.132 (off). I want only a word which contains IP address only not with port and others.. For example, Need like: 204.62.129.132 not (0.0.0.0),12.34.56.78:80,.. . Regs, durai. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
coding sampling techniques in perl
Hi All, I am trying to code Latin Hypercube Sampling and Sobol Sampling Sequences in Perl as a part of a tool we are developing here. I would like to know is there any references (standard codes developed) in Perl for the same? Any help in this regard is welcome. Thanks Regards Guruguhan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Newbie: Perl reg. expression - Correction
My previous mail has a small problem this one should fix it open FILE, test.txt or die Can't open file!: $!; while( FILE ) { my @parts = parts(/\s+/); foreach (@parts){ if (/^(\d+\.\d+\.\d+\.\d+)$/){ print $1\n; } } } close FILE; Rakhitha Karunarathne Web Master www.Ad-Man.tk - Free Unlimited Banner Rotators - Original Message - From: Durai [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:54 AM Subject: Newbie: Perl reg. expression Hello All, open FILE, test.txt or die Can't open file!: $!; while( FILE ) { print if /(\d+\.\d+\.\d+\.\d)/; } close FILE; It gives the following output: # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) #Listen 12.34.56.78:80 # e.g., www.apache.org (on) or 204.62.129.132 (off). I want only a word which contains IP address only not with port and others.. For example, Need like: 204.62.129.132 not (0.0.0.0),12.34.56.78:80,.. . Regs, durai. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Query
Hi Thanks. But there is a small issue. Considering the same example, the piece of code sent by you prints 123456 which is not on the same line as Test: But it doesn't print the characters 123456 ABCDEF which is on the same line as Test: Regards, Sudhindra -Original Message- From: John W.Krahn [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 4:56 PM To: Perl Beginners Subject: Re: Query On Monday 17 May 2004 03:15, Sudhindra Bhat wrote: Hi Hello, I wanted some help on a piece of code that I was writing. Well the requirement is like this. I have a file whose looks like this (1) Test: 123456 ABCDEF 123456 (2) Results: ABCDEF Now I want my script to output all the contents between the two tags Test and Results. i.e. 123456 ABCDEF 123456. Can someone help me with this? while ( FILE ) { if ( /Test:/ .. /Results:/ and !/Test:/ and !/Results:/ ) { print } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Newbie: Perl reg. expression
It gives the output: - Original Message - From: LRMK [EMAIL PROTECTED] To: Durai [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:37 AM Subject: Re: Newbie: Perl reg. expression this should work open FILE, test.txt or die Can't open file!: $!; while( FILE ) { my @parts = split(/\s+/); foreach (@parts){ print if /(\d+\.\d+\.\d+\.\d)/; } } close FILE; Rakhitha Karunarathne Web Master www.Ad-Man.tk - Free Unlimited Banner Rotators - Original Message - From: Durai [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:54 AM Subject: Newbie: Perl reg. expression Hello All, open FILE, test.txt or die Can't open file!: $!; while( FILE ) { print if /(\d+\.\d+\.\d+\.\d)/; } close FILE; It gives the following output: # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) #Listen 12.34.56.78:80 # e.g., www.apache.org (on) or 204.62.129.132 (off). I want only a word which contains IP address only not with port and others.. For example, Need like: 204.62.129.132 not (0.0.0.0),12.34.56.78:80,.. . Regs, durai. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Newbie: Perl reg. expression
Hi, It gives the output: (0.0.0.0) 12.34.56.78:80 204.62.129.132 I need Only IP address. I need like: 204.62.129.132 127.0.0.1 Not like 12.34.56.78:80,(0.0.0.0),..etc. Thanks, Durai. - Original Message - From: LRMK [EMAIL PROTECTED] To: Durai [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:37 AM Subject: Re: Newbie: Perl reg. expression this should work open FILE, test.txt or die Can't open file!: $!; while( FILE ) { my @parts = split(/\s+/); foreach (@parts){ print if /(\d+\.\d+\.\d+\.\d)/; } } close FILE; Rakhitha Karunarathne Web Master www.Ad-Man.tk - Free Unlimited Banner Rotators - Original Message - From: Durai [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:54 AM Subject: Newbie: Perl reg. expression Hello All, open FILE, test.txt or die Can't open file!: $!; while( FILE ) { print if /(\d+\.\d+\.\d+\.\d)/; } close FILE; It gives the following output: # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) #Listen 12.34.56.78:80 # e.g., www.apache.org (on) or 204.62.129.132 (off). I want only a word which contains IP address only not with port and others.. For example, Need like: 204.62.129.132 not (0.0.0.0),12.34.56.78:80,.. . Regs, durai. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Newbie: Perl reg. expression - Correction
Hi, It works fine after I change the following line: my @parts = parts(/\s+/); to my @parts = split(/\s+/); Thanks for your help. Thanks, Durai. - Original Message - From: LRMK [EMAIL PROTECTED] To: Durai [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 12:00 PM Subject: Re: Newbie: Perl reg. expression - Correction My previous mail has a small problem this one should fix it open FILE, test.txt or die Can't open file!: $!; while( FILE ) { my @parts = parts(/\s+/); foreach (@parts){ if (/^(\d+\.\d+\.\d+\.\d+)$/){ print $1\n; } } } close FILE; Rakhitha Karunarathne Web Master www.Ad-Man.tk - Free Unlimited Banner Rotators - Original Message - From: Durai [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:54 AM Subject: Newbie: Perl reg. expression Hello All, open FILE, test.txt or die Can't open file!: $!; while( FILE ) { print if /(\d+\.\d+\.\d+\.\d)/; } close FILE; It gives the following output: # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) #Listen 12.34.56.78:80 # e.g., www.apache.org (on) or 204.62.129.132 (off). I want only a word which contains IP address only not with port and others.. For example, Need like: 204.62.129.132 not (0.0.0.0),12.34.56.78:80,.. . Regs, durai. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Newbie: Perl reg. expression
Durai wrote: Hi, It gives the output: (0.0.0.0) 12.34.56.78:80 204.62.129.132 I need Only IP address. I need like: 204.62.129.132 127.0.0.1 if you want to exclude only 0.0.0.0 , how about print if /(\d+\.\d+\.\d+\.\d)/ and $1 != 0.0.0.0; Not like 12.34.56.78:80,(0.0.0.0),..etc. Thanks, Durai. - Original Message - From: LRMK [EMAIL PROTECTED] To: Durai [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:37 AM Subject: Re: Newbie: Perl reg. expression this should work open FILE, test.txt or die Can't open file!: $!; while( FILE ) { my @parts = split(/\s+/); foreach (@parts){ print if /(\d+\.\d+\.\d+\.\d)/; } } close FILE; Rakhitha Karunarathne Web Master www.Ad-Man.tk - Free Unlimited Banner Rotators - Original Message - From: Durai [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:54 AM Subject: Newbie: Perl reg. expression Hello All, open FILE, test.txt or die Can't open file!: $!; while( FILE ) { print if /(\d+\.\d+\.\d+\.\d)/; } close FILE; It gives the following output: # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) #Listen 12.34.56.78:80 # e.g., www.apache.org (on) or 204.62.129.132 (off). I want only a word which contains IP address only not with port and others.. For example, Need like: 204.62.129.132 not (0.0.0.0),12.34.56.78:80,.. . Regs, durai. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Fw: Newbie: Perl reg. expression - Correction
sorry about that typing mistake Rakhitha Karunarathne Web Master www.Ad-Man.tk - Free Unlimited Banner Rotators - Original Message - From: Durai [EMAIL PROTECTED] To: LRMK [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 12:49 PM Subject: Re: Newbie: Perl reg. expression - Correction Hi, It works fine after I change the following line: my @parts = parts(/\s+/); to my @parts = split(/\s+/); Thanks for your help. Thanks, Durai. - Original Message - From: LRMK [EMAIL PROTECTED] To: Durai [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 12:00 PM Subject: Re: Newbie: Perl reg. expression - Correction My previous mail has a small problem this one should fix it open FILE, test.txt or die Can't open file!: $!; while( FILE ) { my @parts = parts(/\s+/); foreach (@parts){ if (/^(\d+\.\d+\.\d+\.\d+)$/){ print $1\n; } } } close FILE; Rakhitha Karunarathne Web Master www.Ad-Man.tk - Free Unlimited Banner Rotators - Original Message - From: Durai [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:54 AM Subject: Newbie: Perl reg. expression Hello All, open FILE, test.txt or die Can't open file!: $!; while( FILE ) { print if /(\d+\.\d+\.\d+\.\d)/; } close FILE; It gives the following output: # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) #Listen 12.34.56.78:80 # e.g., www.apache.org (on) or 204.62.129.132 (off). I want only a word which contains IP address only not with port and others.. For example, Need like: 204.62.129.132 not (0.0.0.0),12.34.56.78:80,.. . Regs, durai. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/14/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Broke My @INC
set environment var PERLLIB on linux like systems with perl 5.8.3 you will do something like export PERLLIB=/usr/lib/perl5/5.8.3/i386-linux-thread-multi:/usr/lib/perl5/5.8.3:/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi:/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi:/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi:/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi:/usr/lib/perl5/site_perl/5.8.3:/usr/lib/perl5/site_perl/5.8.2:/usr/lib/perl5/site_perl/5.8.1:/usr/lib/perl5/site_perl/5.8.0:/usr/lib/perl5/site_perl:/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi:/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi:/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi:/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi:/usr/lib/perl5/vendor_perl/5.8.3:/usr/lib/perl5/vendor_perl/5.8.2:/usr/lib/perl5/vendor_perl/5.8.1:/usr/lib/perl5/vendor_perl/5.8.0:/usr/lib/perl5/vendor_perl:. On Tue, 2004-05-18 at 02:52, Jason Dusek wrote: Hi List, My @INC is messed up - Perl can't find any modules. If I know the path to a module, is there some kind of quick work around? For those who are curious, I seem to have broken my @INC by installing the ports (I'm on FreeBSD) for Perl 5.6.1 and Perl 5.8.2. -- -- Jason Dusek (`-''-/).___..--''`-._ -- | `6_ 6 ) `-. ( ).`-.__.`) -- | (_Y_.)' ._ ) `._ `. ``-..-' -- | _..`--'_..-_/ /--'_.' ,' -- | (il),-'' (li),' ((!.-' -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: combining data from more than one file...
Well this is the best I could do thinking through what you said. This is actually my first time working with hashes. Also, I am still a PERL newbie. So, I guess a little helpful code would go a long way. I just can't figure out how to link the regular expressions to the hash when searching through the multiple files. to do as you say: That's quite good - you've got more or less all the relevant parts, we just need to put it together. I'll try to give you some hints without revealing the whole black magic ;-) #!/usr/bin/perl # This script will take separate FASTA files and combine the like # data into one FASTA file. # use warnings; use strict; my %organisms ( $orgID = $orgSeq, ); I'd say there´s no need to fill the hash with values at this point; I'd just declare it like this: my %organisms; We'll put values into it later. print Enter in a list of files to be processed:\n; # For example: # CytB.fasta # NADH1.fasta # chomp (my @infiles = STDIN); This doesn't work for me - maybe I just don't know how to use it, but for the moment, I'd hardcode this and concentrate on the concatenation part... my @infiles = ('genetics.txt'); foreach $infile (@infiles) { open (FASTA, $infile) or die Can't open INFILE: $!; Some small things - having set warnings and strict, perl is asking me to declare $infile and FASTA - so for me this looks like: my $FASTA = new FileHandle; open ($FASTA, $infile) or die Can't open INFILE: $!; BTW: For this to work, you need to use FileHandle; on top of your code. $/=''; #Set input operator This is an interesting approach - I've never worked with this input operator, but I think it might make like quite easy... I'll do it manually (which is at least good practice ;-) ), but we should keep this in mind. while (FASTA) { small stuff again: while (defined($_ = $FASTA)) { chomp; # Some regular expression match here? # something that will set, say... cat # as the key $orgID, something similar # to below? # and then set the sequence as the value # $orgSeq like below? Yes, a regexp is a very good idea here. Generally, you just need to distinguish between the start-lines and the regular lines here, i.e. the ones that mark the beginning of an organism and the ones that carry the data. # We're searching for start-lines that look like this: # dog # so try to match something like # \s* zero-to-many characters of #optional whitespace #the bigger-than sign # \w+ one-to-many (word) characters # the parenthesis around the \w+ means that # we want to access this value later using $1 if (/\s*(\w+)/) { print found a new organism called '$1'\n; } # or just some data belonging to the last # organism we found else { print this is just some data : $_\n; } Don't worry if you don't understand this on the first look - regexes can be quite messy, but once you get used to them, they quickly become your best friend (for getting used to them, I can recommend very much chapter 2 of the camel book...). Anyway - now you've got the name of the new organism in a special variable called $1 (if this is a new organism) or the data in $_ (if it´s not). # Do not know if or where to put the following, # but something like: if (exists $organisms{$orgID}) { # somehow concatenate like data # from the different files } This is completely right as well - this line of code lets you check if you already got data of this organism...let´s think about what we want to do. We've got an hash which should look like: cat = funny-sequence-of-a-c-g-whatever, dog = even-funnier-sequence-of-characters With the code from above, we iterate over all files specified on the command line (or hardcoded into the script), and there are two kinds of line we can meet: - start lines - regular data lines We can separate start lines from regular lines with the regexp above. When we come across a start line, we don't have to process any data: a start line, after all, does not contain real data, but only the name identifying the organism to which the following data belongs. But in order to store the data for the right organism, we should keep track of the last start line - I would do this by storing the last ID in a variable (that needs to be outside the while-loop). So now we can do something like this: If the new line is a start line - store the ID If the new line is a regular line - append it to the current entry Since you want to append the individual strings, you don't need to check explicitly if the hash entry exists
RE: Image editing/Creating modules
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: : can someone give a name of any image (JPG or GIF) editing / : creating module, which allow to create images to display on : web pages on the fly by CGI scripts. There are a bunch of those. Have you tried CPAN? http://search.cpan.org/modlist/Graphics GD and Image::Magick are both very popular. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Broke My @INC
Jason Dusek wrote: Hi List, My @INC is messed up - Perl can't find any modules. If I know the path to a module, is there some kind of quick work around? For those who are curious, I seem to have broken my @INC by installing the ports (I'm on FreeBSD) for Perl 5.6.1 and Perl 5.8.2. You installed both versions? How are you running perl? What is /usr/bin/perl linked to? What is 'perl -V'? 'perl5.6.1 -V'? 'perl5.8.2 -V'? Is the environment vars 'PERLLIB' and/or 'PERL5LIB' set? Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Query
On Tue, 2004-05-18 at 07:36, Sudhindra Bhat wrote: Hi Thanks. But there is a small issue. Considering the same example, the piece of code sent by you prints 123456 which is not on the same line as Test: But it doesn't print the characters 123456 ABCDEF which is on the same line as Test: That's because it is *not* printing the line with Test:... it is only printing the lines between the one that matches Test: and the one that matches Results: This prevents the line with Test: from being printed: !/Test:/ This prevents the line with Results: from being printed: !/Results:/ Exactly what output were you expecting? Something like this, perhaps: === 123456 ABCDEF 123456 (2) === Would that be it? If so, try while (FILE) { if ( /Test:/ .. /Results:/ ) { if ( /Test:/ ) { print $' } elsif ( /Results:/ ) { print $` } else { print } } } HTH, jac Regards, Sudhindra -Original Message- From: John W.Krahn [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 4:56 PM To: Perl Beginners Subject: Re: Query On Monday 17 May 2004 03:15, Sudhindra Bhat wrote: Hi Hello, I wanted some help on a piece of code that I was writing. Well the requirement is like this. I have a file whose looks like this (1) Test: 123456 ABCDEF 123456 (2) Results: ABCDEF Now I want my script to output all the contents between the two tags Test and Results. i.e. 123456 ABCDEF 123456. Can someone help me with this? while ( FILE ) { if ( /Test:/ .. /Results:/ and !/Test:/ and !/Results:/ ) { print } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Jos Alves de Castro [EMAIL PROTECTED] Telbit - Tecnologias de Informao -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Query
Hi This doesn't seem to work. I get a blank output. But yes the output that is want is 123456 ABCDEF 123456 Regards, Sudhindra -Original Message- From: Jose Alves de Castro [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 3:55 PM To: Sudhindra Bhat Cc: Perl Beginners Subject: Re: Query On Tue, 2004-05-18 at 07:36, Sudhindra Bhat wrote: Hi Thanks. But there is a small issue. Considering the same example, the piece of code sent by you prints 123456 which is not on the same line as Test: But it doesn't print the characters 123456 ABCDEF which is on the same line as Test: That's because it is *not* printing the line with Test:... it is only printing the lines between the one that matches Test: and the one that matches Results: This prevents the line with Test: from being printed: !/Test:/ This prevents the line with Results: from being printed: !/Results:/ Exactly what output were you expecting? Something like this, perhaps: === 123456 ABCDEF 123456 (2) === Would that be it? If so, try while (FILE) { if ( /Test:/ .. /Results:/ ) { if ( /Test:/ ) { print $' } elsif ( /Results:/ ) { print $` } else { print } } } HTH, jac Regards, Sudhindra -Original Message- From: John W.Krahn [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 4:56 PM To: Perl Beginners Subject: Re: Query On Monday 17 May 2004 03:15, Sudhindra Bhat wrote: Hi Hello, I wanted some help on a piece of code that I was writing. Well the requirement is like this. I have a file whose looks like this (1) Test: 123456 ABCDEF 123456 (2) Results: ABCDEF Now I want my script to output all the contents between the two tags Test and Results. i.e. 123456 ABCDEF 123456. Can someone help me with this? while ( FILE ) { if ( /Test:/ .. /Results:/ and !/Test:/ and !/Results:/ ) { print } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- José Alves de Castro [EMAIL PROTECTED] Telbit - Tecnologias de Informação -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Query
In that case, with this: #!/usr/bin/perl -w use strict; while () { if ( /Test:/ .. /Results:/ and !/Results:/ ) { if ( /Test:\s*/ ) { print $' } else { print if /./ } } } you can get that output ( run the script with the input file). HTH, jac On Tue, 2004-05-18 at 12:28, Sudhindra Bhat wrote: Hi This doesn't seem to work. I get a blank output. But yes the output that is want is 123456 ABCDEF 123456 Regards, Sudhindra -Original Message- From: Jose Alves de Castro [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 3:55 PM To: Sudhindra Bhat Cc: Perl Beginners Subject: Re: Query On Tue, 2004-05-18 at 07:36, Sudhindra Bhat wrote: Hi Thanks. But there is a small issue. Considering the same example, the piece of code sent by you prints 123456 which is not on the same line as Test: But it doesn't print the characters 123456 ABCDEF which is on the same line as Test: That's because it is *not* printing the line with Test:... it is only printing the lines between the one that matches Test: and the one that matches Results: This prevents the line with Test: from being printed: !/Test:/ This prevents the line with Results: from being printed: !/Results:/ Exactly what output were you expecting? Something like this, perhaps: === 123456 ABCDEF 123456 (2) === Would that be it? If so, try while (FILE) { if ( /Test:/ .. /Results:/ ) { if ( /Test:/ ) { print $' } elsif ( /Results:/ ) { print $` } else { print } } } HTH, jac Regards, Sudhindra -Original Message- From: John W.Krahn [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 4:56 PM To: Perl Beginners Subject: Re: Query On Monday 17 May 2004 03:15, Sudhindra Bhat wrote: Hi Hello, I wanted some help on a piece of code that I was writing. Well the requirement is like this. I have a file whose looks like this (1) Test: 123456 ABCDEF 123456 (2) Results: ABCDEF Now I want my script to output all the contents between the two tags Test and Results. i.e. 123456 ABCDEF 123456. Can someone help me with this? while ( FILE ) { if ( /Test:/ .. /Results:/ and !/Test:/ and !/Results:/ ) { print } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Jos Alves de Castro [EMAIL PROTECTED] Telbit - Tecnologias de Informao -- Jos Alves de Castro [EMAIL PROTECTED] Telbit - Tecnologias de Informao -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Query
Thanks a million. It works perfectly. Regards, Sudhindra -Original Message- From: Jose Alves de Castro [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 5:01 PM To: Sudhindra Bhat Cc: Perl Beginners Subject: RE: Query In that case, with this: #!/usr/bin/perl -w use strict; while () { if ( /Test:/ .. /Results:/ and !/Results:/ ) { if ( /Test:\s*/ ) { print $' } else { print if /./ } } } you can get that output ( run the script with the input file). HTH, jac On Tue, 2004-05-18 at 12:28, Sudhindra Bhat wrote: Hi This doesn't seem to work. I get a blank output. But yes the output that is want is 123456 ABCDEF 123456 Regards, Sudhindra -Original Message- From: Jose Alves de Castro [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 3:55 PM To: Sudhindra Bhat Cc: Perl Beginners Subject: Re: Query On Tue, 2004-05-18 at 07:36, Sudhindra Bhat wrote: Hi Thanks. But there is a small issue. Considering the same example, the piece of code sent by you prints 123456 which is not on the same line as Test: But it doesn't print the characters 123456 ABCDEF which is on the same line as Test: That's because it is *not* printing the line with Test:... it is only printing the lines between the one that matches Test: and the one that matches Results: This prevents the line with Test: from being printed: !/Test:/ This prevents the line with Results: from being printed: !/Results:/ Exactly what output were you expecting? Something like this, perhaps: === 123456 ABCDEF 123456 (2) === Would that be it? If so, try while (FILE) { if ( /Test:/ .. /Results:/ ) { if ( /Test:/ ) { print $' } elsif ( /Results:/ ) { print $` } else { print } } } HTH, jac Regards, Sudhindra -Original Message- From: John W.Krahn [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 4:56 PM To: Perl Beginners Subject: Re: Query On Monday 17 May 2004 03:15, Sudhindra Bhat wrote: Hi Hello, I wanted some help on a piece of code that I was writing. Well the requirement is like this. I have a file whose looks like this (1) Test: 123456 ABCDEF 123456 (2) Results: ABCDEF Now I want my script to output all the contents between the two tags Test and Results. i.e. 123456 ABCDEF 123456. Can someone help me with this? while ( FILE ) { if ( /Test:/ .. /Results:/ and !/Test:/ and !/Results:/ ) { print } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- José Alves de Castro [EMAIL PROTECTED] Telbit - Tecnologias de Informação -- José Alves de Castro [EMAIL PROTECTED] Telbit - Tecnologias de Informação -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
working directory with exec command
I'm trying to use fork and exec to kick-start other processes on a Linux box. As with Win32::Process::Create, I'd like to somehow specify or point towards a working directory for the new process since some data files are expected via relative path. I actually tried passing a compound command such as cd /home/otbsaf/OTBSAF/src/OTBSAF;./otbsaf to exec to hope a directory switch would happen as I intended. The new process displays its current directory and the directory shown was that from which the perl script was running, not the hoped for otbsaf. The book I have makes reference to that fact that options can be passed to the exec command as a 2nd parameter, but does not list options besides the -ls switch. Might the exec command have an option for specifying a working directory? Or might some other perl/Linux technique be applicable? Any insight will be gratefully accepted and greatly appreciated. Thanks, Darren Peterson Software Engineer, Amtec Corp. CSTE-DTC-AC-T-MS U.S. Army Aviation Technical Test Center Modeling Simulation Division Bldg 30604, Cairns Army Airfield Fort Rucker, Alabama 36362 phone: 334-255-8226 fax: 334-255-8438
RE: working directory with exec command
Peterson, Darren - Contractor.Westar wrote: I'm trying to use fork and exec to kick-start other processes on a Linux box. As with Win32::Process::Create, I'd like to somehow specify or point towards a working directory for the new process since some data files are expected via relative path. I actually tried passing a compound command such as cd /home/otbsaf/OTBSAF/src/OTBSAF;./otbsaf to exec to hope a directory switch would happen as I intended. The new process displays its current directory and the directory shown was that from which the perl script was running, not the hoped for otbsaf. Just use Perl's chdir() after you fork: defined(my $pid = fork) or die $!; unless ($pid) { chdir('/home/otbsaf/OTBSAF/src/OTBSAF') or die $!; exec './otbsaf' or die $!; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: working directory with exec command
To myself I'll offer a resounding Duh! Sometimes the simplest things are the hardest to see. Thanks very much! -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 7:02 AM To: 'Peterson, Darren - Contractor.Westar'; '[EMAIL PROTECTED]' Subject: RE: working directory with exec command Peterson, Darren - Contractor.Westar wrote: I'm trying to use fork and exec to kick-start other processes on a Linux box. As with Win32::Process::Create, I'd like to somehow specify or point towards a working directory for the new process since some data files are expected via relative path. I actually tried passing a compound command such as cd /home/otbsaf/OTBSAF/src/OTBSAF;./otbsaf to exec to hope a directory switch would happen as I intended. The new process displays its current directory and the directory shown was that from which the perl script was running, not the hoped for otbsaf. Just use Perl's chdir() after you fork: defined(my $pid = fork) or die $!; unless ($pid) { chdir('/home/otbsaf/OTBSAF/src/OTBSAF') or die $!; exec './otbsaf' or die $!; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Regular Expresssion - Matching over multiple lines
On May 17, 2004, at 11:16 PM, Andrew Gaffney wrote: Roman Hanousek wrote: Hi All I have bunch of files that contain code like this: What I am trying to do is match ps:img and this / then check that this piece of code contains a alt= tag. ps:img page=/images/portal/arrow_down.gif border=0 width=9 height=6 alt=${string['lists.list.sort.ascending.alt']} title=${string['lists.list.sort.ascending.alt']} / And if it doen't print the lines where it's missing to screen or file. while($input =~ |ps:img .+(alt\s*=\s*\.+\)?.+/|sgc) { print Missing ALT\n if(! defined $1); } That doesn't give you line numbers, but it does give you an idea of where to start. Be careful. Matching HTML-style markup with regexen is surprisingly tricky. I suspect the version above would not work well in many instances. Remember .+ is super greedy, more so since you allow it to swallow \n as well. The above pattern should match the first ps:img, swallow the rest of ALL the data and then backup until it can find a /. That's probably not going to work out to well, in many cases. Depending on how much is known about the tags, you might have more luck with a pattern like: m!ps:img([^]+)/!g From there it's pretty easy to check $1 for an alt=..., or whatever. Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: coding sampling techniques in perl
N, Guruguhan (GEAE, Foreign National, EACOE) wrote: Hi All, Howdy :) I am trying to code Latin Hypercube Sampling and Sobol Sampling Sequences in Perl as a part of a tool we are developing here. I would like to know is there any references (standard codes developed) in Perl for the same? Any help in this regard is welcome. I'm not sure what the sampling stuff is, I'm assuming audio? Either way I'd check out search.cpan.org to look for audio modules. HTH :) Lee.M - JupiterHost.Net Thanks Regards Guruguhan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: h2xs newbie
Randy W. Sims wrote: JupiterHost.Net wrote: Jeff 'japhy' Pinyan wrote: On May 16, JupiterHost.Net said: So the first question is: To create the tar.gz file needed for upload to cpan I simply tar/gz ify the NewModule/ directory, correct? No. h2xs ... Foo::Bar cd Foo/Bar # make the module perl Makefile.PL make tardist Excellent! That gives me a bit more to look into, thanks :) You might also want to try Andy Lester's Module-Starter which is a Its funny, I was creating a function called ModuleMaker and found that exact module on cpan (surprise its already been done ;p) Thanks for the ideas :) replacement for some of the h2xs functionality. Also, in the above, you should probably also run 'make disttest' (MakeMaker) or './Build make disttest would be done after make tardist correct? disttest' (Module::Build) to test your distribution before uploading it. Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Regular Expresssion - Matching over multiple lines
James Edward Gray II wrote: On May 17, 2004, at 11:16 PM, Andrew Gaffney wrote: Roman Hanousek wrote: Hi All I have bunch of files that contain code like this: What I am trying to do is match ps:img and this / then check that this piece of code contains a alt= tag. ps:img page=/images/portal/arrow_down.gif border=0 width=9 height=6 alt=${string['lists.list.sort.ascending.alt']} title=${string['lists.list.sort.ascending.alt']} / And if it doen't print the lines where it's missing to screen or file. while($input =~ |ps:img .+(alt\s*=\s*\.+\)?.+/|sgc) { print Missing ALT\n if(! defined $1); } That doesn't give you line numbers, but it does give you an idea of where to start. Be careful. Matching HTML-style markup with regexen is surprisingly tricky. I suspect the version above would not work well in many instances. Remember .+ is super greedy, more so since you allow it to swallow \n as well. The above pattern should match the first ps:img, swallow the rest of ALL the data and then backup until it can find a /. That's probably not going to work out to well, in many cases. Depending on how much is known about the tags, you might have more luck with a pattern like: m!ps:img([^]+)/!g From there it's pretty easy to check $1 for an alt=..., or whatever. Hope that helps. Doesn't the 'gc' modified make the whole think not as greedy? As a side effect of continuation, doesn't it try to match as many times as possible? -- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
DBD::Oracle and 64bit libraries
Hi, How can I get DBD::Oracle to compile and work with Oracle's 64bit libraries? The solution to the ELF error I received was to change all references to the 64bit libraries to 32bit. It worked but the developers would like to use 64bit libraries with DBD::Oracle. Tnx, Mike -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
using Sleep instead of Cron
Hi all, I'm writing a script which fetches data every hour. I thought instead of using cron which is platform dependent, to use sleep and a goto statement. Is there any downfalls to this? At the start of the script I check to see if it was ran in the previous hour. BEGINNING: if(open(TIMECHECK, ./synop_daemon_timer.txt)){ my($cur_sec1,$cur_min1,$cur_hour1,$cur_day1,$cur_mon1) = TIMECHECK; my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year)=gmtime(time()); if($cur_hour1 eq $cur_hour $cur_day1 eq $cur_day){ print br SCRIPT IS ALREADY IN ACTION, CANNOT CONTINUE; exit(0); } close(TIMECHECK); } # at the end of the script I write the last time the script was started if(open(TIMER, ./synop_daemon_timer.txt)){ my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year,$junk)=gmtime(time()); print TIMER $cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon\n; close(TIMER); } sleep(360); goto(BEGINNING); Thanks
Re: Regular Expresssion - Matching over multiple lines
On May 18, 2004, at 9:30 AM, Andrew Gaffney wrote: Doesn't the 'gc' modified make the whole think not as greedy? As a side effect of continuation, doesn't it try to match as many times as possible? I'm not familiar with this, but my gut reaction is no. Perhaps on of the Regex experts can clear that up for us... James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: using Sleep instead of Cron
On Tue, 2004-05-18 at 16:02, [EMAIL PROTECTED] wrote: Hi all, I'm writing a script which fetches data every hour. I thought instead of using cron which is platform dependent, to use sleep and a goto statement. Is there any downfalls to this? Yes. With sleep, once the machine is restarted, your process goes away. With Cron, everything resumes its normal behaviour (and there are probably other downfalls). At the start of the script I check to see if it was ran in the previous hour. BEGINNING: if(open(TIMECHECK, ./synop_daemon_timer.txt)){ my($cur_sec1,$cur_min1,$cur_hour1,$cur_day1,$cur_mon1) = TIMECHECK; my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year)=gmtime(time()); if($cur_hour1 eq $cur_hour $cur_day1 eq $cur_day){ print br SCRIPT IS ALREADY IN ACTION, CANNOT CONTINUE; exit(0); } close(TIMECHECK); } I think this is too much work for something that Cron already does... are you really going to take your code to a platform without Cron? # at the end of the script I write the last time the script was started if(open(TIMER, ./synop_daemon_timer.txt)){ my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year,$junk)=gmtime(time()); print TIMER $cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon\n; close(TIMER); } sleep(360); goto(BEGINNING); Thanks Take a look at Schedule::Cron HTH, jac -- Jos Alves de Castro [EMAIL PROTECTED] Telbit - Tecnologias de Informao -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: using Sleep instead of Cron
On Tue, 2004-05-18 at 16:02, [EMAIL PROTECTED] wrote: Hi all, I'm writing a script which fetches data every hour. I thought instead of using cron which is platform dependent, to use sleep and a goto statement. Is there any downfalls to this? Other downfalls: - Cron has automatic e-mail sending (should things go awry) - With Cron, you know it runs every *exact* hour (OTOH, a script started at 15:15 would keep running at *:15 plus some incrementing delay) - service crond start / stop / status are a very good way of keeping track of cron processes. Should you want to stop your script, you would have to find its process id and kill it; plus, running it again would make it run some time later/sooner than expected at first (again, cron resumes normal behaviour). - others, certainly At the start of the script I check to see if it was ran in the previous hour. BEGINNING: if(open(TIMECHECK, ./synop_daemon_timer.txt)){ my($cur_sec1,$cur_min1,$cur_hour1,$cur_day1,$cur_mon1) = TIMECHECK; my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year)=gmtime(time()); if($cur_hour1 eq $cur_hour $cur_day1 eq $cur_day){ print br SCRIPT IS ALREADY IN ACTION, CANNOT CONTINUE; exit(0); } close(TIMECHECK); } # at the end of the script I write the last time the script was started if(open(TIMER, ./synop_daemon_timer.txt)){ my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year,$junk)=gmtime(time()); print TIMER $cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon\n; close(TIMER); } sleep(360); goto(BEGINNING); Thanks -- Jos Alves de Castro [EMAIL PROTECTED] Telbit - Tecnologias de Informao -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: using Sleep instead of Cron
Hi all, I'm writing a script which fetches data every hour. I thought instead of using cron which is platform dependent, to use sleep and a goto statement. Is there any downfalls to this? Sure, all of the differences between a one-off script and a constantly running program. cron is platform dependent, but just about every platform (at least where Perl runs) has a scheduler of some sort, and cron is available on most of them. I am not saying not to do it, just make sure you do it for the right reasons and get the mileage you expect. At the start of the script I check to see if it was ran in the previous hour. BEGINNING: if(open(TIMECHECK, ./synop_daemon_timer.txt)){ my($cur_sec1,$cur_min1,$cur_hour1,$cur_day1,$cur_mon1) = TIMECHECK; my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year)=gmtime(time()); if($cur_hour1 eq $cur_hour $cur_day1 eq $cur_day){ print br SCRIPT IS ALREADY IN ACTION, CANNOT CONTINUE; Already in action? You mean has already run. Big difference, at least when you are talking about making a jump like this. What happens during daylight savings time, assuming your platform has such a thing? What happens if the system time changes, do you run ntpd? exit(0); } close(TIMECHECK); } # at the end of the script I write the last time the script was started if(open(TIMER, ./synop_daemon_timer.txt)){ 'started' or 'ran'... big difference again. my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year,$junk)=gmtime(time()); print TIMER $cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon\n; close(TIMER); } sleep(360); This sleeps for 6 minutes from whenever the last iteration finished, this is a very different thing then when running with a scheduler which is going to run at specific times. aka if you start your script at 12:02 then it runs at 12:08, etc. However, if your script starts at 12:03, then it runs at 12:09, etc. A scheduler will make sure it runs consistently, because it doesn't depend on when it was started (aka because it isn't constantly running). Add to this the dependency on the run time, aka if the processing itself takes a while or is dependent on external uncontrollable forces, such as network speed. Maybe your script starts at 12:04, the first loop takes 2 minutes to run, then your script will run again at 12:12, but this time takes 4 minutes to run, so the next run starts at 12:22, so much for consistency :-) goto(BEGINNING); Speaking of constantly running, are you going to monitor that the process is still alive. How about adding it to the init functions of the computer, in other words, cron is started at boot time, and just runs your script at the next interval. A constantly running program would need to be added to the platform's boot sequence. Can anyone reboot the machine, aka are the sys admin's aware of your app? You may also want to check out Proc::Daemon, are you going to redirect STDIN/STDERR/STDOUT to a log? How about disassociating the process from the terminal? Also consider an 'alarm' call, though I am not sure whether it is considered better or worse than a 'sleep'. perldoc -f alarm Lots to think about, I would caution you to at least think about all of the things that could go wrong with this approach. But again, I am not telling you not to do it http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: using Sleep instead of Cron
My main concern was that the script would die from SIGALARM. I'm testing on and XP box and using the script on a FreeBSD box. How can I get the cron function on my XP box? Also I have to get admin permission for cron jobs. Which I don't think will be a problem. It's not important that the script be ran in exact time intervals. But it is important that I be able to kill the process if necessary, and that it not quit functioning in the middle of the night. So I guess cron is the best way. Thanks so much Tricia
Re: Regular Expresssion - Matching over multiple lines
On May 18, James Edward Gray II said: On May 18, 2004, at 9:30 AM, Andrew Gaffney wrote: Doesn't the 'gc' modified make the whole think not as greedy? As a side effect of continuation, doesn't it try to match as many times as possible? I'm not familiar with this, but my gut reaction is no. Perhaps on of the Regex experts can clear that up for us... Correct. No modifier to a regex changes the greediness of the quantifiers in the regex. All the /g modifier does is say: 1. if the regex is in list context, match, and then try to match again following the first match, etc., until you stop 2. if the regex is in scalar context, match and return, but remember where we left off -- the next time this regex is called with the /g modifier, we will pick up where stopped. this position can also be used with the \G anchor. Here are examples: my $str = japhy knows regexes; @all_letters = $str =~ /\w/g; # @all_letters contains 17 elements: j,a,p,h,y,k,n,o,etc. # and before you ask, NO, I DON'T need parens around \w in there while ($str =~ /(\w+)/g) { print Got: '$1'\n; # Got: japhy; Got: knows; Got: regexes } if ($str =~ /(\w\w)/g) { print Two letters: '$1'\n; # 'ja' if ($str =~ /\G(.{5})/) { print Next five characters: '$1'\n; # 'phy k' } } Once a /g match fails, \G is cleared (\G is linked to the pos() function; that is, whatever pos($str) is equal to is the location in $str that \G anchors to). *ALL* that the /c modifier does (and it only matters when used with the /g modifier) is tell the regex engine NOT to clear \G or pos() when a match fails. Here's a method called the inchworm: print Got '$1'\n while $str =~ /\G([^]*)\s*/gc or $str =~ /\G'([^']*)'\s*/gc or $str =~ /\G(\S+)/gc; This allows us to use $1 no matter which regex matches, and because all three regexes have the /gc modifier, when the first one fails, it'll try the second one, AT THE SAME LOCATION. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: combining data from more than one file...
Ok great. Most of what you show does make sense. However, there are some bits of code that I need further clarification with. Some bits I am able to tell what they are doing but I do not quite know how or why they work they way they do. I'll state these areas in the code we've got together at this point. Hopefully, I have copied over the bits you wrote correctly. I find this is like learning Spanish. I can read and (roughly) get the gist of the code. But when it comes to writing the original code on my own is when I have trouble. I am sure this will go away when I practice more. :-) I didn't finish everything because I just need some code explained / clarified. Start PERL code #!usr/bin/perl -w use strict; use FileHandle; # I am unsure of what this module is. I've tried looking it up # in the Camel and Llama book to no avail, not enough description. # I guess I have to figure out the whole object thing? my %organisms; print Enter in a list of files to be processed:\n; # For example: # Cytb.fasta # NADH1.fasta # ... # chomp (my @infiles = STDIN); # TODO we should make this nicer later my @infiles = ('genetics.txt'); foreach my $infile(@infiles) { my $FASTA = new FileHandle; # Does the above statement tell PERL to create a new # filehandle for each file it finds? I guess I need to understand # what new and the module FileHandle are doing. open ($FASTA, $infile) or die Can't open INFILE:$!; #$/='' #Set input operator my $orgID; while (defined($_ = $FASTA)) { # Above I am unsure of why the defined function # helps us here? I know it has something to do with an # expression containing a valid string, but I am unsure # of it's function here. This is something I would have # never thought to do. :-) chomp; print \nworking on $_\n; if (\s*(\w+)/) { $orgID=$1; print Found a new organism start line ('$orgID')\n; # The above regex makes complete sense. Actually, I was going to put # something similar to that in my original post but wasn't sure # if this was appropriate at the time. I guess it was! } else { print This is just some data: $_\n; print This data needs to be appended to the hash entry for $orgID/n; # okay, in the above you are taking the left over # sequence ($_) and linking it as a value to $orgID ? if (exists ($organsims{$orgID})) { #TODO append the data to the hash here # I guess I would put the following to append to # the already existing hash: # $organism{$orgID} .= $_; } else { #create new hash entry for this data $organsims{$orgID} = $_; } } } # Do not forget to close the input file close ($FASTA) or die Could not close INFILE: $!; # We've processed all input files... print the resulting hash print \n*\n; while (my($orgID, $sequence) = each(%organisms)) { # since I want the output as: # cat # actgac---cgatc-ag-cttag---acg # dog # actatc---actat-at-accta---atc # I would change the print statement to: print . $orgID\n $sequence\n; } end; end PERL code Thanks for all your help so far! Most of this is starting help my thinking. I will be doing a lot more of this multi-file parsing as most of my work entails manipulating data in several files or folders at once. -Mike -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Perl Newbie Question
Hello All, I have a question, I am looking to read the name of the file that I am passing as an argument to the perl script through the while () part of the script. Example: perl script.pl 1.txt 2.txt 3.txt Each file has information that I am parsing to put into a report but I need to get the name of the file that I parsed and print that information as well, so that way I know what values I am getting from each file associates with what file. So the output would look like 1.txt (parsed information) 2.txt (parsed information) 3.txt (parsed information) Any assistance would be great. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Perl Newbie Question
On May 18, 2004, at 1:10 PM, Perl Mail User wrote: Hello All, I have a question, I am looking to read the name of the file that I am passing as an argument to the perl script through the while () part of the script. You're looking for the $ARGV variable. It contains the filename you need. Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Perl Newbie Question
Perl Mail User wrote: Hello All, Hi. Providing a real name would be considered polite. Also, please choose a meaningful subject. I have a question, I am looking to read the name of the file that I am passing as an argument to the perl script through the while () part of the script. The file name is in $ARGV. see perldoc perlvar. If you need to detect when switches from one file to another, see the examples under perldoc -f eof HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Perl Newbie Question
On Tue, May 18, 2004 at 01:10:27PM -0500, Perl Mail User wrote: I have a question, I am looking to read the name of the file that I am passing as an argument to the perl script through the while () part of the script. $ARGV perldoc perlvar -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
CGI radio group help
All, I have been viewing the documentation for CGI.pm in hopes to use the radio_group function. According to the docs my code appears to be correct. Here is a sample and the error, can someone please help? I am sure this is a simple fix. Note - I am an absolute perl n00b with no programming experience. # Create New CGI Object my $q = new CGI; # print form print $q-header, $q-start_html, $q-br, $q-start_multipart_form, $q-p(Select a promotion directory:), %label = ('hw'='..support_docs/HW', 'nw'='..support_docs/NW', 'sw'='..support_docs/SW', 'swmfis'='..support_docs/SW/MFIS', 'swunifi'='..support_docs/SW/Unifi', 'swwebcaaf'='../support_docs/SW/WEBCAAF_eforms'); $q-radio_group ( -name= 'promdir', -labels=\%label, -default='selected', -linebreak='true'), $q-br, $q-submit('Promote'), $q-end_form, $q-end_html; Error: [Tue May 18 13:46:00 2004] promote.cgi: Execution of /www/web/cgi-sec/merlin/promote.cgi aborted due to compilation errors. [Tue May 18 13:46:01 2004] promote.cgi: Global symbol %label requires explicit package name at /www/web/cgi-sec/merlin/promote.cgi line 36. TIA, John
RE : Perl Newbie Question
-Message d'origine- De : Perl Mail User [mailto:[EMAIL PROTECTED] Envoyé : mardi 18 mai 2004 20:10 À : [EMAIL PROTECTED] Objet : Perl Newbie Question Hello All, I have a question, I am looking to read the name of the file that I am passing as an argument to the perl script through the while () part of the script. Example: perl script.pl 1.txt 2.txt 3.txt Each file has information that I am parsing to put into a report but I need to get the name of the file that I parsed and print that information as well, so that way I know what values I am getting from each file associates with what file. So the output would look like 1.txt (parsed information) 2.txt (parsed information) 3.txt (parsed information) Any assistance would be great. Thanks In addition to perldoc perlvar suggested in previous posts you may also give a look to perldoc perlop and search for null filehandle. It's said there : my_paste The null filehandle is special: it can be used to emulate the behavior of sed and awk. Input from comes either from standard input, or from each file listed on the command line. Here's how it works: the first time is evaluated, the @ARGV array is checked, and if it is empty, $ARGV[0] is set to ``-'', which when opened gives you standard input. The @ARGV array is then processed as a list of filenames. The loop while () { ... # code for each line } is equivalent to the following Perl-like pseudo code: unshift(@ARGV, '-') unless @ARGV; while ($ARGV = shift) { open(ARGV, $ARGV); while (ARGV) { ... # code for each line } } except that it isn't so cumbersome to say, and will actually work. It really does shift the @ARGV array and put the current filename into the $ARGV variable. /my_paste -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: combining data from more than one file...
Quite a unique case. If your data is no very huge I would suggest, you just first keep on reading all data into a huge has ( key as the animal value as the data) and then just print out the hash into files like ( writing pseudo code is easier if written in perl :-) ) my @files = qw(file1 file2 file3); $/=\n . '';#this way you could read one record at a time my %alldata=(); foreach $f(@files) { open(IN,$f) || die Couldnt open file; while(IN){ my ($animal) = /^(.*?)\n/; $alldata{$animal} .=$_\n\n; } close IN; } ## %alldata has all the data On Mon, 2004-05-17 at 05:20, Michael S. Robeson II wrote: Hi all, I am having trouble with combining data from several files, and I can't even figure out how to get started. So, I am NOT asking for any code (though pseudo-code is ok) as I would like to try figuring this problem out myself. So, if anyone can give me any references or hints that would be great. So, here is what I am trying to do: I have say 2 files (I'd like to do this to as many files as the user needs): ***FILE 1*** cat atacta--gat--acgt- ac-ac-ggttta-ca-- dog atgcgtatgc-atcgat-ac--ac-a-ac-a-cac mouse acagctagc-atgca-- acgtatgctacg--atg- ***end file 1*** ***FILE 2*** mouse aatctgatcgc-atgca-- acgtaaggctagg- cat atacta--gat--acgt- ac-acacagcta--ca-- dog atgcgtatgc-atcgat -ac--ac-a-ac-a-cac ***end file 2*** Basically, I would like to concatenate the sequence of each corresponding animal so that the various input files would be out put to a file like so: ***output*** cat atacta--gat--acgt-ac-ac-ggttta-ca--atacta--gat--acgt-ac-acacagcta--ca-- dog atgcgtatgc-atcgat-ac--ac-a-ac-a-cacatgcgtatgc-atcgat-ac--ac-a-ac-a-cac mouse acagctagc-atgca--acgtatgctacg--atg-aatctgatcgc-atgca-- acgtaaggctagg- ***output end*** Notice that in the two files the data are not in the same order. So, I am trying to figure out how to have the script figure out what the first organism is in FILE 1( say cat in this case) and find the corresponding cat in the other input files. Then take the sequence data (all the cat data) from FILE 2 and concatenate it to the cat sequence data in FILE 1 to an output file. Then it should go on to the next organism in FILE 1 and search for that next organism in the other files (in this case FILE 2). I do not care about the order of the data, only that the like data is concatenated together. Again, I do NOT want this solved for me (unless I am totally lost). Otherwise, I'll never learn. I would just like either hints / suggestions / pseudo code / even links to books or sites that discuss this particular topic. Meanwhile, I am eagerly awaiting my PERL Cookbook and I'll keep searching the web. -Thanks! -Mike -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Module to validate credit cards
Hello, can someone recommend a decent perl module or a reliabe routine to check credit cards and expiration dates formats... not to actual check if the card is valid, stolen,... etc, but just the format for the common cards used today. TIA -- MikemickaloBlezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Module to validate credit cards
Mike Blezien wrote: Hello, can someone recommend a decent perl module or a reliabe routine to check credit cards and expiration dates formats... not to actual check if the card is valid, stolen,... etc, but just the format for the common cards used today. Go to CPAN Search and search : Credit Card. A number of items you can look at until or if someone sends you something better. A starting point. Any questions and/or problems, please let me know. Thanks. Wags ;) Int: 9-8-002-2224 Ext: 408-323-4225x2224 ** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE : Module to validate credit cards
-Message d'origine- De : Mike Blezien [mailto:[EMAIL PROTECTED] Envoyé : mardi 18 mai 2004 21:32 À : Perl List Objet : Module to validate credit cards Hello, can someone recommend a decent perl module or a reliabe routine to check credit cards and expiration dates formats... not to actual check if the card is valid, stolen,... etc, but just the format for the common cards used today. I discovered Business::CreditCard http://search.cpan.org/~ivan/Business-CreditCard-0.27/CreditCard.pm while reading this article from perl.com http://www.perl.com/lpt/a/2004/04/29/maypole.html Check if it's what you want. HTH, José. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: RE : Module to validate credit cards
Thx's, I'll check it out. Mike Jose Nyimi wrote: -Message d'origine- De : Mike Blezien [mailto:[EMAIL PROTECTED] Envoyé : mardi 18 mai 2004 21:32 À : Perl List Objet : Module to validate credit cards Hello, can someone recommend a decent perl module or a reliabe routine to check credit cards and expiration dates formats... not to actual check if the card is valid, stolen,... etc, but just the format for the common cards used today. I discovered Business::CreditCard http://search.cpan.org/~ivan/Business-CreditCard-0.27/CreditCard.pm while reading this article from perl.com http://www.perl.com/lpt/a/2004/04/29/maypole.html Check if it's what you want. HTH, José. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
bytes to array speed problems
Greetings, Three small questions, 1. I fetch a byte string from file with, sysread $bin_fh, $bytstr, $length; The byte string contains a run of integers that I would like to have access to. I get that access with @array = unpack n*, $bytstr; But this last operation, all in memory, takes much longer than getting the integers from disk. I then tried vec, but that is 2-3 times slower. In fortran, and I believe in C as well, one can read straight into arrays without having to unpack. Is there a way to do something similar in perl? (I searched cpan with mmap and array and looked at some of the hits, but found nothing except Tie::MmapArray which the author calls alpha and last change was made in 1999). 2. Can perl be told to raise error when a variable used in a subroutine is not declared within the routine, but declared outside? 3. Can perl be told to raise error when declared variables are never used within their scope? Niels L -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: CGI radio group help
On May 18, John Pretti said: # Create New CGI Object my $q = new CGI; # print form print $q-header, $q-start_html, $q-br, $q-start_multipart_form, $q-p(Select a promotion directory:), Here's your first problem: %label = ('hw'='..support_docs/HW', 'nw'='..support_docs/NW', 'sw'='..support_docs/SW', 'swmfis'='..support_docs/SW/MFIS', 'swunifi'='..support_docs/SW/Unifi', 'swwebcaaf'='../support_docs/SW/WEBCAAF_eforms'); You're defining this hash in the middle of your print() calls. That's going to create the hash, but then print it out, and then your other HTML-creating functions won't end up printing to anything, since you've ended the print() statement with a semicolon. $q-radio_group ( -name= 'promdir', -labels=\%label, -default='selected', -linebreak='true'), $q-br, $q-submit('Promote'), $q-end_form, $q-end_html; [Tue May 18 13:46:01 2004] promote.cgi: Global symbol %label requires explicit package name at /www/web/cgi-sec/merlin/promote.cgi line 36. But this is the more important problem. You haven't declared %label as a lexical variable, nor have you told Perl to let you use it as a global variable. You want to do: my $q = CGI-new; my %label = ( ... ); # put the creation of the hash here and then print $q-header, $q-start_html, $q-br, $q-start_multipart_form, $q-p(Select a promotion directory:), $q-radio_group ( -name= 'promdir', -labels=\%label, -default='selected', -linebreak='true'), $q-br, $q-submit('Promote'), $q-end_form, $q-end_html; -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Query
Sudhindra Bhat wrote: Hi Hello, This doesn't seem to work. I get a blank output. But yes the output that is want is 123456 ABCDEF 123456 while ( FILE ) { next unless /\S/; if ( s/^.*?Test:\s*// .. /Results:/ and !/Results:/ ) { print } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Newbie: Perl reg. expression
Durai wrote: Hello All, Hello, open FILE, test.txt or die Can't open file!: $!; while( FILE ) { print if /(\d+\.\d+\.\d+\.\d)/; } close FILE; It gives the following output: # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) #Listen 12.34.56.78:80 # e.g., www.apache.org (on) or 204.62.129.132 (off). I want only a word which contains IP address only not with port and others.. For example, Need like: 204.62.129.132 not (0.0.0.0),12.34.56.78:80,.. . open FILE, 'test.txt' or die Can't open file!: $!; while ( FILE ) { print $_\n for /\d+\.\d+\.\d+\.\d+/g; } close FILE; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: RE : Module to validate credit cards
On Tue, 18 May 2004 22:07:16 +0200 Jose Nyimi [EMAIL PROTECTED] wrote: I discovered Business::CreditCard http://search.cpan.org/~ivan/Business-CreditCard-0.27/CreditCard.pm That's a fine module, but you might want to have a separate list of dummy numbers that are valid but used for test purposes only. 4111 is one that comes to mind. -- Owen __0 http://www.pcug.org.au/~rcook/rr.html for rides _ \,_ (_)./(_) http://weather.smh.com.au/weather/canberra.html --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Image editing/Creating modules
use GD; Hope you are able to install on your machine Ram On Tue, 2004-05-18 at 10:37, [EMAIL PROTECTED] wrote: can someone give a name of any image (JPG or GIF) editing / creating module, which allow to create images to display on web pages on the fly by CGI scripts. Rakhitha M. Karunarathne Trainee Software Developer, IFS - R D International, 501,Galle Road ,Cololmbo-6, SRI LANKA. Tel +94 (011)-2-364-440 Ext 841 E-mail [EMAIL PROTECTED] www.ifsworld.com CONFIDENTIALITY AND DISCLAIMER NOTICE Please note that this message may contain confidential information. If you have received this message by mistake, please inform the sender of the mistake by e-mailing [EMAIL PROTECTED], then delete the message from your system without making, distributing or retaining any copies of it. Any views or opinions presented are solely those of the sender and do not necessarily represent those of IFS unless otherwise specifically stated. Although we believe that the message and any attachments are free from viruses and other errors that might affect the computer or IT system where it is received and read, the recipient opens the message at his or her own risk. We assume no responsibility for any loss or damage arising from the receip. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
@UNIQUE=unique(@REDUNDANT);
Hi, Is there an easy way to get all the unique elements of an array? i.e. is there some module or function that does that sort of thing? -- -- Jason Dusek (`-''-/).___..--''`-._ -- | `6_ 6 ) `-. ( ).`-.__.`) -- | (_Y_.)' ._ ) `._ `. ``-..-' -- | _..`--'_..-_/ /--'_.' ,' -- | (il),-'' (li),' ((!.-' -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Image editing/Creating modules
Nope - It gave a error when I try to make it some sort of a fatel error. Thankx .. Any way I installed PERLMagick with ImageMagick so I am going to use it. Ithink there is a bug in ImageMagick when I try to load a image from a perl file handle Windows says that perl.exe performed an ilegal operation. But when I directly give the file name it worked. Rakhitha Karunarathne Web Master www.Ad-Man.tk - Free Unlimited Banner Rotators - Original Message - From: Ramprasad A Padmanabhan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 11:47 AM Subject: Re: Image editing/Creating modules use GD; Hope you are able to install on your machine Ram On Tue, 2004-05-18 at 10:37, [EMAIL PROTECTED] wrote: can someone give a name of any image (JPG or GIF) editing / creating module, which allow to create images to display on web pages on the fly by CGI scripts. Rakhitha M. Karunarathne Trainee Software Developer, IFS - R D International, 501,Galle Road ,Cololmbo-6, SRI LANKA. Tel +94 (011)-2-364-440 Ext 841 E-mail [EMAIL PROTECTED] www.ifsworld.com CONFIDENTIALITY AND DISCLAIMER NOTICE Please note that this message may contain confidential information. If you have received this message by mistake, please inform the sender of the mistake by e-mailing [EMAIL PROTECTED], then delete the message from your system without making, distributing or retaining any copies of it. Any views or opinions presented are solely those of the sender and do not necessarily represent those of IFS unless otherwise specifically stated. Although we believe that the message and any attachments are free from viruses and other errors that might affect the computer or IT system where it is received and read, the recipient opens the message at his or her own risk. We assume no responsibility for any loss or damage arising from the receip. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: @UNIQUE=unique(@REDUNDANT);
On May 18, 2004, at 9:14 PM, Jason Dusek wrote: Hi, Is there an easy way to get all the unique elements of an array? i.e. is there some module or function that does that sort of thing? There are excellent modules to handle this, but it's also pretty simple to roll your own in most cases: sub unique {# see title of this message for usage my @all = @_; my %seen; $seen{$_}++ foreach @all; return keys %seen; } Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Possible OT: Site Spiders?
I need a site spider to stay in the same domain, but follow all links (saving all files encountered) for saving an entire business site. I have been looking around but have not found the one I am looking for, can anyone help? It can be PERL or Windows or PHP, it just needs to be locked to the same domain Thanks, Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: @UNIQUE=unique(@REDUNDANT);
On 5/18/2004 10:46 PM, James Edward Gray II wrote: On May 18, 2004, at 9:14 PM, Jason Dusek wrote: Hi, Is there an easy way to get all the unique elements of an array? i.e. is there some module or function that does that sort of thing? There are excellent modules to handle this, but it's also pretty simple to roll your own in most cases: sub unique {# see title of this message for usage my @all = @_; my %seen; $seen{$_}++ foreach @all; return keys %seen; } or it can be made uglier: sub uniq { return keys %{{ map { $_, 1 } @_ }} } Isn't this in the faq? `perldoc -q faq` Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: @UNIQUE=unique(@REDUNDANT);
On 5/18/2004 11:00 PM, Randy W. Sims wrote: sub uniq { return keys %{{ map { $_, 1 } @_ }} } Sorry for the nice formatting, that should have been: sub uniq{keys%{{map{$_,[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Possible OT: Site Spiders?
On May 18, 2004, at 9:54 PM, Lone Wolf wrote: I need a site spider to stay in the same domain, but follow all links (saving all files encountered) for saving an entire business site. I have been looking around but have not found the one I am looking for, can anyone help? It can be PERL or Windows or PHP, it just needs to be locked to the same domain It's Perl or perl, but never PERL. Windows is an OS, not a programming language, so I'm not sure what you meant there. Maybe not immediately helpful, but I've heard the book Spidering Hacks is a good read. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: @UNIQUE=unique(@REDUNDANT);
What modules handle this? I have been digging around in CPAN all day... -- -- Jason Dusek (`-''-/).___..--''`-._ -- | `6_ 6 ) `-. ( ).`-.__.`) -- | (_Y_.)' ._ ) `._ `. ``-..-' -- | _..`--'_..-_/ /--'_.' ,' -- | (il),-'' (li),' ((!.-' -- James Edward Gray II wrote: On May 18, 2004, at 9:14 PM, Jason Dusek wrote: Hi, Is there an easy way to get all the unique elements of an array? i.e. is there some module or function that does that sort of thing? There are excellent modules to handle this, but it's also pretty simple to roll your own in most cases: sub unique {# see title of this message for usage my @all = @_; my %seen; $seen{$_}++ foreach @all; return keys %seen; } Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Possible OT: Site Spiders?
I need a site spider to stay in the same domain, but follow all links (saving all files encountered) for saving an entire business site. I have been looking around but have not found the one I am looking for, can anyone help? It can be PERL or Windows or PHP, it just needs to be locked to the same domain Thanks, Robert http://swish-e.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: @UNIQUE=unique(@REDUNDANT);
On May 18, 2004, at 10:12 PM, Jason Dusek wrote: What modules handle this? I have been digging around in CPAN all day... Searching the CPAN for array unique, the first match is the super cool Tie::Array::Unique. http://search.cpan.org/~pinyan/Tie-Array-Unique-0.01/Unique.pm Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: @UNIQUE=unique(@REDUNDANT);
On May 18, James Edward Gray II said: On May 18, 2004, at 10:12 PM, Jason Dusek wrote: What modules handle this? I have been digging around in CPAN all day... Searching the CPAN for array unique, the first match is the super cool Tie::Array::Unique. http://search.cpan.org/~pinyan/Tie-Array-Unique-0.01/Unique.pm Yes, I agree, it's super cool. (I'm the author.) All you need to do is drop in: use Tie::Array::Unique; tie my(@array), 'Tie::Array::Unique'; into your code, and @array will automatically be guaranteed to hold only unique elements. You have to download and install the module, of course, but that's a simple process. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: @UNIQUE=unique(@REDUNDANT);
On May 19, Ramprasad A Padmanabhan said: #!/usr/bin/perl my @arr = qw(a b c d a b e f ); print join( , sort @arr) . \n . '#' x 50 . \n; print join( , sort (uniq (@arr))) . \n; exit 0; sub uniq{keys%{{map{$_,[EMAIL PROTECTED] Perl is not sorting the return values of the uniq() function, Perl is using 'uniq' as the comparison function to sort(). This is *ALL* because you have a space after the function name. If you did sort(uniq(@arr)) or sort +uniq(@arr) you'd print the sorted unique values. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: @UNIQUE=unique(@REDUNDANT);
On 5/19/2004 12:30 AM, Ramprasad A Padmanabhan wrote: On Wed, 2004-05-19 at 08:35, Randy W. Sims wrote: On 5/18/2004 11:00 PM, Randy W. Sims wrote: sub uniq { return keys %{{ map { $_, 1 } @_ }} } Sorry for the nice formatting, that should have been: sub uniq{keys%{{map{$_,[EMAIL PROTECTED] Are u sure that works ? I just wrote out a script didnot work for me #!/usr/bin/perl my @arr = qw(a b c d a b e f ); print join( , sort @arr) . \n . '#' x 50 . \n; print join( , sort (uniq (@arr))) . \n; exit 0; sub uniq{keys%{{map{$_,[EMAIL PROTECTED] __END__ The output I got was a a b b c d e f ## a b c d a b e f I dont think there is anything wrong with the function uniq, the function works fine ( when I print within the function ). I think the issue is with the return use strict; use warnings; There is ambiguity in your call to the function; perl does not know it is a function. Prefix the call with '' or '+', and it will work. A better solution might be to use temporaries to construct your list. Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Query
I am using the below command awk -F: ' $3 ~/bharghav/ { print $0 } ' data.file but this command produces both Vijayb:12345:Vijay B bharghav vijaya:12347:vijaya bharghavi what to if I want only record containing exactly the word bharghav that is Vijayb:12345:Vijay B bharghav -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 4:56 PM To: Perl Beginners Subject: Re: Query On Monday 17 May 2004 03:15, Sudhindra Bhat wrote: Hi Hello, I wanted some help on a piece of code that I was writing. Well the requirement is like this. I have a file whose looks like this (1) Test: 123456 ABCDEF 123456 (2) Results: ABCDEF Now I want my script to output all the contents between the two tags Test and Results. i.e. 123456 ABCDEF 123456. Can someone help me with this? while ( FILE ) { if ( /Test:/ .. /Results:/ and !/Test:/ and !/Results:/ ) { print } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response ** This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated. ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response