[25632] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7874 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 10 09:05:53 2005

Date: Thu, 10 Mar 2005 06:05:29 -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           Thu, 10 Mar 2005     Volume: 10 Number: 7874

Today's topics:
    Re: [ANN] j2Perl 2.0 -- Allowing Java to access Perl co <clarke@n_o_s_p_a_m_hyperformix.com>
    Re: [perl-python] a program to delete duplicate files <pu.news.001@gmail.com>
    Re: About tied filehandles limitation: stat operation <tassilo.von.parseval@rwth-aachen.de>
    Re: cant display generated html in browser (perl script (Piet L.)
    Re: Checking for safe paths (Anno Siegel)
    Re: Documentation for shifting elements of @ARGV <do-not-use@invalid.net>
    Re: Documentation for shifting elements of @ARGV <tadmc@augustmail.com>
    Re: file name in perl script? nospam@geniegate.com
    Re: file name in perl script? (Nico)
    Re: file name in perl script? <news@chaos-net.de>
    Re: Help needed to write a regular expression. (Vittal)
    Re: HTML::Parser - duplicated text in <h2> .. </h2> ? <tassilo.von.parseval@rwth-aachen.de>
    Re: HTML::Parser - duplicated text in <h2> .. </h2> ? <tassilo.von.parseval@rwth-aachen.de>
    Re: multidimensional hash modified by test (Anno Siegel)
    Re: negative backreference? <nospam-abuse@ilyaz.org>
    Re: new IO::Socket::INET + UDP/Broadcast = Permission d <vek@station02.ohout.pharmapartners.nl>
    Re: perl contribution <josef.moellers@fujitsu-siemens.com>
    Re: perl contribution <matternc@comcast.net>
    Re: perl contribution <ebohlman@omsdev.com>
        Perl DBI does not print error. <sam.wun@authtec.com>
        Re two array the same <me@nowehere.com>
    Re: Re two array the same <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: Re two array the same <stampes@xilinx.com>
        Solaris 8 Sorry I can't seem to locate the source dir f (Flemming =?iso-8859-1?q?H=F8jstrup?= Hansen)
    Re: Using dot commands in a script <josef.moellers@fujitsu-siemens.com>
    Re: Using dot commands in a script nospam@geniegate.com
    Re: Using dot commands in a script <danfperl@yahoo.com>
    Re: Using dot commands in a script <news@chaos-net.de>
    Re: Using dot commands in a script <tony_curtis32@yahoo.com>
    Re: Using dot commands in a script <stampes@xilinx.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 10 Mar 2005 07:46:56 -0600
From: "AC" <clarke@n_o_s_p_a_m_hyperformix.com>
Subject: Re: [ANN] j2Perl 2.0 -- Allowing Java to access Perl code
Message-Id: <42304fcf$0$38734$39cecf19@news.twtelecom.net>

If you expect this to be used for anything but toy programs, you'll have to 
do better than having the Java program exit if there is a Perl exception. I 
can't image any commercial program that could exist under those conditions. 




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

Date: Thu, 10 Mar 2005 10:54:05 +0100
From: Patrick Useldinger <pu.news.001@gmail.com>
Subject: Re: [perl-python] a program to delete duplicate files
Message-Id: <4230193d$1@news.vo.lu>

I wrote something similar, have a look at 
http://www.homepages.lu/pu/fdups.html.


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

Date: Thu, 10 Mar 2005 09:27:46 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: About tied filehandles limitation: stat operation
Message-Id: <slrnd30182.16n.tassilo.von.parseval@localhost.localdomain>

Also sprach Alian:

> I work on a module that allow access to windows share from unix world with help 
> of samba API. This module allow things like:
>
>
> use Filesys::Smbclient;
> my $smb = new Filesys::SmbClient;
> my $fd = $smb->open("<smb://jupiter/doc/general.css")
>    or die "Can't open it:$!\n";
> while (my $l= $smb->read($fd,50)) {print $l; }
> $smb->close(fd);
>
> but too with the help of the magic tie command:
>
> use Filesys::Smbclient;
> use File::Copy;
>
> local *FD;
> tie(*FD, 'Filesys::SmbClient',">smb://jupiter/toto/tata", 0755);
> copy(\*FD, "/tmp/toto");
>
> But this last one complain with:
> stat() on closed filehandle FD at /usr/local/perl-5.8.5/lib/5.8.5/File/Copy.pm 
> line 82, <F> line 1.
> (The copy command work well even I've been getting an error code from copy method.)
>
> In perldoc perltie, I can read in BUG section:
> Tied filehandles are still incomplete.  sysopen(), truncate(), flock(), fcntl(), 
> stat() and -X can't currently be trapped.
>
> Is this a "todo" or a "can't" ? Can someone give some reasons about this 
> restriction and where I must read code to understand this warning ?

The wording in perltie ("still", "can't currently") suggests that this
limitation isn't written in stone. However, in the past I noticed a
certain reluctance among the perl5-porters to add more trappable
operations to tied data-types. At least those are already mentioned in
the docs so there's a chance it's going to be added at some point
(provided someone has the tuits to do it) especially since additions to
the tied interface aren't that intrusive to the core.

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: 9 Mar 2005 22:18:54 -0800
From: PietLaroy@hotmail.com (Piet L.)
Subject: Re: cant display generated html in browser (perl script)
Message-Id: <c47f81f6.0503092218.591420ab@posting.google.com>

Brian McCauley <nobull@mail.com> wrote in message news:<d0mshq$188$1@sun3.bham.ac.uk>...
> Piet L. wrote:
> 
> >>Anyhow this is not the 'right' way to use XSL on the web.  You should 
> >>simply put a processing instruction in the XML to tell the browser where 
> >>to fetch the XSLT.
> > 
> > How do I do that?
> 
> The processing instruction looks something like this:
> 
>    <?xml-stylesheet href="whatever.xsl" type="text/xsl"?>
> 
> How you put such a processing instruction into an XML document would 
> depend on the tools you are using to generate the XML document.
> 
> For example using XML::DOM to create an XML document it would look 
> something like this:
> 
>      my $stylesheet='whatever.xml';
>      my $xmldoc = XML::DOM::Document->new;
>      $xmldoc->setXMLDecl($xmldoc->createXMLDecl('1.0','UTF-8'));
>      $xmldoc->appendChild
> 	    ( $xmldoc->createProcessingInstruction
> 	      ( 'xml-stylesheet',
> 		qq'href="$stylesheet" type="text/xsl"' ) );

Thank you very much for your answer.

Actually my script is like this:
# create a DBI connection
my $dbh = DBI->connect("DBI:mysql:myDB",$user,$login);

# instantiate a new XML::Handler::YAWriter object
my $handler   = XML::Handler::YAWriter->new(AsString => "-",
				Pretty => {PrettyWhiteNewline => 1,
					   PrettyWhiteIndent => 1,
					   CatchEmptyElement => 1,
					   NoProlog => 1});
my $generator = XML::Generator::DBI->new(
   Handler => $handler,
   dbh     => $dbh,
   Indent  => 1
);

my $ select = qq(.....);
my $xml = $generator->execute($select);
$dbh->disconnect ();

#and then I used the XML::XSLT module to transform and display.

So I now have the following questions,
hope you can answer them.

- How do I put your answer in?
- How will it then be displayed in a browser? Do I need an extra
command in my script or so?


thanx


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

Date: 10 Mar 2005 11:36:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Checking for safe paths
Message-Id: <d0pbga$5io$1@mamenchi.zrz.TU-Berlin.DE>

bill  <please_post@nomail.edu> wrote in comp.lang.perl.misc:
> 
> 
> 
> Is there a module that one can use to portably check for the security
> of a path?  I know how to, e.g. untaint a Unix pathname, but it
> would be nice if there were a module that did this portably.  Also,
> I imagine that there may be other ways for a pathname to be not
> secure other than what can be detected with a general regexp (e.g.
> a well-formed path may include a symbolic link inserted there for
> nefarious purposes).

There is no such thing as a secure path independent of circumstances.

Anno


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

Date: 10 Mar 2005 13:36:33 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Documentation for shifting elements of @ARGV
Message-Id: <yzdu0njvfse.fsf@invalid.net>


Tad McClellan <tadmc@augustmail.com> writes:
> Neil Montgomery <neil@utstat.toronto.edu> wrote:
> 
> > I have solved my actual programming problem, but was frustrated in my 
> > attempt to determine the behaviour of @ARGV in the online docs.
> 
> 
> @ARGV is an array of _data_. 
> 
> Data does not _have_ behaviour, code does.

The data does not have behaviour, but the variable referring to it may
well have. I don't think there is anything wrong with the expression
"the behaviour of <predefined variable name>", generally. It may be
misleading or misinformed in particular cases, of course.

And code, after all, is just data interpreted by a processor.


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

Date: Thu, 10 Mar 2005 07:42:14 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Documentation for shifting elements of @ARGV
Message-Id: <slrnd30jlm.fe0.tadmc@magna.augustmail.com>

Arndt Jonasson <do-not-use@invalid.net> wrote:
> 
> Tad McClellan <tadmc@augustmail.com> writes:
>> Neil Montgomery <neil@utstat.toronto.edu> wrote:
>> 
>> > I have solved my actual programming problem, but was frustrated in my 
>> > attempt to determine the behaviour of @ARGV in the online docs.
>> 
>> 
>> @ARGV is an array of _data_. 
>> 
>> Data does not _have_ behaviour, code does.
> 
> The data does not have behaviour, but the variable referring to it may
> well have. 


Do you have an example of that?

(There isn't such an example in this thread, as it is the null
 filehandle (input operator) that has the behaviour of 
 using/changing the data stored in @ARGV.
)

> I don't think there is anything wrong with the expression
> "the behaviour of <predefined variable name>", generally. 


We will have to agree to disagree on that then.


> It may be
> misleading or misinformed in particular cases, of course.


I would classify "misleading" as "anything wrong", which is
why I said what I said in the first place.

It misled the OP to looking at @ARGV instead of at <>.


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


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

Date: Thu, 10 Mar 2005 09:58:16 GMT
From: nospam@geniegate.com
Subject: Re: file name in perl script?
Message-Id: <Lucy111043987841680x970d60@air.tunestar.net>

In: <4664273a.0503091126.6fe82ac3@posting.google.com>, noordhoeknd@hotmail.com (Nico) wrote:
>Hi, I'm a bit of newby.
>Someone created some pl files for me.

You'll probably want to ask the author.  

I don't know if you paid for it to be done or not, but.. I've seen a lot
of really low bids on programming service auctions. Is this where you 
aquired the scripts? (Thats kind of what it sounds like to me)

Those types of auctions can be a real rip-off for everyone involved except
maybe the site owner. Not saying they're all bad, just a little suspicious
at times. (People try so hard to be the lowest bidder they end up earning 
$0.50 pr. hour, the customer ends up with garbage and everyone is frustrated)

Whoever wrote it should have figured a portion of the estimate would be
required for these types of support questions. You are entitled to an 
explanation of it's use.

If you bug him/her maybe they won't be so tempted to low-ball the next 
customer.

(This is all on my assumption it was one of those n-lance type auctions)

Jamie
-- 
http://www.geniegate.com                    Custom web programming
guhzo_42@lnubb.pbz (rot13)                User Management Solutions


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

Date: 10 Mar 2005 02:25:39 -0800
From: noordhoeknd@hotmail.com (Nico)
Subject: Re: file name in perl script?
Message-Id: <4664273a.0503100225.67d9947f@posting.google.com>

Hi Martin,
Thanks for you advice, I can now see the script working and making the
changes,however, I can not find the result?
I think there must be another command to put the result in a output
directory?
EI2.pl c:/path/editme.txt ..?
I tried this in the script, "$outputdir='output';",but it did not
work.
I guess that I must type something at the command line.

The creator of the scripts can not be found, otherwise...


Thanks in advance,
Nico





Martin Kissner <news@chaos-net.de> wrote in message news:<slrnd2utp1.8cv.news@maki.homeunix.net>...
> Nico wrote :
> > Here are the first line of the pl-script
> >
> > #!c:\perl\bin\perl!
> > #
> > # EI2.pl - 1st pass to prepare for conversion dbtext 
> > # indonesica database to MY format
> > # Piet J, 2/5/2005
> > #
> >
> > $onder = 0 ;
> > $boven = 100000 ;
> > 
> > where to give the name "editme.txt" ?
> > so the script can make the changes in the txt file..?
> > Please advice
> 
> This question can not be answerded if only the first few lines of code
> are presented.
> Best thing would be to ask the author of the script.
> 
> It could be, that you are supposed to pass the filename on the command
> line like this
> 	EI2.pl c:/path/editme.txt
> But this is only a wild guess and I would not dare to try without a
> backup of "editme.txt" if I didn't understand what the script really
> does with "editme.txt".
> 
> Best regards
> Martin


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

Date: Thu, 10 Mar 2005 12:10:03 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: file name in perl script?
Message-Id: <slrnd30aob.9do.news@maki.homeunix.net>

Nico wrote :

Please read http://learn.to/quote to learn how to properly quote in
usenet. - Thank you.

> Hi Martin,
> Thanks for you advice, I can now see the script working and making the
> changes,however, I can not find the result?
> I think there must be another command to put the result in a output
> directory?
> EI2.pl c:/path/editme.txt ..?
> I tried this in the script, "$outputdir='output';",but it did not
> work.

I think it's a waste of time and effort to add code you do not
understand (or somthing that looks like code) to a script which you do
not understand.
It's like soldering some cables into a TV which does not show the
desired program, without any clues of electronics.

> I guess that I must type something at the command line.

This might be or might not be true.
If you see the results in the commandline window try

	EI2.pl c:/path/editme.txt > c:/path/result.txt

This is how it would work on Unix then; I have no idea if this works on
windows, since I do not use it.

> The creator of the scripts can not be found, otherwise...
?

Best regards
Martin 

-- 
perl -e '$|=1;&p(7.74.117.115.116.32);&s();&p(97.110.111);&p(116.104.101
 .114);&s;&p(32.112.101.114.108);&s();&p(32.104.97.99.107.101.114.10);sub
 s{sleep 1};sub p(){print "@_"}'


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

Date: 10 Mar 2005 03:34:13 -0800
From: vsnadagouda@yahoo.com (Vittal)
Subject: Re: Help needed to write a regular expression.
Message-Id: <f9dcc290.0503100334.5959d211@posting.google.com>

Thank you very much John for your help. This is what I exactly wanted
and had been struggling to write the regular expression.

Thanks again
-Vittal
"John W. Krahn" <someone@example.com> wrote in message news:<BDAXd.23079$fc4.20716@edtnps89>...
> Vittal wrote:
> > 
> > I am writing a simple perl script to scan C/C++ Makefiles and list all
> > the macros used in those Makefiles. For this I am using the below
> > mentioned regular expression. The problem with this RE is that it does
> > not show the complete macro definition. It cuts it short at new line
> > character. As per makefile rules, if a line ends with "/" means it
> 
> Don't you mean if a line ends with '\'?  That is what the Makefiles on my 
> system use.
> 
> 
> > continues on to next line also. I want to add this portion into my RE
> > so that I can catch the whole macro definition.
> > 
> > Can someone help in this?
> > 
> > Thanks
> > -Vittal
> > 
> > open INFILE, $FILE || die "Failed to open $FILE file \n";
> 
> You have a precedence error.  As long as $FILE does not contain '' or '0' then 
> the error message will never be printed.  You need to either use parentheses 
> for the open() function or use the lower precedence 'or' operator.  You should 
> also include the $! variable in the error message so you will know why it failed.
> 
> open INFILE, $FILE or die "Failed to open $FILE file: $!";
> 
> 
> >         while (<INFILE>)
> >         {
> >                 # Exclude all the lines starting with # in the
> > makefile
> >                 $temp .=$_ if (!/^#/); 
> >         }
> > 
> >                 $str_macro .= "\n$FILE\n\n";
> >         while ($temp && $temp =~ /(\w+)\s*=(\t| )*([^\n]+)/ )
> >         {
> >                  print "\t$&\n";                  
> >                 $temp = $';
> >         }
> 
> my %macros;
> while ( <INFILE> ) {
> 
>      if ( s/\\\n// ) {
>          $_ .= <INFILE>;
>          redo;
>          }
> 
>      if ( /(\w+)\s*=[\t ]*(.+)/ ) {
>          $macros{ $1 } = $2;
>          }
>      }
> 
> for my $key ( keys %macros ) {
>      print "$key = $macros{$key}\n";
>      }
> 
> 
> 
> 
> John


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

Date: Thu, 10 Mar 2005 09:39:01 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: HTML::Parser - duplicated text in <h2> .. </h2> ?
Message-Id: <slrnd301t5.16n.tassilo.von.parseval@localhost.localdomain>

Also sprach Tad McClellan:

> Geoff Cox <geoff.cox@notquitecorrectfreeuk.com> wrote:
>
>
>> sub register_fh { $fh = $_[1]; }
>
>
> Why call it with 2 arguments if it is only going to make use
> of the 2nd argument?

Because it's an instance-method?

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: Thu, 10 Mar 2005 09:43:40 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: HTML::Parser - duplicated text in <h2> .. </h2> ?
Message-Id: <slrnd3025s.16n.tassilo.von.parseval@localhost.localdomain>

Also sprach Tassilo v. Parseval:

> Also sprach Tad McClellan:
>
>> Geoff Cox <geoff.cox@notquitecorrectfreeuk.com> wrote:
>>
>>
>>> sub register_fh { $fh = $_[1]; }
>>
>>
>> Why call it with 2 arguments if it is only going to make use
>> of the 2nd argument?
>
> Because it's an instance-method?

Sorry, rather a class-method actually. But still a method.

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: 10 Mar 2005 11:50:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: multidimensional hash modified by test
Message-Id: <d0pcb1$5io$2@mamenchi.zrz.TU-Berlin.DE>

LEH <l.heisler@utoronto.ca> wrote in comp.lang.perl.misc:
> 
> "LEH" <l.heisler@utoronto.ca> wrote in message
> news:ID3MJz.AL9@campus-news-reading.utoronto.ca...
> > "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
> > news:Xns961486B46A5B6asu1cornelledu@132.236.56.8...
> > > mike_solomon@lineone.net (Mike Solomon) wrote in
> > > news:56568be5.0503090950.13b1f2d6@posting.google.com:
> > >
> > > > I ran the following script and got what I consider to be a strange
> > result
> > > >
> > > >
> > > > my %data;
> > > >
> > > > $data{a}{a} = 1;

[...]

> > using exists,
> > ie. print "NOT IN HASH\n" unless exists $data{b}{b};
> > also seems to autovivify $data{b}
> >
> > according to perldoc -f exists
> >
> > if (exists &{$ref->{A}{B}{$key}})   { }
> > Although the deepest nested array or hash will not spring into
> > existence just because its existence was tested, any intervening
> > ones will. Thus "$ref->{"A"}" and "$ref->{"A"}->{"B"}" will
> > spring into existence due to the existence test for the $key
> > element above.
> >
> > Larry
> >
> but this works
> print "NOT IN HASH\n" unless exists $data{b} && $data{b}{b};
> although perhaps there is a better way.

You need "exists" in front of "$data{b}{b}" too.  As written, it will
still autovivify $data{ b}->{ b} if only $data{ b} exists.  Also, it
will fail (claim nonexistence) if $data{ a}->{ a} is defined but false.

Anno


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

Date: Thu, 10 Mar 2005 08:29:15 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: negative backreference?
Message-Id: <d0p0gr$2sqd$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de>], who wrote in article <d0nlnj$6c1$1@mamenchi.zrz.TU-Berlin.DE>:
> > > I'm not sure how "(?&" is supposed to work.
> > 
> >   A & B & C & D ...
> > 
> > B should match a substring of what A matched, C should match a
> > substring of what B matched etc...  One can replace & by &! (negating
> > the following group).
> 
> Ah...  Now I'm getting the name too -- successive substrings.
> 
> > Actually, another, "anchored", flavor is useful
> > in other situations: one where B should match *exactly* the string
> > which A matched (and not a substring thereof).  [example above uses
> > the second flavor]
> 
> With infinitesimal onion rings...
> 
> > It was never clear to me how to distinguish these two flavors; maybe
> > something as simple as && vs &...
> 
> Hard to remember which is which in a not-too-often-used construct.
> How about =& ?

The idea of &= is appealing indeed.  Uniformizing, it may become

  &~  &=  &!~ &!=

or just

  &  &=  &!  &!=

Hard to decide between these two...

Thanks,
Ilya


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

Date: 10 Mar 2005 08:03:19 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: new IO::Socket::INET + UDP/Broadcast = Permission denied ?? Why?
Message-Id: <slrnd2vvq7.4ip.vek@station02.ohout.pharmapartners.nl>

On Wed, 9 Mar 2005 13:20:08 -0800,
    Snail <snail@localhost.com> wrote:


> The Following code works fine on my Win32 based system (with the server 
> part running on the Linux system)...
>


Broadcasting needs superuser privileges on unix.


Villy


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

Date: Thu, 10 Mar 2005 08:52:45 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: perl contribution
Message-Id: <d0ouff$ja7$2@nntp.fujitsu-siemens.com>

John Bokma wrote:
> Jay Tilton wrote:
>=20
>=20
>>"robin" <robin@infusedlight.net> wrote:
>>
>>: I do have a contrubution
>>
>>To what are you contributing?
>>
>>: #!/usr/bin/perl
>>: my $c=3D0;  my @key;
>>: my $key;
>>: foreach ( sort %ENV)
>>
>>What on Earth are you doing that for?
>=20
>=20
> Greenhouse effect?
>=20

You mean he took something from the greenhouse and smoked it?

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Thu, 10 Mar 2005 07:29:24 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: perl contribution
Message-Id: <SMidnRcuyKtIoK3fRVn-jA@comcast.com>

robin wrote:

> foreach ( sort %ENV)

Sigh.  Robin, do you realize...

No.  No, you don't.  Robin, this statement
takes the variable names and values in your
environment and sorts them without regard
for which is which.  Once you sort %ENV,
you have lost which variables have which
values--or even which strings are variables
and which values.

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: 10 Mar 2005 13:33:38 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: perl contribution
Message-Id: <Xns96154E45D8B43ebohlmanomsdevcom@130.133.1.4>

John Bokma <postmaster@castleamber.com> wrote in 
news:Xns9614DFF5DC3F2castleamber@130.133.1.4:

> Jay Tilton wrote:
> 
>> "robin" <robin@infusedlight.net> wrote:
>> 
>> : I do have a contrubution
>> 
>> To what are you contributing?
>> 
>> : #!/usr/bin/perl
>> : my $c=0;  my @key;
>> : my $key;
>> : foreach ( sort %ENV)
>> 
>> What on Earth are you doing that for?
> 
> Greenhouse effect?

I thought that that was primarily due to carbon dioxide rather than 
methane.


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

Date: Thu, 10 Mar 2005 21:55:56 +0800
From: sam <sam.wun@authtec.com>
To: Mysql <mysql@lists.mysql.com>
Subject: Perl DBI does not print error.
Message-Id: <423051EC.4070702@authtec.com>

Hi,

The perl DBI does not prints error message:
$sth = $dbh->prepare($insert_sql)
           || print ERRFILE_OUT "prepare: $insert_sql: $DBI::errstr";

The out of this error only does not print why the error was occurred.
eg.
Unable to execute query: DBI::db=HASH(0x8647df0)->errstr:

Dan anyone please tell me how to prints how a description of the error 
from DBI when sql executed failed?

Thanks
Sam


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

Date: Thu, 10 Mar 2005 15:28:59 +0200
From: Me <me@nowehere.com>
Subject: Re two array the same
Message-Id: <rIydnX4flKr31q3fRVn-jw@is.co.za>

How can I find if two given arrays are the same?


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

Date: Thu, 10 Mar 2005 14:49:37 +0100
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Re two array the same
Message-Id: <Xns961596D3F9428elhber1lidotechnet@62.89.127.66>

Me <me@nowehere.com> wrote:

> How can I find if two given arrays are the same?


By comparing them.


-- 
Cheers,
Bernard


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

Date: Thu, 10 Mar 2005 06:49:30 -0700
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Re two array the same
Message-Id: <d0pj9b$hf51@xco-news.xilinx.com>

Me wrote:
> How can I find if two given arrays are the same?

Do you mean the arrays are the same, or the contents of the arrays?

Do you expect the arrys to contain strings, numeric values, references, 
or objects of some sort?

What did you try?  Post code please.

As has been said many times, this is a discussion group, not a help 
desk.  If in the course of discussing your code we help you, that's 
great.  But you are expected to have done your homework yourself first.

And you're especially expected to have read the Posting Guidelines, 
which are posted here frequently, and can be found at:

http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.text

~Jeff


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

Date: 10 Mar 2005 13:25:27 +0100
From: fhh@hsk.dk (Flemming =?iso-8859-1?q?H=F8jstrup?= Hansen)
Subject: Solaris 8 Sorry I can't seem to locate the source dir for perl5.
Message-Id: <y50fyz3y9fs.fsf@hsk.dk>

Machine: Sun Blade 1500
Operating System: Solaris 8
perl version: 5.8.6 (or 5.8.5)

Very quickly after I run:

sh Configure

I get the error message:

Sorry I can't seem to locate the source dir for perl5. Please start
Configure with an explicit path -- i.e. /some/path/Configure.

and the second time:

rm: ./UU is a directory

in front of the same error message.

I have seen the error message in Perl NG before but no explanation. Can
anyone tell me what's wrong?

TIA
Flemming

-- 
Flemming Højstrup Hansen

Hovedstadens Udviklingsråd
(Greater Copenhagen Authority)


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

Date: Thu, 10 Mar 2005 08:49:47 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Using dot commands in a script
Message-Id: <d0ou9v$ja7$1@nntp.fujitsu-siemens.com>

danfperl@yahoo.com wrote:
> I'm trying to load an environment file in a script and I think it may
> be easiest to show it before explaining it.  I've got 2 files,
> /tmp/test.pl and /tmp/test.env.  Here are the contents.
>=20
> test.env:
> #!/usr/bin/ksh
> export BLAH=3DTEST
>=20
> test.pl:
> #!/usr/local/bin/perl
> system('. /tmp/test.env');
> print "\$BLAH is ${BLAH}" ;
>=20
> When I run it I get:
> sh: BLAH=3DTEST: is not an identifier
> $BLAH is
>=20
> How can I get Perl to load the file properly?  It does so from the
> command line but throws the error when I run the script.  For reasons I=

> can't get into I can't change the env file - the perl script needs to
> be modified.  Any help is greatly appreciated!!

Using system() will spawn a new shell which will modify its own=20
environment and pass any modifications on to its children. Nothing is=20
exported upwards or sidewarts the process hierarchy. It's pretty much=20
like trying to "cd" in a shell script and find that you stayed where you =

are in your current shell.

There is, as usual, more than one way to do it:

1. you could do the definition in a perl-file and "require" this file:
test.env:
our $BLAH =3D 'TEST';

test.pl:
#! /usr/bin/perl

use warnings;
use strict;
our $BLAH;

require "test.env";

print "BLAH is $BLAH\n";

2. you could read and parse the shell script:
test.env:
#!/usr/bin/ksh
export BLAH=3DTEST

test.pl:
#! /usr/bin/perl

use warnings;
use strict;

if (open ENV, '<', 'path/to/test.env') {
     while (<ENV>) {
         next if /^\s*#/;
         chomp;
         if (/^\s*(export)?\s+([^=3D]+)=3D(.*)/) {
             my $var =3D $2;
             my $value =3D $3;
             $value =3D~ s/^"(.*)"$/$1/;
             $ENV{$var} =3D $value;
         }
     }
     close ENV;
}
print $ENV{BLAH}, "\n";

(Note that there are several traps lurking, e.g. the following would be=20
accepted by this script but not by ksh:
export BLAH=3DThis is a test
)

HTH,

Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Thu, 10 Mar 2005 09:58:17 GMT
From: nospam@geniegate.com
Subject: Re: Using dot commands in a script
Message-Id: <Lucy111044621641680x943418@air.tunestar.net>

In: <1110399055.402663.101230@l41g2000cwc.googlegroups.com>, danfperl@yahoo.com wrote:
>I'm trying to load an environment file in a script and I think it may
>be easiest to show it before explaining it.  I've got 2 files,
>/tmp/test.pl and /tmp/test.env.  Here are the contents.
>
>test.env:
>#!/usr/bin/ksh
>export BLAH=TEST
>
>test.pl:
>#!/usr/local/bin/perl
>system('. /tmp/test.env');
>print "\$BLAH is ${BLAH}" ;
>
>When I run it I get:
>sh: BLAH=TEST: is not an identifier
>$BLAH is
>
>How can I get Perl to load the file properly?  It does so from the
>command line but throws the error when I run the script.  For reasons I
>can't get into I can't change the env file - the perl script needs to
>be modified.  Any help is greatly appreciated!!

It would probably be easier to source in the environment prior to running
your perl script if this is possible in your case. (be a lot easier too)

If the goal is nothing but getting at the shell variables AND if
they are all the same format:

export BLAH=TEST

Your next bet is probably to literally parse the file yourself. (then
blame someone else when env contains 'export BLAH=$HOME/bark') :-/

Failing that, assuming you can't slurp the environment prior to running your
perl script, you could write another shell script that sources the one you
want, this shell script (in sh, I'm not familiar with ksh) would look something
like:

----------------|wrapper.sh|---------
#!/bin/sh
 . env.ksh
echo "--START--"
env
echo "--END--"

(translate to ksh where appropriate)

Then you execute the shell script in a pipe and parse the lines
between "--START--" and "--END--".

Your problem stems from the UNIX process/environment model, parents aren't 
affected by the childrens environment. When you source a script, you are
running it in the current process.

There is no '. script' available via system(). The perl version is 
'do file.pl', 'do' will not work in your case, because file.pl needs
to be perl. (your current process is a perl interpreter, the perl interpreter
naturally expects perl)

If you are the creative type, and are running on a /proc capable system, there
is a slight chance there will be a null delimited "/proc/$PID/environ" file you
could read and parse. Don't expect it to be very portable though, and some how
you'll need to prevent 'env.sh' from exiting prior to parsing /proc. That would
be more of a "hey thats neat" type of hack. (also useful to track down what 
environment is set where) 

By the way, I believe you want $ENV{'BLAH'} not $BLAH.

Jamie
-- 
http://www.geniegate.com                    Custom web programming
guhzo_42@lnubb.pbz (rot13)                User Management Solutions


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

Date: 10 Mar 2005 05:31:12 -0800
From: "Dan" <danfperl@yahoo.com>
Subject: Re: Using dot commands in a script
Message-Id: <1110461472.267296.146940@f14g2000cwb.googlegroups.com>

Thanks to all for the feedback.  A few notes:

1. system('/usr/bin/ksh /tmp/test.env') and system('/tmp/test.env')
both run successfully (I made test.env executable) but the "export
BLAH=TEST" assignment doesn't persist because of the parent/child shell
business Tony mentioned.

2. I'm becoming resigned to using some kind of line-by-line processing
like Martin described.  I tried to avoid this because it would be so
much simpler if I could just write a single line that would load
everything in the file at once.  It seemed simple enough on the face of
it (shell scripts can just have '. /tmp/test.env' and it works so I
thought moving that into a perl 'system' command would be
straightforward)...

3. I didn't put warnings & strict lines to keep verbiage down.  I went
with the bare minimum to reproduce the problem.



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

Date: Thu, 10 Mar 2005 14:54:30 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Using dot commands in a script
Message-Id: <slrnd30kcm.9do.news@maki.homeunix.net>

Dan wrote :
> Thanks to all for the feedback.  A few notes:
>
> 1. system('/usr/bin/ksh /tmp/test.env') and system('/tmp/test.env')
> both run successfully (I made test.env executable) but the "export
> BLAH=TEST" assignment doesn't persist because of the parent/child shell
> business Tony mentioned.

I don't think that is true.
Check this out (I use zsh):

martin:[~]martin% perl -we 'print $ENV{BLAH},"\n"'
Use of uninitialized value in print at -e line 1.

martin:[~]martin% export BLAH=TEST
martin:[~]martin% perl -we 'print $ENV{BLAH},"\n"'
TEST

This works in perl skripts, too.
If shell variables are exported, they are accessible from the
environment of subsequently executed commands.

HTH
Martin

-- 
perl -e '$|=1;&p(7.74.117.115.116.32);&s();&p(97.110.111);&p(116.104.101
 .114);&s;&p(32.112.101.114.108);&s();&p(32.104.97.99.107.101.114.10);sub
 s{sleep 1};sub p(){print "@_"}'


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

Date: Thu, 10 Mar 2005 07:59:48 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Using dot commands in a script
Message-Id: <871xanob3f.fsf@limey.hpcc.uh.edu>

>> On Thu, 10 Mar 2005 14:54:30 +0100,
>> Martin Kissner <news@chaos-net.de> said:

> Dan wrote :
>> Thanks to all for the feedback.  A few notes:
>> 
>> 1. system('/usr/bin/ksh /tmp/test.env') and
>> system('/tmp/test.env') both run successfully (I made
>> test.env executable) but the "export BLAH=TEST" assignment
>> doesn't persist because of the parent/child shell business
>> Tony mentioned.

> I don't think that is true.  Check this out (I use zsh):

> martin:[~]martin% perl -we 'print $ENV{BLAH},"\n"' Use of
> uninitialized value in print at -e line 1.

> martin:[~]martin% export BLAH=TEST martin:[~]martin% perl
> -we 'print $ENV{BLAH},"\n"' TEST

> This works in perl skripts, too.  If shell variables are
> exported, they are accessible from the environment of
> subsequently executed commands.

Different situation.  Here, perl inherits the environment from
its parent (zsh).  In the OP's case, there is only a transient
child Bourne shell.


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

Date: Thu, 10 Mar 2005 06:54:44 -0700
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Using dot commands in a script
Message-Id: <d0pjj4$hf52@xco-news.xilinx.com>

Dan wrote:
> 2. I'm becoming resigned to using some kind of line-by-line processing
> like Martin described.  I tried to avoid this because it would be so
> much simpler if I could just write a single line that would load
> everything in the file at once.  It seemed simple enough on the face of
> it (shell scripts can just have '. /tmp/test.env' and it works so I
> thought moving that into a perl 'system' command would be
> straightforward)...

The perl 'do' command (perldoc -f do) will 'do' what you want.  But the 
file would need to be in perl syntax.  The restriction that the file 
must stay in ksh syntax forces the line-by-line processing.

> 3. I didn't put warnings & strict lines to keep verbiage down.  I went
> with the bare minimum to reproduce the problem.

Please leave them in, especially in examples you have contrived to 
reproduce the problem.  Doing so may help you help yourself.

Cheers,
~Jeff




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

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


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