Sponsored Content
Full Discussion: Perl substr or similar help
Top Forums Shell Programming and Scripting Perl substr or similar help Post 303025183 by Neo on Friday 26th of October 2018 08:41:45 AM
Old 10-26-2018
Excellent explaination.

Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to declare hashes in KSH similar to Perl ?

Hi, Is it possible to delcare hashes in KSH the way we do it in Perl. Like I want to declare something like: fruits="Juicy" fruits="healthy" fruits="sour" echo fruits Ofcourse this piece of code does not work in KSH. Please let me know if there is a way of doing it in KSH. ... (2 Replies)
Discussion started by: tipsy
2 Replies

2. Shell Programming and Scripting

copy substr in existing string in Perl

Any clue to write something to a particular location in Perl? Suppose $line = ‘abc cde 1234” How to write ( example string "test") on location 4 without parsing the whole line. Output should be $line = ‘abctest 1234” this is not search and replace. just to add substring into... (3 Replies)
Discussion started by: jaivipin
3 Replies

3. UNIX for Dummies Questions & Answers

substr in perl

Let's assume that I have a file with contents delimited by pipe: "The mouse|ran up|the|clock" "May|had a|little|lamb" How would I use 'substr' to get the 3rd field. For example, "the" from the first line, and "little" from the second line? # Loop over a file and read $LINE { ... (2 Replies)
Discussion started by: ChicagoBlues
2 Replies

4. UNIX for Dummies Questions & Answers

substr function in perl

Hi friends, I have written a perl code and it works fine but I am not sure tommorow it works or not, please help me. problem : When diff is 1 then success other than its failure but tomorrow its 20090401 and the enddate is 20090331. thats why I write the code this type but it does not work and... (1 Reply)
Discussion started by: tukuna82
1 Replies

5. Shell Programming and Scripting

20090620231013 to date format i am using substr, any simple way in perl?

Hi Everyone, $tmp="20090620231013"; $tmp = substr($tmp,0,8)." ".substr($tmp,8,2).":".substr($tmp,10,2).":".substr($tmp,12,2); So my output is: 20090620 23:10:13. I only can think substr is easy, any perl can do this just one line very simple efficient one? :eek: Thanks (3 Replies)
Discussion started by: jimmy_y
3 Replies

6. Shell Programming and Scripting

perl file, one line code include "length, rindex, substr", slow

Hi Everyone, # cat a.txt a;b;c;64O a;b;c;d;ee;f # cat a.pl #!/usr/bin/perl use strict; use warnings; my $tmp3 = ",,a,,b,,c,,d,,e,,f,,"; open(my $FA, "a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\;/, $_); if ( ($tmp =~ m/^(64O)/i) || ($tmp... (3 Replies)
Discussion started by: jimmy_y
3 Replies

7. Shell Programming and Scripting

Joining multiple files based on one column with different and similar values (shell or perl)

Hi, I have nine files looking similar to file1 & file2 below. File1: 1 ABCA1 1 ABCC8 1 ABR:N 1 ACACB 1 ACAP2 1 ACOT1 1 ACSBG 1 ACTR1 1 ACTRT 1 ADAMT 1 AEN:N 1 AKAP1File2: 1 A4GAL 1 ACTBL 1 ACTL7 (4 Replies)
Discussion started by: seqbiologist
4 Replies

8. Shell Programming and Scripting

Perl match multiple numbers from a variable similar to egrep

I want to match the number exactly from the variable which has multiple numbers seperated by pipe symbol similar to search in egrep.below is the code which i tried #!/usr/bin/perl my $searchnum = $ARGV; my $num = "148|1|0|256"; print $num; if ($searchnum =~ /$num/) { print "found"; }... (2 Replies)
Discussion started by: kar_333
2 Replies

9. Shell Programming and Scripting

How to use if/else if with substr?

I have a command like this: listdb ID923 -l |gawk '{if (substr($0,37,1)==1 && NR == 3)print "YES" else if (substr ($0,37,1)==0 && NR == 3) print "NO"}' This syntax doesn't work. But I was able to get this to work: listdb ID923 -l |gawk '{if (substr($0,37,1)==1 && NR == 3)print "YES"}' ... (4 Replies)
Discussion started by: newbie2010
4 Replies

10. UNIX for Dummies Questions & Answers

Substr

awk '/^>/{id=$0;next}length>=7 { print id, "\n"$0}' Test.txt Can I use substr to achieve the same task? Thanks! (8 Replies)
Discussion started by: Xterra
8 Replies
User API Assistance.(3) 					    globus xio						   User API Assistance.(3)

NAME
User API Assistance. - Help understanding the globus_xio api. Stack Constuction. The driver stack that is used for a given xio handle is constructed using a globus_xio_stack_t. Each driver is loaded by name and pushed onto a stack. stack setup example: // First load the drivers globus_xio_driver_load('tcp', &tcp_driver); globus_xio_driver_load('gsi', &gsi_driver); //build the stack globus_xio_stack_init(&stack); globus_xio_stack_push_driver(stack, tcp_driver, NULL); globus_xio_stack_push_driver(stack, gsi_driver, NULL); Servers A server data structure provides functionality for passive opens. A server is initialized and bound to a protocol stack and set of attributes with the function globus_xio_server_create(). Once a server is created many 'connections' can be accepted. Each connection will result in an intialized handle which can later be opened. globus_xio_server_t server; globus_xio_attr_t attr; globus_xio_attr_init(&attr); globus_xio_server_create(&server_handle, attr, stack); globus_xio_server_accept(&handle, server); Handle Construction There are two ways to create a handle. The first is for use as a client (one that is doing an active open). The function: globus_xio_handle_create() is used to create such a handle and bind that handle to a protocol stack. globus_xio_handle_create(&handle, stack); The second means of creating a handle is for use as a server (one that is doing a passive open). This is created by accepting a connection on a server_handle with the function globus_xio_server_accept() or globus_xio_server_register_accept(). Mutable attrs can be altered via a call to globus_xio_handle_cntl() described later. globus_xio_server_accept(&xio_handle, server_handle); once a handle is intialized the user can call globus_xio_open() to begin the open process. Timeouts A user can set a timeout value for any io operation. Each IO operation (open close read write) can have its own timeout value. If no timeout is set the operation will be allowed to infinitly block. When time expires the outstanding operation is canceled. If the timeout callback for the given operation is not NULL it is called first to notify the user that the operation timed out and give the user a chance to ignore that timeout. If canceled, the user will get the callback they registered for the operation as well, but it will come with an error indicating that it has been canceled. It is possiblie that part of an io operation will complete before the timeout expires. In this case the opperation can still be canceled. The user will receive there IO callback with and error set and the length value appropriately set to indicate how much of the operation completed. Data Desciptor The data descriptor ADT gives the user a means of attaching/extracting meta data to a read or write operation. Things like offset, out of band message, and other driver specific meta data are contained in the data descriptor. Data descriptors are passed to globus_xio in globus_xio_read() and globus_xio_write(). Within the globus_xio framework it is acceptable to pass NULL instead of a valid data_descriptor, ex: globus_xio_data_descriptor_init(&desc); globus_xio_data_descriptor_cntl(desc, tcp_driver, GLOBUS_XIO_TCP_SET_SEND_FLAGS, GLOBUS_XIO_TCP_SEND_OOB); User Attributes Globus XIO uses a single attribute object for all of its functions. Attributes give an the user an extenable mechanism to alter default values which control parameters in an operation. In most of the globus xio user api functions a user passes an attribute as a parameter. In many cases the user may ignore the attribute parameter and just pass in NULL. However at times the user will wish to tweak the operation. The attribute structure is used for this tweaking. There are only three attribute functions. globus_xio_attr_init globus_xio_attr_cntl and globus_xio_attr_destroy. The init and destroy functions are very simple and require little explaination. Before an attribute can be used it must be intialized, and to clean up all memory associated with it the user must call destroy on it. The function globus_xio_attr_cntl manipulates values in the attribute. For more info on it see globus_xio_attr_cntl. Author Generated automatically by Doxygen for globus xio from the source code. Version 3.3 Mon Apr 30 2012 User API Assistance.(3)
All times are GMT -4. The time now is 10:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy