Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: multiple-pass search?

by propellerhat (Novice)
on Dec 10, 2021 at 00:49 UTC ( [id://11139522]=note: print w/replies, xml ) Need Help??


in reply to Re: multiple-pass search?
in thread multiple-pass search?

This is about the best I can do by way of providing a SSCCE: 1) files: a) title files (one title per file): title-001.tex title-002.tex ... title-999.tex b) catchfile index (one file of a thousand lines; a thousand titles + is about three or four times the number needed): \CatchFileDef{\zerozerozero}{title-000.tex}{} \CatchFileDef{\zerozeroone}{title-001.tex}{} ... \CatchFileDef{\nineninenine}{title-999.tex}{} c) document files (several categories, having same title): article-001.tex article-002.tex ... article-003.tex abstract-001.tex abstract-002.tex ... abstract-003.tex catalogue-001.tex catalogue-002.tex ... catalogue-003.tex 2) In the head of each document file is a placeholder for the English +representation of the serial number of the title: "\zerozerozero". I +f the placeholder is not useful, I can delete it. 3) In the head of each document file is the serial number of the title +, in Arabic representation: "No. 345". 4) The serial number of the title appears also in the filename of the +document file: "article-345". 5) The objective is to write in the document file the English represen +tation of the serial number of the title: "\threefourfive". 6) Once the English representations are in place, I can use Perl to ma +ke necessary adjustments.

Replies are listed 'Best First'.
Re^3: multiple-pass search?
by hippo (Bishop) on Dec 10, 2021 at 10:06 UTC

    Unfortunately you have not provided so much as a single line of Perl here. As such it is impossible to know at which point you are encountering a problem, let alone what that problem is.

    Here is the sort of SSCCE you could have written:

    use strict; use warnings; use Test::More tests => 3; my $filename = 'abstract-345.tex'; my $have = <<'EOT'; foo Here: \zerozerozero bar No. 345 baz EOT my $want = <<'EOT'; foo Here: \threefourfive bar No. 345 baz EOT my @digits = qw/zero one two three four five six seven eight nine/; my ($arabic) = $filename =~ /-([0-9]{3})\.tex/; (my $eng = $arabic) =~ s/([0-9])/$digits[$1]/g; $have =~ s/\\zerozerozero/\\$eng/; is $arabic, '345', 'Digits extracted'; is $eng, 'threefourfive', 'Converted to English'; is $have, $want, 'Replaced in text';

    Now you can see how to perform these three operations. If that doesn't solve your problem you need to provide some runnable code which demonstrates the problem which you are having (ideally with a test such as shown here). In that way we will know what it is you are actually asking.

    There's a detailed rationale at How to ask better questions using Test::More and sample data.


    🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139522]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-25 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found