http://www.perlmonks.org?node_id=1232717

beginAgain has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have been tasked with "correcting" certain items in SVG files. I have never used Perl and after a crash course (using PerlMonks, Stack Overflow, etc.) I can successfully read the SVG file line by line and correct the necessary lines. My final problem, and this is admittedly because of my inexperience, I cannot figure out how to grab the current line so I can do a smartmatch (or something similar). All I need to do is make sure that the current line starts with "<path" and process that line if so. Below is the (partial) code where I read in the file and loop through the lines to make the corrections. EDIT - Ihave added more of the code to show what I want to do with smartmatch - NOTE thta target is set like so:
my $target = '<path';
opendir IN, $dirname; my @in = grep { /^[^.]/ } readdir IN; closedir IN; for my $in (@in) { open IN, '<', "$dirname/$in" || next; open OUT, '>', "$outdirname/$in" || die "can't open file output/$in" +; foreach(<IN>) { #read file line by line # Strings to correct Note: Escaped ( with \ s/rotate\(-180/rotate\(-0/g; # Look at the current line my @look_in = <IN>; # <path is in this line, process line if( $target ~~ @look_in) { for my $key (keys %stroke_width_hash) { s/$key/$stroke_width_hash{$key}/g; } } # Print out line to OUT file print OUT $_; } close OUT; close IN; }
I have tried (sad attempts):
Print (<IN>)
Print IN
etc.
But none of these are grabbing the actual text for that line
Any help will be greatly appreciated...
Charles