473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Perl output to a file

Hai there i have a perl code as follows


Expand|Select|Wrap|Line Numbers
  1.  open(DATA1,'blastout');
  2. while(<DATA1>)
  3.  
  4.  {
  5.    my @data = split /\t/,$_;
  6.    print "@data\n" if $data[3]>=$ln;
  7. }
  8.  
i want to save this printed data into a file
Sep 19 '16 #1
4 3620
RonB
589 Expert Mod 512MB
Ok, you already know about the open and print functions, so what's stopping you?
Sep 19 '16 #2
Am new to programme i tried different way but i couldn't make it
Sep 20 '16 #3
Expand|Select|Wrap|Line Numbers
  1. open(DATA1,'blastout');
  2. while(<DATA1>)
  3.  
  4.  {
  5.   open (OUTFILE, ">upcase");    
  6.   my @data = split /\t/,$_;
  7.   print OUTFILE $_ if $data[3]>=$ln;
  8.    }
  9.  
I tried this way but there is nothing outputted on upcase file
Sep 20 '16 #4
RonB
589 Expert Mod 512MB
Expand|Select|Wrap|Line Numbers
  1. open (OUTFILE, ">upcase");
That needs to be before the while loop and you should add error checking.

Expand|Select|Wrap|Line Numbers
  1. open(DATA1,'blastout');
  2. open (OUTFILE, '>', 'upcase') or die "failed to create 'upcase' <$!>";
  3.  
  4. while(<DATA1>) {  
  5.   my @data = split /\t/, $_;
  6.   print OUTFILE $_ if $data[3] >= $ln;
  7. }
  8.  
Sep 20 '16 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Xah Lee | last post by:
Just bumped into another irresponsibility in perl. the crime in question this time is the module File::Basename. Reproduction: 1. create a directory containing a file of this name:...
2
by: Bob | last post by:
Everybody, I've been doing a lot of on-line research and cannot find any reference to the exact problem I'm having. Let me preface this question with the fact that I'm coming from an Oracle...
10
by: tram | last post by:
How do we pass on the step1 output file to step2 of the same job? I would like to know the current job's output file programmetically, instead of hard coding it. Any idaes would be appreciated. ...
3
by: undshan | last post by:
I am writing a code that needs to open a file, create an output file, run through my function, prints the results to the output file, and closes them within a loop. Here is my code: #include...
5
by: beginnerperl | last post by:
Hello All, I am writing a perl program that pars through a text file and find a particular word and reverse the word. I can do that fine, but when creating the output file, the output files gives me...
1
by: kardon33 | last post by:
I have a Perl Header file i need to include so i can call stuff out of it. Heres my code. The problem in on 8 and 9, when i try to print a variable out of the header file it does not work. ...
4
by: chandru1985 | last post by:
Hi Guys , Can u help me out in Pel Coding as i'm new to perl . Can any one of them say whether it to print a line in a colored way in the output file using Filehandler .. Codin is :::...
0
by: jebbyleezer | last post by:
Hello, I have source code that builds correctly, however, after the program terminates the output file produced is empty. Here is my source code: import java.io.*; import java.util.Scanner;...
1
by: dwaterpolo | last post by:
Hi Everyone, I am trying to read two text files swY40p10t3ctw45.col.txt and solution.txt and compare them, the first text file has a bunch of values listed like: y y y y y y y
5
by: chen shen | last post by:
Hi, I am trying to write to an output file. but "\n" does not do its job. Here's part of my perl code: open(OUT, ">dollars.txt") || die("could not write to a file!"); $array = @array;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.