[7277] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 902 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 21 21:17:16 1997

Date: Thu, 21 Aug 97 18:00:27 -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           Thu, 21 Aug 1997     Volume: 8 Number: 902

Today's topics:
     Re: Alphanumeric Sort Routine? (Andrew M. Langmead)
     Broken Pipe piping to sendmail (Ian Kallen)
     chat on PERL5 sunil@aquas.com
     defined(<file>) bumps handle in perl5.004_1? <nickgeo@merle.acns.nwu.edu>
     Error 49 in SDBM store -- what does it mean? (Michael Schuerig)
     Error in Perl (Andrew D. Arenson)
     extracting a pattern... <jshaw@vellocet.insync.net>
     Re: extracting a pattern... (Tad McClellan)
     Re: Hash + Regex (Jot Powers)
     Re: Hash + Regex (Tad McClellan)
     HELP cant write variable to html doc... tom.kane@litronic.com
     Re: Help with CGI.pm Script <burleigh@hackberry.chem.niu.edu>
     Re: How to use the Filter module? (Haizhou Chen)
     if (/htm/ && !/html/) { (Leonhard Brenner)
     line by line comparison of two files (Susan_Farenci)
     Re: line by line comparison of two files (Tad McClellan)
     Need a routine to check for DATE sunil@aquas.com
     opening (Ai4net)
     Re: Passing 1 programs O/P to anothers I/P via file han <jaydee@worsdall.demon.co.uk>
     Perl 5.004_01 tests fail w/ SunOS 4.1.4 (Anne Kilarjian)
     Re: Perl and OLE Automation <anc@sec.cpg.sony.co.jp>
     Question about arrays. (Nigel Reed)
     Re: Question about arrays. (Tad McClellan)
     Re: Redirecting output...... <nnyxcu@ny.ubs.com>
     Re: Redirecting output...... (Tad McClellan)
     Search Engine scripts ? <rmanocha@rocketmail.com>
     Searching for an email administaion group <jaydee@worsdall.demon.co.uk>
     Re: Socket problem. Works once only... <mark@tstonramp.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 21 Aug 1997 22:52:27 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Alphanumeric Sort Routine?
Message-Id: <EFACvG.5o1@world.std.com>

[redirected to comp.lang.perl.misc, since this has nothing to do with
modules.]

Gip <nospam.gibsonc@aztec.asu.edu> writes:

>I'm tired of writing sort routines for the following situation:

>2a7 should be greater than 2a16, but Perl, in it's wisdom, see's
>the 7 as being greater than 1, instead of 16.

>So I hack in leading 0's, sort, and take them out.  Then 2a07 is
>less than 2a17. Butt ugly and slow!

If you maintain a parallel array that contains that data in an easily
sortable format, you can tell perl to re-arrange the original array
based on how it wants to sort the computed array.

# break each element into its component pieces, so numbers can
# be sorted numerically, letters alphabetically.
foreach $alphanum (@list) {
   push @sorting_data, [ $alphanum =~ /(\d+)(\D+)(\d+)/ ]; 
}

# get a list of indicies, ask perl how to sort them, and use
# them in an array slice that will produce a sorted list.
@sorted = @list[ sort by_alphanum 0 .. $#list ];

sub by_alphanum {
  $sorting_data[$a][0] <=> $sorting_data[$b][0] ||
  $sorting_data[$a][1] cmp $sorting_data[$b][1] ||
  $sorting_data[$a][2] <=> $sorting_data[$b][2];
}

Ugly or not, you'll have to decide for yourself. In the FAQ, there is
an entry on sorting that shows a really slick piece of code that is
called the "Schwartzian Transform", <URL:http://www.perl.com/CPAN/doc/
manual/html/pod/perlfaq4/How_do_I_sort_an_aray_by_anyth.html> but there
are people who will argue about the aesthetics of that, too.

-- 
Andrew Langmead


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

Date: 21 Aug 1997 22:43:41 GMT
From: spidaman@well.com (Ian Kallen)
Subject: Broken Pipe piping to sendmail
Message-Id: <5tigat$432$1@was.hooked.net>

I'd like to bulletproof code that exiting when there's a problem piping 
to sendmail. Instead of just leaving me with "Terminated: Broken Pipe" 
when it's iterating through its loop of sendmail tasks, I'd like to be 
informed of what the problem is and have the script procede to the next 
loop iteration. Anybody have nay code examples that work around stuff 
like that?

thanks
-Ian






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

Date: Thu, 21 Aug 1997 19:35:07 -0600
From: sunil@aquas.com
Subject: chat on PERL5
Message-Id: <872209370.9615@dejanews.com>

Hi,

We have problems working with 'chat' with 'fmbatch' (frame Maker program)
on PERL 5. chat does not seem to work in PERL5.
Is there someone who came across same problem and have a solution or
workaround ?
Please send email to sunil@aquas.com.

Thanks in advance.
Sunil

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


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

Date: Thu, 21 Aug 1997 17:58:47 -0500
From: Nicholas Geovanis  <nickgeo@merle.acns.nwu.edu>
Subject: defined(<file>) bumps handle in perl5.004_1?
Message-Id: <Pine.HPP.3.93.970821175122.12175G-100000@merle.acns.nwu.edu>


It seems that using "defined(<STDIN>)" in an if-statement's
expression in perl5.004_1 under HPUX 10.20 causes an iteration of the
file-handle. My impression from pg. 53 of the 2nd ed. Camel book is that
this isn't supposed to happen. Who's right? Perl or the Camel? Or am I
just wrong?

<--------------------------------------------------------------------------->
      Choice control - behind propaganda             | Nick Geovanis
      Poor information - to manage your anger        | IT Computing Svcs.
      War for territory.......Sepultura              | Northwestern Univ.
<----------------------------------------------------| 2020 Ridge Bldg.
            pgp key available on request             V n-geovanis@nwu.edu




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

Date: Thu, 21 Aug 1997 23:59:57 +0200
From: uzs90z@uni-bonn.de (Michael Schuerig)
Subject: Error 49 in SDBM store -- what does it mean?
Message-Id: <1997082123595735240@rhrz-isdn3-p22.rhrz.uni-bonn.de>


I'm trying to get a script that I wrote using MacPerl to work on a Unix
box. The main difference is that MacPerl uses Berkely DB while on the
Unix machine apparently only SDBM is available.

Well, at home the script works nicely, on Unix, after some work has
already been done successfully, I get an error message telling me that
error 49 occurred in SDBM store. What does it mean and what can be the
cause of this?

Michael

--
Michael Schuerig           Opinions are essentially bets on the truth of
mailto:uzs90z@uni-bonn.de   sentences in a language that you understand.
http://www.uni-bonn.de/~uzs90z/                       -Daniel C. Dennett


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

Date: 21 Aug 1997 16:43:54 -0500
From: arenson@hen.imgen.bcm.tmc.edu (Andrew D. Arenson)
Subject: Error in Perl
Message-Id: <wqk9hfqkit.fsf@hen.imgen.bcm.tmc.edu>


	I've got a script which appears to show that calls to seek
and read end up interfering with perl's internal stack. This is
from solaris2.5, using perl-5.003.

	What seems to happen is that while iterating through an array
of blessed objects using foreach, the last member of the array is not
set properly when its time comes. The array itself appears to be
unaffected.

	The original code this error showed up in included 6 or 7
modules. I've distilled it down to the following script. The three
files mentioned are available from:

	ftp://kiwi.imgen.bcm.tmc.edu/pub/arenson/perl_question/

The commented code below ducks the error. The output I get is:

file1:
file2:
obj is not a reference: 65


#------------------------------------------------------------------------

#!/bin/sh -- perl
eval 'exec perl5 -w -S $0 "$@"'
        if 0;

my(@objs) = ();
foreach $file ('file1','file2','file3') {
    my($obj) = +{};
    bless($obj,'Object');
    $obj->{'file'} = $file;
    push(@objs,$obj);
}

foreach $obj (@objs) {
    if (not ref $obj) {
	print STDERR "obj is not a reference: $obj\n";
	next;
    }
    
    $file = $obj->{'file'};
    print "$file:\n";
    myread($file);
}
exit 0;

sub myread {
    my($file)=shift;
    open(INPUT,$file);
    my($data) = '';
    seek(INPUT,26,0);
    read(INPUT,$data,4);
    my($indexoffset)=unpack("L",$data);
    my($i)=0;
    my(%labels) = ();
    while (1) {
	seek(INPUT,$indexoffset+($i*28),0);
	read(INPUT,$data,28);
	$label=substr($data,0,4);
	if ($label eq "\0\0\0\0") { last; }
	$labels{$label} = $data;
	$i++;
    } 
    $name_len=0;
    $name = '';
    $data=$labels{'SMPL'};
    $name_offset=unpack("L",substr($data,20,4));

    seek(INPUT,$name_offset,0);
    read(INPUT,$name_len,1);
#   if ($name_len ne '') {
        $name_len=unpack("C",$name_len);
        seek(INPUT,$name_offset+1,0);
        read(INPUT,$name,$name_len);
#   }
}


-- 
Andrew D. Arenson            | http://gc.bcm.tmc.edu:8088/cgi-bin/andy/andy
Baylor College of Medicine   | arenson@bcm.tmc.edu        (713)  H 520-7392
Genome Sequencing Center, Molecular & Human Genetics Dept.     | W 798-4689
One Baylor Plaza, Room S903, Houston, TX 77030                 | F 798-5386


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

Date: Thu, 21 Aug 1997 18:37:05 -0500
From: Joe  Shaw <jshaw@vellocet.insync.net>
Subject: extracting a pattern...
Message-Id: <Pine.GSO.3.96.970821180619.10475B-100000@vellocet.insync.net>


I'm wondering if anyone could help me with a problem I'm having.  I need
to extract an IP address from a string, but there is a ton of info in the
line.  I'm thinking about just loading every character into an array and
then removing all the white space, then the letters.  This seems like the
wrong way to do it, and I'm still stuck with the problem of trying to
extract the IP address.  Anyone know of a more efficient way of doing it?

an example of the lines I'm trying to get the information out of it
follow:

Apr 13 15:39:08 propaghandi pppd[478]: local  IP address 153.36.194.204
Apr 13 15:39:08 propaghandi pppd[478]: remote IP address 207.76.48.25

if you reply, please cc a reply to the address below... 
Thanks,
Joe Shaw - jshaw@insync.net
NetAdmin - Insync Internet Services
"Learn more, and you will never starve." - Paraphrase of Lee




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

Date: Thu, 21 Aug 1997 19:24:12 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: extracting a pattern...
Message-Id: <c7mit5.etg.ln@localhost>

Joe Shaw (jshaw@vellocet.insync.net) wrote:

: I'm wondering if anyone could help me with a problem I'm having.  I need
: to extract an IP address from a string, but there is a ton of info in the
: line.  I'm thinking about just loading every character into an array and
: then removing all the white space, then the letters.  This seems like the
: wrong way to do it, and I'm still stuck with the problem of trying to
: extract the IP address.  Anyone know of a more efficient way of doing it?

: an example of the lines I'm trying to get the information out of it
: follow:

: Apr 13 15:39:08 propaghandi pppd[478]: local  IP address 153.36.194.204
: Apr 13 15:39:08 propaghandi pppd[478]: remote IP address 207.76.48.25


   print "$1\n" if /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
or
   print "$1\n" if /(\d{1,3}(\.\d{1,3}){3})/;


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 21 Aug 1997 21:58:49 GMT
From: news@bofh.com (Jot Powers)
Subject: Re: Hash + Regex
Message-Id: <5tidmp$e9k$1@gazette.corp.medtronic.com>

In article <slrn5vp50a.2h8.sami@d246a.mtalo.ton.tut.fi>, Sami Sandqvist wrote:
>On	20 Aug 1997 21:30:55 GMT, Jot Powers <news@bofh.com> wrote:
>>If I were to make a guess, I'd guess that your hash value has special
>>characters (say a /) that make it break.  Observe:
>>
>
>Observe:
>
>------test.pl------
>#!/bin/perl -w
>$test{mykey}="this/is/the/replacement";
>$_ = "Here: Replace me.\n";
>s/Replace me/$test{mykey}/ig; # /ig naturally unnecessary in this program.
>print;
>-------------------
>d246a:[~] % ./test.pl 
>Here: this/is/the/replacement.
>d246a:[~] %
>
>>(Of course, I just did the following, and it didn't break:
>>
>>  DB<6> $_ = 'A<title></title>B'
>> 
>>  DB<7> $bob{'fred'} = "#joe"
>> 
>>  DB<8> s#<title></title>#<title>$bob{$name}</title>#ig
>> 
>>  DB<9> p $_
>>A<title>#joe</title>B
>>
>
>It didn't break because the s///; -line gets broken to its search -
>and replacement- parts long before evaluating the hash value. Had you
>tested with '/' instead of '#' you would not have confused the original
>poster.

I'm obviously missing what you are saying, because it looks to me
like my choice to use # versus / has no impact as long and I'm consistent.

For example his was:

string = "<title></title>"
hash = "something"
s/<title><\/title>/<title>hash<\/title>/ig

And I said if his hash was "something/something" it might
cause a problem.

I showed an example using # as the separator instead of /
as a way to get around that, and then I tested the supposition
by using # as the separator and making sure that # was in my
hash, and it didn't break.

Then, the last lines of my post (which you cut out) said:

So, looks like you have some other problem.  You should provide
the smallest example of code showing your problem and an example
of the data.

(BTW:  I believe Mike Stok probably answered this correctly by
figuring out that the error message was probably a missing ; on
the line before, but since the poster didn't provide that, Mike
went above and beyond).

So, where did I confuse someone?

-Jot
-- 
Jot Powers  news@bofh.com
Unix System Administrator
"Sometimes you just have to grab the bull by the tail and face the situation."


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

Date: Thu, 21 Aug 1997 18:14:55 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Hash + Regex
Message-Id: <f5iit5.4ig.ln@localhost>

Jot Powers (news@bofh.com) wrote:
: In article <slrn5vp50a.2h8.sami@d246a.mtalo.ton.tut.fi>, Sami Sandqvist wrote:
: >On	20 Aug 1997 21:30:55 GMT, Jot Powers <news@bofh.com> wrote:
: >>If I were to make a guess, I'd guess that your hash value has special
: >>characters (say a /) that make it break.  Observe:
: >>
: >
: >Observe:
: >
: >------test.pl------
: >#!/bin/perl -w
: >$test{mykey}="this/is/the/replacement";
: >$_ = "Here: Replace me.\n";
: >s/Replace me/$test{mykey}/ig; # /ig naturally unnecessary in this program.
: >print;
: >-------------------
: >d246a:[~] % ./test.pl 
: >Here: this/is/the/replacement.
: >d246a:[~] %
: >

[ snip ]

: >It didn't break because the s///; -line gets broken to its search -
: >and replacement- parts long before evaluating the hash value. Had you
: >tested with '/' instead of '#' you would not have confused the original
: >poster.

: I'm obviously missing what you are saying, because it looks to me
: like my choice to use # versus / has no impact as long and I'm consistent.
                                   ^^^^^^^^^^^^^

Exactly!

You can use m/$foo/ when $foo contains a slash, and m#$foo# when
$foo contains a slash.

So, which character you use a delimiter does not matter.

Below, you seem to be saying that it _does_ matter...



: For example his was:

: string = "<title></title>"
: hash = "something"
: s/<title><\/title>/<title>hash<\/title>/ig

: And I said if his hash was "something/something" it might
                                                   ^^^^^^^^
: cause a problem.
  ^^^^^^^^^^^^^^^

It most surely does *not* create a problem.

If there was slash in a literal pattern, that _would_ be a problem,
but a slash contained in a scalar matters not at all.


: I showed an example using # as the separator instead of /
: as a way to get around that, 

A way to get around something that is not in the way?  ;-)


: and then I tested the supposition
: by using # as the separator and making sure that # was in my
: hash, and it didn't break.

: Then, the last lines of my post (which you cut out) said:

: So, looks like you have some other problem.  You should provide
: the smallest example of code showing your problem and an example
: of the data.

: (BTW:  I believe Mike Stok probably answered this correctly by
: figuring out that the error message was probably a missing ; on
: the line before, but since the poster didn't provide that, Mike
: went above and beyond).

: So, where did I confuse someone?
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^

You said that having a slash in the scalar was a problem, when
it no bearing whatsoever...


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 21 Aug 1997 17:12:25 -0600
From: tom.kane@litronic.com
Subject: HELP cant write variable to html doc...
Message-Id: <872201000.32145@dejanews.com>

I am trying to write a perl script that will open and read a text file,
then print the data that it read to a html page. If I run this script at
the command line, it works great, but when I run it from my browser, it
will print everything exept the information that it received from the text
file.

please e-mail tom.kane@litronic.com with any suggestions

Thank You
Tom kane

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


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

Date: Thu, 21 Aug 1997 17:29:22 -0500
From: Darin Burleigh <burleigh@hackberry.chem.niu.edu>
Subject: Re: Help with CGI.pm Script
Message-Id: <33FCC142.548C@hackberry.chem.niu.edu>

Roddy Knight wrote:
> 
> Hello,
> I recently wrote a script to automate account registration on my UNIX box.
> I am recently new to the CGI.pm module.  The script I wrote runs fine
                                                              ^^^^^^^^

meaning presumably that it creates the form;

 but
> the web browser doesn't send the information entered in the textfields back
> the the CGI script.  The web browser attempts to download the output >of the
> script to the hard drive.  

I'd guess that 
your server doesn't recognize the script is to be run as CGI.
I'm curious though why all the parameters are missing,
 e.g start_form()


Can anyone give me some help with my script.
> Here is a copy:
> 
> #!/usr/bin/perl -w
> use 5.004;
> use strict;
> use CGI qw(:standard);
> 
> my $writestring = "\r";
> my $password = param("password");
> my $Sender = "account_request\@csus.com";
> my $Address = "root\@student.csus.com";
> my $Subject = "Account Request Automated Form Entry";
> my $username = param("username");
> my $name = param("name");
> print header, start_html("New Account Request Form"), h1("Account Request Form")
> ;
> sub send_mail {
>   if (!open(PIPE, "|/usr/lib/sendmail -t"))
>          {
>          print p("Unable to open pipe to sendmail for msg\n");
> 
>          }
> 
>       select (PIPE);
>       syswrite (STDOUT, "$writestring", 5);
>       $!=1;
> 
>       print <<EOT;
> From: $Sender
> To: $Address
> Subject: $Subject
> \r\n
> $name wants an account as $username with $password as his/her password.
> \r\n\r\n
> 
> EOT
>       close(PIPE);
>       select(STDOUT);
> }
> 
> if(param()) {
>   send_mail();
> print p("Your request form has been processed.  You will be contacted when your
> new account has been created."), hr();
> 
> } else {
>   print hr(), start_form();
>   print p("What is your full name: ", textfield("name"));
>   print p("What username would you like: ", textfield("username"));
>   print p("What password would you like: ", textfield("password"));
>   print p(submit("submit"), reset("clear"));
>   print end_form(), hr();
> }
> print end_html();
> exit;
> 
> --
> Remove "NOSPAM" from e-mail address to send e-mail

-- 
==========================================================
 - darin
burleigh@hackberry.chem.niu.edu
\\//\\//.\\//\\//.\\//\\//. http://hackberry.chem.niu.edu/HOME/dcb/
 '2 kinds of green, look out!' - dieter rot


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

Date: 21 Aug 1997 21:19:36 GMT
From: hachen@cs.umn.edu (Haizhou Chen)
Subject: Re: How to use the Filter module?
Message-Id: <5tibd8$osc@epx.cis.umn.edu>

pmarquess@bfsec.bt.co.uk (Paul Marquess) writes:

>Haizhou Chen (hachen@cs.umn.edu) wrote:
>: Hi,

>:   I am wondering how to use the Filter module. I downloaded the module from
>: CPAN and read the man page. It didn't quite make sense to me.

>:  What I want to do is this: Filter my Perl source and produce something like



>: #!/usr/local/bin/perl

>: use MyFilter;

>: *Il~k^j#%$%^*&&(()JGHIngtotyyy&&(((((!@#$%%nnnnudu
>: .....
>: .....




>: And this this program can be decrypted and executed. Anybody has the
>: experience of doing it?

>Yes, I wrote it. What do you not understand?

>Paul


I have a simple program like this:

#!/usr/local/bin/perl

print "Hello, World.\n"


Please tell me how to encrypt the program and the program can be run.

Thank you.


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

Date: 21 Aug 1997 13:38:32 -0400
From: brenner@slpyff.ed.ray.com (Leonhard Brenner)
Subject: if (/htm/ && !/html/) {
Message-Id: <su2iuwz8mhz.fsf@slpyff.ed.ray.com>

I'll keep it brief, I know there another way but I'm braindead today.

    if (/\.htm/ && !/\.html/) {
      print "Changing file name!\n";
    }

Thank in advance for any help!
	Lenny Brenner(brenner@ed.ray.com, brenner@lbrenner.ne.mediaone.net)


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

Date: 21 Aug 1997 20:42:47 GMT
From: sff@gus.boc.com (Susan_Farenci)
Subject: line by line comparison of two files
Message-Id: <5ti987$so@tmp.boc.com>

Hi,

Newbie question:

Using perl, how would I go about comparing each line
of FILE1 to each line of FILE2 in search of a match?  I
can't figure out how iterate through both files
simultaneously.  I've tried while loops and its not working.

I will be breaking $_ in both files into array elements
and trying to match a couple of elements, writing to
a third file if element1 in both file strings match
but element2 does not.

My "not working" program below:

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

#!/usr/local/bin/perl
 
open (MURA10LP,"/tmp/lslpp.mura10");
open (MURA30LP,"/tmp/lslpp.mura30");
open (OUTFILE,">/tmp/comparelp.out");
ATTEMPT:
{
   while(<MURA30LP>)
   {
        ($dir30, $pkg30, $ver30, $state30, $desc30)=split(/:/);
        ATTEMPT2:
        {
           while(<MURA10LP>)
           {
                ($dir10, $pkg10, $ver10, $state10, $desc10)=split(/:/);
                if ($pkg30 !~ $pkg10)
                {
                   next ATTEMPT2;
                }
                else
                {
                   if ($ver30 !~ $ver10)
                   {
                           print "MURA30 $pkg:$ver VS. MURA10 $pkg:$ver\n";
                           next ATTEMPT;
                   }
                }
           }
        }
    }
}


-- 

TIA,

===================================================
Susan Farenci			
BOC Group			
460 Mountain Avenue
Murray Hill, NJ 07974
sff@im.gus.boc.com	




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

Date: Thu, 21 Aug 1997 18:36:48 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: line by line comparison of two files
Message-Id: <gejit5.gkg.ln@localhost>

Susan_Farenci (sff@gus.boc.com) wrote:
: Hi,

: Newbie question:

: Using perl, how would I go about comparing each line
: of FILE1 to each line of FILE2 in search of a match?  I
: can't figure out how iterate through both files
: simultaneously.  I've tried while loops and its not working.
                                                  ^^^^^^^^^^^

That's not a very helpful observation of your program's behavior...


: I will be breaking $_ in both files into array elements
: and trying to match a couple of elements, writing to
: a third file if element1 in both file strings match
: but element2 does not.

: My "not working" program below:
      ^^^^^^^^^^^

That's not a very helpful observation of your program's behavior.  ;-)


: ------------------------------------------------------

: #!/usr/local/bin/perl

Of course your real code has the -w switch so that perl can help
you find your mistakes...

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

: open (MURA10LP,"/tmp/lslpp.mura10");
: open (MURA30LP,"/tmp/lslpp.mura30");
: open (OUTFILE,">/tmp/comparelp.out");

Your real code also checks the return values, and provides a helpful
diagnostic message, should any of the above open() calls fail.

   open (MURA10LP,'/tmp/lslpp.mura10') || 
      die "could not open '/tmp/lslpp.mura10'  $!";


: ATTEMPT:
: {
:    while(<MURA30LP>)

perl magically puts the line from the MURA30LP filehandle into the
$_ variable for you...


:    {
:         ($dir30, $pkg30, $ver30, $state30, $desc30)=split(/:/);
:         ATTEMPT2:
:         {
:            while(<MURA10LP>)

perl magically puts the line from the MURA10LP filehandle into the
$_ variable for you, overwriting whatever was there from the earlier
read from the MURA30LP filehandle...


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 21 Aug 1997 19:35:04 -0600
From: sunil@aquas.com
To: spoddar@cisco.com
Subject: Need a routine to check for DATE
Message-Id: <872209251.9481@dejanews.com>

Hi there,

I am looking for a way to check validity of the input date.
The date can be in mm/dd/yyyy format. I need routine which will
do leap year and other normal checks for validity of the date.
Please send me code if you  have or give me location where i
can get it.

Thanks,
Sunil

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


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

Date: 21 Aug 1997 21:27:59 GMT
From: ai4net@aol.com (Ai4net)
Subject: opening
Message-Id: <19970821212700.RAA22616@ladder01.news.aol.com>

Opening for PROLOG, Internet and AI programming in California. Great R&D,
high tech environment near the beach.  If you are a good prolog
programmer, a team player, and can deliver clean good code as well as the
know-how of converting new ideas to prolog programs, send resume via
email:   Ai4net@aol.com


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

Date: Thu, 21 Aug 1997 20:51:27 +0100
From: Mark Worsdall <jaydee@worsdall.demon.co.uk>
Subject: Re: Passing 1 programs O/P to anothers I/P via file handles
Message-Id: <FvncLFA$wJ$zEwfN@worsdall.demon.co.uk>

In article <EF9o6H.Mux@world.std.com>, "Andrew M. Langmead"
<aml@world.std.com> writes
>Mark Worsdall <jaydee@worsdall.demon.co.uk> writes:
>
[SNIP]

I thank you all for your suggestions, It has been a long time since
joining a group and getting such quick responses! I will let you all
know which worked best. The File::copy ones looks good but since
traceroute is going to take it's time in bouncing round the net then I
guess transfer speed of characters into mail is not an issue. that is to
say it takes quite a fewe milleseconds between each line of traceroute's
o/p.
-- 
Mark Worsdall - Oh no, I've run out of underpants :(
Home:- jaydee@worsdall.demon.co.uk  WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmaster@shadow.org.uk    WEB site:- http://www.shadow.org.uk


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

Date: 21 Aug 97 15:16:32 GMT
From: anne@cs.sunysb.edu (Anne Kilarjian)
Subject: Perl 5.004_01 tests fail w/ SunOS 4.1.4
Message-Id: <33fc5bd0.0@news.ic.sunysb.edu>

I compiled up Perl 5.004_01 under SunOS 4.1.4.  The compile goes
OK but 4 of the tests fail with the following errors:
 
Failed Test  Status Wstat Total Fail  Failed  List of failed
------------------------------------------------------------------------------
lib/anydbm.t    127 32512    ??   ??       %  ??
lib/gdbm.t      127 32512    ??   ??       %  ??
lib/ndbm.t      127 32512    ??   ??       %  ??
lib/odbm.t      127 32512    ??   ??       %  ??
 
(errors generated:)
 
ld.so: call to undefined procedure _dbm_open from 0xf7762180
ld.so: Undefined symbol: ___builtin_alloca
ld.so: call to undefined procedure _dbm_open from 0xf7762180
ld.so: call to undefined procedure _creat from 0xf77661b8
 
Everything worked fine under SunOS 4.1.3, any ideas about whats
going on here?
 
Thanks in advance -
 
Anne Kilarjian
SUNY Stony Brook
anne@cs.sunysb.edu



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

Date: 21 Aug 1997 07:13:13 GMT
From: "Andrew Collins" <anc@sec.cpg.sony.co.jp>
Subject: Re: Perl and OLE Automation
Message-Id: <01bcae02$79844350$d28b002b@se1ql56>


I will answer my own question to the first part of it, however, still
haven't figured out how to get the returns, and ideas?

> method or property returns an embedded OLE object then perl will
> automatically treat it as a perl object itself... the cited example
is....
> 
> $object->dad->grandad->tell_old_war_stories();
> 

This can be done by using the property dad in object

[propget] Dad([out, retval] IDispatch** oppDispatch);

Perl then resolves the dispatch interface, grandad is similar




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

Date: 21 Aug 1997 21:16:52 GMT
From: nigelr@convex.hp.com (Nigel Reed)
Subject: Question about arrays.
Message-Id: <5tib84$6bq$1@news.rsn.hp.com>

Tomorrow, I'm going to be working on a program to process a file
It'll be in the format

char(8),int,int,int,int,int

Now, what I am going to want to do, is all up all the integer
values for all occurences of char.

For example.

Andy,1,6,5,3,6
Andy,5,6,3,5,2
Bill,5,3,1,4,6
Bill,6,7,3,3,1
Ted,1,5,9,7,5
Tom,4,5,6,2,1

I need to end up with an array like this
Andy,6,12,8,8,8
Bill,11,10,4,7,7
Ted,1,5,9,7,5
Tom,4,5,6,2,1


And so on. Has anyone already written a routine to do this?
(The file is already pre-sorted alphabetically) and I can easily
read in the file in perl, it's just the code to produce the
new array )


TIA

Nigel


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

Date: Thu, 21 Aug 1997 18:51:07 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Question about arrays.
Message-Id: <b9kit5.mlg.ln@localhost>

Nigel Reed (nigelr@convex.hp.com) wrote:

: It'll be in the format

: char(8),int,int,int,int,int

: Now, what I am going to want to do, is all up all the integer
                                         ^^^^^^
                                         ^^^^^^ sum up, I assume?
: values for all occurences of char.

: For example.

: Andy,1,6,5,3,6
: Andy,5,6,3,5,2
: Bill,5,3,1,4,6
: Bill,6,7,3,3,1
: Ted,1,5,9,7,5
: Tom,4,5,6,2,1

: I need to end up with an array like this
: Andy,6,12,8,8,8
: Bill,11,10,4,7,7
: Ted,1,5,9,7,5
: Tom,4,5,6,2,1

: And so on. Has anyone already written a routine to do this?

Probably. But as it would only take ten minutes to write from
scratch, I would not have bothered saving it.


: (The file is already pre-sorted alphabetically) and I can easily
: read in the file in perl, it's just the code to produce the
: new array )


I'll donate ten minutes:

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

while (<DATA>) {
   chomp;
   ($name, @ints) = split /,/;

   if (exists $sum{$name}) {                # add to the values already there
      @sum_ints = split /,/, $sum{$name};   # get the sums so far

      die "arrays do not have the same number of elements"
         unless @ints == @sum_ints;

      for ($i=0; $i<@sum_ints; $i++) {
         $sum_ints[$i] += $ints[$i];        # add to the sum
      }

      $sum{$name} = join ',', @sum_ints;    # put the summed up fields back in
   }
   else {                                   # set the initial values
      $sum{$name} = join ',', @ints;
   }
}

foreach (sort keys %sum) {
   print "$_,$sum{$_}\n";
}


__DATA__
Andy,1,6,5,3,6
Andy,5,6,3,5,2
Bill,5,3,1,4,6
Bill,6,7,3,3,1
Ted,1,5,9,7,5
Tom,4,5,6,2,1
----------------------


This would be better if written using a hash of arrays instead of 
all of that splitting and joining. See the 'perllol' man page if
you really want to do it right.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 21 Aug 1997 18:32:18 -0400
From: Glen Culbertson <nnyxcu@ny.ubs.com>
To: John Devlin <devli002@gold.tc.umn.edu>
Subject: Re: Redirecting output......
Message-Id: <33FCC1F2.7845@ny.ubs.com>

John Devlin wrote:
> 
> I am running a server level cobol program which is executed by a script.
> The output of this program is displayed to the screen.  How do redirect
> this output to a file in PERL?  I tried the following, but it did not
> work:
> 

I think the problem is in your redirection--you probably want STDOUT
rather
than STDERR.

> $_ = `cd /directory_where_the_executable_script_resides; ./script >>
                                                                    ^^
                                                                    >

> /mydirectory/file_I_want_the_output_to_go`;


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

Date: Thu, 21 Aug 1997 18:19:39 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Redirecting output......
Message-Id: <beiit5.4ig.ln@localhost>

Glen Culbertson (nnyxcu@ny.ubs.com) wrote:
: John Devlin wrote:
: > 
: > I am running a server level cobol program which is executed by a script.
: > The output of this program is displayed to the screen.  How do redirect
: > this output to a file in PERL?  I tried the following, but it did not
: > work:
: > 

: I think the problem is in your redirection--you probably want STDOUT
  ^^^^^^^^^^^^^^^^^^^^^^

I think the problem is that you use backticks when you want to
*capture the output* into your Perl script.

You are using a wrench for a hammer if you are using backticks to put
the output somewhere else (it may mostly work, but you are eventually
going to hit the wrong nail).


Just use system() (or a pipe open()) instead.


: rather
: than STDERR.

I'm looking at the below, but I'm not seeing any redirections of STDERR
at all.

Where is he specifying STDERR?


: > $_ = `cd /directory_where_the_executable_script_resides; ./script >>
:                                                                     ^^

That is STDOUT there...

:                                                                     >

That is also STDOUT...


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 21 Aug 1997 23:00:31 GMT
From: "Peter Douglas" <rmanocha@rocketmail.com>
Subject: Search Engine scripts ?
Message-Id: <01bcae86$99c66ce0$384daf80@the-psycho.udel.edu>

Hi,

I am developing a search engine for a company. The search engine is
probably going to be in a similar format as yahoo or search.com where you
can search through many categories. 

I am looking for a script (preferably free) which does a similar thing.

All help will be appreciated.

Thanks.


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

Date: Thu, 21 Aug 1997 20:55:48 +0100
From: Mark Worsdall <jaydee@worsdall.demon.co.uk>
Subject: Searching for an email administaion group
Message-Id: <DfJdnKAE1J$zEw94@worsdall.demon.co.uk>

Hi,

I am looking for a news group that will have info on email, that is to
say, the organisation that has all the email names etc. I think there is
one as that was the one that fell over a bit ago?

Alternatively has anyone managed to get perl to read the Computers
Organization name and Person's name once it has determined the OS is
Windows (mainly Win95)?
-- 
Mark Worsdall - Oh no, I've run out of underpants :(
Home:- jaydee@worsdall.demon.co.uk  WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmaster@shadow.org.uk    WEB site:- http://www.shadow.org.uk


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

Date: Tue, 19 Aug 1997 01:55:42 -0700
From: "Mark J. Schaal" <mark@tstonramp.com>
Subject: Re: Socket problem. Works once only...
Message-Id: <33F95F8E.6C9E@tstonramp.com>

Worik Macky Stanton wrote:
> 
> What is it that I am doing wrong?
> The server and client both work once, but not again.
> This is consistent, and a show stopper!
> 
> # Script 1
> 
> require "cnt.pl";
> use strict;
> for(;;){
>     my $c;
>     while(!defined $c){$c = &client;}
>     my @a = ("This is the reply");
>     &server(\@a);
> }
> 
> 
> #cnt.pl
> 
> use Socket;
> use strict;
> 1;
> sub client {
>     my($remote, $port, $iaddr, $paddr, $proto, $line);
>     $remote = shift || 'localhost';
>     $port = shift || 2345;
>     if($port =~ /\D/){ $port = getservbyname($port, 'tcp')}
>     die "no port" unless $port;
>     $iaddr = inet_aton($remote) or die "No host: $remote";
>     $paddr = sockaddr_in($port, $iaddr);
>     socket(SOCK,PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
>     connect(SOCK, $paddr) or return undef;
>     while($line = <SOCK>){
>         print $line;
>     }
>     close SOCK or die "close $!";
>     return $line;
> }

The problem is in the client sections, so I stripped out the server
section.  The while loop in client() only exits if $line is undefined
(or 0 but that doesn't happen here).  It then returns undef and
thus script merrily continues to call client() rather than moving
on to the server() section as desired.

I assume you are just experimenting and know it's pretty unusual
(not to mention inefficient) to use sockets this way.  Mostly
sockets behave like filehandles so you can both read and write
to them just fine.  Socket do buffering slightly differently so
you'll want to enable autoflush on them.

Also, take a look at IO::Socket as it does nicely encapsulate
socket code.  

Hope this helps,

mark
--
Mark J. Schaal		TST On Ramp Sysadmin	mark@tstonramp.com


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

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

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