[22946] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5166 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 2 06:06:31 2003

Date: Wed, 2 Jul 2003 03:05:07 -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           Wed, 2 Jul 2003     Volume: 10 Number: 5166

Today's topics:
    Re: Delete array element from inside function <islaw@adexec.com>
    Re: Delete array element from inside function <islaw@adexec.com>
        executing "DB2 load command" from perl return errors (Kenjis Kaan)
    Re: executing "DB2 load command" from perl return error <ianbjor@mobileaudio.com>
    Re: fork, childs, zombies, start a process in the backg (Rex Gustavus Adolphus)
    Re: fork, childs, zombies, start a process in the backg (Rex Gustavus Adolphus)
    Re: fork, childs, zombies, start a process in the backg <bobSPAMSUCKS@bob-n.com>
    Re: funny printf behaviour in need of explanation (Dov Levenglick)
    Re: generating executables <xaonon@hotpop.com>
        Help with https and Paypal; (Boris)
    Re: Help with https and Paypal; <simon.andrews@bbsrc.ac.uk>
    Re: Help with https and Paypal; <mbudash@sonic.net>
    Re: How would you mail yourself from XP (Helgi Briem)
    Re: include ASP scripts in PERL <me@privacy.net>
    Re: newbie needs to globally edit his site <islaw@adexec.com>
    Re: newbie needs to globally edit his site <bart.lateur@pandora.be>
    Re: newbie needs to globally edit his site <noreply@gunnar.cc>
    Re: Problem with tk and displaying on the screen (Jay Tilton)
    Re: Problem with tk and displaying on the screen (Helgi Briem)
        Regular Expression Problem <kenneth@baltrinic.com>
    Re: Regular Expression Problem (Sam Holden)
    Re: Regular Expression Problem <fran_cw@hotmail.com>
    Re: SHIFT not shuffling ? <Not_Me@pcug.org.au>
    Re: SHIFT not shuffling ? (Sam Holden)
        XS question -- avoid memory leak <REMOVEsdnCAPS@comcast.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 1 Jul 2003 22:45:11 -0700
From: "Islaw" <islaw@adexec.com>
Subject: Re: Delete array element from inside function
Message-Id: <bdtrh9$tqs56$1@ID-196529.news.dfncis.de>

Andrew Perrin (CLists) wrote:
> JS Bangs <jaspax@u.washington.edu> writes:
>
>> Hey, all:
>>
>> I've got a function that would like to be able to delete an array
>> element from an array in the caller's scope, given only the array
>> element (not the array itself, or a reference to it).
>
> I don't think this is possible, since $word[3] is a scalar and
> contains no reference to @word as a whole.  If you don't need it to be
> a general solution, and for some reason you're opposed to passing an
> array ref, I suppose you could do something like:
>
> $word[3] = {val => $word[3],
>             parent => \@word};
> delete_seg($word[3]);
>
> and then:
>
> sub delete_seg {
>         my @parent = @{$_[0]->{parent}};
>         ...
> }
>
> but I don't see why that would be useful.
>
> Again, I don't think there's a general solution (but would be happy to
> be proved wrong). You could also probably use tie() for a specific
> solution, but again I think it's unlikely to be a better solution than
> just passing the array ref.

Very creative though! (If a tad overkill for the task at hand.) As you
mentioned, a array ref would be a bit cleaner (and more general.)

--
Islaw




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

Date: Tue, 1 Jul 2003 22:50:05 -0700
From: "Islaw" <islaw@adexec.com>
Subject: Re: Delete array element from inside function
Message-Id: <bdtrqf$vilul$1@ID-196529.news.dfncis.de>

Brian McCauley wrote:
>

[Line numbers added]
> 1 my @array = (1,2,3);
> 2 my $r = \$array[1];
> 3 delete $array[2];
> 4 print $$r;

I think you meant
   delete $array[1];
@ line 3 :)

--
Islaw




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

Date: 1 Jul 2003 22:59:55 -0700
From: tivolinewbie@canada.com (Kenjis Kaan)
Subject: executing "DB2 load command" from perl return errors
Message-Id: <6a8ba9f8.0307012159.30d23946@posting.google.com>

Stats:  Perl 5.6.1 on Win2k, DB2 Universal Personal on Win2k (same
machine)

I have a perl program that tries to execute the DB2 load command in
order to import a bunch of rows of data into a DB2 table.  This
command runs fine from the DB2 (DB2 CLP -db2) command line processor
ie. db2=>
However when I tried to use it inside Perl I got an error.  And I
can't seem to understand why.  I hope someone here can help me out. 
Here is an exerpt of the program code that is doing this.

-----exerpt---------------------------------------------------------------

my $stLd = "load from E:/var/Reports/thesum.dat of del modified by
coldel| in
sert into RptData (NODE_NAME,PACKAGE_NAME,START_TIME,END_TIME,OPERATION,STATUS,L
OGCNT,CCMCNT,REMCNT,FCCMCNT,FREMCNT,INSTSRC,INSTALLER,ERRCODE,ERRDESC,SRCDIR,ADM
INFLG,LOGONUSR,SILENTINST,CISCUSTFL)";

my $sth1 = $dbh->prepare($stLd);
$sth1->execute;

-----exerpt_end------------------------------------------------------------

What the program returns are these errors.

DBD::DB2::st execute failed: [IBM][CLI Driver][DB2/NT] SQL0104N  An
unexpected t
oken "load from E:/var/Reports/thesum.dat of del " was found following
"BEGIN-OF
-STATEMENT".  Expected tokens may include:  "<space>".  SQLSTATE=42601

-------------------------------------------------------------------------
I can confirm that the data is there in E:/var/Reports/thesum.dat and
also that this command above as passed in by $stLd runs perfectly on
the DB2 command line processor when I typed it in, and it successful
load the data into the table.
My goal is to be able to have a program that generates the file
thesum.dat and ftp it to the remote machine where DB2 is running on,
then from the perl program
connects to the DB2 server using $dbh->connect  ... etc. and then run
the
$sth1->execute("load... ") above in order to tell the remote DB2
server to upload the data. The power to B decides that we aren't allow
to iteratively use $sth1->execute to load one line or data at a time
as it generates too much traffic.  Don't ask me why they don't go to
more bandwidth. TIA


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

Date: Tue, 1 Jul 2003 23:30:16 -0700
From: "Ian D. Bjorhovde" <ianbjor@mobileaudio.com>
Subject: Re: executing "DB2 load command" from perl return errors
Message-Id: <Pine.LNX.4.44.0307012324080.24192-100000@sidi.phx.dataproxy.com>

On 1 Jul 2003, Kenjis Kaan wrote:

> Stats:  Perl 5.6.1 on Win2k, DB2 Universal Personal on Win2k (same
> machine)
> 
> I have a perl program that tries to execute the DB2 load command in
> order to import a bunch of rows of data into a DB2 table.  This
> command runs fine from the DB2 (DB2 CLP -db2) command line processor
> ie. db2=>
> However when I tried to use it inside Perl I got an error.  And I
> can't seem to understand why.  I hope someone here can help me out. 
> Here is an exerpt of the program code that is doing this.
> 
> -----exerpt---------------------------------------------------------------
> 
> my $stLd = "load from E:/var/Reports/thesum.dat of del modified by
> coldel| in
> sert into RptData (NODE_NAME,PACKAGE_NAME,START_TIME,END_TIME,OPERATION,STATUS,L
> OGCNT,CCMCNT,REMCNT,FCCMCNT,FREMCNT,INSTSRC,INSTALLER,ERRCODE,ERRDESC,SRCDIR,ADM
> INFLG,LOGONUSR,SILENTINST,CISCUSTFL)";
> 
> my $sth1 = $dbh->prepare($stLd);
> $sth1->execute;

LOAD is not an SQL statement, it is a command.  Therefore it can't be 
executed via DBI (or JDBC, ODBC, etc).  You need to execute it using 
either the system() call in perl or by opening the command and reading 
from the pipe, e.g.,

   open(LOAD, "db2 load from ... |");

Or write a perl XS module that calls the sqluload() API!  ;-)


Good luck,






-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: 2 Jul 2003 01:43:46 -0700
From: uffesterner@spamhole.com (Rex Gustavus Adolphus)
Subject: Re: fork, childs, zombies, start a process in the background without waiting for it
Message-Id: <c70a85ff.0307020043.5034b5db@posting.google.com>

gbacon@hiwaay.net (Greg Bacon) wrote in message news:<vg34vlkjvc5b61@corp.supernews.com>...
> In article <c70a85ff.0307010348.69336671@posting.google.com>,
>     Rex Gustavus Adolphus <uffesterner@spamhole.com> wrote:
> 
> : I have a parent program, that should loop (eternally), and start other
> : programs without waiting for them, so many programs can be started at
> : the same time by the parent.
> 
> Careful not to create a forkbomb. :-)
> 
> : Is it true that it's not necessary to handle childsignals if you use
> : this type of logic when you fork processes:
> : 
> : if ($pid = fork) {
> :         # parent                       
> : } elsif (defined $pid) {
> :         # child                        
> :         exec $agent
> :                 or die "Can't do $agent";
> : } else {
> :         # fork error                   
> :         die "can't fork\n";
> : }
> 
> According to the perlipc manpage, it might even be easier, depending
> on your surroundings:
> 
>     On most Unix platforms, the CHLD (sometimes also known
>     as CLD) signal has special behavior with respect to a
>     value of 'IGNORE'. Setting $SIG{CHLD} to 'IGNORE' on
>     such a platform has the effect of not creating zombie
>     processes when the parent process fails to wait() on
>     its child processes (i.e. child processes are
>     automatically reaped). Calling wait() with $SIG{CHLD}
>     set to 'IGNORE' usually returns -1 on such platforms.
> 
> Greg

Thanks Greg!
But I'm sorry I don't understand if your answer means that the
fork-logic code I provided above is OK, so the parent doesn't have to
wait for the childs to avoid zombies?
Could you please clarify?
I like this to be as portable as possible so I'm a bit wary of the
'most' in 'On most Unix platforms...'
(On the Linux i tried, it said 'Can't ignore signal CHLD, forcing to
default.')

RGA


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

Date: 2 Jul 2003 02:59:48 -0700
From: uffesterner@spamhole.com (Rex Gustavus Adolphus)
Subject: Re: fork, childs, zombies, start a process in the background without waiting for it
Message-Id: <c70a85ff.0307020159.7149abb7@posting.google.com>

bob niederman <bobSPAMSUCKS@bob-n.com> wrote in message news:<3f026252_1@127.0.0.1>...
> Greg Bacon wrote:
> > In article <c70a85ff.0307010348.69336671@posting.google.com>,
> >     Rex Gustavus Adolphus <uffesterner@spamhole.com> wrote:
> > 
> > : I have a parent program, that should loop (eternally), and start other
> > : programs without waiting for them, so many programs can be started at
> > : the same time by the parent.
> > 
> > Careful not to create a forkbomb. :-)
> 
> Not a fork-bomb because exec doesn't return.
> 
> W/ perl 5.8.0 on Linux (rh9.0) I couldn't seem to create zobies w/ exec.
> 
> With proccesses that ran perl and exited, I had zombies if I didn't 
> waitpid on them, but only while the parent was up - once the parent 
> finished, the zombie children went away too.  YMMV on other perl/OS 
> combinations.
> 

Thanks Bob,
but since my parent should keep running, I _must_ avoid leaving
zombies around.

I think I found the solution in PerlFAQ 8.12: "double fork"
(I must admit I thougt my previous method was "double fork" but I now
realize it isn't):
You immediately wait() for your first child, and the init daemon will
wait() for your grandchild once it exits.

            unless ($pid = fork) {
                unless (fork) {
                    exec "what you really wanna do";
                    die "exec failed!";
                }
                exit 0;
            }
            waitpid($pid,0);


BTW, whats "YMMV"?
/RGA


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

Date: Tue, 01 Jul 2003 23:39:56 -0500
From: bob niederman <bobSPAMSUCKS@bob-n.com>
Subject: Re: fork, childs, zombies, start a process in the background without waiting for it
Message-Id: <3f026252_1@127.0.0.1>

Greg Bacon wrote:
> In article <c70a85ff.0307010348.69336671@posting.google.com>,
>     Rex Gustavus Adolphus <uffesterner@spamhole.com> wrote:
> 
> : I have a parent program, that should loop (eternally), and start other
> : programs without waiting for them, so many programs can be started at
> : the same time by the parent.
> 
> Careful not to create a forkbomb. :-)

Not a fork-bomb because exec doesn't return.

W/ perl 5.8.0 on Linux (rh9.0) I couldn't seem to create zobies w/ exec.

With proccesses that ran perl and exited, I had zombies if I didn't 
waitpid on them, but only while the parent was up - once the parent 
finished, the zombie children went away too.  YMMV on other perl/OS 
combinations.



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


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

Date: 1 Jul 2003 22:11:34 -0700
From: stam_doar@hotmail.com (Dov Levenglick)
Subject: Re: funny printf behaviour in need of explanation
Message-Id: <8ebf3385.0307012111.6b5481ec@posting.google.com>

> You should not be using $a and $b as assignable variables.  In Perl 5
> they are reserved for use by the sort function.
> 
thank you for pointing that out i wasn't aware of this. be that as it
may, it doesn't solve the problem that i raised in the printf
behaviour.


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

Date: Wed, 02 Jul 2003 06:53:49 GMT
From: Xaonon <xaonon@hotpop.com>
Subject: Re: generating executables
Message-Id: <slrnbg5asr.qfp.xaonon@xaonon.local>

Ned i bach <bdt87n$5qo$2@news8.svr.pol.co.uk>, rod <rhodri@phreaker.net>
teithant i thiw hin: 

> Xaonon wrote:
> 
> > Ned i bach <bdt63a$5qo$1@news8.svr.pol.co.uk>, rod <rhodri@phreaker.net>
> > teithant i thiw hin: 
> > 
> > > that all works fine, but i was wondering how one would go about
> > > creating real executables?  can you do this from perl?  does anyone
> > > have any pointers to resources that would help?  anything would be
> > > great.
> > 
> > Try "man perlcompile".
> 
> ok i looked at that and i know about perlcc and other ways of compiling
> perl into executables, but that's not what i mean.  forgive me here if
> i've missed the point of ur reply, i'm sorry.  what i want to do is  write
> my own executables not for my perl source but for the language i'm
> parsing (a language i made up).

Whoops, I misunderstood you.  Sorry, I don't know much about that.  You
could try modifying your compiler to generate real assembly code and put
that through an assembler like as, or just leave it as interpreted code.

Just out of curiosity, could we see a short sample of what your language
looks like?  If it's similar enough to an already existing compiled
langauge, maybe you could write your Perl compiler to translate it into that
language and compile with already existing tools.

-- 
Xaonon, EAC Chief of Mad Scientists and informal BAAWA, aa #1821, Kibo #: 1
Visit The Nexus Of All Coolness (i.e. my site) at http://xaonon.dyndns.org/
"Xaonon is a sofa that sorts your mail, is built and maintained by tiny
nano-robots and induces lucid dreaming." -- thesurrealist.co.uk/priorart.cgi


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

Date: 2 Jul 2003 00:39:30 -0700
From: bnlitin@yahoo.com (Boris)
Subject: Help with https and Paypal;
Message-Id: <53e8c7c3.0307012339.3a13644c@posting.google.com>

I am trying to write a Perl subroutine to access Paypal's website, to
checkout my shopping cart.  When running on my PC, my PERL complains:

 Failed: Protocol scheme 'https' is not supported501 Protocol scheme
'https' is not supported

When running on a Linux server, it doesn't seem to be using the https
protocol and the Paypal shopping cart fails. Similar Javascript code
works fine.

Can anyone point out why PERL doesn't support https (according to
Perldocs it does) or am I doing something else wrong?

Here is my PERL code:


sub callPaypal {
  my $self = shift;
  use URI;
  use LWP::UserAgent;
  use HTTP::Request::Common;
  my $ua = LWP::UserAgent->new;
  my $url = URI->new($self->{siteUrl});
  $url->query_form(
		   cmd      => $self->{cmd},
		   add      => $self->{add},
		   display  => $self->{display},
		   business => $self->{business},
		   quantity => $self->{quantity},
		   item_name=> $self->{item},
		   amount   => $self->{amount},
		   currency_code => $self->{currency},
		   on0           => 'Op:',
		   os0           => $self->{option1},
		   on1           => 'Cust:',
		   os1           => $self->{option2},
		   image_url     => $self->{image_url},
		   return        => $self->{return},
		   cancel_return => $self->{cancel}
		  );

  my $res = $ua->request(GET $url);

  #print "$url \n";;
  if ($res->is_success) {
    print $res->content;
  } else {
    print "Failed: ",$res->message,$res->status_line, " \n";
  }

}


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

Date: Wed, 02 Jul 2003 08:55:45 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Help with https and Paypal;
Message-Id: <3F029001.7030703@bbsrc.ac.uk>



Boris wrote:
> I am trying to write a Perl subroutine to access Paypal's website, to
> checkout my shopping cart.  When running on my PC, my PERL complains:
> 
>  Failed: Protocol scheme 'https' is not supported501 Protocol scheme
> 'https' is not supported

from perldoc lwpcook:

HTTPS

URLs with https scheme are accessed in exactly the same way as with http
scheme, provided that an SSL interface module for LWP has been properly
installed (see the README.SSL file found in the libwww-perl distribution
for more details). If no SSL interface is installed for LWP to use, then
you will get "501 Protocol scheme 'https' is not supported" errors when
accessing such URLs.

Here's an example of fetching and printing a WWW page using SSL:

You should be able to take it from there....

HTH

Simon.



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

Date: Wed, 02 Jul 2003 08:15:48 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Help with https and Paypal;
Message-Id: <mbudash-3B0496.01154702072003@typhoon.sonic.net>

In article <3F029001.7030703@bbsrc.ac.uk>,
 Simon Andrews <simon.andrews@bbsrc.ac.uk> wrote:

> Boris wrote:
> > I am trying to write a Perl subroutine to access Paypal's website, to
> > checkout my shopping cart.  When running on my PC, my PERL complains:
> > 
> >  Failed: Protocol scheme 'https' is not supported501 Protocol scheme
> > 'https' is not supported
> 
> from perldoc lwpcook:
> 
> HTTPS
> 
> URLs with https scheme are accessed in exactly the same way as with http
> scheme, provided that an SSL interface module for LWP has been properly
> installed (see the README.SSL file found in the libwww-perl distribution
> for more details). If no SSL interface is installed for LWP to use, then
> you will get "501 Protocol scheme 'https' is not supported" errors when
> accessing such URLs.
> 
> Here's an example of fetching and printing a WWW page using SSL:
> 
> You should be able to take it from there....
> 
> HTH
> 
> Simon.
> 

and here's the README.SSL:

SSL SUPPORT
-----------

The libwww-perl package has support for using SSL/TLSv1 with its HTTP
client and server classes. This support makes it possible to access
https schemed URLs with LWP. Because of the problematic status of
encryption software in general and certain encryption algorithms in
particular, in several countries, libwww-perl package doesn't include
SSL functionality out-of-the-box.

Encryption support is obtained through the use of Crypt::SSLeay or
IO::Socket::SSL, which can both be found from CPAN. At present, the
easiest and recommended module to use is Crypt::SSLeay. Crypt::SSLeay
provides "plug-and-play" SSL support for LWP while IO::Socket::SSL
requires patching LWP. In addition to bringing SSL support to the LWP
package, IO::Socket::SSL can be used as an object oriented interface
to SSL encrypted network sockets.

There is yet another SSL interface for perl called Net::SSLeay. It has
a more complete SSL interface and can be used for web client
programming among other things but doesn't directly support LWP.

The underlying SSL support in all of these modules is based on OpenSSL
<http://www.openssl.org/> (formerly SSLeay). For WWW-server side SSL
support (e.g. CGI/FCGI scripts) in Apache see <http://www.modssl.org/>.


-- 
Michael Budash


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

Date: Wed, 02 Jul 2003 09:32:28 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: How would you mail yourself from XP
Message-Id: <3f02a5ec.778542609@news.cis.dfn.de>

On Tue, 1 Jul 2003 19:36:04 -0500, "William Alexander Segraves"
<wsegrave@mindspring.com> wrote:

>> I wouldn't use an external 'mail' program.
>
>Note to OP: Use Mime::Lite, as suggested by Mr. Briem. 
>You will no doubt find it to be an expedient and pleasing 
>solution.

Note to OP:  I suggested MIME::Lite, not Mime::Lite.

Case matters, Bill.  ;-)

MIME is an acronym for "Multipurpose Internet Mail 
Extension", and so should be spelled in all caps, unlike 
Perl, which isn't an acronym for anything, although 
some have been grafted on later.


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

Date: Wed, 2 Jul 2003 17:36:42 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: include ASP scripts in PERL
Message-Id: <bdtqua$10e9ig$1@ID-172104.news.dfncis.de>


"wimf" <wimf@gmx.de> wrote in message
news:dcd2e192.0307010249.4747ccf7@posting.google.com...
> hello everybody,
>
> I want to include a ASP script in my PERL scripts (about 15 scripts).
>
> Is it possible to execute ASP scripts within PERL?
> If yes how?

http://www.apache-asp.org/




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

Date: Tue, 1 Jul 2003 22:32:13 -0700
From: "Islaw" <islaw@adexec.com>
Subject: Re: newbie needs to globally edit his site
Message-Id: <bdtqov$10nabd$1@ID-196529.news.dfncis.de>

Tad McClellan wrote:
> leegold <leegold@mailandnews.com> wrote:
>
>> But I really don't know the basics of
>> running a PERL script on a host.
>
>
> You know how to run, but you don't know how to walk?
>
> That's backwards. You should learn the command line _first_
> and CGI second...

Well, it _is_ possible to practice via a web browser (especially wen using a
local webserver.) Though it's always good to know atleast the basics of the
cmdline part. (Like for compiling/debugging.)

> The name of the language is Perl, not PERL.

True, absolutely. But...
Not to try to start a fight, by why is this always so nicked picked to
death? Never saw a problem with people saying java/JAVA/Java, nor c++, C++
or CPP/cpp/Cpp. Yes, Perl is the proper name. No arguement 'bout that. I
guess all I'm saying is that it wont really hurt anyone for miscasing it
(unless, of course, you type PERL in attempt to invoke Perl itself. ;p )

>> Could someone link
>> me to some real basic intro sites that might apply?
>
>
> No, because it depends on what kind of access your particular
> host makes available.
>
> Ask them how you can get access to a command line on their machine.

Sadly, it's possible he just may not have any shell access. I used to have a
server with Verio adn they don't have any telnet or ssh. Just ftp. (wrote my
own web interface in Perl for issuing shell commands ;p )

--
Islaw




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

Date: Wed, 02 Jul 2003 07:01:44 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: newbie needs to globally edit his site
Message-Id: <dd05gvo8ks5c60ekg5apetrh0dgpa43nif@4ax.com>

leegold wrote:

>I have 25 web pages w/much text and content. I realize now that
>all the pages need the same correction/edit,  a name that was not
>capitalized has to changed to a cap.
>
>The regex ect...is not hard. And I'm sure I can figure out
>how to step though each file search for the word then
>apply a correction. But I really don't know the basics of
>running a PERL script on a host.

What can I say... This really isn't something you should be doing
through a CGI script. (The permissions won't let your script modify the
other files.)  So, essentially, you need shell access, either through
telnet or through ssh.

From the command line, the easiest, least hassle way to run a perl
script is through

	perl yourscript.pl ARGUMENTS

where yourscript.pl is the script file (full path if not in current
directory), and ARGUMENTS is whatever command line parameters you want
to pass it. See the docs under "perlrun" to see an intro.

The other main way (on Unix) is to use

	yourscript.pl ARGUMENTS

which will behave exactly the same way, but which needs some more
details for you to get right first:

 1) The shebang line, = the very first line from the script which starts
with "#!", must contain the real full path to your perl executable,
incl. filename

 2) The file permissions must be set to both "-r" (readable) and "-x"
(executable) for the person or group you want to run the script as.

-- 
	Bart.


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

Date: Wed, 02 Jul 2003 10:38:09 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: newbie needs to globally edit his site
Message-Id: <bdu5k7$10f14s$1@ID-184292.news.dfncis.de>

Bart Lateur wrote:
> leegold wrote:
>> I have 25 web pages w/much text and content. I realize now that 
>> all the pages need the same correction/edit,  a name that was not
>> capitalized has to changed to a cap.
>> 
>> The regex ect...is not hard. And I'm sure I can figure out how to
>> step though each file search for the word then apply a
>> correction. But I really don't know the basics of running a PERL
>> script on a host.
> 
> What can I say... This really isn't something you should be doing 
> through a CGI script. (The permissions won't let your script modify
> the other files.)

Two objections to that:

1) Islaw pointed out that it's possible that OP doesn't have shell
access. Assuming that he is on a shared server, I'd say that that's
_likely_ the case.

2) If it is a typical, modern hosting account, it's _likely_ that the
script does have permissions to edit files, since CGI scripts often
run as the same user as the account holder (via suEXEC, cgiwrap or
something like that). Or it can be a Windows box...

I questioned the sense in editing the files on the remote server, but
for another reason. :)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Wed, 02 Jul 2003 07:34:28 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Problem with tk and displaying on the screen
Message-Id: <3f028a5e.890505805@news.erols.com>

"Brian Helterline" <brian_helterline@hp.com> wrote:

: "derek / nul" <abuse@sgrail.org> wrote in message
: news:q2g3gvka9ougjqmk7ejjhvga0n8b7hhbmj@4ax.com...
: > good call and thank you.
: >
: > The use tk; was wrong
: 
: This is a nasty little feature of Windows (or any case-insensitive OS)
: When it looks for the file to 'use', it succeeds since the OS is doing
: the searching in a case-insensitive manner.  When perl looks for the
: functions
: that were imported, it does it itself in a case-sensitive manner and fails!
: 
: Anyone know of a way to fix this?

How could it be?  A module's filename is not required to have anything
to do with the package names used in that module.



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

Date: Wed, 02 Jul 2003 09:25:07 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Problem with tk and displaying on the screen
Message-Id: <3f02a4de.778272031@news.cis.dfn.de>

On Tue, 1 Jul 2003 14:06:03 -0700, "Brian Helterline"
<brian_helterline@hp.com> wrote:

>> The use tk; was wrong
>
>This is a nasty little feature of Windows (or any case-insensitive OS)
>When it looks for the file to 'use', it succeeds since the OS is doing
>the searching in a case-insensitive manner.  When perl looks for the
>functions that were imported, it does it itself in a case-sensitive 
>manner and fails!
>
>Anyone know of a way to fix this?

Learn to spell properly.


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

Date: Wed, 02 Jul 2003 04:33:24 GMT
From: "Kenneth Baltrinic" <kenneth@baltrinic.com>
Subject: Regular Expression Problem
Message-Id: <ogtMa.8784$Hw.6276188@news2.news.adelphia.net>

I am trying to parse a relatively simple SQL query with a regular
expression. All is going well except for one issue I don't seem to be able
to find a solution for. Handling optional parentheses and brackets. This
seems like a back reference problem to me but I am not sure. Let me give a
simple example.

An table name might be enclosed in brackets or it might not. For the sake of
simplification, lets assume that the pattern [A-Za-z_]+ is what we are
looking for in a table name. A really simple solution to find table names
that are bracket enclosed or not would as follows:

/(\[[A-Za-z_]+\])|([A-Za-z_]+)/

The problem is that the pattern for a table name is not in reality as simple
as [A-Za-z_]+ .  In fact it is quite long, and repeating it twice in the
expression seems inefficient not to mention prone to bugs if I need to tweak
it and don't get each side exactly the same. What I want to do is something
like the following:

/(\[?)[A-Za-z_]+\1/

This almost works except of course that my backreference is looking for an
opening bracket [ when I need it to be looking for a closing bracket ].  So
here it the crux of my question.  Is there any way to do something like
this--to have a backreference that does some sort of fuzzy match? I have a
similar issues with parentheses.

Thanks for the help,
Ken Baltrinic




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

Date: 2 Jul 2003 04:58:51 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Regular Expression Problem
Message-Id: <slrnbg4pkb.qn1.sholden@flexal.cs.usyd.edu.au>

On Wed, 02 Jul 2003 04:33:24 GMT,
	Kenneth Baltrinic <kenneth@baltrinic.com> wrote:
> I am trying to parse a relatively simple SQL query with a regular
> expression. All is going well except for one issue I don't seem to be able
> to find a solution for. Handling optional parentheses and brackets. This
> seems like a back reference problem to me but I am not sure. Let me give a
> simple example.
> 
> An table name might be enclosed in brackets or it might not. For the sake of
> simplification, lets assume that the pattern [A-Za-z_]+ is what we are
> looking for in a table name. A really simple solution to find table names
> that are bracket enclosed or not would as follows:
> 
> /(\[[A-Za-z_]+\])|([A-Za-z_]+)/
> 
> The problem is that the pattern for a table name is not in reality as simple
> as [A-Za-z_]+ .  In fact it is quite long, and repeating it twice in the
> expression seems inefficient not to mention prone to bugs if I need to tweak
> it and don't get each side exactly the same. What I want to do is something
> like the following:

Why not something like:

(\[$table_name_pattern])|($table_name_pattern)

Of course if nested parentheses are needed things get more complicated, and
moving to a non-regex solution is often easier. Something like 
Parse::RecDescent, for example.

> 
> /(\[?)[A-Za-z_]+\1/
> 
> This almost works except of course that my backreference is looking for an
> opening bracket [ when I need it to be looking for a closing bracket ].  So
> here it the crux of my question.  Is there any way to do something like
> this--to have a backreference that does some sort of fuzzy match? I have a
> similar issues with parentheses.

Can't help with that, sorry...

-- 
Sam Holden



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

Date: Wed, 02 Jul 2003 05:27:30 GMT
From: "Chauncey Williams" <fran_cw@hotmail.com>
Subject: Re: Regular Expression Problem
Message-Id: <63uMa.30740$8B.10156@twister.nyroc.rr.com>

> What I want to do is something like the following:
>
> /(\[?)[A-Za-z_]+\1/
>
> This almost works except of course that my backreference is looking
> for an opening bracket [ when I need it to be looking for a closing
> bracket ].  So here it the crux of my question.  Is there any way to
> do something like this--to have a backreference that does some sort
> of fuzzy match? I have a similar issues with parentheses.
>
> Thanks for the help,
> Ken Baltrinic

Maybe a (?<= [ )] positive lookbehind is what you are looking for...

I'm pretty new to this though, and if what you are showing is just a small
part of the regex, it may not work.

XC




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

Date: Wed, 02 Jul 2003 08:02:19 GMT
From: Owen <Not_Me@pcug.org.au>
Subject: Re: SHIFT not shuffling ?
Message-Id: <20030702180322.75338702.Not_Me@pcug.org.au>

On 30 Jun 2003 18:09:40 GMT
"A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote:

> my @a = qw(one two three four five six);
> 
> while(my $a = shift @a) {
> 	print "$a\n" ;
> }

Is there some subtle reason for the "my" in the while loop?

Owen
-- 


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

Date: 2 Jul 2003 08:12:01 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: SHIFT not shuffling ?
Message-Id: <slrnbg54uh.6ro.sholden@flexal.cs.usyd.edu.au>

On Wed, 02 Jul 2003 08:02:19 GMT, Owen <Not_Me@pcug.org.au> wrote:
> On 30 Jun 2003 18:09:40 GMT
> "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote:
> 
>> my @a = qw(one two three four five six);
>> 
>> while(my $a = shift @a) {
>> 	print "$a\n" ;
>> }
> 
> Is there some subtle reason for the "my" in the while loop?

To limit the scope of the variable. 

Not that I'd use $a or $b (even my'd versions of them) in anything
but a sort comparison function, but that's a different matter...

-- 
Sam Holden



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

Date: Wed, 02 Jul 2003 05:00:55 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: XS question -- avoid memory leak
Message-Id: <Xns93AC3D2FBFA11sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

I've used XS for a few small projects over the years, so I'm familiar with 
it but by no means am an expert.  The current situation I find myself in is 
as follows.

My routine needs to return a string whose length is arbitrarily variable 
based on its input parameters.  What I plan to do is to decide how big the 
output string will be, malloc it, and return a char * pointer to it.  But 
this sounds suspiciously like a memory leak, since my code will not ever 
get the chance to free() it.

Will perl automatically free the memory pointed to by an SV created by the 
XS layer as it converts a char* pointer?  I don't see how it could -- how 
could it know that it was created with malloc, or that nothing else points 
to it?  How can I solve this problem?

TIA
- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPwKtU2PeouIeTNHoEQLgVACfXzWZfellY9z7Hz68dhW3CyTD3lEAn3ES
mhLUeoyYdczGzbnPeBFdvmPo
=Nvl9
-----END PGP SIGNATURE-----


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

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


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