joerchb2003 schrieb am 13. Januar 2004 15:55
> %%% SNIP %%%
>
>
> sub section_tag {
>
> my $sub_key = $_[0] ;
> my $sub_val = $_[1] ;
> my $sub_string = $_[2];
>
> # hier habbich das vorher mit if abgefragt, hat dies aber nicht
> # für die aktuelle Zeile mehr getan ...
>
> for ( $sub_string ) {
> /$sub_key/ and do {
> $sub_string =~ s/$sub_key/$sub_val/g;
> return $sub_string;
> last;
> };
> }
> }
>
> %%% SNAP %%%
>
> %%% SNIP %%%
>
> %section_hash = (
> "HEADER" => "<header>",
> "-- BLABLABLA INCLUDES" => "</header><includes>",
> "-- DINGSBUMS FILE DECLARATIONS" =>
> "<includes></file_declarations>",
> "Abc and Cde" => "</file_declarations><abc_and_cde>",
> "<AC>" => "nix",
> "Abc" => "<abc>",
> "Cde" => "<cde>",
> "</AC>" => "nix"
> );
>
>
> %%% SNAP %%%
>
> %%% SNIP %%%
>
LINES:
> foreach $newline ( @input_lines_stage_1 ){
>
>
> MATCH: foreach $key (%section_hash ){
Da du augenscheinlich nur über die Keys des Hashes iterieren willst,
fehlt da offensichtlich ein "keys", i.e.
MATCH: foreach $key (keys %section_hash ){
>
> $write_line = section_tag ($key, $section_hash{$key},
> $newline);
>
> if ($write_line){
>
> print TPX $write_line ;
next LINES ;
statt
> last MATCH ;
>
> } else {
>
> next MATCH ;
>
> }
Der else-Zweig kann weggelassen werden...
>
> }
>
Und hier fehlt kein "print $newline"? So gibt er nur veränderte
Zeilen aus...
>
> }
Was du allerdings tatsächlich vorhast, ist mir auch nicht klar.
20%
20%
20%
20%
20%
20%
20%
20%
20%
20%
20%
20%
20%
> %%% SNIP %%%
>
>
> sub section_tag {
>
> my $sub_key = $_[0] ;
> my $sub_val = $_[1] ;
> my $sub_string = $_[2];
>
> # hier habbich das vorher mit if abgefragt, hat dies aber nicht
> # für die aktuelle Zeile mehr getan ...
>
> for ( $sub_string ) {
> /$sub_key/ and do {
> $sub_string =~ s/$sub_key/$sub_val/g;
> return $sub_string;
> last;
> };
> }
> }
>
> %%% SNAP %%%
>
> %%% SNIP %%%
>
> %section_hash = (
> "HEADER" => "<header>",
> "-- BLABLABLA INCLUDES" => "</header><includes>",
> "-- DINGSBUMS FILE DECLARATIONS" =>
> "<includes></file_declarations>",
> "Abc and Cde" => "</file_declarations><abc_and_cde>",
> "<AC>" => "nix",
> "Abc" => "<abc>",
> "Cde" => "<cde>",
> "</AC>" => "nix"
> );
>
>
> %%% SNAP %%%
>
> %%% SNIP %%%
>
LINES:
> foreach $newline ( @input_lines_stage_1 ){
>
>
> MATCH: foreach $key (%section_hash ){
Da du augenscheinlich nur über die Keys des Hashes iterieren willst,
fehlt da offensichtlich ein "keys", i.e.
MATCH: foreach $key (keys %section_hash ){
>
> $write_line = section_tag ($key, $section_hash{$key},
> $newline);
>
> if ($write_line){
>
> print TPX $write_line ;
next LINES ;
statt
> last MATCH ;
>
> } else {
>
> next MATCH ;
>
> }
Der else-Zweig kann weggelassen werden...
>
> }
>
Und hier fehlt kein "print $newline"? So gibt er nur veränderte
Zeilen aus...
>
> }
Was du allerdings tatsächlich vorhast, ist mir auch nicht klar.
20%
20%
20%
20%
20%
20%
20%
20%
20%
20%
20%
20%
20%