Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Runtime hash array & text processing

Posted on 2002-05-23
10
Medium Priority
?
151 Views
Last Modified: 2013-12-25
Hi

Please tell me how to fill contents into a hash array dynamically. The hash array is empty initially and it is to be filled with key value pairs (say employee no-employee name from database )so that I can process it later.

 My another problem is I would like to get the index of a particular particular character in a string. For example I want to capitalise the first letter in 'abcd.com'. Here I want to capitalise 'a' but I would like to know the way of getting character/text indexes in a string .

Thanks in advance
0
Comment
Question by:boolee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 7030685
$hash{$employee_name} = $employee_no;

$string = ucfirst 'abcd.com';
0
 
LVL 1

Author Comment

by:boolee
ID: 7031431
HI ozo

Thanks. The hash array worked fine and I could capitalise the first letter also. But I would like to know the way of getting character/substring indexes in  strings in perl.  I know the perl regular expressions are very powerful and it can do all kinds test processing.   But still I am looking for this because I was doing my works in java and C where I could replace the character or string at a particular index.  Am i asking something that is not relevant in perl?
0
 
LVL 1

Author Comment

by:boolee
ID: 7031481
HI ozo

Thanks. The hash array worked fine and I could capitalise the first letter also. But I would like to know the way of getting character/substring indexes in  strings in perl.  I know the perl regular expressions are very powerful and it can do all kinds test processing.   But still I am looking for this because I was doing my works in java and C where I could replace the character or string at a particular index.  Am i asking something that is not relevant in perl?
0
Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

 
LVL 84

Expert Comment

by:ozo
ID: 7033295
substr($string,5,1) =~ s/(.)/\U$1/;
0
 
LVL 1

Author Comment

by:boolee
ID: 7036527
HI ozo

would u please explain me the the code

"substr($string,5,1) =~ s/(.)/\U$1/; "
0
 
LVL 84

Expert Comment

by:ozo
ID: 7038435
Capitalize the fifth letter in $string
0
 
LVL 1

Author Comment

by:boolee
ID: 7041002
Ozo

u did it in reverse... How do I know it is the fifth character? any buit in function? For example I want to know the index of second 'e' in 'aebcdefg'...
0
 
LVL 84

Expert Comment

by:ozo
ID: 7041041
'aebcdefg' =~ /e[^e]*(e)/;
print $-[1];

# or

($_ = 'aebcdefg') =~ /e[^e]*e/g;
print ((pos)-1);

# to capitalize the second e

($_ = 'aebcdefg') =~ s/(e[^e]*)(e)/$1\u$2/;


0
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
ID: 7041052
($_ = 'aebcdefg') =~ /e[^e]*/g;
print pos;

#or

print index($_,"e",index($_ = 'aebcdefg',"e")+1);


0
 
LVL 1

Author Comment

by:boolee
ID: 7041570
OK ozo...Its working.......Tell u something... pls add some explanatory comments when u post ur answers... it will be of great help... Thanks.

boolee
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question