Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Equivalent of the Mid function from VB?

Reply
Thread Tools

Equivalent of the Mid function from VB?

 
 
Connell Gauld
Guest
Posts: n/a
 
      05-24-2004
Hey,

I'm trying to grab a section from a piece of text and I was wondering if
there was an equivalent to Visual Basic's Mid function in perl.
Basically it takes a start index (as a number of characters from the
beginning of the string) and a similar end index and returns the text
between them.

Thanks
Connell


 
Reply With Quote
 
 
 
 
Jack Challen
Guest
Posts: n/a
 
      05-24-2004
Connell Gauld wrote:
> I'm trying to grab a section from a piece of text and I was wondering if
> there was an equivalent to Visual Basic's Mid function in perl.


yep. substr().

"perldoc -f substr" for more info
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      05-24-2004
Connell Gauld wrote:
> I'm trying to grab a section from a piece of text and I was wondering
> if there was an equivalent to Visual Basic's Mid function in perl.
> Basically it takes a start index (as a number of characters from the
> beginning of the string) and a similar end index and returns the text
> between them.


perldoc -f substr

jue


 
Reply With Quote
 
Connell Gauld
Guest
Posts: n/a
 
      05-24-2004
Thanks, worked great!


"Connell Gauld" <(E-Mail Removed)> wrote in message
news:c8t287$jpp$(E-Mail Removed)...
> Hey,
>
> I'm trying to grab a section from a piece of text and I was wondering if
> there was an equivalent to Visual Basic's Mid function in perl.
> Basically it takes a start index (as a number of characters from the
> beginning of the string) and a similar end index and returns the text
> between them.
>
> Thanks
> Connell
>
>



 
Reply With Quote
 
Tore Aursand
Guest
Posts: n/a
 
      05-24-2004
On Mon, 24 May 2004 15:58:28 +0100, Connell Gauld wrote:
> I'm trying to grab a section from a piece of text and I was wondering if
> there was an equivalent to Visual Basic's Mid function in perl.
> Basically it takes a start index (as a number of characters from the
> beginning of the string) and a similar end index and returns the text
> between them.


perldoc -f substr

substr EXPR,OFFSET,LENGTH,REPLACEMENT
substr EXPR,OFFSET,LENGTH
substr EXPR,OFFSET
Extracts a substring out of EXPR and returns it. First charac-
ter is at offset 0, or whatever you've set $[ to (but don't do
that). If OFFSET is negative (or more precisely, less than
$[), starts that far from the end of the string. If LENGTH is
omitted, returns everything to the end of the string. If
LENGTH is negative, leaves that many characters off the end of
the string.
[...]


--
Tore Aursand <(E-Mail Removed)>
"Why shouldn't truth be stranger than fiction? Fiction, after all, has
to make sense." (Mark Twain)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Evaluating a Function After X Seconds: Python Equivalent to JavaScript's SetTimeout() Function ycoci0@gmail.com Python 3 06-12-2006 07:45 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Mid() function crippled? Ken VdB ASP General 10 04-04-2004 04:47 PM
problem with mid() function Joeandtel ASP General 3 11-14-2003 09:50 PM
java equivalent function of c atoi() function lonelyplanet999 Java 8 11-03-2003 01:07 AM



Advertisments