[19644] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1839 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 28 18:10:34 2001

Date: Fri, 28 Sep 2001 15:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001715016-v10-i1839@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 28 Sep 2001     Volume: 10 Number: 1839

Today's topics:
        pattern matching starting at end of string (jchiller)
    Re: pattern matching starting at end of string <ilya@martynov.org>
    Re: pattern matching starting at end of string <ren@tivoli.com>
        Perl 5.6.1 / IBM C compiler failure on pp_sys.c <acewood@texas.net>
        Perl Inside Shell Script <Brian.Murphy@swpc.siemens.com>
    Re: Perl Inside Shell Script <jurgenex@hotmail.com>
        Problem executing pgp.exe with systemfunction <alastairm_news@cogapp.com>
        Problems with & <nomail@please.com>
    Re: Problems with & (Eric Bohlman)
        script timing out <zkent@adelphia.net>
    Re: script timing out (Logan Shaw)
    Re: script timing out <zkent@adelphia.net>
    Re: sizeof.ph <nobody@example.com>
    Re: Sourcing Things in Perl ? (Tim Hammerquist)
        spawn program <ericm@iol.ie>
    Re: spawn program (John J. Trammell)
    Re: spawn program <darkon@one.net>
        Strange results... (was: my $cat) <weiss@kung.foo.at>
        treating metacharacters as regular characters. <witkowsk@pop900.gsfc.nasa.gov>
    Re: treating metacharacters as regular characters. (Logan Shaw)
    Re: treating metacharacters as regular characters. <darkon@one.net>
    Re: Trying to send SMS in perl <scott.bell1@ntlworld.com>
    Re: Uninitialized Value... (rab)
    Re: Uninitialized Value... <mjcarman@home.com>
    Re: Unusual error message... (Charles DeRykus)
        use Module vs. use module <brian_helterline@hotmail.com>
    Re: use Module vs. use module <mjcarman@home.com>
    Re: use statement runs package's subs before they are c (Laith Suheimat)
        Where can I get a Perl Script (GetWebWise)
    Re: Where can I get a Perl Script <nothing@nowhere.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 28 Sep 2001 08:48:27 -0700
From: jasonchiller@yahoo.com (jchiller)
Subject: pattern matching starting at end of string
Message-Id: <de79b689.0109280748.aa4d2a@posting.google.com>

All,

I need to search for a pattern in a string but instead of starting the
search at the beginning of the string I need it to start at the end. 
So if I had the string "myscriptmycode" and I wanted to search for the
pattern "my" I need it to find the second "my" in the string.  How can
I do this?  Can this be done through pattern matching or is there a
better way?  Any suggestions would be appreciated.  Thanks.


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

Date: 28 Sep 2001 20:10:56 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: pattern matching starting at end of string
Message-Id: <87k7yji9db.fsf@abra.ru>

>>>>> On 28 Sep 2001 08:48:27 -0700, jasonchiller@yahoo.com (jchiller) said:

j> All,
j> I need to search for a pattern in a string but instead of starting the
j> search at the beginning of the string I need it to start at the end. 
j> So if I had the string "myscriptmycode" and I wanted to search for the
j> pattern "my" I need it to find the second "my" in the string.  How can
j> I do this?  Can this be done through pattern matching or is there a
j> better way?  Any suggestions would be appreciated.  Thanks.

With regexps:

1. Use /.*my/

   .* will eat as much as possible chars this pattern will match last
   'my' string.

2. Intersting technique: reverse string and use reversed pattern
   (/ym/).

Using rindex:

1. rindex $str, 'my';

What should you use? It depends on what are you going to do with this
string.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: 28 Sep 2001 11:03:28 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: pattern matching starting at end of string
Message-Id: <m3zo7fe20f.fsf@dhcp9-161.support.tivoli.com>

On 28 Sep 2001, jasonchiller@yahoo.com wrote:

> I need to search for a pattern in a string but instead of starting
> the search at the beginning of the string I need it to start at the
> end.  So if I had the string "myscriptmycode" and I wanted to search
> for the pattern "my" I need it to find the second "my" in the
> string.  How can I do this?  Can this be done through pattern
> matching or is there a better way?  Any suggestions would be
> appreciated.  Thanks.

Two common ways are:

# allow a leading ".*" to gobble up the whole string so that the
# back-tracking can effectively perform a reverse search
$_ = "myscriptmycode";
/.*(my.*)/ and print "$1\n";

# reverse the string and the pattern
$_ = "myscriptmycode";
$_ = reverse;
/(.*?ym)/ and print scalar reverse($1), "\n";

Which one is better depends on the details.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 28 Sep 2001 18:45:16 GMT
From: Mike Wood <acewood@texas.net>
Subject: Perl 5.6.1 / IBM C compiler failure on pp_sys.c
Message-Id: <3BB4C4B6.25E0A8F8@texas.net>

Hello,

I'm fairly new to compiling software, and have run across a stumper (at
least for me).  I'm using the IBM C compiler v5.0.2, and I am trying to
compile the stable Perl 5.6.1.  sh Configure -de runs OK, but make fails
on pp_sys.c with the following:
-
    `sh  cflags libperl.a pp_sys.o`  pp_sys.c
          CCCMD =  cc -DPERL_CORE -c -D_ALL_SOURCE -D_ANSI_C_SOURCE
-D_POSIX_SOURCE -qmaxmem=16384 -q32 -D_LARGE_FILES -qlonglong -O
"pp_sys.c", line 4356.14: 1506-068 (W) Operation between types "struct
hostent*" and "int" is not allowed.
"pp_sys.c", line 4367.14: 1506-068 (W) Operation between types "struct
hostent*" and "int" is not allowed.
"pp_sys.c", line 4374.14: 1506-068 (W) Operation between types "struct
hostent*" and "int" is not allowed.
"pp_sys.c", line 4388.21: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4389.35: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4389.49: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4392.37: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4399.29: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4401.21: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4407.26: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4409.15: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4418.13: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4419.27: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4463.14: 1506-068 (W) Operation between types "struct
netent*" and "int" is not allowed.
"pp_sys.c", line 4471.14: 1506-068 (W) Operation between types "struct
netent*" and "int" is not allowed.
"pp_sys.c", line 4478.14: 1506-068 (W) Operation between types "struct
netent*" and "int" is not allowed.
"pp_sys.c", line 4488.34: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4490.30: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4497.22: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4499.21: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4505.26: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4507.26: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4551.14: 1506-068 (W) Operation between types "struct
protoent*" and "int" is not allowed.
"pp_sys.c", line 4557.14: 1506-068 (W) Operation between types "struct
protoent*" and "int" is not allowed.
"pp_sys.c", line 4563.14: 1506-068 (W) Operation between types "struct
protoent*" and "int" is not allowed.
"pp_sys.c", line 4573.34: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4575.30: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4582.22: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4584.21: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4590.26: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4640.14: 1506-068 (W) Operation between types "struct
servent*" and "int" is not allowed.
"pp_sys.c", line 4653.14: 1506-068 (W) Operation between types "struct
servent*" and "int" is not allowed.
"pp_sys.c", line 4660.14: 1506-068 (W) Operation between types "struct
servent*" and "int" is not allowed.
"pp_sys.c", line 4673.35: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4677.30: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4684.22: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4686.21: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4695.27: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
"pp_sys.c", line 4698.22: 1506-285 (S) The indirection operator cannot
be applied to a pointer to an incomplete struct or union.
make: 1254-004 The error code from the last command is 1.


Stop.
-
This is AIX 4.3.3 ML8 on a 7044-170.  I've tried both cc and xlc, and
have changed none of the defaults.
-
####->> lslpp -l|grep vac
  vac.C                      5.0.2.0  COMMITTED  C for AIX Compiler
  vac.C.readme.ibm           5.0.2.0  COMMITTED  C for AIX iFOR/LS
Information
  vac.html.DBCS.search       5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.Ja_JP.C           5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.Ja_JP.search      5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.SBCS.search       5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.common.search     5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.en_US.C           5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.en_US.search      5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.zh_CN.C           5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.zh_CN.search      5.0.2.0  COMMITTED  C for AIX Compiler
  vac.msg.en_US.C            5.0.2.0  COMMITTED  C for AIX Compiler
Messages -
  vac.pdf.en_US.C            5.0.2.0  COMMITTED  C for AIX Documentation

  vacpp.cmp.rte              5.0.2.0  COMMITTED  VisualAge C++ Compiler
  vac.C                      5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.DBCS.search       5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.Ja_JP.search      5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.SBCS.search       5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.en_US.search      5.0.2.0  COMMITTED  C for AIX Compiler
  vac.html.zh_CN.search      5.0.2.0  COMMITTED  C for AIX Compiler

Any ideas or help would be greatly appreciated!
Mike Wood
Sr. Network Engineer
University Hospital
San Antonio, TX
-
acewood@texas.net



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

Date: Fri, 28 Sep 2001 14:50:17 -0400
From: Brian Murphy <Brian.Murphy@swpc.siemens.com>
Subject: Perl Inside Shell Script
Message-Id: <3BB4C669.8A177716@swpc.siemens.com>

How do you extract particular parts of a string?  Say I have a variable called ARGS in my ksh script.  $ARGS is a string containing "job=mike analysis cpus=4 (or any number) .... "  I want to look for
the occurrance of cpus=# and return either just the number or the entire string "cpus=#"  $ARGS can have any length and may or may not contain cpus=#.  I just need to check it and if it is there
return it (and not a 1 or 0.)  I have tried referencing O'reilly's Programming Perl and SUN's Perl Programming Student Guide to no avail.  I am running perl 5.6 in Solaris 8.




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

Date: Fri, 28 Sep 2001 12:18:17 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl Inside Shell Script
Message-Id: <3bb4ccf9$1@news.microsoft.com>

"Brian Murphy" <Brian.Murphy@swpc.siemens.com> wrote in message
news:3BB4C669.8A177716@swpc.siemens.com...
> How do you extract particular parts of a string?  Say I have a variable
called ARGS in my ksh script.  $ARGS is a string containing "job=mike
analysis cpus=4 (or any number) .... "  I want to look for
> the occurrance of cpus=# and return either just the number or the entire
string "cpus=#"  $ARGS can have any length and may or may not contain
cpus=#.  I just need to check it and if it is there
> return it (and not a 1 or 0.)  I have tried referencing O'reilly's
Programming Perl and SUN's Perl Programming Student Guide to no avail.  I am
running perl 5.6 in Solaris 8.

$env{ARGS}="job=mike analysis cpus=123"; #normally set outside of the script

if ($env{ARGS} =~/cpus=(\d+)/) {
    print "The number of cpus is 'cpus=$1'";
    } else {
    print "There is no 'cpus=' in \$ARGS\n";
    }




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

Date: Fri, 28 Sep 2001 18:15:40 +0100
From: "Alastair Martindale" <alastairm_news@cogapp.com>
Subject: Problem executing pgp.exe with systemfunction
Message-Id: <L92t7.27189$uM2.3795019@monolith.news.easynet.net>

Hi
I am new to Perl and I am having a problem executing an external program
using the system function.
This is the code I am using. It is part of a .pl script running on an IIS
web server.

    $PGP_TEMPFILE="c:/pscripts/temp/pgpbody.$$";
    $pgpprog = 'c:/Progra~1/Networ~1/PGPcmdln/pgp.exe';

 ...more code here...

    $PGP_TEMPFILE =~ s/\//\\/g;    # replaces forward slash with back slash
for windows file path
    $pgpprog =~ s/\//\\/g;                  # replaces forward slash with
back slash for windows file path
    $PGP_ARGS = " -e";
    $PGP_ARGS .= " -a";
    $PGP_ARGS .= " $PGP_TEMPFILE";
    $PGP_ARGS .= " \"$Config{'pgpuserid'}\"";
    print "command =  $pgpprog $PGP_ARGS";
    print "<BR>result=";
    print system "$pgpprog $PGP_ARGS";

The output is
c:\Progra~1\Networ~1\PGPcmdln\pgp.exe -e -a c:\pscripts\temp\pgpbody.724
"pgptest@cogapp.com"
res=5376

I think result=5376 means that pgp.exe has executed but returned an error of
21. When I run the same command in the DOS prompt the program executes
without problem.

Is there something obvious I have overlooked?
Have I put the arguments together wrong for the system function?
Might there be a permissions problem running the script from IIS?

Thanks in advance
Alastair

PS I tried using
system "$pgpprog $PGP_ARGS" = 0 or die "Error: $?";
but got no output at all. Where do you read the standard error output? How
can you change it so that it is 'printed' to the standard output?
Thanks again.



--
====================
Alastair Martindale
Cognitive Applications
Lees House  21 Dyke Road
Brighton  BN1 3GD  England
tel  +44 (0)1273 821600
fax +44 (0)1273 728866
alastairm_news@cogapp.com
====================




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

Date: Fri, 28 Sep 2001 14:21:09 -0400
From: "Victor Menendez" <nomail@please.com>
Subject: Problems with &
Message-Id: <H53t7.25614$2H2.2038409@e3500-atl1.usenetserver.com>

Converting some data to a well-formed xml doc I encountered a problem with
an entry in a field "L&E310"  where in XML starting with & returns special
symbols. Now using the &amp; in HTML will return the "&" however it would
cut the statement short in PERL. Using the character reference &#nnn would
do the same in PERL.

Does anyone know how I can write back the & to the xml document  using PERL.

Thanks





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

Date: 28 Sep 2001 21:45:23 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Problems with &
Message-Id: <9p2r1j$9a4$1@bob.news.rcn.net>

Victor Menendez <nomail@please.com> wrote:
> Converting some data to a well-formed xml doc I encountered a problem with
> an entry in a field "L&E310"  where in XML starting with & returns special
> symbols. Now using the &amp; in HTML will return the "&" however it would
> cut the statement short in PERL. Using the character reference &#nnn would
> do the same in PERL.

> Does anyone know how I can write back the & to the xml document  using PERL.

I have no idea what you mean by "cut the statement short."  As long as the 
value you're trying to write out doesn't already contain any XML entities, 
a simple

s/&/&amp;/g;

will fix everything.

You might want to consider using XML::Writer, XML::Generator, or something 
similar instead of manually generating XML output.  They all take care of 
the escaping issues for you.



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

Date: Fri, 28 Sep 2001 17:40:54 GMT
From: "Zachary Kent" <zkent@adelphia.net>
Subject: script timing out
Message-Id: <GC2t7.2978$4Y1.2267074@news1.news.adelphia.net>

Greetings,

I have a client whose server times out scripts after 10 seconds.  How can I
keep override the servers timeout settings using Perl?  If this is a module
question or I need to ask this somewheres else?

TIA,
Zach




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

Date: 28 Sep 2001 15:11:26 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: script timing out
Message-Id: <9p2lhe$3j8$1@charity.cs.utexas.edu>

In article <GC2t7.2978$4Y1.2267074@news1.news.adelphia.net>,
Zachary Kent <zkent@adelphia.net> wrote:
>I have a client whose server times out scripts after 10 seconds.

When you say "client", do you mean a person or a program in a client
server arrangement?

When you say "server", what kind of server do you mean?  A web server?
A database server?  A file server?

> How can I
>keep override the servers timeout settings using Perl?

You probably can't, but then again maybe you can, because it all
depends on what you're talking about.

  - Logan
-- 
"Everybody
 Loves to see              
 Justice done
 On somebody else"     ( Bruce Cockburn, "Justice", 1981 )


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

Date: Fri, 28 Sep 2001 21:19:40 GMT
From: "Zachary Kent" <zkent@adelphia.net>
Subject: Re: script timing out
Message-Id: <MP5t7.15$8R.12489@news1.news.adelphia.net>

"Logan Shaw" <logan@cs.utexas.edu> wrote in message
news:9p2lhe$3j8$1@charity.cs.utexas.edu...
> In article <GC2t7.2978$4Y1.2267074@news1.news.adelphia.net>,
> Zachary Kent <zkent@adelphia.net> wrote:
> >I have a client whose server times out scripts after 10 seconds.
>
> When you say "client", do you mean a person or a program in a client
> server arrangement?

Sorry, the client is a person.

> When you say "server", what kind of server do you mean?  A web server?
> A database server?  A file server?

Sorry again.  The server is a Win2K web hosting server (with a 10 second
timeout for perl scripts).  I have never heard of such a thing, but....

> > How can I
> >keep override the servers timeout settings using Perl?
>
> You probably can't, but then again maybe you can, because it all
> depends on what you're talking about.

Well, I didn't think so. But, I am looking at using autoflush to send an
immediate response to the browser so that the server does not kill the
script before the script begins the output.  Think that would help?

Thanks,
Zach




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

Date: Fri, 28 Sep 2001 17:05:24 +0100
From: "Dan Moinescu" <nobody@example.com>
Subject: Re: sizeof.ph
Message-Id: <9p270b$t94$1@kermit.esat.net>

"Ilya Martynov" <ilya@martynov.org> wrote in message
news:87n13fjsix.fsf@abra.ru...
> >>>>> On Fri, 28 Sep 2001 12:37:50 +0100, "Dan Moinescu"
<nobody@example.com> said:
>
> DM> Hello everybody,
> DM> I need to "require sizeof.ph" in order to to use the setitimer
syscall, but
> DM> the file is missing. I've run h2ph, but I still can't find it
anywhere. Can
> DM> anyone tell me how I can generate it, please?
>
> Does your system have sizeof.h installed? h2ph can generate .ph files
> only from installed header files.
>
> DM> I'm using Perl 5.005_03 on RedHat Linux 6.2.
>
> BTW Are you sure that you are looking for correct file? I could not
> find any RPM packages which contain sizeof.h (I searched with RPM find
> on www.redhat.com).
>

No, I didn't find any sizeof.h either.
I came to look for sizeof.ph because 'man perlfaq8' pointed me to a link
(http://www.perl.com/CPAN-local/doc/misc/ancient/tutorial/eg/itimers.pl)
which contains an example of what I want. That example requires sizeof.ph.
With a search on Google I found some instances of that file

http://cvs.macperl.org/cgi-bin/viewcvs.cgi/macperl/perl/h2pl/eg/sizeof.ph?so
rtby=date); it contains a hash with the sizeof's of C types. However, the
script that's supposed to generate it (getioctlsize) doesn't do anything on
my machine.

> And mine Debian system which has most standart header files installed
> also doesn't have this file.
>
> --
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)
|
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6
|
> | AGAVA Software Company (http://www.agava.com/)
|
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




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

Date: Fri, 28 Sep 2001 21:47:07 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Sourcing Things in Perl ?
Message-Id: <slrn9r9snl.87t.tim@vegeta.ath.cx>

Me parece que Tony Curtis <tony_curtis32@yahoo.com> dijo:
> >> On Fri, 28 Sep 2001 01:50:30 GMT,
> >> tim@vegeta.ath.cx (Tim Hammerquist) said:
> 
> > Me parece que Tony Curtis <tony_curtis32@yahoo.com>
> > dijo:
> >> 
> >> system() invokes the Bourne shell (/bin/sh).
> >> 
> >> Using "." instead of "source" would probably make more
> >> sense (bash is not masquerading as sh everywhere, nor
> >> is one's login shell involved).
> 
> > btw, how would /bin/sh handle all the setenv's in a csh
> > script?
> 
> It wouldn't.  At least, not directly.  You could use
> system() to invoke csh and call the C-shell script though.

I guess my sarcasm wasn't thick enough.  I only meant to implant the
thought that, even if you use the sh equiv of csh's 'source' (ie, '.'),
it wouldn't understand the csh-specific commands.

> Of course, as we all know, only nuts write C-shell
> scripts (google: csh why not christiansen) :-)

Nice. =)  I'm a Bourne Again Shell man, meself.  Only messed with tcsh
briefly (my remote shell account only had that and zsh; I messed with
both).

bash++

-- 
M-x induce-carpal-tunnel-syndrome
    -- Greg Bacon


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

Date: Fri, 28 Sep 2001 15:18:55 GMT
From: "Eric Mosley" <ericm@iol.ie>
Subject: spawn program
Message-Id: <zx0t7.1968$j22.7076@news.iol.ie>

Hi,

I want to execute a program from within a perl script - but the program I
execute doesn't ever exit. So, I need the perl program to go on with its
work!

If I do backticks that will "wait" until the spawned process completes - its
the same with system - they all wait for your program to exit.

How can I execute a program and let the perl script continue...

???

Eric




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

Date: Fri, 28 Sep 2001 10:45:14 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: spawn program
Message-Id: <slrn9r96o9.6da.trammell@haqq.hypersloth.net>

On Fri, 28 Sep 2001 15:18:55 GMT, Eric Mosley <ericm@iol.ie> wrote:
> Hi,
> 
> I want to execute a program from within a perl script - but the program I
> execute doesn't ever exit. So, I need the perl program to go on with its
> work!

See Perl FAQ 8, "How do I start a process in the background?".

-- 
[M]en become civilized, not in proportion to their willingness to believe,
but in proportion to their willingness to doubt.            - H.L. Mencken


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

Date: Fri, 28 Sep 2001 16:01:40 -0000
From: David Wall <darkon@one.net>
Subject: Re: spawn program
Message-Id: <Xns912A7A3E671B0darkononenet@207.126.101.97>

trammell@haqq.hypersloth.invalid (John J. Trammell) wrote on 28 Sep 2001:

> On Fri, 28 Sep 2001 15:18:55 GMT, Eric Mosley <ericm@iol.ie> wrote:
>> Hi,
>> 
>> I want to execute a program from within a perl script - but the
>> program I execute doesn't ever exit. So, I need the perl program to go
>> on with its work! 
> 
> See Perl FAQ 8, "How do I start a process in the background?".

It looks like he's using Windows.  There were a couple of posts yesterday 
about this:

http://groups.google.com/groups?hl=en&th=9eded21a18abd68e&seekm=9p0c6l%24d9
%241%40usenet.otenet.gr&frame=off


-- 
David Wall
darkon@one.net


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

Date: Fri, 28 Sep 2001 22:44:10 +0200
From: "Stefan Weiss" <weiss@kung.foo.at>
Subject: Strange results... (was: my $cat)
Message-Id: <1001710128.741845@newsmaster-04.atnet.at>

"Leopold Toetsch" <lt@toetsch.at> wrote:

> After some reformatting and adding the shebang line, it seems to
> be running on my system printing one line looking like 'JAPH';-)
>
> #!/usr/bin/perl -l                         # -lt <lt@toetsch.at>
> $A.=chr&G;&A;map{$;=&G;$:=$A;while(/.*$:./){$F=1/3;$C{_D__B}=1-@
> A;$,.=chr&F+$;;$;+=E()if&B}$,.=' 'if!&B-$C}<_>;sub G{65}$D.='n';
> $_=$,;sub B{$:++eq$A}$F=$D;sub D{open _,$0}s;A;a;;$C='t';$F.=$F{
> B}=$C;sub E{32}sub A{$D='ri';&D}eval"p$F";sub F{$F*length$&}#-lt


Interesting idea.
Took me (and perltidy) a little to figure it out.


While I was playing around with your sig, I accidentally cut&pasted
pasted a piece of code to the wrong place, but only noticed the
mistake when I got completely scrambled output. It was mostly high
ASCII characters, with the string "...@ROGRAMFILES = C:\Prog..." in
the middle. After fiddling around a bit more, I found out that I got
various parts of the %ENV hash and some perl internals in the output,
depending on what parameters I used in the script.

Here is a example (piped to 'strings' and slightly edited):

APPDATA
C:\Documents and Settings\prinz\Application Data
ALLUSERSPROFILE
Windows_NT
ALLUSERSPROFILE
C:\Documents and Settings\All Users
ARGV
ARGV
D:\devel\perl\bin\Perl.exe
tests\strange.pl
MSWin32
stderr
STDERR
English_United States.1252
stdout
STDOUT
stdin
IO::Handle
Handle::
IO::
STDIN
BuildNumber
Sleep
CopyFile
GetLongPathName
GetFullPathName
GetShortPathName
GetTickCount
Spawn
FormatMessage
IsWin95
IsWinNT
GetOSVersion
FsType
DomainName
NodeName
LoginName
SetLastError
GetLastError
GetNextAvailDrive
SetCwd
 .\win32.c
_<.\win32.c
_<.\win32.c
GetCwd
Win32
Win32::
Win32::
perllib.c
_<perllib.c
_<perllib.c
boot_DynaLoader
boot_DynaLoader
DynaLoader
DynaLoader::
DynaLoader::
 ..\xsutils.c
_<..\xsutils.c
_<..\xsutils.c
bootstrap
bootstrap
 ....etc....


And here's the script:

,---[ snip ]-------------------------------------------------------

for(1..1000) {
    for $w ('A'..'Z') {
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ" =~ /.*$w./;
        $, .= chr(.45 * length($& + 65));
    }
}

print $,;

`---[ snap ]-------------------------------------------------------


This happened with Activestate Perl 5.6.1, BB 626 under Win2000. The
above script isn't doing anything useful anymore, of course; I was
only trying to see the effect more clearly.

I also tried the script under Linux - the output is similar, but I had
to use different parameters:

,---[ snip ]-------------------------------------------------------

for(1..1000) {
    for $w ('A'..'Z') {
        "ABCDEF" =~ /.*$w./;
        $, .= chr(.1 * length($& + 65));
    }
}

print $,;
`---[ snap ]-------------------------------------------------------

( "This is perl, v5.6.0 built for i386-linux" )



cheers,
stefan


PS: If you want to test this, I suggest redirecting the output
somewhere, or turning your PC beeper off... ;-)







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

Date: Fri, 28 Sep 2001 15:32:17 -0400
From: Mike Witkowski <witkowsk@pop900.gsfc.nasa.gov>
Subject: treating metacharacters as regular characters.
Message-Id: <3BB4D041.EB3EE02F@pop900.gsfc.nasa.gov>

I am having a problem with regular expressions.  I need
to do some matching and replacements similar to those
in the script below.

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

$str1 = "--some reg chars-- [  --some reg chars--";
$str2 = "[";
$str3 = "<--(left square bracket)-->";
$str1 =~ s/$str2/$str3/;
print "$str1\n";
-------

This clearly fails.  I do not know, before hand, what
meta characters, if any, exist in the string I am using
for matching and the string used for replacement.  I
could process this brute force, but there must be a
better way (I hope).

So, my question is this:

Is there a way to tell perl that the variable being
interpolated in a regular expression is to be treated
as a string of ordinary characters (ie treat any
meta characters as regular characters)?

Michael Witkowski
witkowsk@nccs.gsfc.nasa.gov



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

Date: 28 Sep 2001 15:27:28 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: treating metacharacters as regular characters.
Message-Id: <9p2mfg$3m2$1@charity.cs.utexas.edu>

In article <3BB4D041.EB3EE02F@pop900.gsfc.nasa.gov>,
Mike Witkowski  <witkowsk@pop900.gsfc.nasa.gov> wrote:
>Is there a way to tell perl that the variable being
>interpolated in a regular expression is to be treated
>as a string of ordinary characters (ie treat any
>meta characters as regular characters)?

s/// and m// are "quote-like operators".  So you can use \Q and \E in
them to automatically escape regular expression metacharacters.
An example:

	$e = '...'; 

	s/\Q$e\E/ellipsis/;

That will replace only the string "..." with the word "ellipsis".

  - Logan
-- 
"Everybody
 Loves to see              
 Justice done
 On somebody else"     ( Bruce Cockburn, "Justice", 1981 )


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

Date: Fri, 28 Sep 2001 20:38:30 -0000
From: David Wall <darkon@one.net>
Subject: Re: treating metacharacters as regular characters.
Message-Id: <Xns912AA92D7B2DBdarkononenet@207.126.101.97>

Mike Witkowski <witkowsk@pop900.gsfc.nasa.gov> wrote on 28 Sep 2001:

> Is there a way to tell perl that the variable being
> interpolated in a regular expression is to be treated
> as a string of ordinary characters (ie treat any
> meta characters as regular characters)?

Use \Q before the variable in the regex, e.g.;   /\Q$str/

perldoc -q quote

gives you "How can I quote a variable to use in a regex?"

Also see the quotemeta function in perlfunc:

perldoc -f quotemeta

-- 
David Wall
darkon@one.net


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

Date: Fri, 28 Sep 2001 17:41:04 +0100
From: "Scott Bell" <scott.bell1@ntlworld.com>
Subject: Re: Trying to send SMS in perl
Message-Id: <lv1t7.8384$3Q5.1508484@news2-win.server.ntlworld.com>

After a lot of playing about with modules I got it working, I installed the
module by putting the genie.pm file in the lib\net folder. it works great
now :)


--
Scott Bell
Email: scott.bell1@ntlworld.com

The content of this message has been certified 100% correct.

Scott Bell <scott.bell1@ntlworld.com> wrote in message
news:pM_s7.7666$3Q5.1372095@news2-win.server.ntlworld.com...
> I got some code from
> http://search.cpan.org/doc/AWRIGLEY/Net-SMS-Web-0.002/lib/Net/SMS/Genie.pm
> that lets me send SMS using Genie via Perl. This is what I have:
>
>
>
>     my $sms = Net::SMS::Genie->new(
>         autotruncate => 1,
>         username => 'mylogin',
>         password => 'mypassword',
>         recipient => 'mymobile',
>         subject => 'a test',
>         message => 'a test message',
>     );
>
>
>     $sms->verbose( 1 );
>     $sms->message( 'a different message' );
>     print "sending message to mobile number ", $sms->recipient();
>
>
>     $sms->send_sms();
>
> --------------------------------------------------------------------------
--
> -----------------------
>
> When I run it I get this error:
>
> Can't locate object method "new" via package "Net::SMS::Genie" (perhaps
you
> forg
> ot to load "Net::SMS::Genie"?) at sms.pl line 2.
>
>
> What do I need to do? I guess I need a module in my perl directory, but I
> don't know where I have to get it from.
>
>
>




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

Date: 28 Sep 2001 11:42:11 -0700
From: richardbriggs@att.com (rab)
Subject: Re: Uninitialized Value...
Message-Id: <900b7105.0109281042.7b297e19@posting.google.com>

nobull@mail.com wrote in message news:<u9lmj037s9.fsf@wcl-l.bham.ac.uk>...
> richardbriggs@att.com (rab) writes:
> 
> >     41  my @thatline=split(/ /,$rejec[-1]);
>  
> > Use of uninitialized value at rejects line 41, <SYSLOG> chunk 11558.
>  
> > what's causing these errors?
> 
> @rejec is empty.


why?  Is it a coding error or Because the grep didn't pick anything
up?  How can I avoid this error if infact @rejec is empty   (because
no offending lines in the syslog were grep'd)


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

Date: Fri, 28 Sep 2001 14:34:30 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Uninitialized Value...
Message-Id: <3BB4D0C6.611B6A6E@home.com>

rab wrote:
> 
> nobull@mail.com wrote:
>>
>> @rejec is empty.
> 
> why?  Is it a coding error or Because the grep didn't pick
> anything up?

It could be either. (You haven't told us what it's supposed to do or
what your input looks like.)

> How can I avoid this error if infact @rejec is empty (because
> no offending lines in the syslog were grep'd)

Check it's length before trying to process it.

if (@rejec) {
    # array is not empty, okay to process
    # ...
}

-mjc


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

Date: Fri, 28 Sep 2001 20:58:10 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Unusual error message...
Message-Id: <GKE4wy.MMJ@news.boeing.com>

In article <d641rto78155r52hqpkg9nefqbb30666pl@4ax.com>,
Bart Lateur  <bart.lateur@skynet.be> wrote:
>Ilmari Karonen wrote:
>
>>In article <3BAE5642.53FE388A@earthlink.net>, Benjamin Goldberg wrote:
>>>Ilmari Karonen wrote:
>>>[snip]
>>>> The "EXPR for LIST;" syntax was introduced in perl 5.005.  It
>>>> is exactly equivalent to "for (LIST) {EXPR}", 
>>>
>>>Not *exactly* equivilant... it doesn't introduce a new scope.
>>
>>Actually, it does.  Some might argue that this is a bug.  Certainly none
>>of the other statement modifiers do that.
>
>It must be. Well: if you add a my() declaration in your expression, you
>can't do anything with that variable because it is not available until
>the expression, or rather the statment containing it, is finished
>executing. Like:
>
>	my $foo = 123 and print $foo;
>

Look though at how that's parsed:

perl -MO=Deparse -wle 'my $foo=123 and print $foo'  

Found = in conditional, should be == at -e line 1.
Name "main::foo" used only once: possible typo at -e line 1.

print $foo if my $foo = 123;

-e syntax OK


> lThis does ordinarily *not* print "123", because it doesn't print *this*
>$foo.

>	$foo = 'Old';
> 	(my $foo = 123), print $foo for 1;
>	print $foo;
>-->
>	Use of uninitialized value in print at test.pl line 4.
>	Old
>
>Bloody Hell. What is *that* good for.
>

perl -MO=Deparse -wl 
$foo="Old"; (my $foo = 123), print $foo for 1; print $foo
^D

$foo = 'Old';
foreach $_ (1) {
    my $foo = 123, print($foo);
}
print $foo;

-e syntax OK


Indeed seems like that should print:

Old
Old


--
Charles DeRykus


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

Date: Fri, 28 Sep 2001 12:59:11 -0700
From: "Brian Helterline" <brian_helterline@hotmail.com>
Subject: use Module vs. use module
Message-Id: <9p2kqh$4g0$1@hpcvnews.cv.hp.com>

Hi all,

I have a question about case sensitivity.  I'm running ActivePerl 5.6.0 on
Windows NT4

I mistakenly typed 'use GetOpt::Std;' rather than 'use Getopt::Std;' and the
program compiled without complaint but failed with a Undefined subroutine
&main::getopts message.

How can 'use' correctly find the module but not resolve the functions?  I'm
suspecting that it has to do with the case insensitivity of the OS in
locating the module vs. perl trying to resolve the functions

#!perl -w
use strict;

use GetOpt::Std;    # no complaint????

my $result = getopts( 'od');
exit 0;

-brian




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

Date: Fri, 28 Sep 2001 16:03:51 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: use Module vs. use module
Message-Id: <3BB4E5B7.B6F600BA@home.com>

Brian Helterline wrote:
> 
> I have a question about case sensitivity.  I'm running ActivePerl
> 5.6.0 on Windows NT4
> 
> I mistakenly typed 'use GetOpt::Std;' rather than 'use Getopt::Std;'
> and the program compiled without complaint but failed with a 
> Undefined subroutine &main::getopts message.
> 
> How can 'use' correctly find the module but not resolve the 
> functions?  I'm suspecting that it has to do with the case
> insensitivity of the OS in locating the module vs. perl trying
> to resolve the functions

You're on the right track. Win* is not case-sensitive, so it looks for
the same file regardless of the case of your 'use' clause. This is why
the 'use' succeeds.

Perl, on the other hand, is case sensitive. When you import a module,
the names of anything it exports are aliased into the main:: package.
When determining what gets aliased from where, Exporter takes the
package name specified in the 'use' clause over the package name
specified in the file itself (which shouldn't be surprising).

-mjc


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

Date: 28 Sep 2001 09:11:57 -0700
From: l.suheimat@mdx.ac.uk (Laith Suheimat)
Subject: Re: use statement runs package's subs before they are called
Message-Id: <69f8a22d.0109280811.160f5597@posting.google.com>

> you can also do something like:
> my @a = caller();
> if ((@a && $a[0] eq __PACKAGE__ )|| !$a[0]) {
>  $foo = pkg_sub1();
>  $bar = pkg_sub2();
> }
> 
> this just calls the methods if it's called from the
> commandline or if you set the package explicitly in the
> calling script.
> 

thanks, this slightly amended version is also working:

my @caller = caller();
$called = $caller[0];

if (! $called) {  #if run from command line
   my $foo = sub1();
   my $bar = sub2();
}
else {  #if called from script
   return(1);  #package must return exit value
}

i can now run the script from the command line (eg. to show which
databases are active), or call the relevant sub in the package from a
script (eg. to check the 'active' var in the hash ref returned from
the package).

laith


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

Date: 28 Sep 2001 19:32:18 GMT
From: getwebwise@aol.com (GetWebWise)
Subject: Where can I get a Perl Script
Message-Id: <20010928153218.28900.00001307@mb-cl.aol.com>

Hi Everyone

I have in mind building a script to add, change and delete graphics and text in
a similar fashion to sirensa advertiser (www.sirensa.net)

I am looking for a free script which I can take apart and find out how it
works.

Does anyone have or know of a script I can play with

Regards Ian


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

Date: Fri, 28 Sep 2001 21:19:03 GMT
From: Markus Laire <nothing@nowhere.com>
Subject: Re: Where can I get a Perl Script
Message-Id: <Xns912B359D36Fmarkuslaire@192.89.123.233>

getwebwise@aol.com (GetWebWise) wrote in
news:20010928153218.28900.00001307@mb-cl.aol.com: 

> I am looking for a free script which I can take apart and find out how
> it works.
> 
> Does anyone have or know of a script I can play with
> 


There is a lot of scripts at http://cgi-resources.com/
Check CPAN also (http://cpan.org)


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

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


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