Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Restarting counters in text

by Jasper (Chaplain)
on Aug 10, 2006 at 11:27 UTC ( #566589=note: print w/replies, xml ) Need Help??

in reply to Restarting counters in text

further to the other comment (correcting != to !~, I guess), if you have the whole content stored and sub out all instances of <exm>, then the second resetting line will never happen.

You need to do it line by line, and s///s does the whole thing at once.

edit This is utter nonsense, of course. What I meant to say was:

then the second resetting line will ALWAYS happen.

I don't know what way these lines are coming in - whether he's getting blocks of code with exm's, and never gets a second line containing exms that he wants to be contiguous. I've no idea, but I had sort of confused myself a bit.

Sorry for the late edit

Replies are listed 'Best First'.
Re^2: Restarting counters in text
by udinakar (Novice) on Aug 10, 2006 at 11:35 UTC
    Hi Further to the above comments. Here is the code that might work for you.
    $_ =~ s/<exm>/'<exm num="'.$exmno++.'">'/egs; if ($_ !~ /^<exm.*?$/) { $exmno=0; }
    Refer for the syntax rules before any thing fails :-) -Dinakar

    Edited - Added code tags (davorg)

      Please use <code> tags to make your code easier to read.

      if ($_ !~ /^<exm.*?$/)

      The ".*?$" on the end of that regex is pointless.


      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        Opps It was redundant. I agree . Thanks for spotting :) Dinakar

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://566589]
[LanX]: it's easier to patch then to migrate to a PHP board, there are many semantics like linking , authorisation, templates ,...
[LanX]: I've only seen 30% of the semi professional documentation
[holli]: i was just thinking of the bare content.
[LanX]: Plenty of "templates" realised with CGI-HTML-function
[LanX]: well if you want you can fetch all XML and translate it to another board markup
[moritz]: at this time, a migration could consist of only migrating the rendered HTML of nodes
[moritz]: to a forum software that supports raw HTML input for legacy threads, and uses sane markup for everything else
[holli]: yeah, then vroom will personally stab me in the back at night
[holli]: exactly, moritz
[moritz]: with a big table of redirects to support the old links

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2017-11-20 19:31 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (292 votes). Check out past polls.