[Webinar] Streamline your web hosting managementRegister Today


Help with script

Posted on 2000-02-09
Medium Priority
Last Modified: 2010-03-05
I have n different internet providers and I want to call them to get my mail.
os in a file I have like this:


I need a pice of code that open the file acount.txt

and read user and pass into 2 different variables and I don't know how to fix this.
I like some kind of aray
that I can step through and a counter.
so for n=1
the variable user shall have the value=user1
and pass=pass1
and for n=2 user shall have the value user2 and pass the value=2

how can I fix this
Question by:pucko
  • 3
  • 2
LVL 19

Expert Comment

by:Kim Ryan
ID: 2506807
@lines = <IN_FH>;
foreach $line (@lines)
   ($user,password) = split(/:/,$line);
LVL 51

Accepted Solution

ahoffmann earned 300 total points
ID: 2506827
foreach $l (`cat acount.txt`) {($u,$p)=split(/:/,$l);$u_p{$u}=$p;}
# keys %u_p  returns users
# values %u_p returns passwords
# $u_p{'user1'} is direct access
# to be improved anyhow
LVL 51

Expert Comment

ID: 2506829
oops, there was no comment when I made my suggestion
LVL 19

Expert Comment

by:Kim Ryan
ID: 2507251
Embedding Unix commands like 'cat' in your perl script tend to make you them less portable.
LVL 51

Expert Comment

ID: 2507327
teraplane, you're absolutely right
I usually use open(), but posted a quick&dirty solution (see my comment ;-)

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Article by: Tammy
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

640 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