473,606 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Perl output to a file

5 New Member
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 3634
RonB
589 Recognized Expert Moderator Contributor
Ok, you already know about the open and print functions, so what's stopping you?
Sep 19 '16 #2
akhilciba
5 New Member
Am new to programme i tried different way but i couldn't make it
Sep 20 '16 #3
akhilciba
5 New Member
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 Recognized Expert Moderator Contributor
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
2565
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: "cdrom.html". 2. "use File::Basename;", with the line: ($name,$path,$suffix) = fileparse($File::Find::name, ('.html', '.m'));
2
13478
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 background so my approach may not be the best way to tackle this. However, from the research I have done this approach seems reasonable. Also, I know about the undocumented procedure sp_MSforeachtable. That can give me a
10
8138
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. Thanks
3
4651
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 <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> #include "util.h" //Main Loop
5
2408
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 that text file in one line. I want the progream to insert a new line anytime it sees the new line in the text file. for example, my text file looks like this. 1-database one was in here. where have you been these day. 2- I am not sure what do...
1
2172
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. #!/usr/bin/perl print "Content-type:text/html\n\n"; require "Art-Net.ph"; use IO::Socket; use warnings; print $NETID0;
4
3258
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 ::: Open(OUTFILE, ">$curDir/file2.out"); print OUTFILE "$result1\n\n"; close(OUTFILE);
0
1800
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; public class project { public static void main( String args ) {
1
2664
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
2779
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; print OUT "There are $array values in the file: "; @cents;
0
7939
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8428
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8078
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8299
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6753
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5962
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3919
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2442
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.