Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to read contents of a file without opening it and print the contents

by zek152 (Pilgrim)
on Jun 10, 2011 at 13:38 UTC ( [id://909119]=note: print w/replies, xml ) Need Help??


in reply to How to read contents of a file without opening it and print the contents

I hand you a flash drive. Tell me what information is stored on it without inserting it into any usb host. Also physically opening the drive is not allowed.

This is not meant to be mean nor to insult. I am simply trying to give a more physical analogy to help you see what you are asking and how it sounds.

You have to "open" a file to read the contents.

open FILE, "filename" or die "could not open filename"; while(<FILE>) { print $_; } close FILE;
  • Comment on Re: How to read contents of a file without opening it and print the contents
  • Download Code

Replies are listed 'Best First'.
Re^2: How to read contents of a file without opening it and print the contents
by Anonymous Monk on Jun 10, 2011 at 13:42 UTC

    Based on that analogy, couldn't you have your script open and read /dev/hda1, parse the filesystem, find the file and read its data?

      That's why I put the word open in quotes.

      In your example I would say that "opening" /dev/hda1 means that you are "opening" a set of which the file is a subset. "Opening" a set implies that you have "opened" all subsets. (note the continued use of quotation marks)

      Because I know that someone will point out that opening a set does not imply opening all subsets (example: a box filled with other boxes) I will clarify that in this case I am refering to sets that contain only singletons (in this case bytes or blocks) as elements.

      Update: fixed moderate typo.

        I'm going to have settle for merely hiding the open in a system call:
        `cat filename > /dev/lp0`

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://909119]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-24 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found