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

un defining a specific value of a hash ?

Expand Messages
  • Gordon Stewart
    1) - I have the following code :- foreach $line (sort keys %url){ $le=0; $le=length($line); if ($le
    Message 1 of 1 , Jan 3, 2002
    • 0 Attachment
      1) - I have the following code :-

      foreach $line (sort keys %url){

      $le=0;
      $le=length($line);
      if ($le <5) {
      undef $url{$line};
      }
      }

      - the %url hash contains a list of Urls of websites which i have gathered
      from a site...

      Basically, im getting the length of the URLs - which SHOULD all start with
      http://www etc...

      however, I seem to have a few which just have the url of " & " or some
      other single-length character..

      Im trying to find the length of the url - $le - & if it is LESS than 5
      characters long, I want to undefine that. hash value.

      Ive tried :-

      if ($le <5) {
      undef $url{$line};
      }

      and

      if ($le <5) {
      $url{$line}="";
      }

      However when i re-print the list of the hash - It still contains those
      single-length lines..

      Some examples of the single-length hash values are :- (value of line - Not
      including the quote marks)

      '&'
      ''

      The 2nd one is a blank / empty hash value - But how to i totally delete /
      expunge it from the 'keys' of the hash ?

      How do i un-define / Delete / Expunge / wipe-out a single hash value ?

      Ps - I *could* just create a NEW hash, if the length is over 5 characters -
      But it seems a bit of work - & i'll want to know how to un-define a
      particular hash anyway... - For future use...

      PS - Anyone online now ? - Willing to test my script - See if it extracts
      URLs from their site - correctly..
      (only available when im online.. - Its on my private server..)

      G.
    Your message has been successfully submitted and would be delivered to recipients shortly.