473,385 Members | 1,838 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,385 software developers and data experts.

one token per line

hi sir,
this is my input

i am very happy

i want this output

i
am
very
happy

this is the program i wrote
Expand|Select|Wrap|Line Numbers
  1. open(FH, "worldaff_join.txt") or die("error opening");
  2. @file=<FH>;
  3. foreach $line (@file)
  4. {
  5.  @sentence=split(/ /,  $line);
  6. print"@sentence";
  7. }
  8. close(FH);
  9.  
but the output is not what i wanted
Feb 1 '10 #1
2 1560
chaarmann
785 Expert 512MB
your words are in an array now:

@sentence=("i", "am", "very", "happy");

You must loop through the array and print each array element:

foreach (@sentence){print "$_\n";}
Feb 1 '10 #2
chaarmann
785 Expert 512MB
I found another way without loop:

print join("\n",@sentence);
Feb 1 '10 #3

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

Similar topics

5
by: Andrew James | last post by:
Gentlemen, I'm running into a problem whilst testing the parsing of a language I've created with TPG . It seems that for some reason, TPG balks when I try to parse an expression whose first...
3
by: Frodo Baggins | last post by:
Hi All, I have a piece of code (not written by me) that is failing on compile with the error: pasting "xdr_ndmp_connect_open_request" and "," does not give a valid preprocessing token The...
14
by: Simon Morgan | last post by:
I'm trying to write a function to parse a Reverse Polish Notation string from stdin and return 1 token at a time. For those of you who are unaware an RPN string looks like this: 1 2 + 4 * 3 + ...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
1
by: Hollywood | last post by:
Hello dear membres of the comp.unix.programmer. Please , I've got the following question to submit and I need your help. Here below you'll find a lexical and a syntaxic analysers. The lexical...
4
by: Roger Aikin | last post by:
I've converted a VB6 project to VB.Net 2005. (Actually using vstudio pro 2005). I'm on a machine that also has VB6 and Vstudio.net 2003 on it. The project uses Word, Excel, MapPoint and SqlClient...
7
by: Mark Odell | last post by:
I'm running two different compilers against some hairy macros and one, gcc, doesn't like my token pasting result so much. It says, " "." and "foo" does not give a valid preprocessing token ". Some...
1
by: Ben Walling | last post by:
I'm getting the following error on one of 110 machines that is using a webservice to upload database changes to a central location: System.Web.Services Server was unable to read request. --There...
5
by: amitmool | last post by:
hi, i have used the queue library file and try to use the template as template <class QueueItem> queue <QueueItem>::~queue() // line 25 { } template <class QueueItem> void...
10
by: preeya | last post by:
Hi, I have written the following program: ------------------------------------------------------------------------------------------------------------- 1 #include <stdio.h> 2 #include...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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,...
0
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...

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.