473,574 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Perl - how to skip a line

6 New Member
Hi,

I am new to perl. I want to open a flle with some data and skip the fisrt line, and write to another file.

Source File: source.txt

Data: Bank Acct - Cheking
Balance: $230
Customer: Tom
-------
------

Target File should only contain all the lines, except the first one

target: target.txt

Data: Balance: $230
Customer: Tom
-------
------

Thanks for help on this...
Sep 21 '07 #1
3 12719
numberwhun
3,509 Recognized Expert Moderator Specialist
Hi,

I am new to perl. I want to open a flle with some data and skip the fisrt line, and write to another file.

Source File: source.txt

Data: Bank Acct - Cheking
Balance: $230
Customer: Tom
-------
------

Target File should only contain all the lines, except the first one

target: target.txt

Data: Balance: $230
Customer: Tom
-------
------

Thanks for help on this...
You have posted your question under Perl Articles instead of the Perl Forum.
I have moved it across for you.

Please post all questions to the Perl Forum in the future!


- MODERATOR
Sep 21 '07 #2
KevinADC
4,059 Recognized Expert Specialist
Expand|Select|Wrap|Line Numbers
  1. open(FH,"yourfile") or die "$!";
  2. readline(FH); #<-- read the first line effectively skipping it
  3. while(<FH>){
  4.    print $_;
  5. }
Sep 21 '07 #3
SANDY1722
6 New Member
You have posted your question under Perl Articles instead of the Perl Forum.
I have moved it across for you.

Please post all questions to the Perl Forum in the future!


- MODERATOR

------------------------------------------------------

Thanks a lot
Sep 22 '07 #4

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

Similar topics

3
3398
by: Caj Zell | last post by:
Hello, I am looking a little bit at python and am curious of one thing I often use in perl. Suppose, I want to change the string "best_composer" to "Zappa" in a document called facts.txt, then in perl I would do perl -pi.bak -e "s/best_composer/Zappa/;" facts.txt Can I do that with python from the command line so easily?
4
2460
by: Tom Allison | last post by:
I'm stuck on something stupid. I'm trying to use perl to open up a database handle and I can't find the right database dsn string. my $data_source = "dbi:Pg:mydatabase"; my $username = "mydatebasereader"; my $auth = "secret"; my $dbh = DBI->connect($data_source, $username, $auth);
8
1824
by: gooop | last post by:
I am new to perl. I am having trouble with this code line I wrote. On the third line I keep getting this message when I go to run this. This is just the first part of the code. Please any advice would help.I am using TextPad, and window xp pro os. Usage:C:\Perl\ch1\ filename at C:\Perl\ch1\ line 4, <> line 1. Press any key to continue . . ....
1
1286
by: gooop | last post by:
I am new to perl. I am having trouble with this code line I wrote. On thef fourth line I keep getting this message when I go to run this. . Please any advice would help.I am using TextPad, and window xp pro os.This program is suppose to make a modified copy of a text file. In the copy ,every string Fred should be replaced with Larry. I want to...
6
4386
by: jimwest1995 | last post by:
Hi! I have a text file with 60 lines in it and I need to skip to line 51 to begin processing. In VB6 there was .SkipLine but I don't see that function in VB.Net. Any suggestions on how to do this? Thanks,
2
2435
by: ogo796 | last post by:
hi all i am having a problem with reading the lines from the text file my file look like this: #"11-02-2008 " chief vs tumi "1234" "12-02-2008 " duma vs duma "1254" i am wondering if the is any function that will can help me to skip the line begin with hash.
13
25756
by: youngjin.michael | last post by:
Hello, I am new to Python and have one simple question to which I cannot find a satisfactory solution. I want to read text line-by-line from a text file, but want to ignore only the first line. I know how to do it in Java (Java has been my primary language for the last couple of years) and following is what I have in Python, but I don't...
10
1999
by: babno | last post by:
The console freezes and I get this error message when I search the array is loaded in from a file. the interesting thing though, is the error only comes up if the search is there. if it isn't then it works fine. print"What is the section name"; $input=<STDIN>; chomp($input); $t=0; $m=7; $v=$i;
3
1925
by: ulnanewbie | last post by:
Can some one help me to understand the below perl code line: 1. my @myarray; 2. $myarray {testscore} =0; 3. $myarray {testgrade} = "none"; I understand the code line #1, it is basically declaring the array.
1
5818
by: santhanalakshmi | last post by:
Hi, In Windows 2003, i installed the Active Perl. When i log into this system, i am facing this error "Perl command line interpreter encountered a problem and needed to close" Error Signature: szAppName: perl.exe szAppVer:5.6.1.631 szModName:ntdll.dll szModVer:5.2.3790.3959 offset:000la379 Error Report Contents:...
0
7807
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7730
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...
0
8058
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8241
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...
0
8100
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...
0
6456
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...
1
5624
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...
0
3742
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...
1
1344
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.