[18361] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 529 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 19 21:05:42 2001

Date: Mon, 19 Mar 2001 18:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985053913-v10-i529@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 19 Mar 2001     Volume: 10 Number: 529

Today's topics:
        "Malformed multipart POST" error with  $HTTP::Request:: <glewis@pcocd2.intel.com>
    Re: -w and use strict; <iltzu@sci.invalid>
        Apache::Session:Flex does not validate session ID <pfarber@umich.edu>
    Re: archives <TeKno@supportinfo.com>
        assigning to other then $_ from for loop <kimmfc@mydeja.com>
    Re: assigning to other then $_ from for loop <wyzelli@yahoo.com>
    Re: assigning to other then $_ from for loop <bart.lateur@skynet.be>
        Can an Object have overloaded or multiple constructors? <bbfrancis@networld.com>
    Re: Can an Object have overloaded or multiple construct (Damian James)
    Re: check a pop3 mailbox without using additional modul (Allodoxaphobia)
    Re: confused about my and scoping (J.C.Posey)
    Re: Help about SpreadsheetParseExcel <dan@tuatha.sidhe.org>
        Help! Need script to execute a form POST (Bill Drobin)
    Re: how can I restart a regex within a substitution wit <bart.lateur@skynet.be>
        how to execute non-Perl program from Perl (David)
    Re: how to execute non-Perl program from Perl <Jonathan.L.Ericson@jpl.nasa.gov>
        How to find the existence of an array variable? <jmohan1@ascend.com>
    Re: How to find the existence of an array variable? <DNess@Home.Com>
    Re: How to find the existence of an array variable? <godzilla@stomp.stomp.tokyo>
    Re: How to find the existence of an array variable? <bart.lateur@skynet.be>
    Re: How to find the existence of an array variable? <peter.sundstrom-eds@eds.com>
        how to swap 2 fields in a file <nerdy@lycosasia.com>
    Re: more efficient way to build array of dirs ? <uri@sysarch.com>
    Re: more efficient way to build array of dirs ? (Craig Berry)
    Re: more efficient way to build array of dirs ? <kimmfc@mydeja.com>
        Multiple perl versions on same machine? $kr1pt_k177y@salmahayeksknockers.edu
        perl -> c  compile error on 'use <module>' <jy@dymaxion.ca>
        Perl Illiteracy (humor) <revjack@revjack.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 19 Mar 2001 15:47:48 -0800
From: "Glenn M. Lewis" <glewis@pcocd2.intel.com>
Subject: "Malformed multipart POST" error with  $HTTP::Request::Common::DYNAMIC_FILE_UPLOAD=1;
Message-Id: <3AB69AA4.B800F307@pcocd2.intel.com>

Hi!

	I have the following script, running on Windows 2000 using
ActiveState Perl version 5.6, build 623, called "testme.pl":

======================================================================
#!/usr/bin/perl -w

use LWP::UserAgent;
use HTTP::Request::Common;

$SERVER = '10.10.10.10/cgi-bin';

$ua = new LWP::UserAgent;

$filename = 'd:/work/src/MayaUI/testme.pl';
$filesize = -s $filename;

%upar = (
         PUTJOBFILE => 1,
         PARAMS => 'lotsa stuff',
         DATA => ($filesize ? [ "$filename" ] : 0),
         );
$result = sendJobFile('testme.cgi',\%upar);
print $result;
exit 0;

sub sendJobFile {
  my ($script, $href) = @_;
  my $url = "http://$SERVER/$script";
  $::ua->env_proxy();
  $::ua->timeout(100000);  # Long time... let the file get there!!!
  # Stream the file in chunks for unlimited file sizes...
  $HTTP::Request::Common::DYNAMIC_FILE_UPLOAD = 1;
  my $res = $ua->request(POST $url,
                         Content_Type => 'form-data',
                         Content => $href,
                         );
  return $res->content if $res->is_success;
  warn "Failed: ",$res->error_as_HTML();
  return 0;  # Failed!!!
}
=======================================================================

On the web server, I have a simple file called "testme.cgi":

***********************************************************************
#!/usr/bin/perl -w
# use CGI;
# $q = new CGI;
# print $q->header('text/plain');
# print $q->dump();
# exit 0;

open(OUT, ">>testme.out") || die "Can't open file!";
print OUT "\n\n".localtime(time)."\n";
while (<>) {
  print OUT;
}
close(OUT);
exit 0;
***********************************************************************

The web server is running Apache/1.3.6 (UNIX) on Red Hat/Linux.
When this program runs, the /var/log/httpd/error_log file says:

Malformed multipart POST
[Mon Mar 19 15:16:13 2001] [error] [client 10.1.109.45] Premature end of
script headers: /fs1/home/httpd/cgi-bin/testme.cgi

My question:  How do I debug this to find out why the multi-part POST
is "malformed"?  I can't seem to be able to find what it is actually
sending to the web server.

Thanks!
-- Glenn Lewis
glenn@gmlewis.com


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

Date: 19 Mar 2001 20:51:31 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: -w and use strict;
Message-Id: <985033248.2526@itz.pp.sci.fi>

[Jeopardectomy performed -- please reply below quoted text.]

In article <J8Ps6.1658$Hz.346120@news.uswest.net>, Michael Cook wrote:
>"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
>news:Pine.LNX.4.30.0103170134220.14900-100000@lxplus003.cern.ch...
>>
>> But if it's a CGI script, take care to send the warnings to the script
>> owner, the admin, or the log, rather than to the prospective hacker,
>> who will no doubt be looking for exploitable weaknesses in one's
>> programming style.
>
>How is this (sending the -w warnings to an admin) accomplished?

Use carpout() from CGI::Carp.  Do not use warningsToBrowser().  If you
use fatalsToBrowser, use set_message() with a subroutine that doesn't
reveal the message to the user.

  #!/usr/bin/perl -w
  use strict;

  use CGI::Carp qw/carpout fatalsToBrowser set_message/;
  BEGIN {
      open CGILOG, '>>logfile' or die "Can't open log file: $!\n";
      carpout \*CGILOG;
      set_message sub {
          print '<h1>An error has been logged.</h1>';
      };
  }

Oh, you mean you want the warnings mailed to an admin?  I'd recommend
still using a logfile as above, and having a cron job rotate and mail
the logs maybe once a day.  Sending a message for each and every error
may flood you with mail if the user keeps on trying and trying again.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: Mon, 19 Mar 2001 18:19:22 -0500
From: "Phillip Farber" <pfarber@umich.edu>
Subject: Apache::Session:Flex does not validate session ID
Message-Id: <euwt6.1255$kI5.51261@news.itd.umich.edu>


I'm trying to use Apache::Session:Flex for file-based sessions
with semaphore locking which it looks like it supports.  However,
when the base-class code in Session.pm get a session_id
(indicating) an already existing session it tries to validate at line
379 in Session.pm:

    if (defined $session_id  && $session_id) {

        #check the session ID for remote exploitation attempts
        #this will die() on suspicious session IDs.

        &{$self->{validate}}($self);

But I can't find any way to tell Flex it what validate
subroutine to use when I tie my hash.  The Flex::populate method
only recognizes 4 keys:

sub populate {
    my $self = shift;

    my $store = "Apache::Session::Store::$self->{args}->{Store}";
    my $lock  = "Apache::Session::Lock::$self->{args}->{Lock}";
    my $gen   = "Apache::Session::Generate::$self->{args}->{Generate}";
    my $ser   = "Apache::Session::Serialize::$self->{args}->{Serialize}";

[...]

   $self->{object_store} = new $store $self;
    $self->{lock_manager} = new $lock $self;
    $self->{generate}     = $incl->{$gen};
    $self->{serialize}    = $incl->{$ser}->[0];
    $self->{unserialize}  = $incl->{$ser}->[1];

[...]


but the Session.pm code wants to call $self->{validate}

I blow up with a "strict refs" violation:
Can't use string ("") as a subroutine ref while "strict refs" in use
at /l/local/perl-5.005_03/lib/site_perl/5.005/Apache/Session.pm line 379.

In the eval block around tie %hash
I'm using

      no strict 'refs';

to no avail.

How can I work around this? Any help appreciated.


Phil.


________________________________________________
Phillip Farber, Information Retrieval Specialist
Tel: 734.615.2572 | Fax: 734.647.6897
Email: pfarber@umich.edu | Web: http://www.umich.edu/~pfarber/

Digital Library Production Service (http://www.umdl.umich.edu/)
Hatcher Graduate Library, University of Michigan
308 Hatcher North, Ann Arbor, MI 48104-1205





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

Date: Mon, 19 Mar 2001 19:26:08 GMT
From: "TeKno" <TeKno@supportinfo.com>
Subject: Re: archives
Message-Id: <k3tt6.3$Sg.198752@newssvr10-int.news.prodigy.com>

I am currently archiving ths group and several others at
http://www.supportinfo.com
check the forums area,

"Todd Smith" <todd@designsouth.net> wrote in message
news:8Zit6.17919$Q47.5360544@news1.rdc1.tn.home.com...
> Where can I get the archives of this newsgroup, now that deja.com is down?
>
>




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

Date: Tue, 20 Mar 2001 00:05:50 GMT
From: Kim C <kimmfc@mydeja.com>
Subject: assigning to other then $_ from for loop
Message-Id: <256dbtgats78v2lcvvoib7r6ufh2c3n1dm@4ax.com>

Hi

Is there a way to assign to a declared variable with a
'for(@somearray)' as can be done with a 'foreach
$somevar(@somearray)'?

The problem is this:

#############
use strict;

my $var;
my @array;

{

	#...some code

	foreach $var (@array){
		#...somecode
		&subroutine;
}


sub subroutine {
	#...some code with $var
}	

#############

The problem is that assigning to the global $var using the foreach
loop seems to localize the value of $var so 'subroutine' can't access
it.  Using the following does the trick but is a bit kludgy.

for(@array){
	$var = $_;
	#...somecode
}

Is there a way to assign directly to $var using for(@array), or force
global assignment of $var using foreach()?

Thank you

Kim 


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

Date: Tue, 20 Mar 2001 10:17:03 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: assigning to other then $_ from for loop
Message-Id: <Nzxt6.8$zS.3330@vic.nntp.telstra.net>

"Kim C" <kimmfc@mydeja.com> wrote in message
news:256dbtgats78v2lcvvoib7r6ufh2c3n1dm@4ax.com...
> Hi
>
> Is there a way to assign to a declared variable with a
> 'for(@somearray)' as can be done with a 'foreach
> $somevar(@somearray)'?
>
> The problem is this:
>
> #############
> use strict;
>
> my $var;
> my @array;
>
> {
>
> #...some code
>
> foreach $var (@array){
> #...somecode
> &subroutine;
> }
>
>
> sub subroutine {
> #...some code with $var
> }

You are probably better declaring the variable locally in each case, and
then passing the value you want to the subroutine.

use strict;

my @array = qw(a b c d e);

foreach my $var (@array){ # this var is limited to this subroutine
print $var;
subroutine($var);
}


sub subroutine {
my $var = shift; # this is a different $var, limited to this subroutine
print $var;
}

By declaring within the scope of each use, the two '$var's can never
overwrite each other, and the variable is always being used within its
scope.

Use the return to access the modified variable after the subroutine:

foreach my $var (@array){
print $var;
$var = subroutine($var);
print $var;
}


sub subroutine {
my $var = shift;
$var++;
return $var;
}

HTH

recomended reading: perlsub

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";






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

Date: Tue, 20 Mar 2001 01:10:22 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: assigning to other then $_ from for loop
Message-Id: <cbbdbtcs87oj4h42m29fjjml3v2rnbbioe@4ax.com>

Kim C wrote:

>Is there a way to assign to a declared variable with a
>'for(@somearray)' as can be done with a 'foreach
>$somevar(@somearray)'?
>
>The problem is this:
>
>#############
>use strict;
>
>my $var;
>my @array;
>
>{
>
>	#...some code
>
>	foreach $var (@array){
>		#...somecode
>		&subroutine;
>}
>
>
>sub subroutine {
>	#...some code with $var
>}	
>
>#############
>
>The problem is that assigning to the global $var using the foreach
>loop seems to localize the value of $var so 'subroutine' can't access
>it.

But it's NOT a global variable. It's a lexical. For what you want, you
NEED a global variable. So either do:

	our $var;

instead of "my $var", in case of 5.6 or up, or 

	use vars '$var';

in any reasonably recent version.

-- 
	Bart.


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

Date: 19 Mar 2001 15:59:59 -0700
From: "Brian Francis" <bbfrancis@networld.com>
Subject: Can an Object have overloaded or multiple constructors???
Message-Id: <3ab68f6f$1@nntp.networld.com>


Can an Object have overloaded or multiple constructors???

Posted from NetWORLD Connections, Inc.


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

Date: 19 Mar 2001 23:34:59 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Can an Object have overloaded or multiple constructors???
Message-Id: <slrn9bd5sh.aki.damian@puma.qimr.edu.au>

Brian Francis chose 19 Mar 2001 15:59:59 -0700 to say this:
>
>Can an Object have overloaded or multiple constructors???
>

Yes.

HTH

Cheers,
Damian
-- 
@;=0..23;@;{@;}=split//,<DATA>;while(@;){for($;=@;;--$;;){next if($:=rand($;
+1))==0+$;;@;[$;,$:]=@;[$:,$;]}print map{$;{$_}}(@| ,@;);push@|,shift@;if$;[
0]==@|;$|=1;select$&,$&,$&,1/80;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker


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

Date: 20 Mar 2001 01:39:10 GMT
From: QSB@QRM-QRN.net (Allodoxaphobia)
Subject: Re: check a pop3 mailbox without using additional modules
Message-Id: <slrn9bdd5s.ib9.QSB@animas.frontier.net>

On 19 Mar 2001 10:16:51 -0700, gls@byu.edu scribbled:
>"Paul" <paulthomson@hotmail.com> writes:
>
>> Does anyone know of a way to check a pop3 mailbox without using additional
>> modules to the basic perl 5 installation? The reason I ask is my isp makes a
>> hideous charge for installing modules :(
>
>Check to see if the module that you want to use is straight Perl or
>needs parts compiled (some modules with compiled parts also provide
>Perl only versions).  If you have a Perl only version of the module,
>then you can copy and paste the whole thing (or just the parts you
>need) into your script.  That way you are reusing existing code (the
>goal of modules) without needing your isp to install anything.

Good idea!
On the same topic:  Can one install modules in their own $HOME
(sub)directories and somehow point the perl sorce at that 
executable in that directory?

TIA,
Jonesy
-- 
  | Marvin L Jones       | jonz           |  W3DHJ   |  OS/2
  |  Gunnison, Colorado  |  @             |  Jonesy  |  linux   __
  |   7,703' -- 2,345m   |   frontier.net |  DM68mn             SK


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

Date: 19 Mar 2001 20:28:45 +0000
From: jcp@myrtle.ukc.ac.uk (J.C.Posey)
Subject: Re: confused about my and scoping
Message-Id: <jkohf0p5wqq.fsf@myrtle.ukc.ac.uk>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> According to Rafael Garcia-Suarez <rgarciasuarez@free.fr>:

> > You shouldn't use hard references then. Code that uses hard references
> > is usually hard to maintain.
> 
> s/hard/soft/, surely?
> 
> Anno

Yes Anno, I think you are right, and I think that is what he was getting
at. Thanks all for taking time to answer this thread. Much homework for
me to do--need more time!

Thanks again,
Jake


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

Date: Mon, 19 Mar 2001 21:12:02 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Help about SpreadsheetParseExcel
Message-Id: <CCut6.45375$Ok4.4167253@news1.rdc1.ct.home.com>

Regent Linus <wstsoi@hongkong.com> wrote:
> I found It is rather slow for dumping a 1.5MB excel file.


> It took about 2 minutes to finish the dumping for a 333MHz machine.

> Any ways to speed up?

Rewrite part of it in C, probably. I've used this thing and it's
really nice, but it's also pure perl. Excel spreadsheets aren't the
simplest thing in the world, and parsing them out will take
a good chunk of time with perl.

				Dan


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

Date: Tue, 20 Mar 2001 01:50:16 GMT
From: bdrobin@zdnetonebox.com (Bill Drobin)
Subject: Help! Need script to execute a form POST
Message-Id: <3ab6b767.430363880@news.ne.mediaone.net>

Newbie here.....I have searched high and low and cannot figure out how
to get my perl script to emulate a user filling in a username and
password.   I have the user name and password, and need my perl script
to login to the site so it can automatically access some of its
resources.    Can someone help?

I believe this is the relevant code from the web page.

THANKS IN ADVANCE FOR ANY HELP!!!!

      <FORM synchronize action="/start.jhtml?_DARGS=%2Flogin.jhtml.6"
name="LoginForm" METHOD="post">
      <INPUT TYPE="hidden" value="/start.jhtml"
name="/root/profile/ProfileLoginLogout.successURL"><input
type="hidden" name="_D:/root/profile/ProfileLoginLogout.successURL"
value=" ">
      <INPUT TYPE=HIDDEN VALUE="/login.jhtml"
name="/root/profile/ProfileLoginLogout.cancelURL"><input type="hidden"
name="_D:/root/profile/ProfileLoginLogout.cancelURL" value=" ">
         <table cols="2" width="200">
            <tr>
               

<td align="right" width="20%">
<font class="fieldLabel">E-mail:
</font></td>
<td align="left">
<input type="text" name="loginBox" size="35" maxlength="100"
value="">
<input type="hidden" name="_D:loginBox" value=" ">
</td></tr><tr>

<td align="right">
<font class="fieldLabel">Password:
</font></td>
<td>
<input type="password" size="35" maxlength="30"  value=""
name="/root/profile/ProfileLoginLogout.password">
<input type="hidden"
name="_D:/root/profile/ProfileLoginLogout.password" value=" ">
</td></tr><tr>

<td align="center" colspan="2"><br>
<input type="hidden" value=""
name="/root/profile/ProfileLoginLogout.doLogin">
<input type="hidden"
name="_D:/root/profile/ProfileLoginLogout.doLogin" value=" ">
<input type="submit" value="Login"
name="/root/profile/ProfileLoginLogout.doLogin">
<input type="hidden"
name="_D:/root/profile/ProfileLoginLogout.doLogin" value=" ">
              


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

Date: Mon, 19 Mar 2001 23:48:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: how can I restart a regex within a substitution without leaving the
Message-Id: <i66dbtgstlm9rpi3nsgb5ggddj3bdai397@4ax.com>

info@java.seite.net wrote:

>background is: i want to parse html-templates dynamically on a web-setrver (so
>speed is a criteria) and change some new tags with something else. it
>perfectly works with static defined tag names, but now i want to make it
>possible to define new tags inside the same template....

Then why are you using tags at all. Use something more recognizable, of
a unique structure. The "SGML processing instructions" come to mind:
stuff between "<?" and ">". That's what PHP uses, and it's not a bad
idea.

-- 
	Bart.


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

Date: Mon, 19 Mar 2001 21:45:42 GMT
From: dsedrich@yahoo.com (David)
Subject: how to execute non-Perl program from Perl
Message-Id: <3ab67bb7.522284@news>

I've been trying to execute a batch file from Perl using the System
command and Exec command with limited success.

Both will execute a batch file in my ...\apache\cgi-bin directory but
only a limited number of things appear that I can do successfully and
I haven't figured out what the pattern is.

I can do "DIR > filename" in it
I can call another batch file  with (Dir>filname in it)

I can run a simple EXE program, it appears, that is on my path (not in
the cgi-bin directory) with the exec command at least.

But I can't seem to run imagemagick identify command (identify
-verbose filename > filename) , even if the imagemagick directory is
on the path. 

Can somebody tell me either the correct method to call programs from
within Perl? Or any details associated with the system or exec command
that could explain why I am having these problems?

I dump my path while in the batch file (that works). To the begining
is appended ....c:\program files\apache group\apache.

I try changing that to eliminate that string as well before I execute
anything else but there is no apparent effect.  -- Dave


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

Date: 19 Mar 2001 23:59:10 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: how to execute non-Perl program from Perl
Message-Id: <867l1lcnu9.fsf@jon_ericson.jpl.nasa.gov>

dsedrich@yahoo.com (David) writes:

> I've been trying to execute a batch file from Perl using the System
> command and Exec command with limited success.

I would like to point you to the qx "quote-like operator" documented
in perlop.  (Won't solve your problem, but it's easy to miss.)  system
is more likely than exec to be useful since it returns control to its
parent when it's done processing.

> Can somebody tell me either the correct method to call programs from
> within Perl? Or any details associated with the system or exec command
> that could explain why I am having these problems?
> 
> I dump my path while in the batch file (that works). To the begining
> is appended ....c:\program files\apache group\apache.

There are too many things that could be wrong.  You need to simplify.
Does your script work from the command line?  Have you tried using the
full path to the child program?  Can you reduce the script to a few
lines that reproduce the problem?  Are you using strict and warnings?

Jon


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

Date: Mon, 19 Mar 2001 13:43:05 +0530
From: Jagan Mohan K <jmohan1@ascend.com>
Subject: How to find the existence of an array variable?
Message-Id: <3AB5BF91.2825AC32@ascend.com>

Hi,
  Any idea how to find the whether a variable exists or not in Perl?
What I mean is a command something like  [info exists a ] checks for
existence of the variable in Tcl.

Thanks,
-Jagan


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

Date: Mon, 19 Mar 2001 21:54:21 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: How to find the existence of an array variable?
Message-Id: <3AB68022.44AA8BD9@Home.Com>

Jagan Mohan K wrote:
> 
> Hi,
>   Any idea how to find the whether a variable exists or not in Perl?
> What I mean is a command something like  [info exists a ] checks for
> existence of the variable in Tcl.
> 
> Thanks,
> -Jagan

perldoc -f defined


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

Date: Mon, 19 Mar 2001 14:18:23 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: How to find the existence of an array variable?
Message-Id: <3AB685AF.70611FA9@stomp.stomp.tokyo>

Jagan Mohan K wrote:

> Any idea how to find the whether a variable exists
> or not in Perl?

You need to state clear and concise parameters.
Are you looking for a variable name, a variable
value or both?

A variable name is very easy to find. Simply
open your program and look.

Finding a variable value is equally easy.
Have your program print your variable 
value of interest.

Same snap-your-fingers ease with an
associative array or misnomer hash;
print your key and value pairs.

You will discover your own eyeballs usually
do an adequate job of finding whatevers.


> What I mean is a command something like....

Your "something like" doesn't cut it for 
programming; it is a precise and exacting art.

Godzilla!


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

Date: Mon, 19 Mar 2001 23:49:58 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to find the existence of an array variable?
Message-Id: <nq6dbt8ga5mfqjed233ee40b84h8pptpap@4ax.com>

Jagan Mohan K wrote:

>  Any idea how to find the whether a variable exists or not in Perl?

Use the search utility of a text editor.

-- 
	Bart.


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

Date: Tue, 20 Mar 2001 10:54:56 +1200
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: How to find the existence of an array variable?
Message-Id: <9962oc$jga$1@hermes.nz.eds.com>


"Jagan Mohan K" <jmohan1@ascend.com> wrote in message
news:3AB5BF91.2825AC32@ascend.com...
> Hi,
>   Any idea how to find the whether a variable exists or not in Perl?
> What I mean is a command something like  [info exists a ] checks for
> existence of the variable in Tcl.

Pretty much a SAQ.

perldoc -f exists
perldoc -f defined




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

Date: Tue, 20 Mar 2001 10:46:09 +1000
From: "ckw" <nerdy@lycosasia.com>
Subject: how to swap 2 fields in a file
Message-Id: <3ab6a8dd_2@news01.one.net.au>

how do i swap 2 fields in a file
for eg
abcdef                ghiji
becomes
ghiji                    abcdef






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

Date: Mon, 19 Mar 2001 19:16:52 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: more efficient way to build array of dirs ?
Message-Id: <x7hf0p4li1.fsf@home.sysarch.com>

>>>>> "KC" == Kim C <kimmfc@mydeja.com> writes:

  KC> Hi The included code builds an array of all directories in the
  KC> current directory.  It works, but is there a more
  KC> efficient/elegant/speedy way of doing this?

  KC> foreach (glob ("*")) { push (@dirs , $_) if (-d) }

grep is your friend:

	@dirs = grep -d, glob( '*' ) ;

also look into using opendir/readdir which are faster than glob for most
perls (5.6 does glob internally, older perls fork a shell). but then you
have to filter out . and .. yourself (* in glob won't match those).

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Mon, 19 Mar 2001 20:09:37 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: more efficient way to build array of dirs ?
Message-Id: <tbcps1fsqn8ec9@corp.supernews.com>

Kim C (kimmfc@mydeja.com) wrote:
: The included code builds an array of all directories in the current
: directory.  It works, but is there a more efficient/elegant/speedy way
: of doing this?
: 
: 	foreach (glob ("*")) {	push (@dirs , $_) if (-d)  }

  @dirs = grep { -d } glob('*');

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: Mon, 19 Mar 2001 20:59:53 GMT
From: Kim C <kimmfc@mydeja.com>
Subject: Re: more efficient way to build array of dirs ?
Message-Id: <3qscbtol0nm0ibkfk5qvdt7fl1e7ls9kas@4ax.com>

Thanks!

Kim


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

Date: Mon, 19 Mar 2001 19:38:18 GMT
From: $kr1pt_k177y@salmahayeksknockers.edu
Subject: Multiple perl versions on same machine?
Message-Id: <Kett6.36378$tr5.4314900@news1.telusplanet.net>

One of the servers I mind has perl already installed to /opt/perl5.
Recently, I installed perl56 to /opt/perl56.  Now, I want to compile PERL
DBI for the /opt/perl56 install, but am having the problem that it is 
looking for libraries/modules in the /opt/perl5 directory.

Here is my compile command line:  /opt/perl56/bin/perl Makefile.PL

Even after executing the binary from this location, it appears that it is
looking for particular libraries in /opt/perl5, which is does not find.

How do I set the environment so it knows where to look for things?

Thanks in advance,
Dan.


-- 
 ..............................................................................

"In June 1967, we again had a choice.  The Egyptian Army concentrations in the
 Sinai approaches do not prove that Nasser was really about to attack us.  We
 must be honest with ourselves.  We decided to attack him"

                                              -Menachim Begin

 ...............................................................................
www.geocities.com/pentagon/bunker/1022           swan_daniel@my-dejanews.com



                                 

						
						


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

Date: Mon, 19 Mar 2001 21:42:42 GMT
From: "June Young" <jy@dymaxion.ca>
Subject: perl -> c  compile error on 'use <module>'
Message-Id: <m3vt6.140$k.36002@sapphire.mtt.net>

I am using perl5_6 on VMS_Alpha 7.21. I use CC/DECC for c compiler.

I try to convert a simple perl program to c, and found it does not work if
the perl program try to use modules via "use" statement.
It looks the CC can not find module.

Does any one have suggestion?

Thanks,

JY
-----------------
log:

#dumper.pl
use Data::Dumper;
print "Hello world\n";

$perl -MO=CC,-odumper.c
Prescan
Data::Dumper has method new: saving package
Exporter saved (it is in Data::Dumper's @ISA)
Saving methods
Bootstrap Data::Dumper /perl_root/lib/VMS_AXP/5_6_0/XSLoader.pm
Loaded B
Loaded IO
Loaded Fcntl
Loaded Data::Dumper
bootstrapping Data::Dumper added to xs_init
dumper.prl syntax OK

$perl cc_harness dumper.c

        boot_Data__Dumper(aTHX_ NULL);
 ........^
%CC-I-IMPLICITFUNC, In this statement, the identifier
"boot_Data__Dumper" is implicitly declared as a function.
at line number 21654 in file SYS$SYSDEVICE:[DYWWW.TEST]DUMPER.C;1

  lab_645380:
 ..^
%CC-I-UNREACH, code can never be executed at label lab_645380
at line number 21468 in file SYS$SYSDEVICE:[DYWWW.TEST]DUMPER.C;1

  lab_644d60:
 ..^
%CC-I-UNREACH, code can never be executed at label lab_644d60
at line number 21476 in file SYS$SYSDEVICE:[DYWWW.TEST]DUMPER.C;1

        MAYBE_TAINT_SASSIGN_SRC(sv);
 ........^
%CC-W-UNINIT1, The scalar variable "left" is fetched but not
initialized.
at line number 21415 in file SYS$SYSDEVICE:[DYWWW.TEST]DUMPER.C;1

  lab_649920:
 ..^
%CC-I-UNREACH, code can never be executed at label lab_649920
at line number 21320 in file SYS$SYSDEVICE:[DYWWW.TEST]DUMPER.C;1

  lab_648f78:
 ..^
%CC-I-UNREACH, code can never be executed at label lab_648f78
at line number 21351 in file SYS$SYSDEVICE:[DYWWW.TEST]DUMPER.C;1

        MAYBE_TAINT_SASSIGN_SRC(sv);
 ........^
%CC-W-UNINIT1, The scalar variable "left" is fetched but not
initialized.
at line number 21285 in file SYS$SYSDEVICE:[DYWWW.TEST]DUMPER.C;1

  lab_647bc0:
 ..^
%CC-I-UNREACH, code can never be executed at label lab_647bc0
at line number 21142 in file SYS$SYSDEVICE:[DYWWW.TEST]DUMPER.C;1

 ........




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

Date: 20 Mar 2001 01:48:17 GMT
From: revjack <revjack@revjack.net>
Subject: Perl Illiteracy (humor)
Message-Id: <996ct1$5ne$2@news1.Radix.Net>
Keywords: Hexapodia as the key insight

http://www.bbspot.com/News/2001/03/perl_test.html


-- 
___________________
revjack@revjack.net


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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