Sponsored Content
Full Discussion: String Array
Top Forums UNIX for Dummies Questions & Answers String Array Post 302096399 by tmarikle on Wednesday 15th of November 2006 11:09:01 AM
Old 11-15-2006
Code:
str="name1,name2,name3, "

typeset IFS=' ,'
for i in $str
do
    echo $i
done

works with both ", " and ","
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

string to array

Hi Experts, I'm new to Shell Scripting world and need a little help from you "Scripting Gurus". I want to convert a string (entered by a user) to array in csh. I want something like this: echo "Enter the Numbers: " set num = $< Suppose, user enters: 1 2 3 4 5 6 7 This... (6 Replies)
Discussion started by: sumitgarg
6 Replies

2. Shell Programming and Scripting

how to convert array into the string

Hi I have a line/string as follows: A=" 3498 NORDEA - INDX LINKED NORY" which was converted into an array of characters: p321$ echo "${ARR}" 3 4 9 8 N O R D E A - I N D X L I N K E D N O R Y When I am trying print this array there are blank... (4 Replies)
Discussion started by: aoussenko
4 Replies

3. Programming

String Array in java

Hi , I wonder how I can set up an String array in java. I need the array so I can store different items per line so each item will be like one record. I tried something like : String x = new String; but when it comes to storing the data and retrieve the is when I struggle. The... (2 Replies)
Discussion started by: arizah
2 Replies

4. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

5. Homework & Coursework Questions

passing letters from an array into a string for string comparison

attempting the hangman program. This was an optional assignment from the professor. I have completed the logical coding, debugging now. ##I have an array $wordString that initializes to a string of dashes ##reflecting the number of letters in $theWord ##every time the user enters a (valid)... (5 Replies)
Discussion started by: lotsofideas
5 Replies

6. Shell Programming and Scripting

Shell string array

Hi all, I want to create an array variable in shell, for example: #!/bin/sh name="foo" name="bar" name="baz" But above code didn't work, I also tried with: name=(foo bar baz) and set -A name foo bar baz but none of these worked. Another question is how to know the shell... (6 Replies)
Discussion started by: Roy987
6 Replies

7. Shell Programming and Scripting

How to use string in array name?

Hi, I'm the beginner in bash scripting and I just want to create loop, which will create a few tables with string in name, and each time i try to do this in the following way, I receive: a=1; while do echo "Plik a=$a" for m in {1..4} do echo "Plik m=$m" ... (7 Replies)
Discussion started by: masterqu
7 Replies

8. UNIX for Beginners Questions & Answers

How to split a string into array?

value=malayalam # i need to store the value in an array by splitting the character #the output i need is m a l a y a l a m Please use CODE tags for output data as well as required by forum rules! (5 Replies)
Discussion started by: Meeran Rizvi
5 Replies

9. UNIX for Beginners Questions & Answers

awk Associative Array and/or Referring to Field by String (Nonconstant String Value)

I will start with an example of what I'm trying to do and then describe how I am approaching the issue. File PS028,005 Lexeme HRS # M # PhraseType 1(1:1) 7(7) PhraseLab 501 503 ClauseType ZYq0 PS028,005 Lexeme W # L> # BNH # M #... (17 Replies)
Discussion started by: jvoot
17 Replies

10. UNIX for Beginners Questions & Answers

How to split the string value to an array?

Test1.txt Tom is hot Test.sh filename="/directory/Test1.txt" set - A store while IFS= read value do awk '{split($value,store," ")}' done < "$filename" echo ${#sore} From the code in the executing file, I would like each... (8 Replies)
Discussion started by: TestKing
8 Replies
Mojo::Base(3pm) 					User Contributed Perl Documentation					   Mojo::Base(3pm)

NAME
Mojo::Base - Minimal base class for Mojo projects SYNOPSIS
package Cat; use Mojo::Base -base; has 'mouse'; has paws => 4; has [qw(ears eyes)] => 2; package Tiger; use Mojo::Base 'Cat'; has stripes => 42; package main; use Mojo::Base -strict; my $mew = Cat->new(mouse => 'Mickey'); say $mew->paws; say $mew->paws(5)->ears(4)->paws; my $rawr = Tiger->new(stripes => 23); say $rawr->ears * $rawr->stripes; DESCRIPTION
Mojo::Base is a simple base class for Mojo projects. # Automatically enables "strict", "warnings" and Perl 5.10 features use Mojo::Base -strict; use Mojo::Base -base; use Mojo::Base 'SomeBaseClass'; All three forms save a lot of typing. # use Mojo::Base -strict; use strict; use warnings; use feature ':5.10'; # use Mojo::Base -base; use strict; use warnings; use feature ':5.10'; use Mojo::Base; push @ISA, 'Mojo::Base'; sub has { Mojo::Base::attr(__PACKAGE__, @_) } # use Mojo::Base 'SomeBaseClass'; use strict; use warnings; use feature ':5.10'; require SomeBaseClass; push @ISA, 'SomeBaseClass'; use Mojo::Base; sub has { Mojo::Base::attr(__PACKAGE__, @_) } FUNCTIONS
Mojo::Base exports the following functions if imported with the "-base" flag or a base class. "has" has 'name'; has [qw(name1 name2 name3)]; has name => 'foo'; has name => sub {...}; has [qw(name1 name2 name3)] => 'foo'; has [qw(name1 name2 name3)] => sub {...}; Create attributes, just like the "attr" method. METHODS
Mojo::Base implements the following methods. "new" my $object = BaseSubClass->new; my $object = BaseSubClass->new(name => 'value'); my $object = BaseSubClass->new({name => 'value'}); This base class provides a basic object constructor. You can pass it either a hash or a hash reference with attribute values. "attr" $object->attr('name'); BaseSubClass->attr('name'); BaseSubClass->attr([qw(name1 name2 name3)]); BaseSubClass->attr(name => 'foo'); BaseSubClass->attr(name => sub {...}); BaseSubClass->attr([qw(name1 name2 name3)] => 'foo'); BaseSubClass->attr([qw(name1 name2 name3)] => sub {...}); Create attributes. An array reference can be used to create more than one attribute. Pass an optional second argument to set a default value, it should be a constant or a sub reference. The sub reference will be excuted at accessor read time if there's no set value. DEBUGGING
You can set the "MOJO_BASE_DEBUG" environment variable to get some advanced diagnostics information printed to "STDERR". MOJO_BASE_DEBUG=1 SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Base(3pm)
All times are GMT -4. The time now is 03:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy