Sponsored Content
Full Discussion: split question perl
Top Forums Shell Programming and Scripting split question perl Post 302080819 by reggiej on Thursday 20th of July 2006 04:49:58 PM
Old 07-20-2006
Just thought I'd revisit this cause I discovered that you can get to a specific field by using a splice. If I want the 2nd and 36th field you can do

($field2,$field36) = (split /,/, $tmpArr[$x]) [2,36];

Hope this is helpful to others.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Split and recombine question

Hi guys I would like to be able to split a large file into many smaller part. Then, these smaller files will be transfered onto a windows machine where they need to be recombined. I think tar files may be the best to do this. How can I tar a large file into many small tar files which can be... (1 Reply)
Discussion started by: white_raven0
1 Replies

2. Shell Programming and Scripting

split to array in perl

Collegues I have flat file in the following format. 137 (NNP Kerala) (NNP India) 92 (NN Rent) (NN Range) 70 (NNP Thiruvananthapuram) (NNP Kerala) 43 (NNP Tourist) (NNP Home) 40 (NNP Reserve) (NNP Now) 25 (SYM @) (NN hotelskerala) 25 (NNP Thiruvananthapuram-695001) (NNP Kerala) 23 (NN... (3 Replies)
Discussion started by: jaganadh
3 Replies

3. UNIX for Advanced & Expert Users

Split Command in Perl

Hi, I have to split a line of the form 1232423#asdf#124324#54534#dcfg#wert#rrftt#4567 into an array in perl. I am using @fields; @fields=split('#',$line); if($fields eq "1") But this is not working. By using the syntax, the statements in "if" are never executed. Please help.... (9 Replies)
Discussion started by: rochitsharma
9 Replies

4. Shell Programming and Scripting

Use split function in perl

Hello, if i have file like this: 010000890306932455804 05306977653873 0520080417010520ISMS SMT ZZZZZZZZZZZZZOC30693599000 30971360000 ZZZZZZZZZZZZZZZZZZZZ202011302942311 010000890306946317387 05306977313623 0520080417010520ISMS SMT ZZZZZZZZZZZZZOC306942190000 30971360000... (5 Replies)
Discussion started by: chriss_58
5 Replies

5. Shell Programming and Scripting

Perl split question

hi, I have a seemingly really stupid question, but here goes! What do you enter into split delimiter to seperate something like this "December 12, 1995" and get December 12 1995 ? thanks (5 Replies)
Discussion started by: ade214
5 Replies

6. UNIX for Dummies Questions & Answers

File split question

I have a flat file in UNIX and I have to perform two tasks based on the below data. The data I have printed here is just sample the original data is too long. The position 110 to 111 (two digit value I have bolded the values) theygives the record type detail in the sample above the record types... (7 Replies)
Discussion started by: techsavvy007
7 Replies

7. Programming

Perl Split Issue

Hello All - I am having trouble with the split command in perl. Here is what I am trying to do. 75|2455345|2455349|00:00:00|00:00:00|Once|0|Frank Vacation | | 5 I want to only print out the 8th column. So that would be "Frank Vacation" and "Power Down" I need to run this on a file that... (16 Replies)
Discussion started by: tarken
16 Replies

8. Shell Programming and Scripting

Perl split and join

Hi, I have tried the split and join functions but stuck with unexpected results. Any help appreciated. I pass multiple values at command line like perl test.pl -type java,xml. This works good for me but i am not sure how to print it in the required format. Here is the code i tried:... (4 Replies)
Discussion started by: nmattam
4 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Perl Question - split function with csv file

Hi all, I have a csv file that appears as follows: ,2013/03/26,2012/12/26,4,1,"2017/09/26,5.75%","2017/09/26,1,2018/09/26,1,2019/09/26,1,2020/09/26,1,2021/09/26,1",,,2012/12/26,now when i use the split function like this: my @f = split/,/; the split function will split the data that is... (2 Replies)
Discussion started by: WongSifu
2 Replies

10. Shell Programming and Scripting

Split the string in perl

Hi All, How to split the string KAR_Celltick_Ban_GSMGW3 and want to pickup the third filed. Sometime the string may be "KAR_Celltick_Ban" like this Thanks in advance (1 Reply)
Discussion started by: sujit_kashyap
1 Replies
SPLICE(2)						     Linux Programmer's Manual							 SPLICE(2)

NAME
splice - splice data to/from a pipe SYNOPSIS
#define _GNU_SOURCE /* See feature_test_macros(7) */ #include <fcntl.h> ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags); DESCRIPTION
splice() moves data between two file descriptors without copying between kernel address space and user address space. It transfers up to len bytes of data from the file descriptor fd_in to the file descriptor fd_out, where one of the descriptors must refer to a pipe. If fd_in refers to a pipe, then off_in must be NULL. If fd_in does not refer to a pipe and off_in is NULL, then bytes are read from fd_in starting from the current file offset, and the current file offset is adjusted appropriately. If fd_in does not refer to a pipe and off_in is not NULL, then off_in must point to a buffer which specifies the starting offset from which bytes will be read from fd_in; in this case, the current file offset of fd_in is not changed. Analogous statements apply for fd_out and off_out. The flags argument is a bit mask that is composed by ORing together zero or more of the following values: SPLICE_F_MOVE Attempt to move pages instead of copying. This is only a hint to the kernel: pages may still be copied if the kernel cannot move the pages from the pipe, or if the pipe buffers don't refer to full pages. The initial implementation of this flag was buggy: therefore starting in Linux 2.6.21 it is a no-op (but is still permitted in a splice() call); in the future, a correct implementation may be restored. SPLICE_F_NONBLOCK Do not block on I/O. This makes the splice pipe operations nonblocking, but splice() may nevertheless block because the file descriptors that are spliced to/from may block (unless they have the O_NONBLOCK flag set). SPLICE_F_MORE More data will be coming in a subsequent splice. This is a helpful hint when the fd_out refers to a socket (see also the description of MSG_MORE in send(2), and the description of TCP_CORK in tcp(7)) SPLICE_F_GIFT Unused for splice(); see vmsplice(2). RETURN VALUE
Upon successful completion, splice() returns the number of bytes spliced to or from the pipe. A return value of 0 means that there was no data to transfer, and it would not make sense to block, because there are no writers connected to the write end of the pipe referred to by fd_in. On error, splice() returns -1 and errno is set to indicate the error. ERRORS
EBADF One or both file descriptors are not valid, or do not have proper read-write mode. EINVAL Target file system doesn't support splicing; target file is opened in append mode; neither of the descriptors refers to a pipe; or offset given for nonseekable device. ENOMEM Out of memory. ESPIPE Either off_in or off_out was not NULL, but the corresponding file descriptor refers to a pipe. VERSIONS
The splice() system call first appeared in Linux 2.6.17; library support was added to glibc in version 2.5. CONFORMING TO
This system call is Linux-specific. NOTES
The three system calls splice(), vmsplice(2), and tee(2), provide user-space programs with full control over an arbitrary kernel buffer, implemented within the kernel using the same type of buffer that is used for a pipe. In overview, these system calls perform the following tasks: splice() moves data from the buffer to an arbitrary file descriptor, or vice versa, or from one buffer to another. tee(2) "copies" the data from one buffer to another. vmsplice(2) "copies" data from user space into the buffer. Though we talk of copying, actual copies are generally avoided. The kernel does this by implementing a pipe buffer as a set of reference- counted pointers to pages of kernel memory. The kernel creates "copies" of pages in a buffer by creating new pointers (for the output buf- fer) referring to the pages, and increasing the reference counts for the pages: only pointers are copied, not the pages of the buffer. EXAMPLE
See tee(2). SEE ALSO
sendfile(2), tee(2), vmsplice(2) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2012-05-04 SPLICE(2)
All times are GMT -4. The time now is 07:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy