CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Simple perl prob...

 



2wheeler
New User

Dec 8, 2010, 6:00 AM

Post #1 of 3 (1978 views)
Simple perl prob... Can't Post

Hello guys!
New kid in town needs help.
How can i display a part, per example 15 characters, of a file??


shawnhcorey
Enthusiast


Dec 8, 2010, 9:23 AM

Post #2 of 3 (1967 views)
Re: [2wheeler] Simple perl prob... [In reply to] Can't Post

See:
perldoc perlopentut
perldoc -f open
perldoc perlop and search for /I\/O Operators/
perldoc -f close
perldoc -f substr

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


rovf
Veteran

Dec 9, 2010, 1:56 AM

Post #3 of 3 (1960 views)
Re: [2wheeler] Simple perl prob... [In reply to] Can't Post

If the file is "reasonably" small and a text file, read it in slurp mode (http://www.sysarch.com/Perl/slurp_article.html) and use substr to extract the 15 characters you are interested in.

An alternative is to open the file and use seek to position the file pointer to a specific position, and start reading from there the next 15 bytes using sysread.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives