Dear All,

the script I'm using is really very simple:

<script>
#!/usr/local/bin/perl -w
use strict;

while (<>) {
  chomp;
  print "\n\n$_\n\n";
}

</script>

>From the command line I start the script with "perl script.pl". Now I 
have to enter some text. I just enter any text, either by typing or by 
cutting and pasting. I do not enter any strange characters or 
newlines. I just type in some text. I even take care to just use 
normal characters - no numbers, umlaute or anything else strange. 
As you can see, I did not play with $/.

As I wrote in my initial mail, the answer I get is not the answer I 
expect. Whenever my input is more than 256 character, instead of 
printing everything I entered, it prints only the last part of what I 
entered, everything after character 256. The first part is chopped off.

I experimented with that and had the following results:

The first line I gave was 490 characters long, $_ contained the last 
233
characters. The string was chopped off at character 257.

The second line I gave was 462 characters long, $_ contained the 
last 205 characters. The string was chopped off at character 257.

The third line I gave was 253 characters long, $_ contained the 
whole 253 characters. Nothing was chopped off.

The fourth line I gave was 839 characters long, $_ contained the 
last 68 characters. The string was chopped off at character 771.

Nikola asked: "Exactly how long/big are we talking of making $_?"
The fourth line is already a very long line. I don't thing it will be 
more than a 1000 characters per line.

The script above is the essence of the problem. I found the problem 
when I wrote a script that reads in a line at a time from a file. The 
script was supposed to find a url in each line with an regex, isolate 
the url and do something with it. The script did not find the url in 
lines that were longer than 256 characters, because it appeared 
more in the beginning. I then found out that it was not my regex 
that was wrong, but $_ did not give me what I wanted.

Funny enough, I am able to find the url using index and substring. 
In this way I was able to do what I wanted to do, but it does not 
help solving the problem I have. The subroutine  that worked was:

  open DATEI, "$_" or die "Kann die Datei $_ nicht öffnen ($!)\n";
 
  foreach my $line (<DATEI>) {
    chomp $line;

    if ($line =~ /\<LI\>/i) {
        my $begin_url = index $line, "http";
        my $end_url = index $line, "\" ";
        my $length = ($end_url - $begin_url) ;
        my $url = substr ($line, $begin_url, $length);

and so on.

I would be really grateful for an answer to the puzzle.

Kind regards

Anette



> Perl 5.004_04 on my Solaris 5.6 machine had no problems making $_ of
> length 178956970. Of course I have an elephant crap load of memory on
> this sucker.
> 
> Exactly how long/big are we talking of making $_?
> 
> 
> -----Original Message-----
> From: David Gray [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 12, 2002 9:06 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: How long can $_ be?
> 
> 
> > Is there some limit in how long the contents of the variable $_ can
> > be? 
> 
> Not that I'm aware of, no.
> 
> > I encounter this problem on Solaris machines running Perl 5.005. On
> > Windows with Perl 5.6.1. no such problem was encountered.
> > 
> > What could cause the problem?
> 
> I suppose it might be a a configuration problem of some sort, but I
> doubt that. Could you show us the exact code you're using to load the
> lines from your file into $_ ?
> 
>  -dave
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ----------------------------------------------------------------------
> ------ -------------------- The views and opinions expressed in this
> email message are the sender's own, and do not necessarily represent
> the views and opinions of Summit Systems Inc.
> 


Mit freundlichen Grüßen

Anette Seiler

HBZ-NRW
Geschäftsbereich Digitale Bibliothek 
Tel.: +49-221-40075-196
Fax: +49-221-40075-190
www.hbz-nrw.de

email: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to