[7086] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 711 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 9 00:17:25 1997

Date: Tue, 8 Jul 97 20:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 8 Jul 1997     Volume: 8 Number: 711

Today's topics:
     C to Perl socket connection question (Carl Swanson)
     Re: delete line in file directly(fixed length record) (Emiliano)
     Re: help using ~s/ / / please! <dada@divinf.it>
     How do I Use Perl to edit part of a file but not overwr (Colin Burn-Murdoch)
     Re: How does perl work with Win32?? (Michael Adams)
     Re: how to compiler flock module <rootbeer@teleport.com>
     Re: Installing libwww-perl-5.10 on perl 5.004_01 fo NT  (Jamie O'Shaughnessy)
     Re: Localtime in the year 2000 <mortensi@idt.ntnu.no>
     Re: Oraperl installation problems (John D Groenveld)
     Re: Perl is 20 times slower on Cray J90 than SGI! <rootbeer@teleport.com>
     Re: Perl is 20 times slower on Cray J90 than SGI! <nospam_sloscialo@chubb.com_nospam>
     Re: Perl Win 32 vs Serial Ports (Stephen Frost)
     Q: complex sort function <peter.riocreux@cs.man.ac.uk>
     quick regex help <mehta@mama.indstate.edu>
     Re: Remove/Replace question (Tung-chiang Yang)
     Re: Searching entire directory ,incl sub-dir using rege <sfairey@adc.metrica.co.uk>
     Sending file back to directory? (JChrisen)
     sending variables ("Rick Bauman")
     stat of files on NFS filesystems in Solaris davidb@chelsea.net
     Re: system call <limpj@sterlingdi.com>
     Re: What does this do? (Matthew D. Healy)
     Re: writers=seeking=publication (Matthew D. Healy)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 8 Jul 1997 12:10:18 GMT
From: cswanson@bermuda.io.com (Carl Swanson)
Subject: C to Perl socket connection question
Message-Id: <5ptana$fjv$1@nntp-3.io.com>

I was wondering if someone might have a few ideas:

I am trying to get a C based client to speak to a Perl based server.
The C client is on a UNIX platform called QNX and the Perl server is
on an HP. I use the standard socket communication commands for both
sides (I will detail them below) but although the Perl server says the C
client is connected and that it is listening, when the C client does 
a send to the Perl server, the Perl server never unblocks or hears it.

Now, I do have a Perl client and Perl server working, and I do have a 
C client and C server working, so I know basically my setup and such is 
correct on both sides.

So I guess my big question is: What would prevent the C lient and Perl
server from communicating properly, and why would the Perl server 
never "wake up" and receive the socket send? Do I have to be 
careful with configuring the sockets properly?

 (Just as a note: I do a netstat on the server side and it says 
that there is NOT anything waiting to be received on that socket).

Here is some of the code I use (I stripped a lot, but everything important
is still here).  I know it's a little long, but I really would 
appreciate any help someone could provide me.

Thank you so much!

Carl
cswanson@io.com

***************************************************
********************* C client *********************
***************************************************

struct hostent      *HostInf;  /* Pointer to info for remote host */
struct servent      *ServInf;  /* Pointer to service information */
struct sockaddr_in  LocalAddr;          /* Local socket address */
struct sockaddr_in  PeerAddr;           /* Remote socket address */

ConnectSocket()
{
    /* Setup hostname info */
    PeerAddr.sin_family = AF_INET;
    HostInf =  gethostbyname ("galaxy"); /* machine name */
    PeerAddr.sin_addr.s_addr = ((struct in_addr
*)(HostInf->h_addr))->s_addr;

    /* Setup service info */
    ServInf = getservbyname ("testsocket", "tcp"); /* connection port in
/etc/services as 7020 */
    PeerAddr.sin_port = ServInf->s_port;

    /* Create socket */
    Socket = socket (AF_INET, SOCK_STREAM, 0);

    /* Connect socket */
    if (connect(Socket, (void*)&PeerAddr, sizeof(struct sockaddr_in)) ==
-1) {
        printf("CCemsrelay: unable to connect to remote\n"); exit(1);
    }

    /* Get local socket port info */
    addrlen = sizeof(struct sockaddr_in);
    if (getsockname(Socket, (void*)&LocalAddr, &addrlen) == -1) {
        printf("CCemsrelay: unable to read socket address\n");
        exit(1);
    }

    if (Socket) setsockopt (Socket, SOL_SOCKET, SO_KEEPALIVE, 0, 0); 
    if (Socket) setsockopt (Socket, IPPROTO_TCP, TCP_NODELAY, (char*) &opt,
sizeof(int));

    printf("Connected to %s on port %u\n",HostName,ntohs(LocalAddr.sin_port));
    return (0);
}


main (int argc, char **argv)
{
    SINT command_len, sent_len;
    STRING_80 command_line;

    strcpy (TCPHostName,    "odin");
    strcpy (TCPServiceName, "testsocket");

    ConnectSocket();

    /* Receive and Relay messages until QUIT message */
    while (!Quit) {
        printf("\nCmd>");
        command_len=getline(command_line, 80);
        if (strcmp(command_line, "ETR") == 0){
            sent_len = send(Socket, command_line, strlen(command_line), 0);
            printf ("SENT LENGTH: %d\n", sent_len);
        }
              exit (0);
     }



***********************************************************
********************* PERL SERVER ********************
***********************************************************

#!/usr/local/bin/oraperl

# MAIN PROCEDURE

use Port;

    $myport  = Port->new("INET_STREAM", "s", "testsocket");
   
    if (! $myport->{transport}{connected} ) {
      print $myport->{transport}{error_msg}. "\n";
      exit;
    }
    print "Socket Open\n";

  while (1) {
    print "Trying to receive a message...\n";
    my $from = $myport->get(\$buffer);
    print "Received a message: $buffer!!!!\n";


# SUPPORT PROCEDURE TO OPEN SOCKET

use Socket;

  $SOCK_TEMPL    = 'n n a4 x8';

sub new {
  my ($class, $sock_type, $service, $host) = @_;

  my $obj = bless {
    "port_handle"  => "", "file_nbr"     => -1,
    "file_mask"    => "", "sock_type"    => $sock_type,
    "sock_service" => $service, "sock_host"    => $host,
    "connected"    => 0, "error"        => 0,
    "error_msg"    => "",
  };

  my ($dmy, $proto);
  ($dmy, $dmy, $proto)    = getprotobyname('tcp');
  ($dmy, $dmy, $service)  = getservbyname($service, 'tcp') unless $service
=~ /^\d+$/;

  my $templ = $Port_INET_STREAM::SOCK_TEMPL;
  my $server_addr  = pack($templ, AF_INET, $service, "\0\0\0\0");

  my $TCP_NODELAY = 1;
  if (! $Port_INET_STREAM::SERVER_OPEN) {
    if ( socket(SERVER_SOCK, AF_INET, SOCK_STREAM, $proto) ) {
          setsockopt (SERVER_SOCK, SOL_SOCKET, SO_REUSEADDR, 1) || die;
          setsockopt (SERVER_SOCK, $proto, $TCP_NODELAY, 1) || die;
          setsockopt (SERVER_SOCK, SOL_SOCKET, SO_RCVBUF, 30000) || die;
          setsockopt (SERVER_SOCK, SOL_SOCKET, SO_SNDBUF, 30000) || die;
      if ( bind(SERVER_SOCK, $server_addr) ) {
        if ( listen(SERVER_SOCK, 5) ) {
          my $oldfh = select(SERVER_SOCK); $| = 1; select($oldfh);
          setsockopt (SERVER_SOCK, $proto, $TCP_NODELAY, 1) || die;
          $Port_INET_STREAM::SERVER_OPEN = 1;
        } } } }
  if (! $Port_INET_STREAM::SERVER_OPEN) { return 0; }
  
  my $handle = "Port_INET_STREAM::fh". $next_file_nbr++;
  if ( accept($handle, SERVER_SOCK) ) {
    my $oldfh = select($handle); $| = 1; select($oldfh);
    setsockopt ($handle, $proto, $TCP_NODELAY, 1);
    setsockopt ($handle, SOL_SOCKET, SO_RCVBUF, 30000);
    setsockopt ($handle, SOL_SOCKET, SO_SNDBUF, 30000);
    $this->{port_handle}   = $handle;
    $this->{file_nbr}      = fileno($handle);
    vec($this->{file_mask}, $this->{file_nbr}, 1) = 1;
    $this->{connected}     = 1;
    $this->{sock_host}     = "localhost";
    $this->{sock_service}  = $service;
    $this->{error}         = "";
    $this->{error_msg}     = "";
  }

  return $this->{connected};
}


sub get {
-- SNIP --
    my $tot_read = 0;
    $tot_read += read $handle, $$buffer, $len;
    while ($tot_read < $len) {
      $tot_read += read $handle, $$buffer, $len;
-- SNIP --
  return $this->{sock_host}. ":". $this->{sock_service};
}


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

Date: Mon, 7 Jul 1997 13:23:39 GMT
From: qqehe@st5-oa6.oce.nl (Emiliano)
Subject: Re: delete line in file directly(fixed length record)
Message-Id: <ECyAJF.Dv8@oce.nl>

On 7 Jul 1997 09:28:44 GMT, Pui Ming WONG wrote:
:It's explained in the FAQ that there's no direct way of deleting
:a line in a file unless a new file is used for output and then
:renaming it to the old file afterwards.
:BUT, it's also said something like it is POSSIBLE to do it directly
:IF the file has all the lines of the same length.
:Now my file consists of all 8-bytes (9 if the \n is also counted)
:length records.
:What exactly should my statements be if i have to say, delete the
:5th record from my file directly.

If your record equals a line in a text file, I think

$^I = "";
while (<>) {
	print unless $. == 5;
}

should do the job. Or, alternately

$^I = "";
@file = <>;
splice @file, 4, 1;
print join('', @file);

Or, alternately ..... (the TMTOWTDI nature of Perl.. I love it!)

-- 
Bye,

Emile
============
When you try to make an impression, the chances are that is the
impression you will make.


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

Date: Tue, 08 Jul 1997 16:07:10 +0200
From: Aldo Calpini <dada@divinf.it>
To: shane whinfrey <oa32@dial.pipex.com>
Subject: Re: help using ~s/ / / please!
Message-Id: <33C2498E.FA4060BF@divinf.it>

Hi Shane,

shane whinfrey wrote:
> ...
> i get the following error message:-
> 
>      /*!*/: ?+* follows nothing in regex
> 
> could someone tell me where i'm going wrong please?

'*' is a special character in regexps. It matches any number of
characters, so it needs a character before. For example, 'A*' matches
any number (from zero to infinite) of 'A' characters.
If you want to match a literal '*', you need to quote it with a
backslash to prevent standard interpretation. Thus, you need:

     $print_address =~s/\*!\*/\r/g;
     $print_address =~s/\*!!\*/\n/g;

Bye,
Aldo Calpini
---/\-----------------------------------------------------------
--/  \--------------------------------- mailto:dada@divinf.it --
-<dada>-- POPULUS VULT DECIPI, -------- mailto:sis@divinf.it ---
--\  /------- ERGO DECIPIATUR --------- http://sis.divinf.it ---
---\/-----------------------------------------------------------


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

Date: Mon, 07 Jul 1997 15:11:37 GMT
From: colin@tubl.demon.co.uk (Colin Burn-Murdoch)
Subject: How do I Use Perl to edit part of a file but not overwrite it all
Message-Id: <33c1054d.2936495@news.demon.co.uk>

Hi,

Can anyone help me?  I know how to append to the end of a file, and to
overwrite it all but how do I take part of a file and change it?  ie.
If I have a database file in the form:

Entry One|1
Entry Two|2
Entry Three|3

I can search through the file for "Entry Two" and from that get "2" as
the result, how do I, for example add 1 to the number and print the
result to the file to get:

Entry One|1
Entry Two|3
Entry Three|3

Thanks a lot for any help, could you email ay replies to me as well as
the newsgroup as I'm going on holiday and the messages may expire from
the news server before I get back.  

Thanks again,

Colin Burn-Murdoch.


-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.3ia

mQCNAzNAdaIAAAEEALq1EcntKo2FP+W+mvtGXI8lKE9kWpH02XdTGgDtFyUyFVb6
sg5WO3nS2KwCBhgr3XEyrFVnmfUIKG/V3YV2ypYUp05hZ+x+qqz5PiWbxgXiBKJC
QSHS5z0qjSBCT6ExEciE7WJ6lu2KMOe+rxQvbY0V1nkcbUUOB1LQDZWz6f3VAAUR
tCtDb2xpbiBCdXJuLU11cmRvY2ggPGNvbGluQHR1YmwuZGVtb24uY28udWs+iQCV
AwUQM0B1o1LQDZWz6f3VAQGaOAP+M4BBmpdp+pdQyk9nBNfTp5ZkiisR6QCS1sR5
BlwQylNolf17/eN5/490btbKT+S8+IsMyyMFLORZ4gWmLR6nCa7wNYUP4BYCfMrr
MG05VGCiUDFirtY22893lM2ySkI6ifmliZLi5A9j7qXAEXz2jZvqOysIrPgbYn2g
VzVU7t0=
=a6w0
-----END PGP PUBLIC KEY BLOCK-----


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

Date: Wed, 9 Jul 1997 01:08:08 GMT
From: msadams@netcom.com (Michael Adams)
Subject: Re: How does perl work with Win32??
Message-Id: <msadamsED11tK.6vv@netcom.com>


Try the following steps:

1)  Download Build 306 of Perl (not Perlscript or ISAPI) from the 
ActiveWare site.

2)  Run the installation.

3)  Follow the instructions for the Microsoft Knowledge Base article 
Q150629, which is located at the support.microsoft.com, or at the 
ActiveWare site in their FAQ section.

4)   Be sure to accurately enter the pathname for the registry entry 
which you will be doing in step 3 above, as that fouled me up for a long 
time (C:\Perl\bin\perl.exe %s %s).  Also put the helloworld.pl script in 
a directory which can be read by PWS.  I put it in the \Webshare\Scripts 
directory.  To create the helloworld.pl script, I just cut and pasted it 
from the Knowledge Base article into Notepad, and then saved the file as 
helloworld.pl.

5)  If you have cgi scripts, you will also want to add a registry entry 
for those, too, as outlined in step 3.

6)  Make sure you restart the Personal Web Server.  This can be done 
manually, or done by restarting your computer.

7)  To run the script, I loaded Internet Explorer, and typed in 
http://default/Scripts/helloworld.pl? for the address.  Keep in mind that 
I did not change my server name when I installed PWS, so it is just 
"default".

Hope this helps,

Michael Adams
-- 
                                             msadams@netcom.com


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

Date: Mon, 7 Jul 1997 08:54:28 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Steel Tsai <steel@mail.ntis.com.tw>
Subject: Re: how to compiler flock module
Message-Id: <Pine.GSO.3.96.970707085202.9019U-100000@kelly.teleport.com>

On Mon, 7 Jul 1997, Steel Tsai wrote:

> 	My perl language version is 5.0001 and I want to using the
> flock function, but when I complier the flock module source code. It
> get me a message is "libperl.a" can not find. 

I'm not sure what's happening here. flock() is an internal function which
has been supported in Perl for a long time. If it's not available in your
perl binary, it was probably miscompiled. You should probably compile
5.004. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 07 Jul 1997 15:05:16 GMT
From: joshaugh@uk.oracle.com (Jamie O'Shaughnessy)
Subject: Re: Installing libwww-perl-5.10 on perl 5.004_01 fo NT - problems
Message-Id: <33c2052b.1030917453@newshost.us.oracle.com>

On 07 Jul 1997 14:49:06 +0000, Gisle Aas <aas@bergen.sn.no> wrote:

>joshaugh@uk.oracle.com (Jamie O'Shaughnessy) writes:
>
>> perl makefile.pl does it's stuff OK, it seems, but when running the makefile
>> (nmake) it gives:
>> 
>>         ..\perl -e 'use Config; chdir q{blib\script}; foreach (qw(GET HEAD
>> POST)
>> ) {'  -e 'unlink "$_";'  -e 'system("$Config{\"lns\"} lwp-request $_") && die;
>> }
>> '
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>> NMAKE : fatal error U1077: '..\perl' : return code '0xff'
>> Stop.
>> 
>> I've tried by hand to fix this by editing the makefile and the above perl. I've
>> pretty much succeeded, but the problem seems to be that "lns" in Config does
>> not have a value. What is "lns" and what's the above part of the makefile
>> supposed to be doing?
>
>$Config{\"lns\"} is usually "ln -s".  It makes a symbolic link.
>
>The above part makes the lwp-request program available as the aliases
>GET HEAD and POST.  Making the makefile with "perl Makefile.PL -n"
>should get rid of this section.
>
>-- 
>Gisle Aas <aas@sn.no>

Thanks, that worked fine. The tests won't run on Win32 either as they rely on
#! being interpreted at the beginning of the file, but I can run the tests by
hand. Everything seems to install OK though.

Again, thanks.

Jamie

___________________________________________________________________________ 
Jamie O'Shaughnessy                        Work: joshaugh@uk.oracle.com 
Oracle Designer/2000 Forms Generator Team  Home: jamie@thanatar.demon.co.uk 
______________________________________________________  __  __ _  __ .   __ 
Opinions expressed here are my own and not those of... (__)|-</-\(__ |__ -_ 


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

Date: 7 Jul 1997 14:46:40 GMT
From: Morten Simonsen <mortensi@idt.ntnu.no>
Subject: Re: Localtime in the year 2000
Message-Id: <5pqvgg$b5p@due.unit.no>

: This post also raises a red flag to all the regulars on the newsgroup
: that we can expect more questions straight from the docs from your
: particular email address. Some might even put that address in a list
: of addresses that would end up reducing the number of experienced
: Perl programmers who see your postings in the future...

TO ALL THE INTERNET COMMUNITY: I AM SORRY

THIS WILL NEVER HAPPEN AGAIN. HOPE YOU HAVE NOT WASTED TO MUCH TIME
READING MY QUESTION. I DO ADMIT IT WAS FOOLISH TO SEND
A QUESTION WITHOUT STUDYING THE FAQS. MY ONLY APOLOGY WAS THAT
I DID NOT THINK OF THE POSSIBILITY, I DID NOT SEND THE MAIL JUST
BECAUSE I WOULDN'T TAKE THE TIME TO READ THE FAQS. 

Morten Simonsen


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

Date: 5 Jul 1997 00:00:35 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Oraperl installation problems
Message-Id: <5pkgt3$ihi$1@tholian.cse.psu.edu>

Get a more recent version of perl. Then get the DBI and DBD::Oracle modules.
http://www.perl.com/CPAN/

Your problem is that you are trying use oraperl, the perl4 extension, with
perl5. The Oraperl emulation within DBD::Oracle is the right way to go.
See http://www.dejanews.com for more info.
John
groenvel@cse.psu.edu


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

Date: Tue, 8 Jul 1997 09:31:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brett Denner <Brett.W.Denner@lmtas.lmco.com>
Subject: Re: Perl is 20 times slower on Cray J90 than SGI!
Message-Id: <Pine.GSO.3.96.970708092302.10418D-100000@kelly.teleport.com>

On Tue, 8 Jul 1997, Brett Denner wrote about a simple Perl script which
takes 14 times longer to execute on a Cray than on an SGI machine. 

Gosh, you give some people a Cray and they still complain that it's not
fast enough!

Well, it may be that your copy of Perl on the Cray is not so hot for one
reason or another. Are you using 5.004 on both machines? 

Could there be some reason that your Cray is (for whatever reason) slow at
everything? For example, if you run a simple C program, does it exhibit a
similar differential? 

There may also be some Perl configuration option which makes a big
difference. I don't know which one it would be, though.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/




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

Date: 8 Jul 1997 17:53:44 GMT
From: "Sergio Loscialo" <nospam_sloscialo@chubb.com_nospam>
Subject: Re: Perl is 20 times slower on Cray J90 than SGI!
Message-Id: <01bc8bc7$a1878fe0$c61012ac@sloscialo.chubb.com>

Add RAM...oops that's for the wintel group. <gd&r>
-- 
Sergio Loscialo
Chubb Computer Services

Brett Denner <Brett.W.Denner@lmtas.lmco.com> wrote in article
<33C248A2.41C6@lmtas.lmco.com>...
> Thus, this script takes about 14X longer to run on the Cray than on the
> SGI.  Is this typical?  Why is this happening, and can I do anything to
> speed up my Perl script on the Cray?
> 
> Thanks,
> Brett
> 
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  Brett W. Denner                                    Lockheed Martin TAS
>  Brett.W.Denner@lmtas.lmco.com                      P.O. Box
> 748            
>  (817) 935-1142 (voice)                             Fort Worth, TX 76101
>  (817) 935-1212 (fax)                               MZ 9333
> 


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

Date: 5 Jul 1997 07:11:11 GMT
From: frostbyt@shell02.ozemail.com.au (Stephen Frost)
Subject: Re: Perl Win 32 vs Serial Ports
Message-Id: <5pks2f$l1j@proxy5.proxy.ozemail.net>

I haven't tried this, but does the old DOS 'MODE' command work?  Here's
the help display for MODE running under Windows 95.

C:\>mode /?
Configures system devices.

Printer port:      MODE LPTn[:] [COLS=c] [LINES=l] [RETRY=r]
Serial port:       MODE COMm[:] [BAUD=b] [PARITY=p] [DATA=d] [STOP=s] 
[RETRY=r]
Device Status:     MODE [device] [/STATUS]
Redirect printing: MODE LPTn[:]=COMm[:]
Prepare code page: MODE device CP PREPARE=((yyy[...]) [drive:][path]filename)
Select code page:  MODE device CP SELECT=yyy
Refresh code page: MODE device CP REFRESH
Code page status:  MODE device CP [/STATUS]
Display mode:      MODE [display-adapter][,n]
                   MODE CON[:] [COLS=c] [LINES=n]
Typematic rate:    MODE CON[:] [RATE=r DELAY=d]

Steve

Jeff Walls (wallsj@fc.hp.com) wrote:
: redleader@cedep.net wrote:
: > 
: > Is it possible to send and receive data over the serial port with
: > Perl Win 32 ???

: Yes it is.  It's more difficult to actually configure
: the serial port with the correct parameters.  In fact,
: I haven't found a way to do this yet that doesn't involve
: C.  In Unix, I believe you can issue a stty.  Is there
: an equivalent call under Win32?  If you find a way, 
: please let me know! :-)

: Basically, treat the serial port as a file.  Eg:

: open (SERPORT, "+>COM1:") || die "Can't open serial port";

: print (SERPORT ....);
: read (SERPORT, ....);

: close (SERPORT);

: Again, the port needs to be configured to work properly, 
: though.

: -- Jeff
: +-----------------------------------------------------+
: | Hewlett-Packard, Co.           970-229-2424 - voice |
: | Graphics Products Lab          970-229-3687 - fax   |
: +-----------------------------------------------------+

--
********************************************************************
Steve Frost                      Steve Frost          PGP Public Key
Frostbyte Computer Consultants   OzEmail Limited      available from
Melbourne, Australia             Sydney, Australia    my web site.
--------------------------------------------------------------------
http://www.frostbyte.com.au     "I want to stay angry at the evil,
steve.frost@frostbyte.com.au     I want to be hungry for the truth."


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

Date: 08 Jul 1997 09:10:15 -0700
From: Peter Riocreux <peter.riocreux@cs.man.ac.uk>
Subject: Q: complex sort function
Message-Id: <9kn2nx8qzc.fsf@cs.man.ac.uk>

I have looked in the camel book, the man pages and the faq, and found
nothing this detailed, but if there is an online reference covering
this somewhere....

Can anyone explain how to get sort to give the result I need.

If I have three typical lines:

timer.u29.u4$15.mu15
timer.u29.u4$15.mu7
timer.u29.u4$2

This is the order that sort outputs them, but I want them in the
order:

timer.u29.u4$2
timer.u29.u4$15.mu7
timer.u29.u4$15.mu15

These variable length numbers can occur anywhere in the strings, but
will probably be bounded on the right by a period, a $ or an end of
line.  They are, I think the sole problem.  One way I thought of was
that maybe all groups of consecutive digits could be padded out to,
say, 8 digits, with preceding zeroes, and then the normal cmp would
work, but I couldn't figure out how to pad the digit runs.

Can anyone help me with a sort function that would cope.  Speed is not
particularly important, so even grindingly slow solutions are welcome.



Pete

-- 
Peter Riocreux, Amulet Group, Dept. Computer Science, Manchester University,
Oxford Road, MANCHESTER, M13 9PL, UK.      <http://www.cs.man.ac.uk/amulet/> 
Voice: +44 161-2753531      Mobile: +44 966-175986      Fax: +44 161-2756204


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

Date: Mon, 7 Jul 1997 15:12:19 GMT
From: Miten S Mehta <mehta@mama.indstate.edu>
To: Chipmunk <Ronald.J.Kimball@dartmouth.edu>
Subject: quick regex help
Message-Id: <Pine.LNX.3.93.970707100821.5555A-100000@mama.indstate.edu>

7/7/97

Dear Regex Crackers,


Here is the string:


public class SrvFeaturesTransaction extends lpTransaction
                        implements NsTransaction, FeaturesConstants {

        protected boolean debug__ = true;

        private final static int SNMP_GET_WAIT_TIME = 1000;
        private final static int SNMP_SET_WAIT_TIME = 5000;

        protected  NsNodeBnx nsNodeBnx_;
        String community;
        int cctId     = -1;

        public SrvFeaturesTransaction () {

                if (debug__) {
                        System.out.println ("===> In SrvFea Constructor");
                }
        }


Herte is my regex:
$x = "/* %I% %M% %H% */";
$y = "private static String sccs_var=\"%W%\";";
$data=~s/(public( )+((class)||(interface))(.)+{)/$1\n\n\n$y\t$x\n\n\n/;

I get $1 =  public SrvFeaturesTransaction () {
I want it to be  as below

public class SrvFeaturesTransaction extends lpTransaction
                        implements NsTransaction, FeaturesConstants {

is there a way I can tell first match only for substitution?


Have a good day !!!

Best Regards,

Miten Mehta.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
Res:                                            |
Miten S Mehta                                   |
311 S Lasalle St, 39E,		                |
Durham, NC 27705                                |
Tel: 919 416 3889                               |             
e-mail: mehta@mama.indstate.edu                 |
resume url:                                     |
ftp://mama.indstate.edu/users/mehta/resume.html | 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             





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

Date: Sat, 5 Jul 1997 03:46:28 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Remove/Replace question
Message-Id: <tcyangECtuHG.Msr@netcom.com>

Usually it is easier for you to find the original data file, make
corrections, and then export to get the Postscript files.

Ken French wrote after zapping the scum of the universe:
: I have a post script file with some lines in it that I want to remove and 
: replace with one expression.
:   There are 20 lines that follow each other that look like this
: 30 478 px
: 30 479 px
: 30 456 px
: ...and so on.
:  There is one space between each number and the px.
: the 21st line looks like this
: 30 474 34 474 li
: then there are 20 more of the px lines followed by
: 30 456 40 498 li

: What I need to do is remove the px lines that are grouped together

What do you mean here?  You mean you keep /^\d\d \d\d\d px$/ lines if
they are alone, and delete this kind of lines if they show up in consecutive
lines?

: (deleted)
: (the problem is too complicated and I believe divide-and-conquer is)
: (better.)

--
========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: Tue, 08 Jul 1997 15:22:47 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Shaun O'Shea <lmisosa@eei.ericsson.se>
Subject: Re: Searching entire directory ,incl sub-dir using regexps, for files.
Message-Id: <33C24D37.FF6@adc.metrica.co.uk>

Shaun O'Shea wrote:
> 
> Hi
>    I'm rtelatively new to this so bear with me. I want to use
> reg-exps(or any other method) to search through a directory (including
> it's sub directories) for certain files.
>                                         Is this possible?
> Any help would be great!
> Thanks!
> 
>                                 Shaun...................:-)
> 
> 
> ***********************************************************************
>                         Shaun O'Shea                                                    lmisosa@eei.ericsson.se     OR
> shaunos@orca.ucd.ie
> 
> ***********************************************************************

Why not use unix find and then run find2perl.
ie. to find all html files in the current directory and all
subdirectories

Unix: find . -name "*.html"

'find2perl find . -name "*.html"' will give something like:
-----------------
#!bin/perl

require "find.pl";

# Traverse desired filesystems
&find('find','.');

exit;

sub wanted {
    /^.*\.html$/;
}
-----------------
The wanted sub which it creates is where it tests each filename it
encounters, so you can put whatever you like in the way of reg-exps or
file tests in here.

Simon


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

Date: 9 Jul 1997 02:24:30 GMT
From: jchrisen@aol.com (JChrisen)
Subject: Sending file back to directory?
Message-Id: <19970709022400.WAA04093@ladder02.news.aol.com>

Hi,

We are setting up an application that allows a user to pick a file and
convert it to another format, such as a word document being converted to a
 .pdf document.  This application is being done through the use of a form
in Netscape.  The problem we are having is once the file is converted what
script is needed to send the file back to the user.  We could also use
something as simple as sending the file to a certain directory.  If anyone
has any examples of how to do this it would be appreciated.

Thanks...


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

Date: Tue, 8 Jul 1997 14:47:36 +0000
From: rick@internetx.net ("Rick Bauman")
Subject: sending variables
Message-Id: <199707081744.NAA27249@smtp.internetx.net>

How can I send variables to an executing command?
example, if I run the command

passwd username

how can I get the perl program to send the password twice?

passwd username somepassword 

wont work on the flavor of unix I am using

tia
r
Rick Bauman
IT'S OFFICIAL, 
check out the website below
all moral support is appreciated
http://www.rbauman.org/
System Administrator/Internet Express
rick@internetx.net  www.internetx.net
finger rick@internetx.net for pgp public key
******************************************
The views expressed here are my own 
and in no way reflect those of my 
employer, family, friends, pets, or 
other associates.



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

Date: Mon, 07 Jul 1997 10:13:28 -0600
From: davidb@chelsea.net
To: davidb@chelsea.net
Subject: stat of files on NFS filesystems in Solaris
Message-Id: <868287664.3135@dejanews.com>

Folks,

Has the behavior of stat() under Solaris and PERL changed sometime in the
last few months/years?  I recall that a stat of an NFS mounted file at one
time returned a negative device number if it was NFS mounted.  Programming
PERL bears me out.  Alas, this no longer appears to be the case.

Scan of docs returns no notes to the contrary, yet I am consistently
getting positive device numbers for NFS mounted file systems.  I could
always fork a "df -F ufs" in my script, but hey; that ain't right.

Anybody know what's up?  I use PERL 5.003 and Solaris 2.5.1.

Thanks in advance; please email, I will post summary.

David.

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Tue, 08 Jul 1997 09:50:47 -0400
From: Patrick J Lim <limpj@sterlingdi.com>
Subject: Re: system call
Message-Id: <33C245B7.5051@sterlingdi.com>

We are trying to do a system call from a Perl script.
However, we are getting a return status of 1, when
we expect 0.  For example, "system(date)" returns 1,
and we are not getting the output from the date command.

Also, we have a series of system calls being done.  If
one of them returns some non-zero value (usually 1), then
all the subsequent calls in the script also return a
non-zero value.

Any hints, suggestions, comments?

Thanks in advance,

Patrick Lim
limpj@sterlingdi.com

Cathy Colavito
colavich@sterlingdi.com


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

Date: Mon, 07 Jul 1997 11:16:25 -0500
From: Matthew.Healy@yale.edu (Matthew D. Healy)
Subject: Re: What does this do?
Message-Id: <Matthew.Healy-0707971116250001@pudding.med.yale.edu>

In article <33BA7D05.3EAA@storm.simpson.edu>, schneide@storm.simpson.edu wrote:

> I'm fairly new to Perl and I'm trying to debug a script written by the
> person I replaced.  Could somebody "interpret" the following line:
> 
> $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> 

Let me make a wild guess: it's a CGI script of some kind, right?
This command takes what is called an URLencoded string, which is
the format used for query strings and fill-out-form data on the
web, and converts it back to the original string.  There are some
other applications for this encoding scheme, but CGI scripts are
far and away the most common use.

If it is for a CGI script, you should be aware that there are several
very nice tools already written to handle CGI forms automatically; you
really should use one of those.  Some of these also have built-in
debugging tools that will make your work _much_ easier!

My homepage has pointers to some websites with more information about
this.
--------
Matthew.Healy@yale.edu           http://ycmi.med.yale.edu/~healy/
As of 26 Jun 1997, only 918 days until Y2K....
Any person with a phone line can become a town crier with a voice
that resonates farther than it could from any soapbox.
--The US Supreme Court, overturning the Communications Decency Act


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

Date: Mon, 07 Jul 1997 10:58:56 -0500
From: Matthew.Healy@yale.edu (Matthew D. Healy)
Subject: Re: writers=seeking=publication
Message-Id: <Matthew.Healy-0707971058560001@pudding.med.yale.edu>

In article <5por9j$67e$5185@roadrunner.miracle.net>, ftr45r@aol.com wrote:

In article <33b475c6.0@news1.ibm.net>, Litagent345@aol.com wrote:

 ...
> WOODSIDE INTERNATIONAL LITERARY AGENCY>>>
 ...
> Woodside, New York>>>>
 ...

Aaaack. This is an incredibly notorious spammer.  Before having anything
whatsoever to do with them, I would advise lurking on misc.writing for a
while, paying particular attention to postings with subject lines that
contain the strings "Woodside", "Woody", "Woodsiting", "Woodchuck", and
the like...
--------
Matthew.Healy@yale.edu           http://ycmi.med.yale.edu/~healy/
As of 26 Jun 1997, only 918 days until Y2K....
Any person with a phone line can become a town crier with a voice
that resonates farther than it could from any soapbox.
--The US Supreme Court, overturning the Communications Decency Act
--------
Matthew.Healy@yale.edu           http://ycmi.med.yale.edu/~healy/
As of 26 Jun 1997, only 918 days until Y2K....
Any person with a phone line can become a town crier with a voice
that resonates farther than it could from any soapbox.
--The US Supreme Court, overturning the Communications Decency Act


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 711
*************************************

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