Duplicate HashEntry

Duplicate HashEntry

am 28.02.2005 15:56:15 von Michael.Ruehling

Hi,
I'm trying to write a Script that must have the ability
to duplicate a line in a HTML-Document.
Is is possible anyway?
e. G.


foreach $zeile (@dateiinhalt)
{
if ($zeile =~ m/Platzhalter1\.jpg/o)
{
# duplicate that line before substitution and s///i
# 1 line afterwards
$zeile =~ s/Platzhalter1\.jpg/$Bild1Name/i;
}
else
{
if ($zeile =~ m/Platzhalter2\.jpg/o)
{
$zeile =~ s/Platzhalter2\.jpg/$Bild2Name/i;
}
}
print VORLAGE ("$zeile");
}
close (VORLAGE);

Please excuse the German names, but since i am german it is easier for
me to understand that lang.


Michael

Re: Duplicate HashEntry

am 28.02.2005 17:30:35 von Gunnar Hjalmarsson

Michael.Ruehling@t-online.de wrote:
>
> Subject: Duplicate HashEntry

Not sure what your query has to do with hashes...

> I'm trying to write a Script that must have the ability
> to duplicate a line in a HTML-Document.
> Is is possible anyway?

Yes, of course it is, and the question is asked frequently:

perldoc -q "insert a line"

To prevent that the loop gets confused when you add lines/elements, you
may want to loop through the array backwards.

However, since it's an HTML document, I don't understand why there is a
need to add lines. Can't you add whatever it is you want to add on
existing lines?

> Please excuse the German names, but since i am german it is easier for
> me to understand that lang.

What's easier for *you* to understand is irrelevant if you want that
others shall read your post. When asking for help, you should make it
easy for others to help you.

Now, personally I'm not bothered by those German var names, even if
Swedish names would of course have been much more convenient to me. ;-)

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Re: Duplicate HashEntry

am 28.02.2005 20:33:18 von Michael.Ruehling

On Mon, 28 Feb 2005 17:30:35 +0100, Gunnar Hjalmarsson
wrote:

>Michael.Ruehling@t-online.de wrote:
>>
>> Subject: Duplicate HashEntry
>
>Not sure what your query has to do with hashes...
>
>> I'm trying to write a Script that must have the ability
>> to duplicate a line in a HTML-Document.
>> Is is possible anyway?
>
>Yes, of course it is, and the question is asked frequently:
>
> perldoc -q "insert a line"
>
>To prevent that the loop gets confused when you add lines/elements, you
>may want to loop through the array backwards.
>
>However, since it's an HTML document, I don't understand why there is a
>need to add lines. Can't you add whatever it is you want to add on
>existing lines?
I take that file as a Template for an indexfile (index.html) and i
want to add lines usings Perl's Pattern matching functions.

e. g.:





>


oohh, great. After thinking another two Hours, i think i have a
solution.
(just Pattern-Match on the first and write a correct line AFTER
it)
>> Please excuse the German names, but since i am german it is easier for
>> me to understand that lang.
>
>What's easier for *you* to understand is irrelevant if you want that
>others shall read your post. When asking for help, you should make it
>easy for others to help you.
>
>Now, personally I'm not bothered by those German var names, even if
>Swedish names would of course have been much more convenient to me. ;-)
I may be incorrect, but since they all are var-names they should be
clear. Okay they are not hashes. Sorry for that.


Michael

Re: Duplicate HashEntry

am 28.02.2005 21:10:57 von Gunnar Hjalmarsson

Michael.Ruehling@t-online.de wrote:
> Gunnar Hjalmarsson wrote:
>> However, since it's an HTML document, I don't understand why there is
>> a need to add lines. Can't you add whatever it is you want to add on
>> existing lines?
>
> I take that file as a Template for an indexfile (index.html) and i
> want to add lines usings Perl's Pattern matching functions.
>
> e. g.:
>
>
>


>
>

What I mean is that



is rendered exactly the same as



That's why I don't understand why you need to bother with adding extra
lines to the file.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl