Solved

Opening and Printing out

Posted on 2000-02-16
5
136 Views
Last Modified: 2010-03-05
#!/usr/bin/perl

                 open(IN,"</home/tmclaugh/list/text.txt") || die "cannot open file>:!";
                 open(OUT,">/home/tmclaugh/list/zinger1.txt") || die "Cannot open file>:!";

                 $/='ACCESSION NUMBER             : ';
                 printf("%20s %20s %s\n",
                      "Accession Number",
                      "Word in Narrative",
                      "Sequence");
                 while(<IN>){
                      my ($an)= /(\d+)/g;
                      my @words;
                      ($_)=/NARRATIVE\s+:(.+)\n\w+\s+:/gs;
                      @words=/(\w+)(?!\n\w+\s:)/gs;
                      my $i=0;
                      for my $word (@words){
                      $i++;
                      printf("%20s %20s %d\n",
                      $an,$word,$i);
                      }
                 }
                 close(IN);
                 close(OUT);


                 will not open or print to OUT can someone help
0
Comment
Question by:tomatocans
  • 4
5 Comments
 

Author Comment

by:tomatocans
ID: 2529472
Sorry no point left
0
 

Author Comment

by:tomatocans
ID: 2529487
changed to usr/local/bin/perl got output for header to screen nothing else on screen
                 or in output file.
0
 

Author Comment

by:tomatocans
ID: 2529506
HELP
0
 
LVL 84

Accepted Solution

by:
ozo earned 0 total points
ID: 2529723
#you probably want
die "cannot open file>:$!";
#to tell you the reason for a failure

#if you want to print to OUT, you can say
printf OUT ("%20s %20s %s\n",
           "Accession Number",
           "Word in Narrative",
           "Sequence");

#what's in /home/tmclaugh/list/text.txt?
#are you sure the /NARRATIVE\s+:(.+)\n\w+\s+:/gs matches anything?
0
 

Author Comment

by:tomatocans
ID: 2538626
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now