jhs3 has asked for the wisdom of the Perl Monks concerning the following question:
Inside a script (shell script or perl) I read each line and pass the line to another script that parses the line and sets up variables for me to use. The subscript (parse-dbinfo) in Unix uses the 'cut' command to return the fields like this:bar|development|/usr/bar/db|/dbdump
With this information, my shell script can work with the variables to get work done. I can refer to a specific database by '$DBDIR/$DB' to get '/usr/bar/db/bar'.DB=`echo $1 | cut -f 1 -d "|"` HOST=`echo $1 | cut -f 2 -d "|"` DBDIR=`echo $1 | cut -f 3 -d "|"` DUMPDIR=`echo $1 | cut -f 4 -d "|"`
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parse a pipe-delimited list
by ptum (Priest) on Sep 20, 2006 at 16:41 UTC | |
|
Re: Parse a pipe-delimited list
by EvanCarroll (Chaplain) on Sep 20, 2006 at 16:43 UTC | |
by grep (Monsignor) on Sep 20, 2006 at 17:14 UTC | |
|
Re: Parse a pipe-delimited list
by rodion (Chaplain) on Sep 20, 2006 at 17:51 UTC |