[29066] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 310 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 5 21:09:57 2007

Date: Thu, 5 Apr 2007 18:09:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 5 Apr 2007     Volume: 11 Number: 310

Today's topics:
    Re: CGI "working" message/page ? <derek.moody@clara.net>
    Re: CGI "working" message/page ? <glex_no-spam@qwest-spam-no.invalid>
    Re: CGI "working" message/page ? xhoster@gmail.com
    Re: Grab a redirected URL infomation, howto? <glex_no-spam@qwest-spam-no.invalid>
    Re: Grab a redirected URL infomation, howto? <lihao0129@gmail.com>
        Hash question <bcc@nospam.net>
    Re: Hash question <noreply@gunnar.cc>
    Re: Hash question xhoster@gmail.com
    Re: Looking for a Perl or (similar) type of script to p <greg.ferguson@icrossing.com>
    Re: Perl reliability? <rvtol+news@isolution.nl>
        perl system command keepyourstupidspam@yahoo.co.uk
    Re: perl system command <paduille.4060.mumia.w+nospam@earthlink.net>
        system command <dw149@acmex.gatech.edu>
    Re: system command <glex_no-spam@qwest-spam-no.invalid>
    Re: system command <purlgurl@purlgurl.net>
    Re: Testing against a list of values ? <uri@stemsystems.com>
    Re: Testing against a list of values ? xhoster@gmail.com
    Re: Testing against a list of values ? <rvtol+news@isolution.nl>
    Re: Testing against a list of values ? <uri@stemsystems.com>
    Re: Testing against a list of values ? <uri@stemsystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 5 Apr 2007 14:02:38 +0100
From: "Derek.Moody" <derek.moody@clara.net>
Subject: Re: CGI "working" message/page ?
Message-Id: <ant051338b49BxcK@strongarm.dereks.pad>

In article <Lc117572316743930x8c3a1b8@pong.podro.com>, Jamie
<URL:mailto:nospam@geniegate.com> wrote:
> In <09c8131jsaj1kjmmtggablp7g2vqqff3ov@4ax.com>,
> - Bob - <uctraing@ultranet.com> mentions:

> I guess it's sort of CGI related..
> 
> You can't do it. (with CGI)

You can't do it -as requested- with CGI

> The way to reliably do this is to have a javascript function disable the submit

And you can't rely on javascript being enabled.

> I tried once to solve this w/out javascript, using perl and lock ID's, etc..
> no matter what I did there was the lag between "submit", the servers

If you keep the page *simple* (no tables/frames/lists/nested structures)
then every browser I have tried it on is able to display partial output:
           
  use strict;
  use CGI qw/:standard/;

  $|=1; # autoflushing on

  print header(),start_html('Slow Page'),p('Please Wait');

  do_something_time_consuming();

  print p('Done.');

  show_results();

  print end_html;


Hth. Cheerio,

-- 
>> derek.moody@clara.net



------------------------------

Date: Thu, 05 Apr 2007 17:36:39 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: CGI "working" message/page ?
Message-Id: <461579f7$0$490$815e3792@news.qwest.net>

Derek.Moody wrote:
> In article <Lc117572316743930x8c3a1b8@pong.podro.com>, Jamie
> <URL:mailto:nospam@geniegate.com> wrote:
>> In <09c8131jsaj1kjmmtggablp7g2vqqff3ov@4ax.com>,
>> - Bob - <uctraing@ultranet.com> mentions:
> 
>> I guess it's sort of CGI related..
>>
>> You can't do it. (with CGI)
> 
> You can't do it -as requested- with CGI
> 
>> The way to reliably do this is to have a javascript function disable the submit
> 
> And you can't rely on javascript being enabled.
> 
>> I tried once to solve this w/out javascript, using perl and lock ID's, etc..
>> no matter what I did there was the lag between "submit", the servers
> 
> If you keep the page *simple* (no tables/frames/lists/nested structures)
> then every browser I have tried it on is able to display partial output:
>            
>   use strict;
>   use CGI qw/:standard/;
> 
>   $|=1; # autoflushing on
> 
>   print header(),start_html('Slow Page'),p('Please Wait');
> 
>   do_something_time_consuming();
> 
>   print p('Done.');
> 
>   show_results();
> 
>   print end_html;
> 
> 
> Hth. Cheerio,
> 

No, the HTTP connection will likely time out on more time consuming tasks.

For a more proper solution, see: 
http://www.stonehenge.com/merlyn/WebTechniques/col20.html


------------------------------

Date: 05 Apr 2007 22:46:46 GMT
From: xhoster@gmail.com
Subject: Re: CGI "working" message/page ?
Message-Id: <20070405184649.621$cT@newsreader.com>

"J. Gleixner" <glex_no-spam@qwest-spam-no.invalid> wrote:
> Derek.Moody wrote:
> > In article <Lc117572316743930x8c3a1b8@pong.podro.com>, Jamie
> > <URL:mailto:nospam@geniegate.com> wrote:
> >> In <09c8131jsaj1kjmmtggablp7g2vqqff3ov@4ax.com>,
> >> - Bob - <uctraing@ultranet.com> mentions:
> >
> >> I guess it's sort of CGI related..
> >>
> >> You can't do it. (with CGI)
> >
> > You can't do it -as requested- with CGI
> >
> >> The way to reliably do this is to have a javascript function disable
> >> the submit
> >
> > And you can't rely on javascript being enabled.
> >
> >> I tried once to solve this w/out javascript, using perl and lock ID's,
> >> etc.. no matter what I did there was the lag between "submit", the
> >> servers
> >
> > If you keep the page *simple* (no tables/frames/lists/nested
> > structures) then every browser I have tried it on is able to display
> > partial output:
> >
> >   use strict;
> >   use CGI qw/:standard/;
> >
> >   $|=1; # autoflushing on
> >
> >   print header(),start_html('Slow Page'),p('Please Wait');
> >
> >   do_something_time_consuming();
> >
> >   print p('Done.');
> >
> >   show_results();
> >
> >   print end_html;
> >
> >
> > Hth. Cheerio,
> >
>
> No, the HTTP connection will likely time out on more time consuming
> tasks.

Just doing an occasional print will take care of that, in my experience
(which is on apache server with both firefox and IE browsers).

If you can't control the time-consuming part so that print occasionally,
I've found that this usually works:

$|=1; ## if not already
{
  local $SIG{ALRM}= sub { print ".\n"; alarm 10 };
  alarm 10;
  do_something_time_consuming();
  alarm 0;
}
print "<hr>\n", show_results();

>
> For a more proper solution, see:
> http://www.stonehenge.com/merlyn/WebTechniques/col20.html

I agree that that is a nice solution, but sometimes it is over-kill.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Thu, 05 Apr 2007 15:23:11 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Grab a redirected URL infomation, howto?
Message-Id: <46155ab0$0$508$815e3792@news.qwest.net>

lihao0129@gmail.com wrote:
> Hi, there:
> 
> I have a question about grabbing the URI information of a redirected
> weblink. For example, in my Apache configuration file, I added:
> 
>     ErrorDocument 404 /error.html
> 
> then if I enter a wrong URL like:
> 
>     http://myweb.com/dir/non-exist.html
> 
> the httpd server will automatically redirect my request to
> http://myweb.com/error.html...
> 
> Now I want to display some dynamic information in error.html, for
> example, the original request URL:
> 
>      http://myweb.com/dir/non-exist.html
> 
> In HTML::Mason, I tried adding:
> 
> $m->request_comp->source_file
> # returns  /comp/root/error.html
> $r->uri()
> # returns /error.html
> 
> which are not what I wanted..
> 
> Are there any functions in mod_perl or HTML::Mason or other APIs that
> I can grab '/dir/non-exist.html' from within '/error.html'..
> 
> Thank you very much for your input and suggestions..
> 
> Best regards,
> Hao
> 
$r->parsed_uri->unparse.

See:
http://www.masonhq.com/docs/manual/Admin.html#error_reporting_and_exceptions


------------------------------

Date: 5 Apr 2007 17:06:56 -0700
From: "lihao0129@gmail.com" <lihao0129@gmail.com>
Subject: Re: Grab a redirected URL infomation, howto?
Message-Id: <1175818016.110598.39680@y80g2000hsf.googlegroups.com>

On Apr 5, 4:23 pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
wrote:
> lihao0...@gmail.com wrote:
> > Hi, there:
>
> > I have a question about grabbing the URI information of a redirected
> > weblink. For example, in my Apache configuration file, I added:
>
> >     ErrorDocument 404 /error.html
>
> > then if I enter a wrong URL like:
>
> >    http://myweb.com/dir/non-exist.html
>
> > the httpd server will automatically redirect my request to
> >http://myweb.com/error.html...
>
> > Now I want to display some dynamic information in error.html, for
> > example, the original request URL:
>
> >      http://myweb.com/dir/non-exist.html
>
> > In HTML::Mason, I tried adding:
>
> > $m->request_comp->source_file
> > # returns  /comp/root/error.html
> > $r->uri()
> > # returns /error.html
>
> > which are not what I wanted..
>
> > Are there any functions in mod_perl or HTML::Mason or other APIs that
> > I can grab '/dir/non-exist.html' from within '/error.html'..
>
> > Thank you very much for your input and suggestions..
>
> > Best regards,
> > Hao
>
> $r->parsed_uri->unparse.
>
> See:http://www.masonhq.com/docs/manual/Admin.html#error_reporting_and_exc...

Thank you very much for your helpful link. And I finally figured it
out, and used the following code:

    my $url = $r->prev->unparsed_uri;

which returns exactly the URI I wanted. :-P

BTW. the code at masonhq is for mod_perl 1.* which doesnot work for
mod_perl 2.0+.:-)

Thanks again and have a good day,

Hao..



------------------------------

Date: Thu, 05 Apr 2007 22:47:05 GMT
From: Bryan <bcc@nospam.net>
Subject: Hash question
Message-Id: <J%eRh.12516$JZ3.10498@newssvr13.news.prodigy.net>

I have the following hash:
$VAR1 = {
       'directory' => {
             'name' => 'GLMSR',
             'directory' => {
                        'A17' => {
                               'file' => {
                                     'name' => 'A17.xml'
                                         }
                                 },
                        'F19' => {
                               'file' => {
                                     'name' => 'F19.xml'
                                         }
                                 },
                        'B01' => {
                               'file' => {
                                     'name' => 'B01.xml'
                                         }
                                 }
                        }
                 }
         };


I need to iterate over this structure, and for each directory, check if 
it exists in a new location- if it doesnt, create the directory on disk. 
  If the hash element is a file, then I need to do something specific 
with the file, and then write out a new file to the corresponding directory.

So at the end, I would have a duplicate directory structure on disk, 
which contains the processed files instead of the originals.

What is the appropriate way to do this?

Thanks,
B


------------------------------

Date: Fri, 06 Apr 2007 00:56:32 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Hash question
Message-Id: <57ld95F2dps00U1@mid.individual.net>

Bryan wrote:

<specification snipped>

> What is the appropriate way to do this?

Writing a Perl program is one way.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: 05 Apr 2007 23:33:20 GMT
From: xhoster@gmail.com
Subject: Re: Hash question
Message-Id: <20070405193323.163$Lp@newsreader.com>

Bryan <bcc@nospam.net> wrote:
> I have the following hash:
> $VAR1 = {
>        'directory' => {
>              'name' => 'GLMSR',
>              'directory' => {
>                         'A17' => {
>                                'file' => {
>                                      'name' => 'A17.xml'
>                                          }
>                                  },
>                         'F19' => {
>                                'file' => {
>                                      'name' => 'F19.xml'
>                                          }
>                                  },
>                         'B01' => {
>                                'file' => {
>                                      'name' => 'B01.xml'
>                                          }
>                                  }
>                         }
>                  }
>          };

That is a pretty gnarly hash.  It looks like you took Evotec's crappy XML
and just converted it to a hash.

Can the top level hash have more than one key-value pair?  If so, what
format would other ones have?  If not, then what is the point of it
existing?  Can directories keep nesting beyond what you show, and if so how
would that look? If the Well hash can only have one key, whose value is
hash that can only have one key, what is the point of having all the
hashes?

>
> I need to iterate over this structure, and for each directory, check if
> it exists

perldoc -f -X, look for "-d"

> in a new location-

That suggests it already exists in an old location.  Why not just walk
through the filesystem structure of the old location, rather than walking
through a poorly designed hash based on the filesystem structure?

> if it doesnt, create the directory on disk.

perldoc -f mkdir

>   If the hash element is a file, then I need to do something specific
> with the file, and then write out a new file to the corresponding
> directory.

How you do something depends on what that something is.

>
> So at the end, I would have a duplicate directory structure on disk,
> which contains the processed files instead of the originals.
>
> What is the appropriate way to do this?

Learn Perl, or hire someone who already knows.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: 5 Apr 2007 13:40:33 -0700
From: "gf" <greg.ferguson@icrossing.com>
Subject: Re: Looking for a Perl or (similar) type of script to parse XML files for errors
Message-Id: <1175805633.642700.55460@n76g2000hsh.googlegroups.com>

On Apr 4, 1:27 pm, WBi...@gmail.com wrote:
> I'm looking for a Perl script ( or assistance on how to write one) for
> performing a a pattern match in XML data files to search for the Error
> message and match them w/ the actual offending data records.  ie. The
> error search string would be "Error system"  which displays the
> applicable error message immediately following. Ideally it would
> redirect the errors messages to an output file w/ the data record ids
> matched in a prompted XML tag.

You might want to do a search for xml_grep on CPAN, which is part of
the XML::Twig module.

It has a --text-only option that makes it very convenient for parsing
XML from the command line and retrieving the content of the XML tag. I
use it to locate particular sections of XML configuration files from
bash shells and initialize variables in the shell script.

Otherwise, read through the source of xml_grep to see how they
implemented it in XML::Twig.

http://search.cpan.org/search?query=xml_grep




------------------------------

Date: Fri, 6 Apr 2007 01:02:22 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Perl reliability?
Message-Id: <ev46p7.1g0.1@news.isolution.nl>

MikeJohnson schreef:

> my $debug_msg = "Error connecting!\n";
> $debug_msg .= "Error was:\n";
> $debug_msg .= "$DBI::errstr\n";         # $DBI::errstr is the error
> received from the SQL server
> &LogErrorMessage ($debug_msg);

Alternative:

  LogErrorMessage <<"EOT";
Error connecting!
Error was:
$DBI::errstr
received from the SQL server
EOT

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: 5 Apr 2007 14:30:38 -0700
From: keepyourstupidspam@yahoo.co.uk
Subject: perl system command
Message-Id: <1175808638.507237.40150@y80g2000hsf.googlegroups.com>

Hi,

I am trying to run this command using system but it fails.

gmake.exe -r -R --win32 --f makefile.mk 2>&1 | perl %SRC_DIR_XP%
\scripts\tee.pl build.log


@args1 = ("$SRC_DIR_XP\\make\\gmake.exe", "-r", "-R", "--win32",
"--f", "$SRC_DIR_ISEE_NT\\makefile.mk",  "2>&1", "|",
"perl", "$SRC_DIR_XP\\scripts\\tee.pl", "build.log");

system(@args1) == 0
         or die "system @args failed: $?";

Anyone know how to get this to work?


Enda



------------------------------

Date: Thu, 05 Apr 2007 22:53:59 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: perl system command
Message-Id: <b6fRh.21396$Jl.2214@newsread3.news.pas.earthlink.net>

On 04/05/2007 04:30 PM, keepyourstupidspam@yahoo.co.uk wrote:
> Hi,
> 
> I am trying to run this command using system but it fails.
> 
> gmake.exe -r -R --win32 --f makefile.mk 2>&1 | perl %SRC_DIR_XP%
> \scripts\tee.pl build.log
> 
> 
> @args1 = ("$SRC_DIR_XP\\make\\gmake.exe", "-r", "-R", "--win32",
> "--f", "$SRC_DIR_ISEE_NT\\makefile.mk",  "2>&1", "|",
> "perl", "$SRC_DIR_XP\\scripts\\tee.pl", "build.log");
> 
> system(@args1) == 0
>          or die "system @args failed: $?";
> 
> Anyone know how to get this to work?
> 
> 
> Enda
> 

AFAIK, this form of the system command omits starting the shell, so 
shell redirection attempts ("2>&1" and "| perl") should fail. You would 
have to put everything into a single string.



------------------------------

Date: Thu, 5 Apr 2007 22:39:57 +0000 (UTC)
From: David Williams <dw149@acmex.gatech.edu>
Subject: system command
Message-Id: <ev3trt$1of$1@news-int2.gatech.edu>

Hello everyone,
 I am writing a script that runs a command which needs a password.
 I don't want the user to have to enter the password, I want the script
 to supply it.  I think the system command will allow me to do this.
 Does anyone have any examples of how to do this and can I somehow also
 prevent the password from being seen clear text?

 Thanks

-- 
David Williams
Georgia Institute of Technology, Atlanta Georgia, 30332
Email: dw149@prism.gatech.edu


------------------------------

Date: Thu, 05 Apr 2007 17:43:53 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: system command
Message-Id: <46157ba9$0$10307$815e3792@news.qwest.net>

David Williams wrote:
> Hello everyone,
>  I am writing a script that runs a command which needs a password.
>  I don't want the user to have to enter the password, I want the script
>  to supply it.  I think the system command will allow me to do this.
>  Does anyone have any examples of how to do this and can I somehow also
>  prevent the password from being seen clear text?

perldoc IPC::Open2



------------------------------

Date: Thu, 05 Apr 2007 16:33:35 -0700
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: system command
Message-Id: <-pGdneFuz_HRGojbnZ2dnUVZ_qWvnZ2d@giganews.com>

David Williams wrote:

>  I am writing a script that runs a command which needs a password.
>  I don't want the user to have to enter the password, I want the script
>  to supply it.  I think the system command will allow me to do this.

system ("path_to_some_command some_password");

David, I am sure you are aware of this but I would be remiss
to not mention security. A need for a password indicates a
need for security. Be careful about allowing a user to run
a program which requires a password for execution.

Purl Gurl


------------------------------

Date: Thu, 05 Apr 2007 17:01:22 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Testing against a list of values ?
Message-Id: <x7zm5m7cyl.fsf@mail.sysarch.com>

>>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:

  GH> Uri Guttman wrote:
  >> a simple way to make a hash of keys with undef values is:
  >> my %isa_foo ;
  >> @isa_foo{ @values } = () ;
  >> i think i have seen tricks (randal?) on how to merge those line

  GH>      my %isa_foo = map { $_ => undef } @values;

  GH> Is that a trick? ;-)

nope. i know that map idea from way back and mention it in my article on
hash slices. the wacky trick was doing that for an anon hash or some
other thing that needed strange ref munging. it was very fugly but
amusing and i can't recall who posted it nor would i know how to search
for it easily. not a problem since i wouldn't use that wacko code in
production.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: 05 Apr 2007 23:21:13 GMT
From: xhoster@gmail.com
Subject: Re: Testing against a list of values ?
Message-Id: <20070405192116.205$Vc@newsreader.com>

Uri Guttman <uri@stemsystems.com> wrote:
> >>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
>
>   GH> Uri Guttman wrote:
>   >> a simple way to make a hash of keys with undef values is:
>   >> my %isa_foo ;
>   >> @isa_foo{ @values } = () ;
>   >> i think i have seen tricks (randal?) on how to merge those line
>
>   GH>      my %isa_foo = map { $_ => undef } @values;
>
>   GH> Is that a trick? ;-)
>
> nope. i know that map idea from way back and mention it in my article on
> hash slices. the wacky trick was doing that for an anon hash or some
> other thing that needed strange ref munging. it was very fugly but
> amusing and i can't recall who posted it nor would i know how to search
> for it easily. not a problem since i wouldn't use that wacko code in
> production.

Perhaps something like this:

@$_{@values}=() foreach (\my %$isa_foo);

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Fri, 6 Apr 2007 01:47:12 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Testing against a list of values ?
Message-Id: <ev48tb.1kk.1@news.isolution.nl>

Uri Guttman schreef:

> a simple way to make a hash of keys with undef values is:
> 
> my %isa_foo ;
> @isa_foo{ @values } = () ;


IIRC there was a difference between the result of that and this:

  my %isa_foo ;
  @isa_foo{ @values } = () x @values ;

(undef as status and undef as value) 

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: Thu, 05 Apr 2007 20:31:14 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Testing against a list of values ?
Message-Id: <x7odm2738t.fsf@mail.sysarch.com>

>>>>> "R" == Ruud  <rvtol+news@isolution.nl> writes:

  R> Uri Guttman schreef:
  >> a simple way to make a hash of keys with undef values is:
  >> 
  >> my %isa_foo ;
  >> @isa_foo{ @values } = () ;

  R> IIRC there was a difference between the result of that and this:

  R>   my %isa_foo ;
  R>   @isa_foo{ @values } = () x @values ;

  R> (undef as status and undef as value) 

yep. you can tell the difference in the amount of storage used and
probably with some internal probing with a scalar::util func or
something.

a hash entry can be totally empty and it will return an undef if
accessed. or it can have a proper sv in the entry which is undef
itself. i am not sure of any other direct way to get the undef slot but
the assignment of an empty list to a slice. but there probably is one
and i don't know it or some module can do it.

and in both cases you test for a key in the set with exists. some like
to assign 1 or some true value so they can just do a boolean test and
drop the exists. either way is fine with me.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Thu, 05 Apr 2007 20:33:27 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Testing against a list of values ?
Message-Id: <x7k5wq7354.fsf@mail.sysarch.com>

>>>>> "x" == xhoster  <xhoster@gmail.com> writes:

  x> Uri Guttman <uri@stemsystems.com> wrote:
  >> >>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
  >> 
  GH> Uri Guttman wrote:
  >> >> a simple way to make a hash of keys with undef values is:
  >> >> my %isa_foo ;
  >> >> @isa_foo{ @values } = () ;
  >> >> i think i have seen tricks (randal?) on how to merge those line
  >> 
  GH> my %isa_foo = map { $_ => undef } @values;
  >> 
  GH> Is that a trick? ;-)
  >> 
  >> nope. i know that map idea from way back and mention it in my article on
  >> hash slices. the wacky trick was doing that for an anon hash or some
  >> other thing that needed strange ref munging. it was very fugly but
  >> amusing and i can't recall who posted it nor would i know how to search
  >> for it easily. not a problem since i wouldn't use that wacko code in
  >> production.

  x> Perhaps something like this:

  x> @$_{@values}=() foreach (\my %$isa_foo);

that looks like what i recall and you can see why i would never use it
in production. :) it was to declare a scalar to hold a hash ref and
assign boolean keys in one line.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 310
**************************************


home help back first fref pref prev next nref lref last post