RE: Reading contents of file

2006-01-08 Thread Dhanashri Bhate
Ok, got it now :-) , sorry, I misunderstood your problem earlier.

If you are expecting multiple matches in a single line, then i would
suggest, keep the regex match as it is  i.e. while
($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi),

But inside the loop when you a find a match and do relevant things, modify
$line in such a way, that you get the next ( may be replace the matched
substring with empty string? ) This way the lop will end once all matches on
the line are found.

 

Well I'm not a Perl expert, so this is what I could think of :-) But I'm
sure there must be a better way to do it!

 

Dhanashri

 

 

 

 

  _  

From: anand kumar [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 09, 2006 12:56 PM
To: [EMAIL PROTECTED]; beginners@perl.org
Subject: RE: Reading contents of file

 

Hi

 

   I have already tried the way u have told but when i use '
while($line=)' and the regex in the if loop then the regex pattern is
matched only once in the current line and does'nt get repeated for the same
line with differnt bookname present in the same line.

 

For Eg.

 

If the input is Genesis 45. with 1 chron ..

 

here genesis an 1 chron are the book names which can be identified by the
function .

 

the output is:

Genesis 45. eith 1 chron..

here the loop does'nt get repeated for 1 chron.

 

Please help in this regard

Dhanashri Bhate <[EMAIL PROTECTED]> wrote:

Hi Anand,
Yo! u know where its going wrong then change it :)

Ok, I haven't gone into the regex etc. but I see these 2 major problems:

1. $line=; should be also there inside the while loop, to make the
program get the next line in the file, and hence eventually come out of the
loop when it reaches EOF.
Or, make the change the while loop as "while ( $line = )" and put the
regex check in "if" conditional.

2. Again, you want to make some changes to the line you've read, and then
print it to the output file, the line "print OUT $line;" should be in the
while loop, not outside.

See this:
while ( $line = 
{
if ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
{
..
... do what u want if regex matches
...
print OUT $line;
}
}

Dhanashri

-Original Message-
From: anand kumar [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 09, 2006 11:31 AM
To: beginners@perl.org
Subject: Reading conte! nts of file


Hi

I am new to PERL. I have a doubt, The following script is used to read the
contents of a file (word by word (or) word preceeded by a number), check for
the existence of the matched pattern which is done by the help of bookref()
sub, if it is found then the matched pattern is prefixed with the tag
. When I run the following script it goes to unending because it is
not pointing to the next string after the complete execution of the loop .
Please correct me 

open IN, "r1.dat";
open OUT, ">r1.txt";
$/=undef;
$line=;
while ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
{
$book=$1;
print $book,"\n";
$t_book=$book;
$t_book=~s/\.//g;
$t_book=~s/\\l=([a-z]+)\\/$1/ig;
$t_book=~s/<(|\/)(B|I|SC|U)>//ig;
$quote=bibref($t_book);
if($quote)
{
$line=~s/($book)/$1/ig;
}
}
print OUT $line;
close(IN);

Thanks in advance for the help.

Regards
Anand
Send instant messages to your online friends http://in.messenger.yahoo.com 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




 

Send instant messages to your online friends http://in.messenger.yahoo.com 



Re: Want to develop a windows based application

2006-01-08 Thread Octavian Rasnita
From: "Anish Kumar K." <[EMAIL PROTECTED]>

Hi

I want to develop a windows based application with PERL. Can anyone tell me
which is best way to go..

You can use the following libraries:

Win32::GUI
It is the most simple to use, it creates accessible programs for screen
readers, it uses the standard Win32 API, but the programs can run only under
Windows.

WX
This library can create programs which are portable on more operating
systems. The interface is pretty accessible for screen readers, but the
syntax of this library is some more complicated. If you know C, you might
find it easier to use.

Tk
It is pretty much used, but it uses the TCL/Tk GUI library which is not
accessible for the screen readers. It creates portable programs.

GTK2
It is not very much used for the moment, and it is not accessible for the
screen readers. I think it creates accessible programs.

Then I assume you also want to create .exe programs.
For this you can use perlapp (from Perl Dev Kit - www.activestate.com), PAR
module (it is free - search.cpan.org), or perl2exe (from
www.indigostar.com).

Teddy


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Reading contents of file

2006-01-08 Thread anand kumar
Hi
   
 I have already tried the way u have told but when i use ' 
while($line=)' and the regex in the if loop then the regex pattern is 
matched only once in the current line and does'nt get repeated for the same 
line with differnt bookname present in the same line.
   
  For Eg.
   
  If the input is Genesis 45. with 1 chron ..
   
  here genesis an 1 chron are the book names which can be identified by the 
function .
   
  the output is:
  Genesis 45. eith 1 chron..
  here the loop does'nt get repeated for 1 chron.
   
  Please help in this regard

Dhanashri Bhate <[EMAIL PROTECTED]> wrote:
  Hi Anand,
You know where its going wrong then change it :)

Ok, I haven't gone into the regex etc. but I see these 2 major problems:

1. $line=; should be also there inside the while loop, to make the
program get the next line in the file, and hence eventually come out of the
loop when it reaches EOF.
Or, make the change the while loop as "while ( $line = )" and put the
regex check in "if" conditional.

2. Again, you want to make some changes to the line you've read, and then
print it to the output file, the line "print OUT $line;" should be in the
while loop, not outside.

See this:
while ( $line = {
if ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
{
..
... do what u want if regex matches
...
print OUT $line;
}
}

Dhanashri

-Original Message-
From: anand kumar [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 09, 2006 11:31 AM
To: beginners@perl.org
Subject: Reading contents of file


Hi

I am new to PERL. I have a doubt, The following script is used to read the
contents of a file (word by word (or) word preceeded by a number), check for
the existence of the matched pattern which is done by the help of bookref()
sub, if it is found then the matched pattern is prefixed with the tag
. When I run the following script it goes to unending because it is
not pointing to the next string after the complete execution of the loop .
Please correct me 

open IN, "r1.dat";
open OUT, ">r1.txt";
$/=undef;
$line=;
while ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
{
$book=$1;
print $book,"\n";
$t_book=$book;
$t_book=~s/\.//g;
$t_book=~s/\\l=([a-z]+)\\/$1/ig;
$t_book=~s/<(|\/)(B|I|SC|U)>//ig;
$quote=bibref($t_book);
if($quote)
{
$line=~s/($book)/$1/ig;
}
}
print OUT $line;
close(IN);

Thanks in advance for the help.

Regards
Anand

Send instant messages to your online friends http://in.messenger.yahoo.com 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



  


Send instant messages to your online friends http://in.messenger.yahoo.com 

RE: Reading contents of file

2006-01-08 Thread Dhanashri Bhate
Hi Anand,
You know where its going wrong then change it :)

Ok, I haven't gone into the regex etc. but I see these 2 major problems:

1. $line=; should be also there inside the while loop, to make the
program get the next line in the file, and hence eventually come out of the
loop when it reaches EOF.
Or, make the change the while loop as "while ( $line =  )" and put the
regex check in "if" conditional.

2. Again, you want to make some changes to the line you've read, and then
print it to the output file, the line "print OUT $line;" should be in the
while loop, not outside.

See this:
while ( $line = mailto:[EMAIL PROTECTED] 
Sent: Monday, January 09, 2006 11:31 AM
To: beginners@perl.org
Subject: Reading contents of file


  Hi
   
  I am new to PERL. I have a doubt, The following script is used to read the
contents of a file (word by word (or) word preceeded by a number), check for
the existence of the matched pattern which is done by the help of bookref()
sub, if it is found then the matched pattern is prefixed with the tag
. When I run the following script it goes to unending because it is
not pointing to the next string after the complete execution of the loop .
Please correct me 
   
  open IN, "r1.dat";
  open OUT, ">r1.txt";
  $/=undef;
  $line=;
  while ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
  {
  $book=$1;
  print $book,"\n";
  $t_book=$book;
  $t_book=~s/\.//g;
  $t_book=~s/\\l=([a-z]+)\\/$1/ig;
  $t_book=~s/<(|\/)(B|I|SC|U)>//ig;
  $quote=bibref($t_book);
  if($quote)
  {
  $line=~s/($book)/$1/ig;
  }
  }
  print OUT $line;
  close(IN);
   
  Thanks in advance for the help.
   
  Regards
  Anand

Send instant messages to your online friends http://in.messenger.yahoo.com 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Reading contents of file

2006-01-08 Thread anand kumar

  Hi
   
  I am new to PERL. I have a doubt, The following script is used to read the 
contents of a file (word by word (or) word preceeded by a number), check for 
the existence of the matched pattern which is done by the help of bookref() 
sub, if it is found then the matched pattern is prefixed with the tag . 
When I run the following script it goes to unending because it is not pointing 
to the next string after the complete execution of the loop . Please correct me 
   
  open IN, "r1.dat";
  open OUT, ">r1.txt";
  $/=undef;
  $line=;
  while ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
  {
  $book=$1;
  print $book,"\n";
  $t_book=$book;
  $t_book=~s/\.//g;
  $t_book=~s/\\l=([a-z]+)\\/$1/ig;
  $t_book=~s/<(|\/)(B|I|SC|U)>//ig;
  $quote=bibref($t_book);
  if($quote)
  {
  $line=~s/($book)/$1/ig;
  }
  }
  print OUT $line;
  close(IN);
   
  Thanks in advance for the help.
   
  Regards
  Anand

Send instant messages to your online friends http://in.messenger.yahoo.com 

Re: Want to develop a windows based application

2006-01-08 Thread Chris Devers
On Mon, 9 Jan 2006, Anish Kumar K. wrote:

> I want to develop a windows based application with PERL. Can anyone 
> tell me which is best way to go..

Make it web-based and then access it from IE or Firefox on Windows or 
any other platform. That's often the easiest way to do it.

If you want a graphical Windows desktop program, your best bet is 
probably using one of the cross-platform graphical toolkits like Tk or 
WxWindows. Tk is older and as such better known; WxWindows is newer and 
seems to do a better job of actually looking like a proper Windows (or 
X11, or Mac, etc) application.

But to get this to work, I think you'll need to bundle both Perl and the 
graphical libraries along with your script, as neither of these is 
typically available on Windows. I'm sure that there's a way to do it -- 
and reading up on the documentation for Perl/Tk or Perl/WxWindows will 
probably lead to useful sugggestions -- but then this is the point 
where, as I noted above, I personally usually find it easier to just 
cheat and develop a web application instead. 


-- 
Chris Devers
DO NOT LEAVE IT IS NOT REAL

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: testing perl

2006-01-08 Thread Owen Cook

On Mon, 9 Jan 2006, Saurabh_Agarwal wrote:

> I want to know how to use perl -d


Try

perldoc -q debug


-
Found in /usr/share/perl/5.8/pod/perlfaq3.pod
   How do I debug my Perl programs?

lots more



Owen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Want to develop a windows based application

2006-01-08 Thread Anish Kumar K.
Hi

I want to develop a windows based application with PERL. Can anyone tell me 
which is best way to go..

Anis

RE: testing perl

2006-01-08 Thread Chris Devers
On Mon, 9 Jan 2006, Saurabh_Agarwal wrote:

> I want to know how to use perl -d

perldoc perldebug
 


-- 
Chris Devers
DO NOT LEAVE IT IS NOT REAL

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: testing perl

2006-01-08 Thread Saurabh_Agarwal
I want to know how to use perl -d

-Original Message-
From: Owen Cook [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 09, 2006 10:51 AM
To: Saurabh_Agarwal
Cc: beginners@perl.org
Subject: Re: testing perl


On Mon, 9 Jan 2006, Saurabh_Agarwal wrote:

> How can we test our Perl script?


At the command prompt run

#perl -c script.pl

If there are no errors, it compiles ok
If there are errors, fix them

then run

#perl script.pl

and see if your logig is correct


HTH


Owen




DISCLAIMER:
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]
 




Re: testing perl

2006-01-08 Thread Chris Devers
On Mon, 9 Jan 2006, Saurabh_Agarwal wrote:

> How can we test our Perl script?

We can test our Perl script carefully.


-- 
Chris Devers
DO NOT LEAVE IT IS NOT REAL

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: testing perl

2006-01-08 Thread Owen Cook

On Mon, 9 Jan 2006, Saurabh_Agarwal wrote:

> How can we test our Perl script?


At the command prompt run

#perl -c script.pl

If there are no errors, it compiles ok
If there are errors, fix them

then run

#perl script.pl

and see if your logig is correct


HTH


Owen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




testing perl

2006-01-08 Thread Saurabh_Agarwal
How can we test our Perl script?

 



DISCLAIMER:
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.


Re: executing external binaries

2006-01-08 Thread Dr.Ruud
Shawn Corey:
> Saurabh Singhvi:

>> the external binary is HUGE in terms of ram usage so i need a way to
>> keep it loaded in the memory
>> so that i can keep passing the next parameters, instead of loading
>> it each time.
>
> If you're running UNIX you can set the binary's sticky bit. See `man
> chmod` and `man 2 chmod`. The sticky bit tells UNIX to leave the
> program in RAM for a little while in case it is called again very
> soon.

If the binary allocates the massive amount of memory at init and frees
it at exit, then you still need a malloc-cloak that keeps that memory at
hand. Maybe 'daemonize' can be adjusted to do that.

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: script to count message sizes on an imap server

2006-01-08 Thread Tom Phoenix
On 1/8/06, Martin J Hooper <[EMAIL PROTECTED]> wrote:
> Does anyone know of a script I can download

That's a poor way to open a message in a programming forum; it makes
it sound as if you don't plan to write any code yourself! Since this
is a forum for beginning Perl programmers, you could at least pretend
that you're having trouble writing your program before you ask to
download one. :-)

> which will connect to my
> IMAP server and transverse all folders counting up the size of each
> message in the folder and then spitting it out..?

Maybe CPAN has a module that would help you. I suspect you could do
what you want fairly easily with Net::IMAP::Simple or one of the
others.

http://search.cpan.org/~cfaber/Net-IMAP-Simple-1.14/lib/Net/IMAP/Simple.pm
http://search.cpan.org/search?query=imap&mode=all

If you get stuck, though, please post again. Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: executing external binaries

2006-01-08 Thread Saurabh Singhvi
hi all

thanks for the help!! i am  hoping to use the chmod thing
or the one from zentara.

thanks again
Saurabh

On 1/8/06, zentara <[EMAIL PROTECTED]> wrote:
>
> On Sat, 7 Jan 2006 11:09:25 +, [EMAIL PROTECTED] (Saurabh
> Singhvi) wrote:
>
> >hi people
> >
> >i have a script that executes external binaries using the system command.
> >now the problem is this:
> >
> >the external binary is HUGE in terms of ram usage so i need a way to keep
> it
> >loaded in the memory
> >so that i can keep passing the next parameters, instead of loading it
> each
> >time.
> >
> >kindly guide me about this
>
> Assuming you are talking about a single script execution:
>
> If you only need to feed it on STDIN and not collect output, you can use
> the piped form of open.
> ##
> open( FH, " | my_huge_program") or warn "$!\n";
>
> print FH "data1";
> #wait
> print FH "data2";
>
> # etc etc etc
> close FH;  #will remove it from memory
> 
>
> If you need to collect the STDOUT and STDERR too, you
> can open it with IPC::Open3, feed it's STDIN and collect
> it's STDOUT and STDERR
>
> ##
>
> use warnings;
> use strict;
> use IPC::Open3;
> use IO::Select;
>
> #interface to "bc" calculator
> my $pid = open3(\*WRITE, \*READ,\*ERROR,"bc");
>
> my $sel = new IO::Select();
>
> $sel->add(\*READ);
> $sel->add(\*ERROR);
>
> my($error,$answer)=('','');
>
> while(1){
>
> print "Enter expression for bc, i.e. 2 + 2\n";
> chomp(my $query = );
>
> #send query to bc
> print WRITE "$query\n";
>
> foreach my $h ($sel->can_read)
> {
>my $buf = '';
>if ($h eq \*ERROR)
>{
>  sysread(ERROR,$buf,4096);
>  if($buf){print "ERROR-> $buf\n"}
>}
>else
>{
>  sysread(READ,$buf,4096);
>  if($buf){print "$query = $buf\n"}
>}
> }
> }
>
> waitpid($pid, 1);
> # It is important to waitpid on your child process,
> # otherwise zombies could be created.
> __END__
>
>
>
>
>
>
>
> --
> I'm not really a human, but I play one on earth.
> http://zentara.net/japh.html
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>


Re: script to count message sizes on an imap server

2006-01-08 Thread Chris Devers
On Sun, 8 Jan 2006, Martin J Hooper wrote:

> Does anyone know of a script I can download which will connect to my 
> IMAP server and transverse all folders counting up the size of each 
> message in the folder and then spitting it out..?
> 
> I'm sure I'm not the only one to want to do this... ;)

Well, you're not the only one that wants other people to do your work 
for you... :-)

The thing with having a very specific idea of what you want to do is 
that it makes it increasingly unlikely that there will be a "canned" 
solution for it that you can download. On the other hand, it also means 
that you have a clear idea of what you need, so a CPAN search will often 
turn up tools that can make your task much easier.

So. There are several IMAP related libraries on CPAN. Did you search for 
them? Did you try any? Have you written any code? This list is for 
helping people improve their code writing skills, not doing the writing 
for you. If you want it written for you, I'm sure someone could be 
talked into helping you out for a reasonable fee :-) 


-- 
Chris Devers
DO NOT LEAVE IT IS NOT REAL

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: new for reading file containing multiple records

2006-01-08 Thread chen li
Hi Shawn,

Thanks for the detailed explanations.

But Edward(see one of posts in my thread) tells me to
try Bio::SeqIO from www.bioperl.org. After I try I
think it is what I really need.

Once again thank you so much for the help.

Li 




__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




script to count message sizes on an imap server

2006-01-08 Thread Martin J Hooper
Does anyone know of a script I can download which will connect to my 
IMAP server and transverse all folders counting up the size of each 
message in the folder and then spitting it out..?


I'm sure I'm not the only one to want to do this... ;)


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: new for reading file containing multiple records

2006-01-08 Thread Shawn Corey

chen li wrote:


You are 50% right. This method is not correct for the
first record(which actually contains ">' only) but it
is correct for the last record(and others in between).



I want to edit the file first and try to delete the
first ">" in this big file. I browse Programming Perl
and Perl Cookbook there is not such  example: just
delete the first charater in a file. But they have
examples to delete the last line from a file. It seems
odd to me. 


First, I'd recommend against changing a large file. Unless your program 
is the only user of the file, you would have to change all the other 
programs. And in this case, you would be unable to distinguish one 
record from another.


There are three ways to distinguish records in a file: by record 
separators, by beginning-of-record tokens, and by end-of-record tokens. 
Your file may use one, two or all three methods. When writing code, your 
preference should be (in order) record separator, end-of-record token, 
and finally beginning-of-record token.


In Perl, the variable $/ is used to distinguish the end-of-record token; 
even though it is called the INPUT_RECORD_SEPARATOR. Its name is 
misleading. If it was a true record separator, your code would never 
have to process the record separator; it would be discarded at a lower 
level.


The records in your file are distinguished only by a beginning-of-record 
token, specifically a greater-than sign at the beginning of a record. 
You can process the file in two ways: treat the beginning-of record 
token as an end-of-record token, or read ahead in the file and process 
the record only after reading the beginning of the next record. Both 
have the advantages and disadvantages.


If you want to treat the beginning-of-record token as an end-of-record 
one, your records are going to have some anomalies. The first record is 
going to have a beginning-of-record token attached to it. Your last 
record is not going to have an end-of-record token. For your case, it 
would look something like this:


my $beginning_token = '>';
my $end_token = "\n$beginning_token";
$/ = $end_token;
my $first = 1;
while(  ){
  if( $first ){
s/^\Q$beginning_token//;
$first = 0;
  }
  s/\Q$end_token\E$//;
  process_record( $_ );
}

If you want to use only the beginning-of-record token, you will have to 
do at least a partial read ahead. This means you have to store the read 
ahead and the last record will be processed outside the read loop. For 
you case:


my $beginning_token = '>';
my $record = '';
while(  ){
  if( /^\Q$beginning_token/ ){
if( $record =~ /^\Q$beginning_token/ ){
  process_record( $record );
}
$record = '';
  }
  $record .= $_;
}
if( $record =~ /^\Q$beginning_token/ ){
  process_record( $record );
}



--

Just my 0.0002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Need some help and direction

2006-01-08 Thread Shawn Corey

Daniel Gladstone wrote:
I thought this would be easy but I can not get it to work - can someone 
please help me:


Problem: I have a file of 7.5 million records that are pipe delimted, 
the first field is a record
number. I want to search for around 10 records with a specific record 
number and if they
meet that condition, output them to a secondary output. And if it does 
not meet the record

number criteria, output to the primary output.

Code so far(Please don't laugh - I am a newbie)

#!/usr/bin/perl -w
use strict;
# pullbad filename fieldtocount
die "usage: count   \n" unless (@ARGV == 2);
my ($filename, $cntfldnum) = @ARGV;
$cntfldnum--; # zero-base fldnum
my $records = 0; # count records processed

open(IN, $filename) or die "could not open $filename $!\n";
my %count = (); # hash the count key and value here
while () {
 $records++;
 my @rec=split(/\|/,$_);
 #$count{$rec[$cntfldnum]}++;
 if ($rec[$cntfldnum] =~ m/\D/g) {
print STDERR $rec[$cntfldnum] . " -> " . $rec[0] . " record # = " . 
$records . "\n";

 }


Your code doesn't seem to match the problem you stated. What does 
$cntfldnum contain? If you are searching, as you stated, for a record 
number then the match pattern should be for column zero: $rec[0] =~ 
/$pattern/ Could you please clarify your intent?



--

Just my 0.0002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]