[ale] [OT] sed/php/bash-script programming question

jonathan glass (ibb) jonathan.glass at ibb.gatech.edu
Sun Oct 27 19:57:20 EST 2002


In a perfect world, yep...but this is reality and the ballots are
controlled by students, so nope.  That uniq command did the trick. Thank
you.

One more questions for the experts here:

I have modified the script, and now it creates the MySQL tables
correctly (thanks to Danny Cox)...but the PHP Array portion has an extra
comma, and I cannot figure out how to strip out ONLY the last comma of a
text file.  I've been tinkering with sed, and the man pages say to use
"$", but I cannot get it to work!  Every time I try, I end up removing
ALL the commas! (sed  $s/","/g /tmp/vote-array.tmp) ARGH!  Any tips? 
Here is a sample of my output.  I output each section (GK,GH,PI,PK)
separately, so I could, in theory, remote the trailing "," if I could
figure out how to replace the last character on the last line.  Any
help/thoughts/flames/ideas where in TFM to read? 

$VOTE_POST_ARRAYS = array (
"GK" => array (
"required_src_sec"=>"20",
"required_gk_crc1"=>"20",
"required_gk_crc2"=>"20",
"required_gk_crc3"=>"20",
"required_gk_cab"=>"20",
"required_male_vis"=>"20",
),
"GH" => array (
"required_sga_pol"=>"20",
"required_src_sec"=>"20",
"required_gh_vp"=>"20",
"required_gh_sec"=>"20",
"required_gh_cja"=>"20",
"required_gh_sga"=>"20",
"required_gh_cab"=>"20",
"required_male_vis"=>"20",
),
"PK" => array (
"required_pk_vp"=>"20",
"required_pk_trs"=>"20",
"required_pk_sec"=>"20",
"required_pk_cja1"=>"20",
"required_pk_cja2"=>"20",
"required_pk_cja3"=>"20",
"required_pk_cja4"=>"20",
"required_pk_cja5"=>"20",
"required_pk_cja6"=>"20",
"required_pk_cja7"=>"20",
"required_pk_sga1"=>"20",
"required_pk_sga2"=>"20",
"required_pk_sga3"=>"20",
"required_pk_sga4"=>"20",
"required_pk_sga5"=>"20",
"required_pk_sga6"=>"20",
"required_pk_sga7"=>"20",
),
"PI" => array (
"required_pir_sga"=>"20",
));
~

Thanks

Jonathan Glass

On Sun, 2002-10-27 at 14:02, Danny Cox wrote:
> Jonathan,
> 
> On Sun, 2002-10-27 at 11:07, jonathan glass (ibb) wrote:
> > echo "CREATE TABLE GKVoteRESULTS ("
> > grep "<input" ballot.html \
> > | sed s/"[<|>]"//g \
> > | sed s/"^ *input "//g \
> > | sed s/"type=radio "//g\
> > | sed s/"value=[a-z ]* "//g \
> > | sed s/"name="//g \
> > | sed s/"$"/" varchar(20) NOT NULL,"/g
> 
>   | uniq
> 
> > echo "id int(5) NOT NULL auto_increment,
> > time timestamp(14) NOT NULL,
> > PRIMARY KEY  (id)
> > )"
> 
> 	At first blush, this ought to do it....  Can you be sure that the dups
> will always be be together?
> 
> -- 
> kernel, n.: A part of an operating system that preserves the
> medieval traditions of sorcery and black art.
> 
> Danny



---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list