Hello,
I get the following error message from RUBY when I try to run the script
shown below. Sorry, the hash is huge.
I need to match the beginning of file names with the keys in a hash. If
there's a match, then I need to pull the value for that matching key.
That's all really.
Thanks,
Peter
Error:
test2.rb:7: parse error, unexpected kEND, expecting '}'
Ruby Script:
1 require 'FileUtils'
2 Dir.chdir('u:/indexes')
3 fileshash = { :aacmc7p => 'aacm00', :acm059p => 'bacm00', :acm061p =>
'bacm00', :acmc59p => 'bacm00', :acmt59p => 'bacm00', :adc064p =>
'adam00', :adm064p => 'adam00', :adm065p => 'adam00', :apr005p =>
'tmap00', :atc071p => 'atrr00', :bac054p => 'bnkr00', :bkc031p =>
'bblr00', :bpc061p => 'btm000', :cal158p => 'clas00', :car125p =>
'care00', :cbncc7p => 'cbnc00', :cgmprp_ => 'cglw00', :chc074p =>
'chem00', :chc075p => 'chem00', :clc017p => 'clr000', :crc074p =>
'crl000', :ctl157p => 'ctlr00', :dec079p => 'der000', :dlc080p =>
'dlr000', :dtc069p => 'dt0000', :edc131p => 'eddg00', :edr094p =>
'edr000', :edt131p => 'eddg00', :eeomc7p => 'eeom00', :eip066p =>
'eplr00', :emgc15p => 'emgd00', :erc023p => 'er0000', :ercr25p =>
'er0000', :exe155p => 'exer00', :fcc093p => 'fcr000', :flc046p =>
'flr000', :gec099p => 'gerr00', :hac076p => 'hzrf00', :hcc201p =>
'hccg00', :hcci01p => 'hccg00', :hcp030p => 'hce000', :hct201p =>
'hccg00', :hcti01p => 'hccg00', :hfr085p => 'hfra00', :hla020p =>
'hblw00', :hlb020p => 'hblw00', :hlr036p => 'hlr000', :hltc20p =>
'hblw00', :hpr042p => 'hppr00', :hrr081p => 'hrr000', :ierc77p =>
'iner00', :ierc78p => 'iner00', :itc010p => 'itr000', :itc101p =>
'itr000', :jsc047p => 'josh00', :lrc013p => 'lrr000', :lrc096p =>
'lrwk00', :lrfc74p => 'lrr000', :lrfl21p => 'lrr000', :lrgc68p =>
'lrr000', :lrnm21p => 'lrr000', :lrrc21p => 'lrr000', :lrrc22p =>
'lrr000', :lrrc24p => 'lrr000', :lrrc37p => 'lrr000', :lrrc49p =>
'lrr000', :lrrc74p => 'lrr000', :lrrc82p => 'lrr000', :lrrmc6p =>
'lrr000', :lrrt37p => 'lrr000', :lrt013p => 'lrr000', :lrtc68p =>
'lrr000', :lwc001p => 'lw0000', :lwc002p => 'lw0000', :lwca85p =>
'lw0000', :lwgc86p => 'lw0000', :lwsc85p => 'lw0000', :mal058p =>
'malr00', :mcc019p => 'mcr000', :mopc68p => 'mopc00', :mopd68p =>
'mopc00', :mopec8p => 'mopc00', :mopt68p => 'mopc00', :mpc067p =>
'mopc00', :mrl150p => 'mrlr00', :osbc35p => 'oshr00', :osc022p =>
'oshr00', :pec029p => 'pen000', :pgc116p => 'pygd00', :pgc117p =>
'pygd00', :plr126p => 'plir00', :psc044p => 'pslr00', :pslc45p =>
'pslr00', :psvc45p => 'pslr00', :ptcc54p => 'ptcj00', :pvl162p =>
'pvlr00', :rtc129p => 'rkpg00', :src087p => 'srlr00', :tlc100p =>
'txlr00', :tmc030p => 'tmeg00', :tmc032p => 'tmwr00', :tmc040p =>
'tmf000', :tmc045p => 'tmtr00', :tmc050p => 'tmfp00', :tmc060p =>
'tmcp00', :tmc065p => 'tmpl00', :tmc070p => 'tmeg00', :tmc080p =>
'tmi000', :tmc090p => 'tmre00', :tmc100p => 'tm0000', :tmcc20p =>
'tmcp00', :tmf186p => 'tmf000', :tmi185p => 'tmus00', :tmic20p =>
'tmus00', :tmrc20p => 'tmre00', :tms190p => 'stat00', :tmsp50p =>
'stat00', :tmt055p => 'tmtr00', :uln007p => 'ulr000', :wcr006p =>
'wcr000', :whl164p => 'wplr00', :ad137b1p => 'lrr000', :ad137b2p =>
'lrr000', :adc095 => 'lrr000', :eb062b1p => 'ebcd00', :eb161b1p =>
'ebcd00', :eb161b2p => 'ebcd00', :eb161b4p => 'ebcd00', :eb960b1p =>
'ebcd00', :eb960b2p => 'ebcd00', :er022b1p => 'er0000', :er022b2p =>
'er0000', :er121b1p => 'er0000', :er121b2p => 'er0000', :er121b5p =>
'er0000', :er901b1p => 'er0000', :er901b2p => 'er0000', :er901b3p =>
'er0000', :fe015b1p => 'lrr000', :ie005b1p => 'lrr000', :ie105b1p =>
'lrr000', :it071b1p => 'itr000', :it171b1p => 'itr000', :it171b3p =>
'itr000', :lr315b1p => 'lrr000', :lr315b2p => 'lrr000', :lrr084 =>
'lrr000', :lrr089 => 'lrr000', :lrr090 => 'lrr000', :lrr095 => 'lrr000',
:lrr096 => 'lrr000', :lrr122 => 'lrr000', :ml032b1p => 'med000',
:ml032b1t => 'med000', :ml032b2p => 'med000', :ml032b2t => 'med000',
:ml131b1p => 'med000', :ml131b1t => 'med000', :ml131b2t => 'med000',
:ml930b1p => 'med000', :ml930b1t => 'med000', :os042b2p => 'oshr00',
:os142b2p => 'oshr00', :osh034 => 'osh200', :pq181b1p => 'pq0000',
:pq181b1t => 'pq0000', :pq181b2p => 'pq0000', :pq181b3t => 'pq0000',
:pq192b1p => 'pq0000', :pq192b1t => 'pq0000', :pq192b3p => 'pq0000',
:wh650b1p => 'lrr000', :wh650b2p => 'lrr000 }
4 psfiles = Dir.glob("*.ps")
5 psfiles.each do |psfile|
6 filehash.each { |key, value| puts "#{value}" if
File.fnmatch('#{key}*', #{psfile}) }
7 end
···
--
Posted via http://www.ruby-forum.com/.