[28592] in Perl-Users-Digest
Perl-Users Digest, Issue: 9956 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 11 18:05:44 2006
Date: Sat, 11 Nov 2006 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, 11 Nov 2006 Volume: 10 Number: 9956
Today's topics:
=?utf-8?B?UmU6IGZpbHRlciBvdXQgInN0cmFuZ2UiIHRleHQgaW4gc <jack_posemsky@yahoo.com>
Re: =?utf-8?B?UmU6IGZpbHRlciBvdXQgInN0cmFuZ2UiIHRleHQga anno4000@radom.zrz.tu-berlin.de
=?utf-8?B?ZmlsdGVyIG91dCAic3RyYW5nZSIgdGV4dCBpbiBwZXJsI <jack_posemsky@yahoo.com>
Re: =?utf-8?B?ZmlsdGVyIG91dCAic3RyYW5nZSIgdGV4dCBpbiBwZ anno4000@radom.zrz.tu-berlin.de
Re: count lines,words,punctuations and characters in pe <angel_dsgs@yahoo.com>
Re: count lines,words,punctuations and characters in pe <bik.mido@tiscalinet.it>
Re: count lines,words,punctuations and characters in pe <angel_dsgs@yahoo.com>
Re: count lines,words,punctuations and characters in pe <tadmc@augustmail.com>
Re: count lines,words,punctuations and characters in pe <bik.mido@tiscalinet.it>
Re: count lines,words,punctuations and characters in pe <cdalten@gmail.com>
Re: filter out "strange" text in perl ? íµ?½????â? <bik.mido@tiscalinet.it>
Re: how to source an environment file <damercer@comcast.net>
Re: how to source an environment file <damercer@comcast.net>
Re: Perl modules installed <brian.d.foy@gmail.com>
Re: Perl with setuid enabled <bik.mido@tiscalinet.it>
Re: Perl with setuid enabled <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Nov 2006 09:46:32 -0800
From: "Jack" <jack_posemsky@yahoo.com>
Subject: =?utf-8?B?UmU6IGZpbHRlciBvdXQgInN0cmFuZ2UiIHRleHQgaW4gcGVybCA/IMOtwrXilpPCvc+E4pSk4paRzqbDouKCpw==?=
Message-Id: <1163267191.913256.133260@f16g2000cwb.googlegroups.com>
anno4000@radom.zrz.tu-berlin.de wrote:
> Jack <jack_posemsky@yahoo.com> wrote in comp.lang.perl.misc:
> > Hi
> >
> > I am parsing a text file and see what looks like in the datafiel a NULL
> > (nothing) in between my delimeter but Perl is recognizing a value when
> > I print to the screen as: =C3=AD=C2=B5=E2=96=93=C2=BD=CF=84=E2=94=A4=E2=
=96=91=CE=A6=C3=A2=E2=82=A7
>
> Posting "strange characters" to Usenet is useless. Every news reader
> will show something else. In fact, my reader shows your string
> differently in the subject and the body of the message.
>
> To communicate the data unambiguously you could print the numeric
> value of each character:
>
> printf "%d ", ord $_ for split //, $string;
> print "\n";
>
> Be sure to post not only the output but also the proglet that
> generated it.
>
> > This is screwing up my program and I want to get rid of it ! Does
> > anyone know how to auto match / detect this so I can remove it / deal
> > with it ?!!
>
> What exactly do you mean by "this"? Simply deleting the exact sequence
> of bytes wherever it appears would be a horrible solution, and probably
> not a solution at all if similar but not identical strings appear
> elsewhere.
>
> You should find out why the disruptive strings are there in the first
> place. Then there may be a realistic chance to get rid of them.
>
> Anno
Ok then - does anyone know what the syntax is to detect:
1- ASCII
2- double byte characters
3- UTF-8
Thank you,
Jack
------------------------------
Date: 11 Nov 2006 19:37:10 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: =?utf-8?B?UmU6IGZpbHRlciBvdXQgInN0cmFuZ2UiIHRleHQgaW4gcGVybCA/IMOtwrXilpPCvc+E4pSk4paRzqbDouKCpw==?=
Message-Id: <4rmn36Fs1ofeU1@mid.dfncis.de>
Jack <jack_posemsky@yahoo.com> wrote in comp.lang.perl.misc:
>
> anno4000@radom.zrz.tu-berlin.de wrote:
> > Jack <jack_posemsky@yahoo.com> wrote in comp.lang.perl.misc:
> > > Hi
> > >
> > > I am parsing a text file and see what looks like in the datafiel a NULL
> > > (nothing) in between my delimeter but Perl is recognizing a value when
> > > I print to the screen as: Ã沫細胞
> >
> > Posting "strange characters" to Usenet is useless. Every news reader
> > will show something else. In fact, my reader shows your string
> > differently in the subject and the body of the message.
> >
> > To communicate the data unambiguously you could print the numeric
> > value of each character:
> >
> > printf "%d ", ord $_ for split //, $string;
> > print "\n";
> >
> > Be sure to post not only the output but also the proglet that
> > generated it.
> >
> > > This is screwing up my program and I want to get rid of it ! Does
> > > anyone know how to auto match / detect this so I can remove it / deal
> > > with it ?!!
> >
> > What exactly do you mean by "this"? Simply deleting the exact sequence
> > of bytes wherever it appears would be a horrible solution, and probably
> > not a solution at all if similar but not identical strings appear
> > elsewhere.
> >
> > You should find out why the disruptive strings are there in the first
> > place. Then there may be a realistic chance to get rid of them.
> >
> > Anno
>
> Ok then - does anyone know what the syntax is to detect:
That's not a syntax question. Code untested:
> 1- ASCII
For a single character:
ord $char < 128
For use in a regex:
[[:ascii:]]
> 2- double byte characters
ord $char >= 256
[^\0-\xff]
> 3- UTF-8
UTF-8 and ASCII overlap.
Anno
------------------------------
Date: 11 Nov 2006 08:37:25 -0800
From: "Jack" <jack_posemsky@yahoo.com>
Subject: =?utf-8?B?ZmlsdGVyIG91dCAic3RyYW5nZSIgdGV4dCBpbiBwZXJsID8gICAgw63CteKWk8K9z4TilKTilpHOpsOi4oKn?=
Message-Id: <1163263045.071864.46680@h54g2000cwb.googlegroups.com>
Hi
I am parsing a text file and see what looks like in the datafiel a NULL
(nothing) in between my delimeter but Perl is recognizing a value when
I print to the screen as: =C3=AD=C2=B5=E2=96=93=C2=BD=CF=84=E2=94=A4=E2=96=
=91=CE=A6=C3=A2=E2=82=A7
This is screwing up my program and I want to get rid of it ! Does
anyone know how to auto match / detect this so I can remove it / deal
with it ?!!
Thanks Jack..
------------------------------
Date: 11 Nov 2006 17:03:30 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: =?utf-8?B?ZmlsdGVyIG91dCAic3RyYW5nZSIgdGV4dCBpbiBwZXJsID8gICAgw63CteKWk8K9z4TilKTilpHOpsOi4oKn?=
Message-Id: <4rme32Fr532kU1@mid.dfncis.de>
Jack <jack_posemsky@yahoo.com> wrote in comp.lang.perl.misc:
> Hi
>
> I am parsing a text file and see what looks like in the datafiel a NULL
> (nothing) in between my delimeter but Perl is recognizing a value when
> I print to the screen as: Ã沫細胞
Posting "strange characters" to Usenet is useless. Every news reader
will show something else. In fact, my reader shows your string
differently in the subject and the body of the message.
To communicate the data unambiguously you could print the numeric
value of each character:
printf "%d ", ord $_ for split //, $string;
print "\n";
Be sure to post not only the output but also the proglet that
generated it.
> This is screwing up my program and I want to get rid of it ! Does
> anyone know how to auto match / detect this so I can remove it / deal
> with it ?!!
What exactly do you mean by "this"? Simply deleting the exact sequence
of bytes wherever it appears would be a horrible solution, and probably
not a solution at all if similar but not identical strings appear
elsewhere.
You should find out why the disruptive strings are there in the first
place. Then there may be a realistic chance to get rid of them.
Anno
------------------------------
Date: 11 Nov 2006 08:22:23 -0800
From: "angel" <angel_dsgs@yahoo.com>
Subject: Re: count lines,words,punctuations and characters in perl script
Message-Id: <1163262143.314938.309530@h54g2000cwb.googlegroups.com>
hello thanks for the reply...where can i find that posting guidelines?
i just need someone to help me with my script. im not really a
programmer. perl is just one part of my course and its really my first
time to join a group i just find it very interesting and educational.
i already done half of my script but its the counting of the
lines,words etc that i dont have any idea.
here's my script:
#!c:\perl\bin\perl.exe -w
open(READFILE, "<StringText.txt"> || die "couldn't open file$!";
while (<READFILE>)
{
print "$_";
}
close(READFILE);
print"\n\nOutput:\n";
open(READFILE, "<StringText.txt"> || die "couldn't open file:$!";
while(<READFILE>)
{
while($_=~s/(\w+)(.*)/$2/)
{
$word= $2;
$wordHash{$word}++;
}
while(($word, $count) = each(%wordHash))
{
$wordArray[$i] = "$word\t$count";
$i++;
chomp($count);
print("words: $count\n");
close(READFILE);
print"\n\nString:\n";
open(READFILE, "<StringText.txt"> || die "couldn't open file:$!";
while(<READFILE>)
{
$_=~s/\s+//gi;
$_=~s/\,//gi;
$_=~s/\.//gi;
$_=~tr/A_Z/a-z/;
print"$_";
}
close(READFILE);
the output should be:(from READFILE)
Hey, diddle, diddle,
The cat and the fiddle,
The cow jumped over the moon.
The little dog laughed
To see such sport,
And the dish ran away with the spoon.
Output:
lines: 6
words:30
characters: 154
String:
heydiddlediddlethecatandthefiddlethecowjumpedoverthemoonthelittledoglaughedtoseesuchsportandthedishwanawaywiththespoon
i was able to do the first and the last (string) but its the counting
that im having difficulty.
yankeeinexile@gmail.com wrote:
> "angel" <theryne_rc@yahoo.co.uk> writes:
> > hello im a perl beginner.
>
> Hello. Welcome.
>
> > is there anybody who can help me by giving me
> > simple perl script?
>
> If you want to hire a programmer jobs.perl.org is down the hall. If
> you want help to write your own script, go read the posting
> guidelines, and then come back.
>
> > i need to know on how to count lines, words,
> > punctuations and characters of a pharagraph.
>
> This smells like a homework assignment. Do you really think your
> lecturer doesn't read this group?
>
> > pls i really need help
> > thanks a lot. i would really appreciate your help thanks!
>
> What work have you done thus far, and how has it failed to meet your
> needs?
>
> There was only one e. e. cummings -- you're not him. Use mixed case and
> try to spell. Writing (good) programs requires clarity and precision
> in any language. Practice being clear and precise in human languages,
> too.
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
> Computer software consists of only two components: ones and
> zeros, in roughly equal proportions. All that is required is to
> sort them into the correct order.
------------------------------
Date: Sat, 11 Nov 2006 17:28:50 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: count lines,words,punctuations and characters in perl script
Message-Id: <97ubl2lapv4uulgos1klgc0jh6b92klihc@4ax.com>
On 11 Nov 2006 06:50:44 -0800, "angel" <theryne_rc@yahoo.co.uk> wrote:
>hello im a perl beginner. is there anybody who can help me by giving me
>simple perl script? i need to know on how to count lines, words,
Yes, and chances are that some will do.
>punctuations and characters of a pharagraph. pls i really need help
>thanks a lot. i would really appreciate your help thanks!
However... are you a perl beginner or do you need to use perl for some
reason for once only? If the latter, than specify why: if it's a good
reason then it may be easier for some to pretend this is a help desk.
But generally we're not, and in the former case we prefer to ask you
to show us what you've tried thus far and what you're having
difficulties with.
General purpose pointers:
perldoc -q 'by paragraph'
perldoc -f split
perldoc -f m
perldoc -f length
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: 11 Nov 2006 09:14:37 -0800
From: "angel" <angel_dsgs@yahoo.com>
Subject: Re: count lines,words,punctuations and characters in perl script
Message-Id: <1163265277.382086.58430@e3g2000cwe.googlegroups.com>
thanks for the reply...im a pel beginner and i will be using perl when
i started making websites.
thanks a lot!
Michele Dondi wrote:
> On 11 Nov 2006 06:50:44 -0800, "angel" <theryne_rc@yahoo.co.uk> wrote:
>
> >hello im a perl beginner. is there anybody who can help me by giving me
> >simple perl script? i need to know on how to count lines, words,
>
> Yes, and chances are that some will do.
>
> >punctuations and characters of a pharagraph. pls i really need help
> >thanks a lot. i would really appreciate your help thanks!
>
> However... are you a perl beginner or do you need to use perl for some
> reason for once only? If the latter, than specify why: if it's a good
> reason then it may be easier for some to pretend this is a help desk.
> But generally we're not, and in the former case we prefer to ask you
> to show us what you've tried thus far and what you're having
> difficulties with.
>
> General purpose pointers:
>
> perldoc -q 'by paragraph'
> perldoc -f split
> perldoc -f m
> perldoc -f length
>
>
> 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: Sat, 11 Nov 2006 11:56:36 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: count lines,words,punctuations and characters in perl script
Message-Id: <slrnelc3mk.jrh.tadmc@tadmc30.august.net>
angel <angel_dsgs@yahoo.com> wrote:
> where can i find that posting guidelines?
They are posted to this newsgroup twice each week. Or see:
http://www.augustmail.com/~tadmc/clpmisc.shtml
> here's my script:
>
> #!c:\perl\bin\perl.exe -w
>
> open(READFILE, "<StringText.txt"> || die "couldn't open file$!";
^
^
That is not a Perl program.
Why aren't you asking about the syntax error that that lines generates?
Is this your real code?
> print "$_";
perldoc -q vars
What’s wrong with always quoting "$vars"?
> while($_=~s/(\w+)(.*)/$2/)
A loop that must iterate zero or one times is the same as an "if",
so then, it should be written as an "if".
If you expect it to iterate more than one time, then you need
a "g" modifier on your s/// operator.
> while(($word, $count) = each(%wordHash))
> {
> $wordArray[$i] = "$word\t$count";
> $i++;
If you use the push() function instead of indexing yourself, then you
won't need to maintain $i.
push @wordArray, "$word\t$count";
[ snip TOFU ]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 11 Nov 2006 19:50:46 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: count lines,words,punctuations and characters in perl script
Message-Id: <mn6cl2ti1nfqnaqrkkat4h1dd86qcirvpk@4ax.com>
(Post edited for clarity - *Please* do not top-post!)
>> General purpose pointers:
>>
>> perldoc -q 'by paragraph'
>> perldoc -f split
>> perldoc -f m
>> perldoc -f length
On 11 Nov 2006 09:14:37 -0800, "angel" <angel_dsgs@yahoo.com> wrote:
>thanks for the reply...im a pel beginner and i will be using perl when
>i started making websites.
The be sure to add
perldoc CGI
to the list. And don't trust the average quadratic "tutorial" you will
find on the web. If in doubt, ask whether the particular one that may
seem fine to you is actually also good!
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: 11 Nov 2006 12:04:43 -0800
From: "grocery_stocker" <cdalten@gmail.com>
Subject: Re: count lines,words,punctuations and characters in perl script
Message-Id: <1163275483.333025.199400@b28g2000cwb.googlegroups.com>
angel wrote:
> hello im a perl beginner. is there anybody who can help me by giving me
> simple perl script? i need to know on how to count lines, words,
> punctuations and characters of a pharagraph. pls i really need help
> thanks a lot. i would really appreciate your help thanks!
Two seconds of google yielded the following:
http://www.stonehenge.com/merlyn/UnixReview/col02.html
------------------------------
Date: Sat, 11 Nov 2006 19:46:31 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: filter out "strange" text in perl ? íµ?½????â?
Message-Id: <li6cl2t9uhpf2q3m28trlfrnitictirnd7@4ax.com>
On 11 Nov 2006 09:46:32 -0800, "Jack" <jack_posemsky@yahoo.com> wrote:
>Ok then - does anyone know what the syntax is to detect:
>1- ASCII
This is easy:
/[[:ascii:]]/
But then you may want the [:print:] charachter class.
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: Sat, 11 Nov 2006 13:55:57 -0600
From: "Dan Mercer" <damercer@comcast.net>
Subject: Re: how to source an environment file
Message-Id: <x9qdnRBtcszYtsvYnZ2dnUVZ_uGdnZ2d@comcast.com>
<dcruncher4@aim.com> wrote in message news:1163083944.521955.293620@k70g2000cwa.googlegroups.com...
: I want my perl script to read a file containing environment variables
: and source it back
: to the script. That is, when the script is executed, these variables
: are not defined
: in enviroment. Once the script starts, variables defined in that env
: file is sourced
: in. In korn shell we can do
: dot(.) scriptname
:
: How do we do the same in perl.
:
: I found a crude approach. I do
: system(". scriptname; env > /tmp/env.$$")
: then I open /tmp/env.$$ file and store all env defined there
: in $ENV{envvar}.
:
: There should be a better way of doing it, shouldn't it?
:
: thanks.
:
Here's the source function from a module I wrote:
#!/usr/bin/perl -w
# Copyright Singing Pig Consulting 2005-
#
# Author Dan Mercer (Singing Pig Consulting)
# Date Created: 09/11/04 at 01:48:42 PM
use strict;
use warnings;
sub source
{
# Format: source file[,shell]
# : modifies the current environment
my ($srcfile, $shell, $legal, $srccmd, $pipeline, $perlcmd);
# filehandles
my ($hostsfh, $pipefh);
my $me = (caller(0))[3];
$srcfile = shift or die "$me: Missing source file argument\n";
$shell = shift or $shell = $ENV{SHELL} or $shell = "sh";
die "Unknown shell '$shell'\n" unless ($shell =~ /sh$/);
$srcfile = cwd() . "/" . $srcfile unless($srcfile =~ m{/});
# get full pathname
unless ($shell =~ m{^/})
{
my @path = split(/:/, $ENV{PATH});
foreach (@path)
{
next unless (-x "$_/$shell");
$shell = "$_/$shell";
last;
}
die "$me: unrecognized shell '$shell'\n" unless ($shell =~ m{^/});
}
# make sure it's a legal shell
$legal = 0;
if (open($hostsfh,"<","/etc/shells"))
{
while (<$hostsfh>)
{
chomp;
if ($_ eq $shell)
{
$legal = 1;
last;
}
}
close $hostsfh;
}
else
{
$legal = 1;
}
die "$me: illegal shell '$shell'\n" unless ($legal);
# determine source command
$srccmd = ($shell =~ /csh$/) ? "source" : ".";
# set up pipeline to source file then have perl print it out
# using NUL's as file and record separators
$perlcmd = "$^X -l0 -e '" . '\$,=\$\\;print %ENV' . "'";
$pipeline = "$shell -c \"$srccmd $srcfile;$perlcmd\"";
open ($pipefh, "$pipeline |") or die "$me: pipeline failed - $!\n";
my @env = %ENV;
local $/ = "\0"; # IRS to NUL - use local so WHHSH
my @newenv = <$pipefh>;
chomp @newenv;
push @env,@newenv;
close $pipefh;
%ENV = @env;
}
__DATA__
Dan Mercer
------------------------------
Date: Sat, 11 Nov 2006 13:57:56 -0600
From: "Dan Mercer" <damercer@comcast.net>
Subject: Re: how to source an environment file
Message-Id: <x9qdnRNtcszbtsvYnZ2dnUVZ_uGdnZ2d@comcast.com>
<dcruncher4@aim.com> wrote in message news:1163083944.521955.293620@k70g2000cwa.googlegroups.com...
: I want my perl script to read a file containing environment variables
: and source it back
: to the script. That is, when the script is executed, these variables
: are not defined
: in enviroment. Once the script starts, variables defined in that env
: file is sourced
: in. In korn shell we can do
: dot(.) scriptname
:
: How do we do the same in perl.
:
: I found a crude approach. I do
: system(". scriptname; env > /tmp/env.$$")
: then I open /tmp/env.$$ file and store all env defined there
: in $ENV{envvar}.
:
: There should be a better way of doing it, shouldn't it?
:
: thanks.
:
Here's the source function from a module I wrote:
#!/usr/bin/perl -w
# Copyright Singing Pig Consulting 2005-
#
# Author Dan Mercer (Singing Pig Consulting)
# Date Created: 09/11/04 at 01:48:42 PM
use strict;
use warnings;
sub source
{
# Format: source file[,shell]
# : modifies the current environment
my ($srcfile, $shell, $legal, $srccmd, $pipeline, $perlcmd);
# filehandles
my ($hostsfh, $pipefh);
my $me = (caller(0))[3];
$srcfile = shift or die "$me: Missing source file argument\n";
$shell = shift or $shell = $ENV{SHELL} or $shell = "sh";
die "Unknown shell '$shell'\n" unless ($shell =~ /sh$/);
$srcfile = cwd() . "/" . $srcfile unless($srcfile =~ m{/});
# get full pathname
unless ($shell =~ m{^/})
{
my @path = split(/:/, $ENV{PATH});
foreach (@path)
{
next unless (-x "$_/$shell");
$shell = "$_/$shell";
last;
}
die "$me: unrecognized shell '$shell'\n" unless ($shell =~ m{^/});
}
# make sure it's a legal shell
$legal = 0;
if (open($hostsfh,"<","/etc/shells"))
{
while (<$hostsfh>)
{
chomp;
if ($_ eq $shell)
{
$legal = 1;
last;
}
}
close $hostsfh;
}
else
{
$legal = 1;
}
die "$me: illegal shell '$shell'\n" unless ($legal);
# determine source command
$srccmd = ($shell =~ /csh$/) ? "source" : ".";
# set up pipeline to source file then have perl print it out
# using NUL's as file and record separators
$perlcmd = "$^X -l0 -e '" . '\$,=\$\\;print %ENV' . "'";
$pipeline = "$shell -c \"$srccmd $srcfile;$perlcmd\"";
open ($pipefh, "$pipeline |") or die "$me: pipeline failed - $!\n";
my @env = %ENV;
local $/ = "\0"; # IRS to NUL - use local so WHHSH
my @newenv = <$pipefh>;
chomp @newenv;
push @env,@newenv;
close $pipefh;
%ENV = @env;
}
__DATA__
Dan Mercer
------------------------------
Date: Sat, 11 Nov 2006 15:11:14 -0600
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: Perl modules installed
Message-Id: <111120061511146871%brian.d.foy@gmail.com>
In article <1163179814.478176.118510@e3g2000cwe.googlegroups.com>, mike
<hillmw@charter.net> wrote:
> Does anyone know how I can run a script and see what Perl modules are
> installed on my box?
If you have a version of Perl that came with my cpan(1) script, its
autobundle feature will list all installed modules and their versions:
$ cpan -a
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Sat, 11 Nov 2006 17:07:35 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl with setuid enabled
Message-Id: <48tbl2dfsadu6cm638ngp66k34al5k5hf4@4ax.com>
On Mon, 06 Nov 2006 20:43:12 +0100, Mark Clements
<mark.clementsREMOVETHIS@wanadoo.fr> wrote:
>You can have multiple versions of perl installed on each system. You
>could have symlinks pointing at the latest version, and then each script
> just starts
>
>#!/usr/local/bin/perl
>
>or somesuch.
And not only one *can* or *could* do so, but that's what's generally
done. Unless I'm missing something, I don't see any particular
advantage in more clumsy alternatives.
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: Sat, 11 Nov 2006 17:08:42 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl with setuid enabled
Message-Id: <gatbl2h647ad026odml9oluntppn00i2ai@4ax.com>
On Tue, 07 Nov 2006 00:51:31 GMT, "Dan Mercer" <dmercer@mn.rr.com>
wrote:
>use env
>
>#!/usr/bin/env perl
Possible flame bait for endless (but not trivial) discussions about
how env is subject to the same problems it is supposed to solve...
;-)
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: 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 9956
***************************************