Array element & string variable


 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Array element & string variable
# 1  
Old 05-26-2010
Array element & string variable

Hello,

I am trying to assign
Code:
$string = $a[0]; #a[0]= 10100

Code:
print " $string"; # showing 10100

I am using this $string as $result = index($string, $char, $offset);

As above, is not capturing binary nos. in following format;
Code:
$string = '10100';

so index is not working.

kindly suggest.

Last edited by Yogesh Sawant; 05-28-2010 at 08:29 AM.. Reason: added code tags
# 2  
Old 05-26-2010
What kind of shell are you using ?
# 3  
Old 05-28-2010
I am using MS DOS.
in windows XP platform.
# 4  
Old 05-28-2010
It's a UNIX forum here. You should post Windows or DOS questions there : Windows & DOS: Issues & Discussions
# 5  
Old 05-29-2010
Hi mate!

Is it Perl Smilie

$result = index($string, $char, $offset);

What did you expect $result to be Smilie Did you set $char Smilie Did you set $offset Smilie
Are you sure index is the right function to get that thing done Smilie Smilie Using the Perl index() function

Please post your complete script and the wanted output if you need further help Smilie

PS: Are you the guy with Perl 8.5? Smilie Smilie

Last edited by pseudocoder; 05-29-2010 at 04:57 AM..
# 6  
Old 05-31-2010
It is capturing binary nos. in the index format.It was the looping statement that was not allowing it to read.Now I corrected it.

Thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding an element to a bash array with a variable

Hello, I have a simple task and I am having some trouble with the syntax. I have a variable with an assigned value, CMD_STRING='-L 22 -s 0 -r -O -A i -N 100 -n' I would like to add that variable to an array. As far as I have been able to look up, the syntax should be something like, ... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

2. UNIX for Advanced & Expert Users

Array Element

This question is for someone that's more familiar with Array Element. I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024? param_array="$param_nam" counter=$counter+1 #to avoid space... (3 Replies)
Discussion started by: cumeh1624
3 Replies

3. Shell Programming and Scripting

Multiplying array element

I am trying to take all the elements of an array and multiply them by 2, and then copy them to a new array. Here is what I have i=0 for true in DMGLIST do let DMGSIZES2="${DMGSIZES}"*2 let i++ done unset i echo ${DMGSIZES2} It does the calculation correctly for the first element,... (7 Replies)
Discussion started by: nextyoyoma
7 Replies

4. Emergency UNIX and Linux Support

Assigning zero to element of ksh array.

set -A matched #find referenced files. for i in ${file_names_html} do counter_j=0 for j in ${file_names_minus_index} do match=`cat $i | grep... (1 Reply)
Discussion started by: robin_simple
1 Replies

5. Shell Programming and Scripting

How to assign an array element to a variable

Hi every one.. I'm new to shell scripting... I would like to assign a single array element to a variable... Is it possible to do it.... Could any body help me.... (3 Replies)
Discussion started by: kaushik_87
3 Replies

6. Shell Programming and Scripting

remove an element from array

I need to remove an element from the below array variable TABLENAME. #!/bin/ksh set -A TABLENAME "mirf roxar keke mirs" echo "the array is ${TABLENAME}" If i need to remove say keke and have the final TABLENAME as below, how this could be achieved. Pls throw some light. echo "Modified... (3 Replies)
Discussion started by: michaelrozar17
3 Replies

7. Shell Programming and Scripting

Shift array element

I want to delete and 0th element of array in shell scrpit and also shift all others to one level up. (2 Replies)
Discussion started by: darshakraut
2 Replies

8. UNIX for Dummies Questions & Answers

How to check a particular element in a string variable

Hi, I have a string variable containing value say abc123 I want to check if the 3rd element of this string is "c" in a if statement.Actually i dont know the syntax of how to use substring in an if statement in shell script. Please reply soon. Regards Navjot (3 Replies)
Discussion started by: navjotsingh
3 Replies

9. Shell Programming and Scripting

Remove an element from an array in PERL

Hello guys, I have the following question. Consider the following code in PERL for($xeAnumber=0; $xeAnumber<@xeAnumber; $xeAnumber++) { if(@xeAnumber==@final_file) { @final_file=@xeTimeStamp; }... (3 Replies)
Discussion started by: chriss_58
3 Replies

10. Shell Programming and Scripting

accessing my first element of array

Hello everyonel, I have an array set like so num=4 read name arr=name I go through while loop to assign different values to different array element from 1 to 4. when I try to access the FIRST element of the array I get the last one first. Like if I say ${arr} it will show the last element... (4 Replies)
Discussion started by: afadaghi
4 Replies
Login or Register to Ask a Question