473,569 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Splice function

1 New Member
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 2017
KevinADC
4,059 Recognized Expert Specialist
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
3317
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, section 9.2.6, pg 144). I'm using IE6. var a = new Array( 1,2,3,4,5 ); document.write( a.splice( 0 ) ); // returns "", should return "1,2,3,4,5"
2
5209
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 down to a very simple test case which can be cut-n-pasted into a .html file and viewed in a browser: ...
2
2534
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 elts. may be invalidated. I have one system (Linux gcc) which outputs: 0 3 and another (HP aCC) which outputs:
6
4731
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
5391
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 if you execute the latter, the size of the resulting lists cannot be known without explicitly counting the sizes of the new lists. I was thinking:...
1
2971
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: var arr1 = ; arr1 = "a"; arr2 = "d";
1
1255
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 would like to delete. My plan is use javascript to delete the null values from the textboxes so the length of that element will correspond with the...
18
1817
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
2206
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 reason, this goes down to how the hardware works. They have the advantage of being super efficient but this comes at the expense of some...
0
7703
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
7926
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
8138
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...
1
7679
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...
0
7983
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...
1
5514
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
3657
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...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1228
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.