?
Solved

Runtime hash array & text processing

Posted on 2002-05-23
10
Medium Priority
?
150 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
Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

 
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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
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

764 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