problem with simple pattern matching



Hi,

I hope this is simple, as i am very new to perl.

I am trying to use pattern matchinig to create many srcipts from
a template file which i have read into a list then print out to files.

the problem is the patter match only matches on the first 2 successful matches
after that it keeps the valuse found in those first 2 successes and writes them out
after that

the sub below is called in a for loop which pulls out some new data to fill the args

Thanks

Jim

the lines im trying to match are

#! DATASET="C:\jim\MinePlan\StratMinePlan\Data_In\2007\2 year detailed stage plan\DGN_IN.dgn"
DEFAULT_MACRO SourceDataset_IGDS_1 C:\jim\MinePlan\StratMinePlan\Data_In\2007\2 year detailed stage plan\DGN_IN.dgn
#! DATASET="C:\jim\MinePlan\StratMinePlan\Data_In\2007\2 year detailed stage plan\CSVOUT"
DEFAULT_MACRO DestDataset_CSV_1 C:\jim\MinePlan\StratMinePlan\Data_In\2007\2 year detailed stage plan\CSVOUT
#! DATASET="C:\jim\MinePlan\StratMinePlan\Data_In\2007\2 year detailed stage plan\DESTDIR"
DEFAULT_MACRO DestDataset_MAPINFO_1 C:\jim\MinePlan\StratMinePlan\Data_In\2007\2 year detailed stage plan\DESTDIR

as i said the first file out is written with the bits filled in correctly ... but only the first :(

sub mk_fme_from_template
{

my $data_class = shift;
my $dgn_fname = shift;
my $prediction_year = shift;
my $dgn_src_dir = shift;
my $mapinfo_dest_dir = shift;
my $mapinfo_text_dir = shift;
my $i = 0;

# search patterns
my $search_dgn_in = "DGN_IN";
my $search_dest_dir = "DESTDIR";
my $search_csv_out = "CSVOUT";

my $prepend;
my $curr_yr_pred = $current_year . "_" . $data_class . "_" . $prediction_year;

foreach my $line (@fme_template_file)
{

if ($line =~ m/$search_dgn_in/g)
{
if ($line =~ m/DEFAULT_MACRO/g)
{
$prepend = "DEFAULT_MACRO SourceDataset_IGDS_1 ";
} else {
$prepend = "#! DATASET=\"";
}
$line = "$prepend$dgn_src_dir\\$dgn_fname\n";
$dgn_in = 1;
}

if ($line =~ m/$search_dest_dir/)
{
if ($line =~ m/DATASET/)
{
$prepend = "#! DATASET=\"";
} else {
$prepend = "DEFAULT_MACRO DestDataset_MAPINFO ";
}
$line = $prepend . $mapinfo_dest_dir . "\"\n";
}

if ($line =~ m/$search_csv_out/)
{
if ($line =~ m/DATASET/)
{
$prepend = "#! DATASET=\"";
} else {
$prepend = "DEFAULT_MACRO DestDataset_CSV_1 ";
}
$line = $prepend . $mapinfo_text_dir . "\\" . $prediction_year . ".csv\"\n";
}

$fme_output_script[$i++] = $line;
}

write_fme_file($data_class, $prediction_year);
}

.



Relevant Pages

  • Re: Mutli Rosters within Division
    ... I am trying to make life for us (I am a shift supervisor) in managing our ... then you can determine the pattern they are on from there. ... e.g. a table of roster patterns with a starting date for each one. ... and allow the shift and crew to be assigned to each employee. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Psychology of rhythm
    ... No, listeners will automatically make the mental shift as they walk in, ... > for this to happen if the performance accented the pattern as you have ... with music though I'm afraid that my ears are just not good enough ... > or what but I tend to not want to play the keyboard cause of that. ...
    (rec.music.theory)
  • Re: Mutli Rosters within Division
    ... I suspect you realize that we can only give the broadest brush strokes as a response. ... You currently have 3 patterns, which are presumably tied to the person's job descriptions If so, and each employee has just ONE current job description, then you can determine the pattern they are on from there. ... And with the person's job description tied to the roster pattern, you can now determine the shifts for each person. ... and allow the shift and crew to be assigned to each employee. ...
    (microsoft.public.access.modulesdaovba)
  • Re: bit bashing
    ... By exactly what means do you think understanding will occur? ... characterized by choice of mask and shift value. ... 0x33333333 is the bit pattern 0101010101010101. ... Note how there are zeros in every other column. ...
    (comp.lang.c)
  • Re: Whats the point of bitshift?
    ... Because for some stuff you want to shift some pattern of bits a ... and what power of 2 the shift represents. ... final bit pattern at compile time, ... > their equivalent math expressions. ...
    (comp.lang.java.programmer)