Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while(<TOCFILE>)
- {
- $toc_line = $_;
- $toc_line =~ s/<inlineFig.*?(../pics/ch09_inline99_*?.jpg)*?</inlineFig>/<img src="${1}" alt="" />/g;
- $new_toc_file .= $toc_line;
- }
- <img src="../pics/ch09_inline99_00" alt="" />
- <img src="" alt="" />
- inline99_*?.jpg
- ^^^
- ($PATTERN)*?
- $_ = 'one two three';
- s/(w+s*)*/$1/;
- print;
- while(<TOCFILE>)
- {
- $toc_line = $_;
- $toc_line =~
- s/ # replace the follwoing
- <inlineFig # match this text
- .*? # then any characters until the next sequence matches
- ( # throw the match into $1
- ../pics/ch09_inline99_ # ..picscho9_inline99_
- d*?.jpg # folowed by 0 or more numbers
- )*? # keeping doing that until the next sequence matches
- </inlineFig> # match this text
- / # with the follwoing
- <img src="${1}" alt="" /> # some text and the result of $1 above.
- /xg; # <- the x makes it ignore whitespace and #comments
- $new_toc_file .= $toc_line;
- }
- #!/usr/bin/perl
- use warnings;
- use strict;
- my $new_toc_file;
- {
- # localizing $_ protects any existing value in the global $_
- # you should localize $_ even if you choose to assign it to a variable
- local $_;
- while(<DATA>) {
- # in the absence of the bind operator =~, s/// operates against $_
- s!<inlineFig.*?(../pics/ch09_inline99_.*?.jpg)</inlineFig>!<img src="$1" alt="" />!g;
- $new_toc_file .= $_;
- }
- }
- print $new_toc_file, "n";
- __END__
- <inlineFig>../pics/ch09_inline99_00.jpg</inlineFig>
Add Comment
Please, Sign In to add comment