[23992] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6193 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 28 18:05:43 2004

Date: Sat, 28 Feb 2004 15:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 28 Feb 2004     Volume: 10 Number: 6193

Today's topics:
    Re: [newbie] printing a hash <tadmc@augustmail.com>
    Re: [newbie] printing a hash <tadmc@augustmail.com>
        Along a similar vein (Was Re: hash of hashes with lists <joec@aracnet.com>
    Re: Along a similar vein (Was Re: hash of hashes with l <tadmc@augustmail.com>
    Re: Along a similar vein (Was Re: hash of hashes with l <gnari@simnet.is>
    Re: Finding a string in an other string, then.. <joel@hotmail.ru>
    Re: Finding a string in an other string, then.. <tadmc@augustmail.com>
    Re: Finding a string in an other string, then.. <gnari@simnet.is>
        how die in AUTOLOAD <yshtil@cisco.com>
    Re: HTML in utf8 and perl <niewiap@NOSPAM.widzew.net.INVALID>
    Re: HTML in utf8 and perl <flavell@ph.gla.ac.uk>
        LWP User Agent/HTTP Request help needed! <bumble@what.the.heck>
    Re: LWP User Agent/HTTP Request help needed! <gnari@simnet.is>
        reading output file data as input data (Stephen Moon)
        Regex help needed for complicated mass renaming (BBQ)
    Re: Regex help needed for complicated mass renaming (Jay Tilton)
    Re: Regex help needed for complicated mass renaming <fifo@despammed.com>
        Regexp problem <chatiman@free.fr>
    Re: Regexp problem <tadmc@augustmail.com>
    Re: Thanks for the advice <tadmc@augustmail.com>
        umask and CPAN installs (JVarsoke)
    Re: umask and CPAN installs <jwillmore@remove.adelphia.net>
    Re: umask and CPAN installs <todd@tdegruyl.com>
    Re: using sed from with a perl script <fifo@despammed.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 28 Feb 2004 08:22:47 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [newbie] printing a hash
Message-Id: <slrnc4191n.5hg.tadmc@magna.augustmail.com>

Iain <spamtrap@deepsea.force9.co.uk> wrote:

>> while (<FILE>) {
> 
> Whereas <> as the sole condition for a while loop is magic, and is 
> shorthand for:
> 
> while ( $_ = <FILE> ) {


It is actually shorthand for:

   while ( defined($_ = <FILE>) ) {


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 28 Feb 2004 08:25:23 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [newbie] printing a hash
Message-Id: <slrnc4196j.5hg.tadmc@magna.augustmail.com>

David <auto87829@hushmail.com> wrote:

> I can't really visualise what's going on in this code. 


> my @fields = qw/a b c d e f g h i j k/;
[snip]
>     @hash{@fields} = split(/\t/, $record);


I'll guess that this is what is throwing you (despite the many
other problems in your program).

That is a "hash slice". Read all about it in the "Slices" section of:

   perldoc perldata


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 28 Feb 2004 08:38:47 -0800
From: Joe Cipale <joec@aracnet.com>
Subject: Along a similar vein (Was Re: hash of hashes with lists)
Message-Id: <4040C417.97451743@aracnet.com>

Along a similar vein as to the original thread:
I have an cgi-app I am beginning to encode. It is an online fee
calculation page. Users need to be able to add/edit/delete an entry at
wiil, and have 
the entries be visible after each operation.

I could use a variant of an online merchant form, but that (appears) to
operate off of a fixed database/storage mechanism. What I am hoping for
is a dynamic hash list (similar to a linked-list in C/C++). Can a hash
of a hash be allocated dynamically?

Regards,

Joe
-- 
#----------------------------------------------------------#
#                "Don't fear the penguin!"                 #
#----------------------------------------------------------#
# Registered Linux user: #309247     http://counter.li.org #
#----------------------------------------------------------#


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

Date: Sat, 28 Feb 2004 11:47:16 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Along a similar vein (Was Re: hash of hashes with lists)
Message-Id: <slrnc41l14.6c9.tadmc@magna.augustmail.com>

Joe Cipale <joec@aracnet.com> wrote:

> What I am hoping for
> is a dynamic hash list (similar to a linked-list in C/C++). 


Please do not re-ask FAQs.

   perldoc -q linked

       How do I handle linked lists?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 28 Feb 2004 18:42:54 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Along a similar vein (Was Re: hash of hashes with lists)
Message-Id: <c1qndh$iff$1@news.simnet.is>

"Joe Cipale" <joec@aracnet.com> wrote in message
news:4040C417.97451743@aracnet.com...
> Along a similar vein as to the original thread:
> I have an cgi-app I am beginning to encode. It is an online fee
> calculation page. Users need to be able to add/edit/delete an entry at
> wiil, and have
> the entries be visible after each operation.
>
> I could use a variant of an online merchant form, but that (appears) to
> operate off of a fixed database/storage mechanism. What I am hoping for
> is a dynamic hash list (similar to a linked-list in C/C++). Can a hash
> of a hash be allocated dynamically?

your problem is not clear.
you use word combinations that do not ring any bells
in what way are hashes similar to linked lists?

maybe a more concrete example of what you are tryng to do
would make things clearer.
the comment about storage seems to imply that you need
session information to be carried from request to request,
but you do not want to use storage. is this the case?

I suspect we have a XY problem here. you want to do X,
but think you need Y to do that and ask about Y

if your question is really about linked lists, the read the FAQ,
and then you can ask here it that does not help

gnari





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

Date: Sat, 28 Feb 2004 18:12:05 +0300
From: Joel <joel@hotmail.ru>
Subject: Re: Finding a string in an other string, then..
Message-Id: <urb1409fb7t92g7kl1hk9vo9aguquq1at0@4ax.com>


Yes it worked already like that, but the problem is that my number tis
a DECIMAL one (xx.yyyy) and I get only the "xx" with this method !


Thanks,

Joel

On Sat, 28 Feb 2004 10:58:25 GMT, Beable van Polasm
<beable+unsenet@beable.com.invalid> wrote:

>Joel <joel@hotmail.ru> writes:
>
>> I have a text $alltext, and want to find a specific string
>> $stringtofind that is in the text.
>> 
>> Then, I want the script to read a number that is right after the
>> string.
>
>This sounds like a job for... Regular Expressions! Please read these
>documents:
>
>perldoc perlrequick
>perldoc perlretut
>perldoc perlre
>
>> What is the best way to get it ?
>
>It depends upon your definition of "number", and so on. This
>program might do something like what you want.
>
>#!/usr/bin/perl
>
>use strict;
>use warnings;
>
>my $alltext = "some string with some stuff in it 34454 and a number";
>my $stringtofind = "stuff in it ";
>
>if ($alltext =~ m/$stringtofind(\d+)/)
>{
>    my $number = $1;
>    print(" found string, number is $number\n");
>}
>else
>{
>    print("string not found\n");
>}
>
>__END__
>
>
>   




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

Date: Sat, 28 Feb 2004 09:26:40 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Finding a string in an other string, then..
Message-Id: <slrnc41cpg.633.tadmc@magna.augustmail.com>


[ Please do not post upside-down.
  Text rearranged into actual chronological order.
  Please do not quote an entire article.
]


Joel <joel@hotmail.ru> wrote:
> On Sat, 28 Feb 2004 10:58:25 GMT, Beable van Polasm
><beable+unsenet@beable.com.invalid> wrote:
>>Joel <joel@hotmail.ru> writes:
>>
>>> I have a text $alltext, and want to find a specific string
>>> $stringtofind that is in the text.
>>> 
>>> Then, I want the script to read a number that is right after the
>>> string.

>>> What is the best way to get it ?


>>if ($alltext =~ m/$stringtofind(\d+)/)
                                 ^^^^^
                                 ^^^^^ "number" is specified here

> Yes it worked already like that, but the problem is that my number tis
> a DECIMAL one (xx.yyyy) and I get only the "xx" with this method !


Then change the method so as to accomodate your definition of "number".

Show us what you have tried so far, and we will help you fix it.

The Perl FAQ has regexes for various definitions of "number".

   perldoc -q number

      How do I determine whether a scalar is a number/whole/integer/float?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 28 Feb 2004 15:33:13 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Finding a string in an other string, then..
Message-Id: <c1qc9r$h70$1@news.simnet.is>

"Joel" <joel@hotmail.ru> top-posted in message
news:urb1409fb7t92g7kl1hk9vo9aguquq1at0@4ax.com
>
> Yes it worked already like that, but the problem is that my number tis
> a DECIMAL one (xx.yyyy) and I get only the "xx" with this method !

so what did you try to fix that, and how did it fail ?

>
> On Sat, 28 Feb 2004 10:58:25 GMT, Beable van Polasm
> <beable+unsenet@beable.com.invalid> wrote:

[snipped WHOLE message quotes]

gnari






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

Date: Sat, 28 Feb 2004 13:22:24 -0800
From: Yuri Shtil <yshtil@cisco.com>
Subject: how die in AUTOLOAD
Message-Id: <40410690.4090204@cisco.com>

Hi all

I wrote the following code to call functions in an another package and 
process the return value.

I check if the computed routine exists in the target package and call
die if it does not. When I run this code there is no die message 
displayed, the program exits silently.

Any thoughts?

no strict;
sub AUTOLOAD
   {
       my ($name, $oldsub);
       my $sub = $oldsub = $AUTOLOAD;

       $sub =~ s/.*::_(.+)$/package::$1/;

       $name = $1;

       if (! defined &$sub) {
          die "cannot autoload $oldsub";

       }

       $AUTOLOAD = $sub;
       my $ret = &$AUTOLOAD;

# Process return value
}



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

Date: Sat, 28 Feb 2004 18:14:52 +0000 (UTC)
From: Pawel Niewiadomski <niewiap@NOSPAM.widzew.net.INVALID>
Subject: Re: HTML in utf8 and perl
Message-Id: <Xns949DC20CA5BE2niewiapNOSPAMwidzewn@212.51.192.18>

"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in 
news:Pine.LNX.4.53.0402281305100.23691@ppepc56.ph.gla.ac.uk:

> On Sat, 28 Feb 2004, Pawel Niewiadomski wrote:
> 
> Where's your strict and warnings ?  Please read the group guidelines
> and help yourself before asking others to help you.  (Even if it isn't
> the actual issue here).
Indeed. Thanks for your advice
> Why on Earth use printf() instead of print() here?  Again not the
> specific issue here - but one day that's going to bite.
> http://www.perldoc.com/perl5.8.0/pod/func/printf.html
> 
Just the old C habits. You're absolutely right
> 
> The character U+D184 is in the Hangul Syllables area, not Cyrillic
> http://www.unicode.org/charts/PDF/UAC00.pdf
> 
> Your CYRILLIC SMALL LETTER EF character is \x{0444}
> 
>> produces two characters encoded differently, although theoretically it
>> should generate two russian ef's identically encoded.
> 
> No, theoretically the second one should generate the Unicode character
> which you specified.  You're confusing Unicode values with their utf-8
> encodings.
That was the answer I was looking for. I didn't really quite understand 
the difference between the encoding of the character in utf8 and its 
value in Unicode. I swear I have searched at least 3 faq's and looked 
through the newsgroups archives. I must have been looking in the wrong 
places :-)
> 
>> refer me to a sensible source of information.
> 
> perldoc perluniintro, perldoc perlunicode, and
Been there, seen that. Again it didn't give me much as I was mixing up 
the idea of Unicode value and utf8 encoding. I was using a UTF-8 
translation table instead of the original Unicode tables.
> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
> 
> good luck

Thanks a lot,
Pawel


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

Date: Sat, 28 Feb 2004 18:45:26 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: HTML in utf8 and perl
Message-Id: <Pine.LNX.4.53.0402281833500.23691@ppepc56.ph.gla.ac.uk>

On Sat, 28 Feb 2004, Pawel Niewiadomski wrote:

> "Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in

> > No, theoretically the second one should generate the Unicode character
> > which you specified.  You're confusing Unicode values with their utf-8
> > encodings.
>
> That was the answer I was looking for. I didn't really quite understand
> the difference between the encoding of the character in utf8 and its
> value in Unicode.

Glad it helped.

Of course, now that you know the answer, it should easy to find it in
the documentation.  :-}

The Unicode "code points" (the term used in the perluniintro) are
encoded in different ways (different bit-patterns) in utf-8, utf-16 or
indeed other applicable Unicode encodings, but they still represent
the same "code point".  It just so happens that Perl chose internally
to represent characters by using utf-8 representation, but the ord()
values of the Unicode characters are still their code point values,
and, as you've now seen, the wide character constant is represented by
\x{...} using its code point value, the same as is tabulated in the
character code charts at the Unicode site,
http://www.unicode.org/charts/

all the best


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

Date: Sat, 28 Feb 2004 18:48:48 -0000
From: "Bumble" <bumble@what.the.heck>
Subject: LWP User Agent/HTTP Request help needed!
Message-Id: <c1qnp0$d6m$1@news7.svr.pol.co.uk>

Hey all, basically I've got the LWP User Agent all working, it retrieves a
HTML page at the specified HTTP location... Now I only need a small part of
the HTML, the bit with the actual data in, what's the best way of doing
this? I was originally outputting the retrieved HTML to a HTML file and then
reading the file in, line by line until I found the required data and then
extracting that... However this requires creating a file on the server, of
which I don't seem to have permission to do, and seems a bit of a long
winded way of doing it. Is there a better way? Can I do a search of the my
$response variable somehow and then just store the bit I need? I am working
on getting file writing access on server, as I need to store the data
somehow...

Here is a snippet of the code...

$ua = LWP::UserAgent->new;
$ua->proxy('http', 'cache address here');

$request = HTTP::Request->new('GET', http://address here);

my $response = $ua->request($request);

-- 
Bumble




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

Date: Sat, 28 Feb 2004 19:53:01 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: LWP User Agent/HTTP Request help needed!
Message-Id: <c1qrgv$it5$1@news.simnet.is>

"Bumble" <bumble@what.the.heck> wrote in message
news:c1qnp0$d6m$1@news7.svr.pol.co.uk...
> Hey all, basically I've got the LWP User Agent all working, it retrieves a
> HTML page at the specified HTTP location... Now I only need a small part
of
> the HTML, the bit with the actual data in, what's the best way of doing
> this? I was originally outputting the retrieved HTML to a HTML file and
then
> reading the file in, line by line until I found the required data and then
> extracting that... However this requires creating a file on the server, of
> which I don't seem to have permission to do, and seems a bit of a long
> winded way of doing it. Is there a better way? Can I do a search of the my
> $response variable somehow and then just store the bit I need?

yes. what exactly is the problem with that?

if you need to process the data line by line, you can split it into
an array
    my @arr=split /\n/,$response;
    for my $line (@arr) {
      # do stuff
    }
or:
    for my $line (split /\n/,$response) {...}

but with HTML does not really have a line structure, so it is
doubtful you gain anything by that.

if the data you are looking for is easily recognisable, you
can use a regular expression, otherwise you can use a
HTML parser from CPAN

 gnari






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

Date: 28 Feb 2004 14:51:08 -0800
From: vibfft@yahoo.com (Stephen Moon)
Subject: reading output file data as input data
Message-Id: <9feadd98.0402281451.61314473@posting.google.com>

At the command prompt, 

I type "perl test.pl <file1> <file2> <file3>" to run the program.

Initially, I open <file1> as an input file and output the information
to <file2>.  Later on in the same program, I use <file2> as an input
and write the output to <file3>.

I get an error saying that "filehandler FH opened for output only"
although I close the <file2> and reopen it with a new filehandle.

-Steve


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

Date: 28 Feb 2004 10:18:56 -0800
From: bbq_pit@hotmail.com (BBQ)
Subject: Regex help needed for complicated mass renaming
Message-Id: <d6017ce4.0402281018.6399c8e8@posting.google.com>

I have inherited a series of files in the following format:

TestTest1.txt
TestTest2.jpg
Test_Test3.txt
Test_TestTest4.txt
NASATest.txt
NASATest5.txt
TestTestTestTest.mpg
Test6Test.txt
Test.txt

which I want to rename as follows:

test_test1.txt
test_test2.jpg
test_test3.txt
test_test_test4.txt
nasa_test.txt
nasa_test5.txt
test_test_test_test.mpg
test6_test.txt
test.txt

In other words: everything lower case (this bit I can do) and
underscores before each uppercase letter (as long as it is not the
first character).

I've been trying (and failing) to put a '_' before every captial
letter, I was then going to chop of the first character if it is a '_'
(which I can do) and then lower case everything (which I can do). As
for not inserting multiple '_'s in between multiple capitials in a row
(NASATest.txt -> nasa_test.txt), I'm not sure where to start. I was
going to just alter those by hand.

Better solutions are most welcome (and if they are quite cryptic, a
few comments also would be great).


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

Date: Sat, 28 Feb 2004 19:26:10 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Regex help needed for complicated mass renaming
Message-Id: <4040e7f6.75676797@news.erols.com>

bbq_pit@hotmail.com (BBQ) wrote:

: I have inherited a series of files in the following format:
: 
: TestTest1.txt
: TestTest2.jpg
: Test_Test3.txt
: Test_TestTest4.txt
: NASATest.txt
: NASATest5.txt
: TestTestTestTest.mpg
: Test6Test.txt
: Test.txt
: 
: which I want to rename as follows:
: 
: test_test1.txt
: test_test2.jpg
: test_test3.txt
: test_test_test4.txt
: nasa_test.txt
: nasa_test5.txt
: test_test_test_test.mpg
: test6_test.txt
: test.txt
: 
: In other words: everything lower case (this bit I can do) and
: underscores before each uppercase letter (as long as it is not the
: first character).
: 
: I've been trying (and failing) to put a '_' before every captial
: letter, I was then going to chop of the first character if it is a '_'
: (which I can do) and then lower case everything (which I can do). As
: for not inserting multiple '_'s in between multiple capitials in a row
: (NASATest.txt -> nasa_test.txt), I'm not sure where to start. I was
: going to just alter those by hand.

A zero-width negative lookahead assertion is just the ticket.

    s/
        (   [[:upper:]] ) # An upper-case character
        (?! [[:upper:]] ) # that is not followed by another
    /_$1/xg; # Insert a preceding underscore

In fact, zero-width lookahead/lookbehind assertions can take care of most
of the other requirements.

    s/
        (?! ^) # Don't match at the string's beginning.
        (?<! _ ) # A character not preceded by an underscore,
        (?=
            [[:upper:]] # ...that is a UC letter,
            (?!
                [[:upper:]] # ...but is not followed by another.
            )
        )
    /_/xg; # Jam an underscore in the matched position

All that's left to do after that is to lower-case the string.



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

Date: Sat, 28 Feb 2004 19:54:50 +0000
From: fifo <fifo@despammed.com>
Subject: Re: Regex help needed for complicated mass renaming
Message-Id: <20040228195446.GB3446@fleece>

At 2004-02-28 19:26 +0000, Jay Tilton wrote:
> bbq_pit@hotmail.com (BBQ) wrote:
> 
> : I have inherited a series of files in the following format:
> : 
> : TestTest1.txt
> : TestTest2.jpg
> : Test_Test3.txt
> : Test_TestTest4.txt
> : NASATest.txt
> : NASATest5.txt
> : TestTestTestTest.mpg
> : Test6Test.txt
> : Test.txt
> : 
> : which I want to rename as follows:
> : 
> : test_test1.txt
> : test_test2.jpg
> : test_test3.txt
> : test_test_test4.txt
> : nasa_test.txt
> : nasa_test5.txt
> : test_test_test_test.mpg
> : test6_test.txt
> : test.txt
> : 
> 
[snip]
> In fact, zero-width lookahead/lookbehind assertions can take care of most
> of the other requirements.
> 
>     s/
>         (?! ^) # Don't match at the string's beginning.
>         (?<! _ ) # A character not preceded by an underscore,
>         (?=
>             [[:upper:]] # ...that is a UC letter,
>             (?!
>                 [[:upper:]] # ...but is not followed by another.
>             )
>         )
>     /_/xg; # Jam an underscore in the matched position
> 
> All that's left to do after that is to lower-case the string.
> 

This works for the given list, but it doesn't handle things like
"TestNASA.txt", which may or may not be a problem.  Here's another WTDI:

  my $word = '[A-Z][A-Z][A-Z0-9]*(?![a-z])|[A-Z][a-z0-9]*';
  s/($word)/_$1/og;
  s/(^|_)_($word)/$1$2/og;


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

Date: Sat, 28 Feb 2004 18:32:02 +0100
From: "chatiman" <chatiman@free.fr>
Subject: Regexp problem
Message-Id: <4040d08f$0$29951$626a14ce@news.free.fr>

Hello,

I'd like to match a line which does not begin with a given words and match a
given regexp.
eg:
lines which contains "bar" but does not begin with "foo"

I tried the following regexp but this doesn't work:
/^(?<!foo).*bar/

Any ideas to do that in 1 regexp?






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

Date: Sat, 28 Feb 2004 11:42:37 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regexp problem
Message-Id: <slrnc41kod.6c9.tadmc@magna.augustmail.com>

chatiman <chatiman@free.fr> wrote:

> lines which contains "bar" but does not begin with "foo"
> 
> I tried the following regexp but this doesn't work:
> /^(?<!foo).*bar/


You are looking in the wrong direction.


> Any ideas to do that in 1 regexp?


    /^(?!foo).*bar/


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 28 Feb 2004 08:18:47 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Thanks for the advice
Message-Id: <slrnc418q7.5hg.tadmc@magna.augustmail.com>

JC <jwcorpening@verizon.net> wrote:
> Tad McClellan wrote:
>>>I code alot with PERL, 
>> No you don't.
>> You code a lot with Perl.
>> Perl is not an acronym.
> 
> Why do you waste your time to "correct" me?


1) because you are wrong.

2) because it is not a waste of time to help you clear up 
   your misunderstanding.

3) because I assumed you would _want_ to be correct.

4) so people don't continue to snicker at you because you can't
   even spell the name of the language you are using.


If you prefer to have your ignorance laughed at, that is certainly
up to you.

I just wanted to give you the opportunity to be taken seriously.


> PERL = Practical Extraction and Report Language.


Errr, that pretty much proves my point.

Larry chose the name first, the expansion came later.

If you wanted to prove your incorrect point, it would go in
the other direction, the expansion would lead to the name:

   Practical Extraction and Report Language = PERL


> Get a life, 


Get multiple interconnected brain cells.


> or a girlfriend.


While I have a great wife, I doubt that she is great enough to go 
along with that suggestion...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 28 Feb 2004 08:11:59 -0800
From: usenet.9.jvarsoke@spamgourmet.com (JVarsoke)
Subject: umask and CPAN installs
Message-Id: <bfa58f21.0402280811.214af42a@posting.google.com>

The root account on my system has a very strict umask for security
reasons.  Normally when I install programs this is not a problem.  But
when I use perl -MCPAN to install modules they are always installed
with the umask, and thus nobody can use them except root.  Is there a
way to tell CPAN to open the permissions on modules at installation
time?  Otherwise I need to hunt around for all the files (.pm and .so)
and chmod 644 them -- which is error prone and annoying.

Any suggestions?

-jason


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

Date: Sat, 28 Feb 2004 11:59:45 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: umask and CPAN installs
Message-Id: <pan.2004.02.28.16.59.42.155795@remove.adelphia.net>

On Sat, 28 Feb 2004 08:11:59 -0800, JVarsoke wrote:

> The root account on my system has a very strict umask for security
> reasons.  Normally when I install programs this is not a problem.  But
> when I use perl -MCPAN to install modules they are always installed
> with the umask, and thus nobody can use them except root.  Is there a
> way to tell CPAN to open the permissions on modules at installation
> time?  Otherwise I need to hunt around for all the files (.pm and .so)
> and chmod 644 them -- which is error prone and annoying.
> 
> Any suggestions?

I'm not sure this will work, but I'll toss it out there and see if anyone
says yea or nay :-)

You could fashion a script to set your umask to something less
restrictive, run the CPAN shell, then unset the umask.

So, you could have ....

#!/bin/bash
unmask 0022
perl -MCPAN -e 'shell'
unset umask

My thinking is this ...
since you start another invocation of a shell (I use bash, but it could
be any), you can (un)set the umask as needed and it will be available
*only* for that invocation of the shell.  The one issue I see right off
is if the CPAN shell will inherit the umask you set in this new
invocation or start yet another invocation of the shell, getting the
unask from somewhere like your .bashrc or .profile of somewhere else. If
it does, you're in business. If not, then you'll need another way.

Another option is to use 'look' instead of 'install'.  Here, you start
another invocation of your shell within the CPAN shell.  Set your umask. 
Then do your install (perl Makefile.PL, make, make test, make install ). 
This defeats the whole idea of using the shell, but I'm pretty certain it
will work.

Yet another option is to fashion your own install script using the CPAN
module (`perldoc CPAN` for more info).  This isn't as nice as using the
CPAN shell, but would solve the issue, maybe.  I'm not 100% sure how you
would set the umask in this way that would stick.  Using 'system' won't
work, AFAIK, and I'm not sure if setting it with the %ENV hash
($ENV{'umask'}) will work; although it's worth a shot.

Others may have other options.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
You can learn many things from children.  How much patience you
<have, for instance.   -- Franklin P. Jones 



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

Date: Sat, 28 Feb 2004 17:00:01 GMT
From: Todd de Gruyl <todd@tdegruyl.com>
Subject: Re: umask and CPAN installs
Message-Id: <nht6h1-8ma.ln1@espresso.tdegruyl.com>

JVarsoke wrote:
> The root account on my system has a very strict umask for security
> reasons.  Normally when I install programs this is not a problem.  But
> when I use perl -MCPAN to install modules they are always installed
> with the umask, and thus nobody can use them except root.  Is there a
> way to tell CPAN to open the permissions on modules at installation
> time?  Otherwise I need to hunt around for all the files (.pm and .so)
> and chmod 644 them -- which is error prone and annoying.
> 
> Any suggestions?

This is not really a perl answer, since I don't know if there is a way 
to do this in CPAN.  My answer is also dependant upon what shell you 
use, but you should be able to use the umask command (after you su or 
login to root) before beginning your install.

-- 
Todd de Gruyl
todd@tdegruyl.com
http://www.tdegruyl.com


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

Date: Sat, 28 Feb 2004 18:58:15 +0000
From: fifo <fifo@despammed.com>
Subject: Re: using sed from with a perl script
Message-Id: <20040228185814.GA3446@fleece>

At 2004-02-28 13:03 +0000, fifo wrote:
>
>   {
>     open my $in, '<', 'file.csv' or die $!;
>     open my $out, '>', 'file.csvnew' or die $!;
>     while (<$in>) {
>       last if eof;
>       print;

Of course that should have been

      print $out $_;

>     }
>   }
> 


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

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 6193
***************************************


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