in reply to no good a chomping
That loops through the file, dropping any trailing whitespace (e.g a newline), then splits on the colon and assigns the left side of the colon to $user and the right side to $pass (the code assumes that your data will only ever look like user:pass). See. split for more info on splitting a string.#!/usr/bin/perl open USRS, "users" or die "can't open file: $!"; while(<USRS>) { chomp; my($user, $pass) = split ':'; # do stuff with $user and $pass } close USRS;
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: no good a chomping
by Skeeve (Parson) on Jun 13, 2003 at 12:03 UTC | |
by Lachesis (Friar) on Jun 13, 2003 at 12:13 UTC |