[28272] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9636 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 22 18:05:49 2006

Date: Tue, 22 Aug 2006 15:05:06 -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           Tue, 22 Aug 2006     Volume: 10 Number: 9636

Today's topics:
    Re: constructing a scalar reference <benmorrow@tiscali.co.uk>
    Re: Help in comparision and writting in Matrix form <someone@example.com>
        How do I run the MS Windows file search program from ht <muforo@gmail.com>
    Re: How do I run the MS Windows file search program fro <mevans76@gmail.com>
    Re: How do I run the MS Windows file search program fro <bik.mido@tiscalinet.it>
    Re: How do I run the MS Windows file search program fro <annoyed@you.now>
    Re: How do I run the MS Windows file search program fro <hmessinger.removethis@comcast.net>
    Re: How do I run the MS Windows file search program fro <"nije\"nego"@net.hr>
    Re: How do I run the MS Windows file search program fro <bik.mido@tiscalinet.it>
    Re: How do I run the MS Windows file search program fro <annoyed@you.now>
        Multiple copies of perl rashmiek@gmail.com
    Re: Multiple copies of perl <bik.mido@tiscalinet.it>
        Permission denied trying to execute shell commands from oleg106@yahoo.com
    Re: Problems with Win32::Internet FTP->put <aragorn.m@gmail.com>
    Re: Question about UNIVERSAL <benmorrow@tiscali.co.uk>
    Re: References - problem understanding them <m@remove.this.part.rtij.nl>
    Re: References - problem understanding them <David.Squire@no.spam.from.here.au>
    Re: References - problem understanding them <uri@stemsystems.com>
    Re: References - problem understanding them <David.Squire@no.spam.from.here.au>
        Spazio utilizzato dagli utenti alessandro.mendolia@gmail.com
        variable with empty space <>
    Re: variable with empty space usenet@DavidFilmer.com
    Re: variable with empty space <hjp-usenet2@hjp.at>
    Re: variable with empty space <>
    Re: variable with empty space <someone@example.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 22 Aug 2006 17:05:00 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: constructing a scalar reference
Message-Id: <cimrr3-d8r.ln1@osiris.mauzo.dyndns.org>


Quoth Josef Moellers <josef.moellers@fujitsu-siemens.com>:
> Dibosia wrote:
> > $r = {}; # a hashref
> > $r = []; # an arrayref
> 
> These are _anonymous_ references (i.e. the thingy referred to (the 
> "referent"?) has no name of its own).
> 
> > $r = ?; # a scalar ref
> 
> AFAIK no _anonymous_ scalar references exist.

Of course they do. Consider Anno's scalar-ref-constructor:

    my $sref = do {\ my $x};

The $x name goes out of scope at the end of the do block, so thereafter
the scalar referred to by $sref has no name.

Ben

-- 
   Razors pain you / Rivers are damp
   Acids stain you / And drugs cause cramp.                    [Dorothy Parker]
Guns aren't lawful / Nooses give
  Gas smells awful / You might as well live.            benmorrow@tiscali.co.uk


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

Date: Tue, 22 Aug 2006 19:34:54 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help in comparision and writting in Matrix form
Message-Id: <y%IGg.14574$365.1405@edtnps89>

Ved wrote:
> Hi all,
> I have posted this message in perl.beginers,but didnt get any reply so
> am posting here.

You have posted from Google Groups which has read-only access to the Perl
beginners mailing list.  To post to the actual mailing list go to
http://lists.cpan.org/showlist.cgi?name=beginners and subscribe.


> I have two set of data which I need to comapre.
> The data set is actually a 16x16 Matrix.
> 
> Till now I am reading one row at a time by manually changing the
> @comp_vhdl0, @comp_vhdl1.... till @comp_vhdl15  and so on.
>  I want:
> 1)  this to be done  using some loop (or some other better method) and
> then write it to a file in 16x16 matrix form.

use constant ROW_LEN => 16;

my @comp_vhdl = map [ splice @VHDL, 0, ROW_LEN ], 0 .. $#VHDL / ROW_LEN;

my @comp = map [ splice @C_based, 0, ROW_LEN ], 0 .. $#C_based / ROW_LEN;

print "The VHDL items are:\n";
printf '%20f' x ROW_LEN, @$_ for @comp_vhdl;

print "The C items are:\n";
printf '%20f' x ROW_LEN, @$_ for @comp;


> 2) After that I want to compare the corresponding values and write the
> results in a Marix form( say 1 if match occurs and 0 when mismatch). So
> result looks like this
> 
> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> ..........
> ..........
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

print "Comparison:\n";
for my $index ( 0 .. $#comp ) {
    print join ' ', map $comp_vhdl[ $index ][ $_ ] == $comp[ $index ][ $_ ] ?
1 : 0, 0 .. $#{ $comp[ $index ] };
    }



John
-- 
use Perl;
program
fulfillment


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

Date: 22 Aug 2006 11:46:37 -0700
From: "Ray Muforosky" <muforo@gmail.com>
Subject: How do I run the MS Windows file search program from html
Message-Id: <1156272397.889234.313070@m79g2000cwm.googlegroups.com>

Hello all:

Task: I want to do file search, using the "conatining text" option from
a web page.

How do I search for a file on my local drive containing a certain
string, from a web page. That is, how do run the windows search program
from a web page.

Any help will be appreciated.



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

Date: 22 Aug 2006 12:42:42 -0700
From: "moojoo" <mevans76@gmail.com>
Subject: Re: How do I run the MS Windows file search program from html
Message-Id: <1156275762.051029.270670@74g2000cwt.googlegroups.com>

I am sure you could do it with Asp.NET. You may need an activex control
or some DLL to get it working though. I do more PHP/MySQL so I am not
entirely sure.

Ray Muforosky wrote:
> Hello all:
>
> Task: I want to do file search, using the "conatining text" option from
> a web page.
>
> How do I search for a file on my local drive containing a certain
> string, from a web page. That is, how do run the windows search program
> from a web page.
> 
> Any help will be appreciated.



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

Date: 22 Aug 2006 21:43:27 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How do I run the MS Windows file search program from html
Message-Id: <vfnme2hbq8m3uoclvdeov09m960nr17hv2@4ax.com>

On 22 Aug 2006 11:46:37 -0700, "Ray Muforosky" <muforo@gmail.com>
wrote:

>How do I search for a file on my local drive containing a certain
>string, from a web page. That is, how do run the windows search program
>from a web page.

How does this have to do with Perl? Unless you're using PerlScript, or
expect people to, for what it matters, that is...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Tue, 22 Aug 2006 14:47:23 -0500
From: Ivan Marsh <annoyed@you.now>
Subject: Re: How do I run the MS Windows file search program from html
Message-Id: <pan.2006.08.22.19.47.22.335533@you.now>

> Ray Muforosky wrote:
>> Hello all:
>>
>> Task: I want to do file search, using the "conatining text" option from
>> a web page.
>>
>> How do I search for a file on my local drive containing a certain
>> string, from a web page. That is, how do run the windows search program
>> from a web page.
>> 
>> Any help will be appreciated.
On Tue, 22 Aug 2006 12:42:42 -0700, moojoo wrote:

> I am sure you could do it with Asp.NET. You may need an activex control
> or some DLL to get it working though. I do more PHP/MySQL so I am not
> entirely sure.

 ...and the client would have to grant access to do it so if we're talking
about a public site (or a client not running Windows obviously) you can
forget it.

-- 
The USA Patriot Act is the most unpatriotic act in American history.
  Feingold-Obama '08 - Because the Constitution isn't history,
                           It's the law.



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

Date: Tue, 22 Aug 2006 16:04:24 -0400
From: Harlan Messinger <hmessinger.removethis@comcast.net>
Subject: Re: How do I run the MS Windows file search program from html
Message-Id: <4l16aaFe7pn3U1@individual.net>

Ray Muforosky wrote:
> Hello all:
> 
> Task: I want to do file search, using the "conatining text" option from
> a web page.
> 
> How do I search for a file on my local drive containing a certain
> string, from a web page. That is, how do run the windows search program
> from a web page.

You can't, unless, possibly, you use some kind of ActiveX object and 
your users have their security levels set dangerously low.

I'm trying to picture the situation where someone would want to find 
something on his hard drive and would go to your web site to do it 
instead of using the Windows search feature directly.


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

Date: Tue, 22 Aug 2006 23:03:15 +0200
From: Nije Nego <"nije\"nego"@net.hr>
Subject: Re: How do I run the MS Windows file search program from html
Message-Id: <bmavz894iqdm.1pvs2mv050p8n$.dlg@40tude.net>

On 22 Aug 2006 11:46:37 -0700, Ray Muforosky wrote:

> Hello all:
> 
> Task: I want to do file search, using the "conatining text" option from
> a web page.
> 
> How do I search for a file on my local drive containing a certain
> string, from a web page. That is, how do run the windows search program
> from a web page.
> 
> Any help will be appreciated.

Upload your local drive and submit it to MSN.

-- 
buy, bought, bye


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

Date: 22 Aug 2006 23:06:59 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How do I run the MS Windows file search program from html
Message-Id: <5asme2l8te15n2pkbuii76tmg2ij0dn3dj@4ax.com>

On Tue, 22 Aug 2006 14:47:23 -0500, Ivan Marsh <annoyed@you.now>
wrote:

>>> How do I search for a file on my local drive containing a certain
>>> string, from a web page. That is, how do run the windows search program
>>> from a web page.
[snip]
>...and the client would have to grant access to do it so if we're talking
>about a public site (or a client not running Windows obviously) you can
>forget it.

And it would be awkward, albeit maybe not strictly impossible to even
want to run the Windows search program on a machine not running
Windows. It's clear that the question was referring to a client
running on a Windows box.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Tue, 22 Aug 2006 17:03:36 -0500
From: Ivan Marsh <annoyed@you.now>
Subject: Re: How do I run the MS Windows file search program from html
Message-Id: <pan.2006.08.22.22.03.35.20912@you.now>

On Tue, 22 Aug 2006 23:06:59 +0200, Michele Dondi wrote:

> On Tue, 22 Aug 2006 14:47:23 -0500, Ivan Marsh <annoyed@you.now>
> wrote:
> 
>>>> How do I search for a file on my local drive containing a certain
>>>> string, from a web page. That is, how do run the windows search program
>>>> from a web page.
> [snip]
>>...and the client would have to grant access to do it so if we're talking
>>about a public site (or a client not running Windows obviously) you can
>>forget it.
> 
> And it would be awkward, albeit maybe not strictly impossible to even
> want to run the Windows search program on a machine not running
> Windows. It's clear that the question was referring to a client
> running on a Windows box.

That's what obviously means.

-- 
The USA Patriot Act is the most unpatriotic act in American history.
  Feingold-Obama '08 - Because the Constitution isn't history,
                           It's the law.



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

Date: 22 Aug 2006 12:17:43 -0700
From: rashmiek@gmail.com
Subject: Multiple copies of perl
Message-Id: <1156274263.750559.281290@m73g2000cwd.googlegroups.com>

Hi,

I am struck with a problem.I have a perl script that takes UART port
number as a command line input. Using this input the same perl script
will have to be run on different hardware platforms.
Basically, I want to execute multiple copies of the same perl script.
Not sure how to achieve this.
I would appreciate if anyone can reply to this.

Thanks & Regards,
Rash



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

Date: 22 Aug 2006 21:47:39 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Multiple copies of perl
Message-Id: <vnnme2to49d606258fn4elqlomef5tjgmf@4ax.com>

On 22 Aug 2006 12:17:43 -0700, rashmiek@gmail.com wrote:

>Basically, I want to execute multiple copies of the same perl script.
>Not sure how to achieve this.

  $ perl -e '{redo}' & perl -e '{redo}' &
  [1] 14257
  [2] 14258
  $ ps x
    PID TTY      STAT   TIME COMMAND
  14238 ?        S      0:00 sshd: blazar@pts/11
  14239 pts/11   Ss     0:00 -bash
  14257 pts/11   R      0:04 perl -e {redo}
  14258 pts/11   R      0:03 perl -e {redo}
  14259 pts/11   R+     0:00 ps x


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 22 Aug 2006 12:00:57 -0700
From: oleg106@yahoo.com
Subject: Permission denied trying to execute shell commands from Perl/CGI.
Message-Id: <1156273257.589018.94330@p79g2000cwp.googlegroups.com>

Hi,

I just installed Apache and I am trying to call a script that should
output some stuff to my browser.  I can't get this to work at all.

Simple script

#! /usr/bin/perl -w
print "Content-type:text/html\n\n";
print `ls`;

The screen is blank.  httpd logs indicate permission denied ...

[Tue Aug 22 14:54:32 2006] [error] [client 172.25.31.80] ls: .,
referer: http://salrhellog01/maillog/
[Tue Aug 22 14:54:32 2006] [error] [client 172.25.31.80] : Permission
denied, referer: http://host/log/

Any idea?  The script works just fine locally, but not via the web.  I
tried exec and system, same deal.  User nobody has access to everything
it needs.



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

Date: 22 Aug 2006 11:29:33 -0700
From: "AJ" <aragorn.m@gmail.com>
Subject: Re: Problems with Win32::Internet FTP->put
Message-Id: <1156271373.937686.96570@i3g2000cwc.googlegroups.com>

Matt Garrish wrote:
>
> If you're using MS proxy server:
>
> http://support.microsoft.com/kb/233285/EN-US/
>
> Other thoughts: Have you tried specifying the remote file name? Since
> only the local is specified, you're also trying to write to
> 'c:/temp/testfile.tst' on the remote server. Is that really what you're
> trying to do?
>
> You might also want to try setting pasv before opening the connection.
>
> Matt

Matt,

Good insight, that was it. This thing has been plaging me for far to
lang... Thank you for your help and thanks to eveyone elese for taking
the time to give me your thoughts.

--AJ



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

Date: Tue, 22 Aug 2006 17:20:50 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Question about UNIVERSAL
Message-Id: <2gnrr3-d8r.ln1@osiris.mauzo.dyndns.org>


Quoth "Ferry Bolhar" <bol@adv.magwien.gv.at>:
> In the next line, I saw this code:
> 
> push @UNIVERSAL::ISA, 'Attribute::Handlers::UNIVERSAL'
>        unless grep /^Attribute::Handlers::UNIVERSAL$/, @UNIVERSAL::ISA;
> 
> This will push class "Attribute::Handlers::UNIVERSAL" (and so the methods
> defined above)

The 'methods defined above' are not pushed anywhere. They can be called
on objects inheriting from UNIVERSAL (which is everything).

> into UNIVERSAL's @ISA array.
> 
> Until now, I thought that, if Perl cannot find a method, it will look as
> last chance
> in package UNIVERSAL. Therefore, if one writes
> 
> package UNIVERSAL;
> 
> sub MySub {...};
> 
> "MySub" will be used if a method named "MySub" cannot be found in a class
> or all inherited classes.
> 
> But I thought there is one and only one class named "UNIVERSAL"!

Well, yes...

> What about class "Attribute::Handlers::UNIVERSAL"? Will this be a
> different UNIVERSAL class? Another "last chance" to look up for
> methods?

No, it's a completely different class called
'Attribute::Handlers::UNIVERSAL'. Perl doesn't attach any significance
to it: the name is just a reminder of its function.

> And does the ISA-mechanism apply to UNIVERSAL as well? If one writes
> 
> push @UNIVERSAL::ISA, "AnotherClass";
> 
> does Perl look in "UNIVERSAL" and then in "AnotherClass" as well as
> last chance?

What happened when you tried it?

> Couldn't cause this cyclic endless lookups?

No. Perl already handles cycles in the @ISA hierarchy (with an error);
the only thing special about UNIVERSAL is that it is implicitly at the
end of every @ISA. (Yes, there must be some special-case code that makes
Perl only consider UNIVERSAL once per method-lookup, and simply fail
rather than producing an error if it encounters it twice.)

> Can someone explain the purpose of these commands?

I would have thought it was obvious: to add some methods to every class
in a cleaner way than simply adding them to UNIVERSAL.

I would respectfully suggest that if you can't figure this out for
yourself, you're probably better off staying out of the guts of Deep
Magic modules like Attribute::Handlers.

Ben

-- 
        I must not fear. Fear is the mind-killer. I will face my fear and
        I will let it pass through me. When the fear is gone there will be 
        nothing. Only I will remain.
benmorrow@tiscali.co.uk                                   Frank Herbert, 'Dune'


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

Date: Tue, 22 Aug 2006 22:38:58 +0200
From: Martijn Lievaart <m@remove.this.part.rtij.nl>
Subject: Re: References - problem understanding them
Message-Id: <pan.2006.08.22.20.38.57.747600@remove.this.part.rtij.nl>

On Mon, 21 Aug 2006 14:21:36 -0400, Uri Guttman wrote:

>>>>>> "ML" == Martijn Lievaart <m@remove.this.part.rtij.nl> writes:
> 
>   >> Sure, this will work, but the entire hash gets copied when the sub 
>   >> returns. For large data structures this can be very inefficient. Passing 
>   >> around references is much more memory and time efficient for large and 
>   >> complex data structures.
> 
>   ML> Although excelent advice in heneral, in this case I would expect
>   ML> Perl to optimize it out. A return of something can be implemented
>   ML> as copy-destroy, or as a 'move'. The second is much more
>   ML> efficient.
> 
> it is trickier than just that. and perl 6 will be doing lazy copies and
> copy on write so that will be optimizable. it would be (almost?)
> impossible to make perl5 do this internally as it uses a stack to handle
> sub arguments and returns.

Right. I don't know anything about perls internals, so I believe you. It
sounds kind of illogical though, such a stack probably does not contain
the whole hash, probably some small data structure to the guts of the
hash. It seems like a big win to only copy that small datastructure.

But as I said, I know nothing of perls internals, the (mighty inefficient)
parsers/interpreters I've written myself are my only frame of reference
(no pun intended).

M4
-- 
Redundancy is a great way to introduce more single points of failure.



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

Date: Tue, 22 Aug 2006 21:50:45 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: References - problem understanding them
Message-Id: <ecfqn6$2t0$1@gemini.csx.cam.ac.uk>

Martijn Lievaart wrote:
> On Mon, 21 Aug 2006 14:21:36 -0400, Uri Guttman wrote:
> 
>>>>>>> "ML" == Martijn Lievaart <m@remove.this.part.rtij.nl> writes:
>>   >> Sure, this will work, but the entire hash gets copied when the sub 
>>   >> returns. For large data structures this can be very inefficient. Passing 
>>   >> around references is much more memory and time efficient for large and 
>>   >> complex data structures.
>>
>>   ML> Although excelent advice in heneral, in this case I would expect
>>   ML> Perl to optimize it out. A return of something can be implemented
>>   ML> as copy-destroy, or as a 'move'. The second is much more
>>   ML> efficient.
>>
>> it is trickier than just that. and perl 6 will be doing lazy copies and
>> copy on write so that will be optimizable. it would be (almost?)
>> impossible to make perl5 do this internally as it uses a stack to handle
>> sub arguments and returns.
> 
> Right. I don't know anything about perls internals, so I believe you. It
> sounds kind of illogical though, such a stack probably does not contain
> the whole hash, probably some small data structure to the guts of the
> hash. 

Why would you say that, having just admitted that it you don't know 
anything about perl internals? The *whole thing* gets put on the stack - 
(all the keys and values as a list), as my reply to your original post 
illustrates. Neither the address of the hash nor those of its internal 
elements are preserved.

> It seems like a big win to only copy that small datastructure.

It would be (modulo caveats about other references etc.). I've seen C++ 
compilers do exactly that optimization. Perl doesn't though. As many 
have now pointed out.


DS


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

Date: Tue, 22 Aug 2006 17:03:26 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: References - problem understanding them
Message-Id: <x71wr8jxep.fsf@mail.sysarch.com>

>>>>> "ML" == Martijn Lievaart <m@remove.this.part.rtij.nl> writes:

  ML> On Mon, 21 Aug 2006 14:21:36 -0400, Uri Guttman wrote:

  >> it is trickier than just that. and perl 6 will be doing lazy copies and
  >> copy on write so that will be optimizable. it would be (almost?)
  >> impossible to make perl5 do this internally as it uses a stack to handle
  >> sub arguments and returns.

  ML> Right. I don't know anything about perls internals, so I believe you. It
  ML> sounds kind of illogical though, such a stack probably does not contain
  ML> the whole hash, probably some small data structure to the guts of the
  ML> hash. It seems like a big win to only copy that small datastructure.

and what about deep vs shallow copies? and circular refs? and reference
counting? if you want those you have to be explicit and do it
yourself. there is no easy solution to those problems and perl5 decided
long ago to just provide a simple stack for call args and returns. it
makes it clean and easy to understand and also not difficult for the
coder to create solutions to the above problems. remember one of perl's
(many) mottos is to make easy things easy and hard things possible. a
stack with user code refs fits that very well.

  ML> But as I said, I know nothing of perls internals, the (mighty
  ML> inefficient) parsers/interpreters I've written myself are my only
  ML> frame of reference (no pun intended).

so please don't make any comments on what would be easy to do inside
perl. if you understand any of the problems i listed then you will know
why they are not handled directly in perl5.

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: Tue, 22 Aug 2006 22:05:13 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: References - problem understanding them
Message-Id: <ecfri9$45m$1@gemini.csx.cam.ac.uk>

David Squire wrote:
> Martijn Lievaart wrote:
>> On Mon, 21 Aug 2006 14:21:36 -0400, Uri Guttman wrote:
>>
>>>>>>>> "ML" == Martijn Lievaart <m@remove.this.part.rtij.nl> writes:
>>>   >> Sure, this will work, but the entire hash gets copied when the 
>>> sub   >> returns. For large data structures this can be very 
>>> inefficient. Passing   >> around references is much more memory and 
>>> time efficient for large and   >> complex data structures.
>>>
>>>   ML> Although excelent advice in heneral, in this case I would expect
>>>   ML> Perl to optimize it out. A return of something can be implemented
>>>   ML> as copy-destroy, or as a 'move'. The second is much more
>>>   ML> efficient.
>>>
>>> it is trickier than just that. and perl 6 will be doing lazy copies and
>>> copy on write so that will be optimizable. it would be (almost?)
>>> impossible to make perl5 do this internally as it uses a stack to handle
>>> sub arguments and returns.
>>
>> Right. I don't know anything about perls internals, so I believe you. It
>> sounds kind of illogical though, such a stack probably does not contain
>> the whole hash, probably some small data structure to the guts of the
>> hash. 
> 
> Why would you say that, having just admitted that it you don't know 
> anything about perl internals? The *whole thing* gets put on the stack - 
> (all the keys and values as a list)

 ...and if you don't believe me, try this:

----

#!/usr/bin/perl

use strict;
use warnings;

sub hashlike_list {
	my @list = qw(one uno two dos);
	return @list;
}

sub listlike_hash {
	my %hash = (
		'one' => 'einz',
		'two' => 'zwei',
	);
	return %hash;
}

my %test_hash = hashlike_list();
print "\$test_hash{one} = $test_hash{one}\n";
print "\$test_hash{two} = $test_hash{two}\n";

my @test_list = listlike_hash();
print map "$_, ", @test_list;

----

Aug 22 - 22:02 % ./test.pl
$test_hash{one} = uno
$test_hash{two} = dos
one, einz, two, zwei,


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

Date: 22 Aug 2006 15:04:35 -0700
From: alessandro.mendolia@gmail.com
Subject: Spazio utilizzato dagli utenti
Message-Id: <1156284275.698501.269430@h48g2000cwc.googlegroups.com>

Ciao a tutti, =E8 da un po che scandaglio questo NG ma non ho trovato
nessuno con un problema simile al mio dal quale capirci qualcosa di
+=2E..

Passando al problema:
Nella consolle questo comando mi restituisce la dimensione in kb di
ogni singolo file trovato sotto /home/Shared appartenente all' utente
pippo...

find /home/Shared/* -user pippo -ls | awk '{ print $2 }'

La mia idea era quella di fare in perl:

$writeout =3D 'find /home/Shared/* -user alessandro -ls | awk '{ print $2
}' '> echo FileList.txt'

in modo da poi riesaminare il file FileList.txt ed eseguire la somma
dei valori di ogni singola riga, e ricavare quindi lo spazio utilizzato
da quel determinato utente...

Il problema =E8 che perl quando eseguo:

#!/usr/bin/perl
$writeout =3D 'find /home/Shared/* -user alessandro -ls | awk '{ print $2
}' ' > echo FileList.txt'

si arrabbia perche credo che trovi un po troppe ' (virgoletta
singola)...

L' output che mi interessa =E8 la seconda colonna che questo comando mi
restituisce:
find /home/Shared/* -user alessandro -ls

Mi potete dare una mano, magari anche consigliandomi il modo di evitare
l' appoggio ad un file temporaneo?

Grazie a tutti!



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

Date: Tue, 22 Aug 2006 14:20:41 -0400
From: yo <>
Subject: variable with empty space
Message-Id: <qqhme2d59rtd18rulneipn7qolsjbha5k5@4ax.com>

Hi, 1st off I'm not a perl programmer and just know a few things that
I have picked up here and there.

I'm having trouble trying to figure out how to handle a value that's
being passed to my perl script. The value is, "      !", six spaces
and and a ! mark. I am having a difficult time making the script stop
executing the rest of the perl code when it sees this valued being
passed to it.

Ideally if the value being passed to it has a space, all spaces or
just on space I would like the script to stop also. 



I tried the following  

if ($username eq '')
if ($username eq ' ')
if ($username)
if ($username eq " ")
if ($username eq ''      !")
if ($username eq ''     \ !")

I do however want to be able to have this perl script run all the way
through if it does not see the value above or any blank space.

Heres part of the script that matters.


#!/usr/bin/perl

open(INFILE, "@ARGV[0]") ||
        die("Can't open @ARGV[0] for processing");
        $username = <INFILE>;
close(INFILE);

@rm_user = ("/usr/sbin/userdel $username","\n");

##### check empty dirs

if ($username eq ' ')
{
        print "\n";

        die("null variable");
}

elsif ($username eq "mail")
{
        print "\n";

        die(" ");
}

elsif ($username eq "root")
{
        print "\n";

        die(" ");
}


elsif (length($username) == 1)          # If above fails, try this
{
        print "The string has one character\n";

        @rm_user_outmail_me = ("cat /dev/null | /bin/mail -s
one.lenght  razor@meganet.net","\n");

        die("1 lenght variable");
}
else                            # Now, everything has failed
{


TIA, P


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

Date: 22 Aug 2006 11:37:16 -0700
From: usenet@DavidFilmer.com
Subject: Re: variable with empty space
Message-Id: <1156271836.728350.247940@74g2000cwt.googlegroups.com>

yo wrote:
[a multipoted question]

But the bot is presently turned off....

-- 
David Filmer (http://DavidFilmer.com)



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

Date: Tue, 22 Aug 2006 20:48:44 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: variable with empty space
Message-Id: <pan.2006.08.22.18.48.44.126102@hjp.at>

On Tue, 22 Aug 2006 14:20:41 -0400,  wrote:
> I'm having trouble trying to figure out how to handle a value that's
> being passed to my perl script. The value is, "      !", six spaces
> and and a ! mark. I am having a difficult time making the script stop
> executing the rest of the perl code when it sees this valued being
> passed to it.
> 
> I tried the following  
> 
> if ($username eq '')
> if ($username eq ' ')
> if ($username)
> if ($username eq " ")
> if ($username eq ''      !")
> if ($username eq ''     \ !")

why didn't you try the obvious 

  if ($username eq "      !")

?

> Ideally if the value being passed to it has a space, all spaces or
> just on space I would like the script to stop also. 

One space anywhere in the username? 

That would be (for example) 

  if ($username =~ / /)

> Heres part of the script that matters.
> 
> 
> #!/usr/bin/perl
> 
> open(INFILE, "@ARGV[0]") ||
>         die("Can't open @ARGV[0] for processing");
>         $username = <INFILE>;

You almost certainly want a
	chomp($username);
here, otherwise $username will contain a trailing newline.

Also, you only read the first line of the file. Is this what you want?

> close(INFILE);
> 

	hp

-- 
   _  | Peter J. Holzer    | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR       | > ist?
| |   | hjp@hjp.at         | Was sonst wäre der Sinn des Erfindens?
__/   | http://www.hjp.at/ |	-- P. Einstein u. V. Gringmuth in desd



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

Date: Tue, 22 Aug 2006 15:16:16 -0400
From: yo <>
Subject: Re: variable with empty space
Message-Id: <0clme292mtqu6aqs9ofraai8i3vke9eoof@4ax.com>

hmmm i tried that althought it didnt work, im seeing the      ! come
through, at least its showing up on the logs and i can't seem to match
that string.

However i changed your example below to  this if ($username =~ /!/)
and that worked.

thanks

On Tue, 22 Aug 2006 20:48:44 +0200, "Peter J. Holzer"
<hjp-usenet2@hjp.at> wrote:

>On Tue, 22 Aug 2006 14:20:41 -0400,  wrote:
>> I'm having trouble trying to figure out how to handle a value that's
>> being passed to my perl script. The value is, "      !", six spaces
>> and and a ! mark. I am having a difficult time making the script stop
>> executing the rest of the perl code when it sees this valued being
>> passed to it.
>> 
>> I tried the following  
>> 
>> if ($username eq '')
>> if ($username eq ' ')
>> if ($username)
>> if ($username eq " ")
>> if ($username eq ''      !")
>> if ($username eq ''     \ !")
>
>why didn't you try the obvious 
>
>  if ($username eq "      !")
>
>?
>
>> Ideally if the value being passed to it has a space, all spaces or
>> just on space I would like the script to stop also. 
>
>One space anywhere in the username? 
>
>That would be (for example) 
>
>  if ($username =~ / /)
>
>> Heres part of the script that matters.
>> 
>> 
>> #!/usr/bin/perl
>> 
>> open(INFILE, "@ARGV[0]") ||
>>         die("Can't open @ARGV[0] for processing");
>>         $username = <INFILE>;
>
>You almost certainly want a
>	chomp($username);
>here, otherwise $username will contain a trailing newline.
>
>Also, you only read the first line of the file. Is this what you want?
>
>> close(INFILE);
>> 
>
>	hp



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

Date: Tue, 22 Aug 2006 20:01:44 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: variable with empty space
Message-Id: <IoJGg.14576$365.4093@edtnps89>

yo wrote:
> Hi, 1st off I'm not a perl programmer and just know a few things that
> I have picked up here and there.
> 
> I'm having trouble trying to figure out how to handle a value that's
> being passed to my perl script. The value is, "      !", six spaces
> and and a ! mark. I am having a difficult time making the script stop
> executing the rest of the perl code when it sees this valued being
> passed to it.
> 
> Ideally if the value being passed to it has a space, all spaces or
> just on space I would like the script to stop also. 
> 
> 
> 
> I tried the following  
> 
> if ($username eq '')
> if ($username eq ' ')
> if ($username)
> if ($username eq " ")
> if ($username eq ''      !")
> if ($username eq ''     \ !")

You probably want to use a regular expression:

if ( $username =~ /\A *!?\z/ )


> I do however want to be able to have this perl script run all the way
> through if it does not see the value above or any blank space.
> 
> Heres part of the script that matters.
> 
> 
> #!/usr/bin/perl

use warnings;
use strict;

You should include these two pragmas and let perl help you find mistakes.


> open(INFILE, "@ARGV[0]") ||

You are using an array slice when you want a scalar and you are needlessly
quoting it.

open(INFILE, $ARGV[0]) ||


>         die("Can't open @ARGV[0] for processing");

Again, you want a scalar not a slice:

         die("Can't open $ARGV[0] for processing");


>         $username = <INFILE>;
> close(INFILE);
> 
> @rm_user = ("/usr/sbin/userdel $username","\n");

That should either be:

my $rm_user = "/usr/sbin/userdel $username";

Or:

my @rm_user = ( '/usr/sbin/userdel', $username );

You don't need a newline in there in either case.


> ##### check empty dirs
> 
> if ($username eq ' ')
> {
>         print "\n";
> 
>         die("null variable");
> }
> 
> elsif ($username eq "mail")
> {
>         print "\n";
> 
>         die(" ");
> }
> 
> elsif ($username eq "root")
> {
>         print "\n";
> 
>         die(" ");
> }
> 
> 
> elsif (length($username) == 1)          # If above fails, try this
> {
>         print "The string has one character\n";
> 
>         @rm_user_outmail_me = ("cat /dev/null | /bin/mail -s
> one.lenght  razor@meganet.net","\n");

Again, you don't need a newline at the end and perl will interpolate @meganet
as an array so you need to either escape the '@' character or use single quotes.

         $rm_user_outmail_me = 'cat /dev/null | /bin/mail -s one.length
razor@meganet.net';


> 
>         die("1 lenght variable");

         die("1 length variable");


> }
> else                            # Now, everything has failed
> {


John
-- 
use Perl;
program
fulfillment


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

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 V10 Issue 9636
***************************************


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