Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Answer ? Seek ???

Expand Messages
  • Jenda Krynicky
    To: , From: Gordon Stewart Date sent: Mon,
    Message 1 of 3 , Sep 3, 2001
      To: <perl@yahoogroups.com>, <perl-beginner@yahoogroups.com>
      From: "Gordon Stewart" <Gordon.Stewart@...>
      Date sent: Mon, 03 Sep 2001 12:39:31 +1200
      Send reply to: perl-beginner@yahoogroups.com
      Subject: [PBML] Answer ? Seek ???

      > I think ive found it (will try it later - at home - 8-9 hours time)
      >
      > read FILEHANDLE,SCALAR,LENGTH,OFFSET
      >
      > (For this example, query, Changed it to read 150 characters)
      >
      > I can do
      >
      > $store = read (INF, 50,150,0) ;
      >
      > Starting with SCALAR of 50 (starting poiint), - Reading another 150
      > characters, and offset of 0

      No. It should be

      seek INF, 50, 0
      read INF, $store, 150, 0;

      if you wanted to skip the first 50 characters and read the next 150.

      > Q. What does the OFFSET do ?

      The offset specifies where IN THE $store VARIABLE should the
      data be read to. This way if you for example have a buffer that
      contains some data and you want to read the next chunk you may
      do this :

      read INF, $buff, 1024, length($buff);

      This way the data you read are appended to the end of $buff.

      The return value of read() is the number of characters read. This
      way if you get less characters than you asked for you know that
      there is nothing left in the filehandle (at least for now, if it is a
      socket or pipe you may get some more data later)

      Jenda

      == Jenda@... == http://Jenda.Krynicky.cz ==
      : What do people think?
      What, do people think? :-)
      -- Larry Wall in <199808071736.KAA12738@...>
    • gordon stewart
      ...
      Message 2 of 3 , Sep 3, 2001
        --- Jenda Krynicky <Jenda@...> wrote:


        > No. It should be
        >
        > seek INF, 50, 0
        > read INF, $store, 150, 0;
        >
        > if you wanted to skip the first 50 characters and
        > read the next 150.
        >
        > > Q. What does the OFFSET do ?

        <

        Thanks.. - Ive already done it, at after-noon tea-time
        at work (I sent the script i used - to the group).

        Basically, my file is over 180 megabytes..
        & (before) - Using a for-each loop - On my own
        Pc/Server , it took 4-6 minutes to loop through the
        file.

        The routine i sent to the group, did it in 1/4 - 1/2 a
        second.

        (I think thats a big improvement)

        G.


        =====
        G. Stewart
        New Zealand chat & Discussion group email
        new_zealand-help@yahoogroups.com for details.

        http://travel.yahoo.com.au - Yahoo! Travel
        - Got Itchy feet? Get inspired!
      Your message has been successfully submitted and would be delivered to recipients shortly.