[28628] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9992 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 21 11:05:56 2006

Date: Tue, 21 Nov 2006 08:05:07 -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           Tue, 21 Nov 2006     Volume: 10 Number: 9992

Today's topics:
    Re: Change user <nobull67@gmail.com>
    Re: Change user <na@noaddress.com>
    Re: How to post back the data by selecting a value from <kunanu@gmail.com>
    Re: Multiline substitution <njus@larshaugseth.com>
    Re: Multiline substitution <gooliverNOSP@mlibero.it>
    Re: Multiline substitution <njus@larshaugseth.com>
    Re: Multiline substitution <mritty@gmail.com>
    Re: Multiline substitution <gooliverNOSP@mlibero.it>
    Re: Multiline substitution anno4000@radom.zrz.tu-berlin.de
    Re: Perl is worth nothing!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <jurgenex@hotmail.com>
        Perl substitution working on some machines but not othe therocket79@yahoo.co.uk
    Re: Perl substitution working on some machines but not  anno4000@radom.zrz.tu-berlin.de
    Re: Perl substitution working on some machines but not  therocket79@yahoo.co.uk
        search replace retain and compare strings? <balaji.draj@gmail.com>
    Re: search replace retain and compare strings? <spamtrap@dot-app.org>
    Re: search replace retain and compare strings? <njus@larshaugseth.com>
    Re: string assignment and concatenation <mritty@gmail.com>
    Re: using an array to set up hash keys <nobull67@gmail.com>
    Re: Win32::Registry::File - update values in file (reading news)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 21 Nov 2006 04:52:15 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Change user
Message-Id: <1164113535.901072.172440@m7g2000cwm.googlegroups.com>



On Nov 21, 3:23 am, lucas <n...@noaddress.com> wrote:
> Is there a way to change the user from root to say 'nobody' after a perl
> script is executed?

Define "the user" and "after".

I suspect you are asking if a process can alter the UID of its parent.
The answer is no.

>   Aside from using the English module that is.

I don't see how that fits in.



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

Date: Tue, 21 Nov 2006 10:06:26 -0500
From: lucas <na@noaddress.com>
Subject: Re: Change user
Message-Id: <36a2c$456315f0$cef8bf78$3633@TEKSAVVY.COM>

John W. Krahn wrote:


> $< = getpwnam 'nobody';

Thanks john.  I'm running Slackware10.1 and that didn't quit work for me.  I
looked it up and there is the Real ID and the Effective ID.  Here's the
quote:

"The $< and $> variables contain, respectively, the real user ID and
effective user ID for the program. The real user ID is the ID under which
the user of the program logged in. The effective user ID is the ID
associated with this particular program (which is not always the same as
the real user ID)."

So, I tried the Effective ID and it worked when I looked at the process from
another window.  Here's the test code:

perl -e 'print "$> - $)\n";$>=getpwnam "nobody";$)=getgrnam
"nobody";sleep(5);print "$> - $)\n";'

Thanks for your help,
-- 
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------


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

Date: 21 Nov 2006 07:29:24 -0800
From: "Kuna" <kunanu@gmail.com>
Subject: Re: How to post back the data by selecting a value from drop down list
Message-Id: <1164122964.276537.274590@f16g2000cwb.googlegroups.com>


Gunnar Hjalmarsson wrote:
> Kuna wrote:
> > I got your point that we can only use JavaScript for this purpose.
>
> That's not what Paul told you.
>
> Actually I just posted some Perl code at
> http://www.thescripts.com/forum/thread566345.html
>
> > I will must go
> > through the posting guidelines before posting my next post.
>
> Yeah, you'd better do that. But even more imporant is that you stop
> multi-posting: http://lipas.uwasa.fi/~ts/http/crospost.html
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

Hi Gunnar,

Thanks for the suggestion, but I was looking for the solution of my
problem with some reliable answer. So I had posted in different forums
in your words multi-posting. I was not really trieng to do any kind of
nonsence things but my requirement makes me to do so. Sorry again to
all my members if I had done any thing wrong.

Thanks again,
Kuna



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

Date: Tue, 21 Nov 2006 12:15:11 GMT
From: Lars Haugseth <njus@larshaugseth.com>
Subject: Re: Multiline substitution
Message-Id: <87lkm5xb57.fsf@durin.larshaugseth.com>


* gooliver <gooliverNOSP@mlibero.it> wrote:
> 
> I've this text on a TeX-file source.tex:
>
>   bla bla bla...
>   $$
>   some equation
>   $$
>   bla bla bla...
>
> and i want convert source.tex in a file dest.tex where $$
> are replaced from the couple \[...\]
>
>   bla bla bla...
>   \[
>   some equation
>   \]
>   bla bla bla...
>
> but i've encountered most difficulties about pattern-matching
> of the multiline string $$...$$ !!!
>
> Have you some suggestion?

Assuming two $ characters never appear next to each other in
other circumstances:

$code =~ s{ \$\$ (.*?) \$\$ }{\\[$1\\]}gxms;

-- 
Lars Haugseth

"If anyone disagrees with anything I say, I am quite prepared not only to
 retract it, but also to deny under oath that I ever said it." -Tom Lehrer


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

Date: Tue, 21 Nov 2006 12:32:57 GMT
From: gooliver <gooliverNOSP@mlibero.it>
Subject: Re: Multiline substitution
Message-Id: <op.tjc844fixr5pep@amilol1300>

> Assuming two $ characters never appear next to each other in
> other circumstances:
>
> $code =3D~ s{ \$\$ (.*?) \$\$ }{\\[$1\\]}gxms;
>

 ...but i've the lines of my source.tex file one-by-one:

   while ($r =3D <IN> ) {
    $line =3D ...
   ...
   print OUT $line; }


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

Date: Tue, 21 Nov 2006 13:00:11 GMT
From: Lars Haugseth <njus@larshaugseth.com>
Subject: Re: Multiline substitution
Message-Id: <87hcwtx8is.fsf@durin.larshaugseth.com>


* gooliver <gooliverNOSP@mlibero.it> wrote:
> 
>> Assuming two $ characters never appear next to each other in
>> other circumstances:
>>
>> $code =~ s{ \$\$ (.*?) \$\$ }{\\[$1\\]}gxms;
>
> ...but i've the lines of my source.tex file one-by-one:
>
>    while ($r = <IN> ) {
>     $line = ...
>    ...
>    print OUT $line; }

Do you have to do it this way? Consider using slurp:

 my $code = do { local $/; <IN> };

If you're processing one line at a time, you'll have to use a flag
indicating whether you're inside a $$-block or not, and substituting
accordingly.

-- 
Lars Haugseth

"If anyone disagrees with anything I say, I am quite prepared not only to
 retract it, but also to deny under oath that I ever said it." -Tom Lehrer


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

Date: 21 Nov 2006 05:10:29 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Multiline substitution
Message-Id: <1164114629.873825.302900@h48g2000cwc.googlegroups.com>

gooliver wrote:
> > Assuming two $ characters never appear next to each other in
> > other circumstances:
> >
> > $code =~ s{ \$\$ (.*?) \$\$ }{\\[$1\\]}gxms;
> >
>
> ...but i've the lines of my source.tex file one-by-one:
>
>    while ($r = <IN> ) {
>     $line = ...
>    ...
>    print OUT $line; }

"Doctor, Doctor, it hurts when I raise my arm like this!!"

Paul Lalli



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

Date: Tue, 21 Nov 2006 14:29:32 GMT
From: gooliver <gooliverNOSP@mlibero.it>
Subject: Re: Multiline substitution
Message-Id: <op.tjdejfv3xr5pep@amilol1300>

In data Tue, 21 Nov 2006 14:10:29 +0100, Paul Lalli <mritty@gmail.com> h=
a  =

scritto:

> "Doctor, Doctor, it hurts when I raise my arm like this!!"

The doctor replies, "Then don't raise your arm over your head." (-:

 ...
$code=3D"";
while ( $r =3D <IN> ) {
  $code =3D $code . $r;
}
close(IN);
$code =3D~ s{ \$\$ (.*?) \$\$ }{\\[$1\\]}gxms;
print OUT $code;
close(OUT);


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

Date: 21 Nov 2006 14:50:43 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Multiline substitution
Message-Id: <4sgi23Fvcl1aU2@mid.dfncis.de>

gooliver  <gooliverNOSP@mlibero.it> wrote in comp.lang.perl.misc:
> > Assuming two $ characters never appear next to each other in
> > other circumstances:
> >
> > $code =~ s{ \$\$ (.*?) \$\$ }{\\[$1\\]}gxms;
> >
> 
> ...but i've the lines of my source.tex file one-by-one:
> 
>    while ($r = <IN> ) {
>     $line = ...
>    ...
>    print OUT $line; }

Then your subject is misleading.  You don't have multiline
substitutions.

    my @replace = qw( [ ]);
    my $which = 0;
    while ( <DATA> ) {
        s/^\$\$$/$replace[ $which]/ and $which = 1 - $which;
        print;
    }

Anno


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

Date: Tue, 21 Nov 2006 15:11:52 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl is worth nothing!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Message-Id: <YGE8h.5058$IW2.570@trndny03>

robertospara wrote:
> I will be with you guys to the end of the world.
> ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Hardly. At least not with me

**PLONK**

jue 




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

Date: 21 Nov 2006 04:02:19 -0800
From: therocket79@yahoo.co.uk
Subject: Perl substitution working on some machines but not others?
Message-Id: <1164110539.146567.6110@m7g2000cwm.googlegroups.com>

Hi,

I have a question about the following line of code:

$new_file =~ s/^$from_dir/$to_dir/;

I have 2 variables $from_dir and $to_dir which are different directory
path names.  I also have the $new_file variable which is the full path
of a file.  I am trying to substitute the first part of the file path
($from_dir) with a new file path ($to_dir), following on from this I
copy the original file to the new location.

An example:

$new_file = C:/directory1/file.txt
$from_dir = C:/directory1
$to_dir = C:/directory2

I would like the result of the substitution to be $new_file =
C:/directory2/file.txt, so I can then copy C:/directory1/file.txt to
C:/directory2/file.txt

However, this seems to work on some machines but fail on others.  The
reason being the substitution doesn't seem to take place correctly and
I end up trying to copy something to the same location.  Can anyone
help with why this is happening?



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

Date: 21 Nov 2006 14:36:11 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Perl substitution working on some machines but not others?
Message-Id: <4sgh6rFvcl1aU1@mid.dfncis.de>

 <therocket79@yahoo.co.uk> wrote in comp.lang.perl.misc:
> Hi,
> 
> I have a question about the following line of code:
> 
> $new_file =~ s/^$from_dir/$to_dir/;
> 
> I have 2 variables $from_dir and $to_dir which are different directory
> path names.  I also have the $new_file variable which is the full path
> of a file.  I am trying to substitute the first part of the file path
> ($from_dir) with a new file path ($to_dir), following on from this I
> copy the original file to the new location.
> 
> An example:
> 
> $new_file = C:/directory1/file.txt
> $from_dir = C:/directory1
> $to_dir = C:/directory2
> 
> I would like the result of the substitution to be $new_file =
> C:/directory2/file.txt, so I can then copy C:/directory1/file.txt to
> C:/directory2/file.txt
> 
> However, this seems to work on some machines but fail on others.  The
> reason being the substitution doesn't seem to take place correctly and
> I end up trying to copy something to the same location.  Can anyone
> help with why this is happening?

Too little info.  What is the exact code that does (or doesn't do) the
substitution?  What is the content of $from_dir, $to_dir and $new_file
in a case where it works and in a case where it doesn't?  Also name the
OS and its version for a working case and one that doesn't work.

Anno


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

Date: 21 Nov 2006 08:00:55 -0800
From: therocket79@yahoo.co.uk
Subject: Re: Perl substitution working on some machines but not others?
Message-Id: <1164124855.251270.103040@j44g2000cwa.googlegroups.com>

Hi,

Thanks for your response.  I've managed to get it wokring now, it was
actually to do with forward and backslashes being included in file
paths inconsistently.

Thanks again.

anno4000@radom.zrz.tu-berlin.de wrote:

> <therocket79@yahoo.co.uk> wrote in comp.lang.perl.misc:
> > Hi,
> >
> > I have a question about the following line of code:
> >
> > $new_file =~ s/^$from_dir/$to_dir/;
> >
> > I have 2 variables $from_dir and $to_dir which are different directory
> > path names.  I also have the $new_file variable which is the full path
> > of a file.  I am trying to substitute the first part of the file path
> > ($from_dir) with a new file path ($to_dir), following on from this I
> > copy the original file to the new location.
> >
> > An example:
> >
> > $new_file = C:/directory1/file.txt
> > $from_dir = C:/directory1
> > $to_dir = C:/directory2
> >
> > I would like the result of the substitution to be $new_file =
> > C:/directory2/file.txt, so I can then copy C:/directory1/file.txt to
> > C:/directory2/file.txt
> >
> > However, this seems to work on some machines but fail on others.  The
> > reason being the substitution doesn't seem to take place correctly and
> > I end up trying to copy something to the same location.  Can anyone
> > help with why this is happening?
>
> Too little info.  What is the exact code that does (or doesn't do) the
> substitution?  What is the content of $from_dir, $to_dir and $new_file
> in a case where it works and in a case where it doesn't?  Also name the
> OS and its version for a working case and one that doesn't work.
> 
> Anno



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

Date: 21 Nov 2006 06:01:03 -0800
From: "IJALAB" <balaji.draj@gmail.com>
Subject: search replace retain and compare strings?
Message-Id: <1164117662.081539.193150@h48g2000cwc.googlegroups.com>

I have lines like:

$PSTIL,IRQ, 48 bytes
9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09

$PSTIL,IRQ,9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09

$PSTIL,IRQ,9,37 bytes
9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09

I need to remove these 37 and 48 bytes text from these lines and print
the remaining string to another file. Also I need to check for any
newline characters in the end of every line.

Finally I need to compare each of these line with another file that
also has a similar output and report if any discrepancy exists.
Note: i dont have commas in few lines....so i am unable to split with
commas.

also i am using s/^*.* Bytes*.*//g expression, doesn;t serve the
purpose
Can anyone help in this.

Thanks,
Bala



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

Date: Tue, 21 Nov 2006 09:35:34 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: search replace retain and compare strings?
Message-Id: <m2mz6k50ll.fsf@Sherm-Pendleys-Computer.local>

"IJALAB" <balaji.draj@gmail.com> writes:

> I have lines like:
>
> $PSTIL,IRQ, 48 bytes
> 9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09
>
> $PSTIL,IRQ,9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09
>
> $PSTIL,IRQ,9,37 bytes
> 9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09
>
> I need to remove these 37 and 48 bytes text from these lines and print
> the remaining string to another file. Also I need to check for any
> newline characters in the end of every line.
>
> Finally I need to compare each of these line with another file that
> also has a similar output and report if any discrepancy exists.
> Note: i dont have commas in few lines....so i am unable to split with
> commas.
>
> also i am using s/^*.* Bytes*.*//g expression, doesn;t serve the
> purpose
> Can anyone help in this.

Help with what? You didn't post any code for anyone to help with.

Have you read the posting guidelines that appear here frequently?

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Tue, 21 Nov 2006 14:45:09 GMT
From: Lars Haugseth <njus@larshaugseth.com>
Subject: Re: search replace retain and compare strings?
Message-Id: <87d57gyicy.fsf@durin.larshaugseth.com>


* "IJALAB" <balaji.draj@gmail.com> wrote:
> 
> I have lines like:
>
> $PSTIL,IRQ, 48 bytes
> 9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09
>
> $PSTIL,IRQ,9,9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09
>
> $PSTIL,IRQ,9,37 bytes
> 9,IDLE,0,0,CC,0,0,MC,1,1,NF,2,2,CD,2,0,AI,1,1,LP,81,83*09
>
> I need to remove these 37 and 48 bytes text from these lines and print
> the remaining string to another file. Also I need to check for any
> newline characters in the end of every line.

s{ \s* \d+ bytes \s* [\r\n]* }{}gxms;

> Finally I need to compare each of these line with another file that
> also has a similar output and report if any discrepancy exists.

Perhaps you should use "diff" for that.

-- 
Lars Haugseth

"If anyone disagrees with anything I say, I am quite prepared not only to
 retract it, but also to deny under oath that I ever said it." -Tom Lehrer


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

Date: 21 Nov 2006 05:26:52 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: string assignment and concatenation
Message-Id: <1164115612.714358.190830@h54g2000cwb.googlegroups.com>

dt wrote:
> Quit sounding like an ungrateful sloth and accept the help in
> the spirit it was given.

What help?  The OP posted code that used File::Copy's move() function.
You posted a response that told him he meant to use Perl's built-in
rename() function, then copy and pasted a piece of documentation that
says to use File::Copy's move() function.

There was zero content to your post.  

Paul Lalli



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

Date: 21 Nov 2006 04:54:13 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: using an array to set up hash keys
Message-Id: <1164113653.701025.143440@b28g2000cwb.googlegroups.com>



On Nov 21, 1:05 am, "John W. Krahn" <some...@example.com> wrote:
> my %hash;
> @hash{ @array } = ( 1 ) x @array;
>
> my %hash = map { $_ => 1 } @array;
>
> my %hash;
> $hash{ $_ } = 1 for @array;

Don't forget

 $_  = 1 for @hash{ @array };



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

Date: Tue, 21 Nov 2006 12:16:20 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: Win32::Registry::File - update values in file
Message-Id: <o6C8h.1606$tM1.894@newsread1.news.pas.earthlink.net>

On 11/20/2006 03:53 AM, MoshiachNow wrote:
> HI,
> 
> Having a .reg file,I need to update all occurances of the old machine
> name there into a new name.
> Some stings are just plane (REG_SZ) ex:
> "NodeList"="KDI-PGY2500"
> 
> but some are of multiple type (REG_MULTI_SZ) ex:
> "VolumeList"=hex(7):5c,00,5c,00,50,00,47,00,59,00,32,00,36,00,30,00,30,00,5c,\
> 
> 00,32,00,36,00,30,00,30,00,5c,00,41,00,72,00,61,00,78,00,69,00,56,00,6f,00,\
> 
> 6c,00,75,00,6d,00,65,00,5f,00,50,00,47,00,59,00,32,00,36,00,30,00,30,00,5f,\
>   . . .
> 6f,00,66,00,69,00,6c,00,65,00,73,00,00,00,00,00
> 
> (Note that the above hex stirngs ALSO hides inside the old machine name
> KDI-PGY2500,it's just hidden by formatting)
> I need to go over the whole file and replace ALL VALUES from the old
> name to a new one using Win32::Registry::File.
> Any idea how to do it ?
> Thanks
> 

What have you tried?

Consider using the "Encode" module to convert the data you get from the 
 .reg file from and to UCS-2LE.

You seem to be not getting too many responses to your messages; I advise 
you to follow the posting guidelines for this newsgroup:

http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


-- 
paduille.4060.mumia.w@earthlink.net



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

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


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