Hi - this script works for me:

use strict;
use warnings;

# make dummy input for test
my $line = "x" x 100 . "Sleeping for 10" . "x" x 100;

print substr($line, 97,21), "\n";  # print extra to test
print substr($line, 100,15), "\n"; # just print it

# note comma required after $line, and length is 15 not 16

# if you just want to test if Sleeping for 10 is there,
# why not use a Regex?

print "Got it!\n" if $line =~ m/Sleeping for 10/;

# then you can get fancy and use some regex features,
# such as ignore case:

print "Got it!\n" if $line =~ m/sleeping for 10/i;

# or find all occurences:

my @results = $line =~ m/(sleeping for 10)/gi;
print 'Found ', scalar (@results), " occurences\n";

output  =>

xxxSleeping for 10xxx
Sleeping for 10
Got it!
Got it!
Found 1 occurences

Aloha => Beau.

-----Original Message-----
From: Lance Prais [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 23, 2002 9:05 AM
To: Perl
Subject: subsrting question


I am trying to use the substr() to search a text doc.   The starting place
is 100.

I am trying to test to see if   "Sleeping for 10"  is there.

This is the code I am trying to use substr($line 100,16)  but is only
returning "Sleeping f"

What could I be doing wrong?



Thank you in advance,
Lance


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




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

Reply via email to