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

Splice function

Hi all,

I am a newbie and trying to use splice function to read data from text file.
It seems the data doesn't have line breaks but only separated by spaces. All I know is that each row has specific byte size. I am wondering if there is any way to splice data if I know byte size of each row. I have tried by array indexing but that doesn't work very well (basically, it doesn't splice data uniformly).

-Manish

Below is the code and piece of data

Expand|Select|Wrap|Line Numbers
  1. my @morenames = split(/\s+/, $data); 
  2.  
  3.  
  4. for ($i=0; $i< 10; $i++)
  5. {
  6. my @someNames= splice(@morenames, 0, 39); 
  7.  
  8. print $someNames[0]."**\t". $someNames[2]."***\n"; 
  9. }; 
  10. close (FM); 
  11.  
Expand|Select|Wrap|Line Numbers
  1. $data='WA2000-03   WA7WMU03BTRAABADYBTRWA737360161    37360161    14394306CA1  11200004272030050120000601   450000.00   447755.82 8.583  1050000.00  1050000.0020360 3.950 0.0 0.0 1   20000   42.86 0.0001125.080  2.500 0.000 0.000 7.500 0.00011.500 0.000  1 12  1  0  009   7751          0    0.000 0.000          0.00  0.00 42.86  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2000-03   WA7WMU03BTRAAIFgMBTRWA733739236    33739236    14395138CA1  11200004132030050120000601   496000.00   491124.57 8.583   620000.00   620000.0020360 3.950 0.0 0.0 1   20000   80.00 0.0001125.080  2.500 0.000 0.000 7.500 0.00011.500 0.000  1 12  1  0  009   7141          0    0.000 0.000          0.00  0.00 80.00  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2000-01   WA1WA001BTRAAPptBBTRWA118450317    18450317    13490277CA4  43199604102026040119960510   600000.00   577178.60 7.752        0.00   750000.0020360 4.450 0.0 0.01141  0000   80.00 0.0001  0.021  2.900 0.000 0.000 7.500 0.00011.750 3.000  1 12  3  0  0Z       1          1    0.000 0.000          0.00  0.00 80.00  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2001-07   WMAWU107BTRAAQOoIBTRWMA39727615    39727615    14892061CA1  11200101042031010120010201   982000.00   986842.69 7.961  2200000.00  2200000.0020360 3.950 0.0 0.0 3   20000   44.63 1.0501125.080  2.250 0.000 0.000 7.500 0.00011.950 0.000  1 12  2 13  009   6901          1036 0.000 0.000          0.00  0.00  0.00  0.00  0.00                                                                                                                                                                WA2000-01   WA1WA001BTRAAQuNTBTRWA116367646    16367646    13490814CA1  11199311222023110119931220   380000.00   337349.51 7.052        0.00   480000.0020360 5.150 0.0 0.01341  0000   79.16 0.0001  0.021  2.200 0.000 0.000 7.500 0.00010.950 3.000  1 12  6  0  0Z       1          0    0.000 0.000          0.00  0.00 79.16  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2001-07   WMAWU107BTRAAfYmwBTRWMA43981141    43981141    14892024CA1  11200104192031050120010601   419950.00   419950.00 3.950   524990.00   534000.0020360 3.950 0.0 0.0 1   20000   79.99 1.1501125.080  2.350 0.000 0.000 7.500 0.00011.950 0.000  1 12  2 13  009   7161          0    0.000 0.000          0.00  0.00  0.00  0.00  0.00                                                                                                                                                                WA2000-01   WA1WA001BTRAAmqMUBTRWA159714881    59714881    13492651CA2  11199703242027040119970501   800000.00   827209.58 7.552        0.00  1500000.0020360 3.950 0.0 0.01242 20000   53.33 0.0001125.021  2.700 0.000 0.000 7.500 0.00011.950 2.700  1 12  0  0  009   6601          1    0.000 0.000          0.00  0.00 53.33  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2000-01   WA1WA001BTRAAsozsBTRWA156588026    56588026    13494402CA1  11199608202026090119961001   507500.00   471218.93 7.402        0.00   725000.0020360 4.750 0.0 0.0134Z  0000   70.00 0.0001110.021  2.550 0.000 0.000 7.500 0.00012.050 2.550  1 12  0  0  0Z       1          0    0.000 0.000          0.00  0.00 70.00  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2000-01   WA1WA001BTRAAzLHaBTRWA126191338    26191338    13492663CA2  11199903302039040119990501   412500.00   421376.92 7.852        0.00   550000.0020480 3.950 0.0 0.01242 20000   75.00 0.0001125.021  3.000 0.000 0.000 7.500 0.00011.950 3.000  1 12  0  0  009   6951          1    0.000 0.000          0.00  0.00 75.00  0.00  0.00WA Mutl                       N/A  ' ;
  2.  
Sep 8 '08 #1
1 2011
KevinADC
4,059 Expert 2GB
what it is you are trying to get out of the data?
Sep 8 '08 #2

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

Similar topics

6
by: Gary N. | last post by:
Hi - I'm not sure if I've found a bug with the "splice" function or if I just need better documentation. Splice doesn't work quite how O'Reilly describes it (Javascript, 4th edition, Jan 2002,...
2
by: BrianP | last post by:
Hi, I have had to invent a work-around to get past what looks like a JavaScript bug, the malfunctioning Perl-like JavaScript array functions including SPLICE() and UNSHIFT(). I have boiled it...
2
by: Mark P | last post by:
What should be the output of the following program? The SGI STL docs say that all iterators remain valid during a splice operation. The dinkumware library reference says that iterators to spliced...
6
by: danmcleran | last post by:
Is there a good way to splice two lists together without resorting to a manual loop? Say I had 2 lists: l1 = l2 = And I want a list: as the result.
19
by: Juha Nieminen | last post by:
If I'm not completely mistaken, the only reason why std::list::size() may be (and usually is) a linear-time operation is because they want std::list::splice() to be a constant-time operation, and...
1
by: agendum97 | last post by:
MSDN says splice has the following arguments: arrayObj.splice(start, deleteCount, ]]]) Thus I can insert items into an array using splice. But how do I insert an entire array? For example:...
1
by: fishctr | last post by:
Hello, I am trying to save information from a text box if the checkbox is selected. The checkboxes are dynamically created with php from mysql tables, so I don't know the index of the array that I...
18
by: dhtml | last post by:
Array.splice({}) What should it do? I think it should return a new Array with length 0. Array.splice(arr, start, deleteCount ]]) http://bclary.com/2004/11/07/#a-15.4.4.12 Example:
0
by: Michael C | last post by:
"John Brock" <jbrock@panix.comwrote in message news:gg56ab$qsn$1@reader1.panix.com... You really need to stop trying to write perl code in dot net and VBA. Arrays are hard to resize for a good...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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
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,...
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...

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.