[11183] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4783 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 30 02:07:26 1999

Date: Fri, 29 Jan 99 23:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 29 Jan 1999     Volume: 8 Number: 4783

Today's topics:
        @xyz = {}; and @xyz = (); What do these mean? (R. Nottrott)
    Re: @xyz = {}; and @xyz = (); What do these mean? <rra@stanford.edu>
    Re: @xyz = {}; and @xyz = (); What do these mean? (Larry Rosler)
    Re: Can someone give me information as to where i could <perlgirl@my-dejanews.com>
    Re: converting %20 to spaces, etc <jdf@pobox.com>
    Re: converting %20 to spaces, etc (Larry Rosler)
    Re: Deleting dupes with Perl <bik@benton.com>
        Embedding a perl interpreter in C hemantp@duettech.com
    Re: Fixed width, but varying # of fields - better way? <staffan@ngb.se>
    Re: Fixed width, but varying # of fields - better way? (Tad McClellan)
    Re: Getting the last number in an IP addr with a regex. <mds-resource@mediaone.net>
        Help a newbie Please. <rblake@brookes.ac.uk>
    Re: Help on deleting an item in an array? (Greg Andrews)
    Re: Help with RE for separate Perl codes and comments (Tad McClellan)
        Help: POST doesnt work!!! <mkshanx@ust.hk>
    Re: how to pass scalars AND variables to a sub? <staffan@ngb.se>
    Re: how to pass scalars AND variables to a sub? <jdf@pobox.com>
        Multi Line Print rsarcomo@my-dejanews.com
    Re: Multi Line Print <abey@hill.ucr.edu>
        Parsing FTP Directory listing <gpace@i-2000.com>
        Perl 4 question (JoeJoeInMB)
        Perl and OO   :Someone help !! (Thapliyal)
    Re: Perl Criticism [summary] <mds-resource@mediaone.net>
    Re: Perl Criticism <mds-resource@mediaone.net>
    Re: Perl Threads <sugalskd@netserve.ous.edu>
    Re: Simple Perl Function Question for ya <bik@benton.com>
    Re: strange behaviour with tr/// <uri@home.sysarch.com>
    Re: substr() Assistance still needed (Tad McClellan)
        Sys::Syslog trouble... <phraktyl@home.com>
        Test... Ignore... <phraktyl@home.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 29 Jan 1999 21:51:53 GMT
From: RNott@LTERnet.edu (R. Nottrott)
Subject: @xyz = {}; and @xyz = (); What do these mean?
Message-Id: <78tahf$h2f@yuggoth.ucsb.edu>

Having done most of my programming in C and Java, I am somewhat shaky
with certain Perl constructs.  Would someone out there please help by
explaining the meaning following declarations (or if they are not
declarations what are they ?).  Both occur at the beginning of a perl
script:

@xyz = {};
@uvw = ();

They look like arrays, but what about the {} versus ()?

Thanks for your help, 

R. Nottrott
UCSB



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

Date: 29 Jan 1999 19:08:42 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: @xyz = {}; and @xyz = (); What do these mean?
Message-Id: <yln23131ad.fsf@windlord.stanford.edu>

R Nottrott <RNott@LTERnet.edu> writes:

> Having done most of my programming in C and Java, I am somewhat shaky
> with certain Perl constructs.  Would someone out there please help by
> explaining the meaning following declarations (or if they are not
> declarations what are they ?).  Both occur at the beginning of a perl
> script:

> @xyz = {};
> @uvw = ();

> They look like arrays, but what about the {} versus ()?

The second one clears @uvw, basically.  It sets @uvw equal to the empty
list, which is similar (but not quite the same) as undef @uvw.  There's
*probably* no point in doing that initialization if it's just at the
beginning of the script.

The first one may be an error.  {} is the empty anonymous hash.  @xyz = {}
puts the list ({}) into @xyz; in other words, it sets @xyz to the
one-element list containing a reference to an empty anonymous hash.  I can
see times when you'd want to do this, but it's sort of odd.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Fri, 29 Jan 1999 19:54:52 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: @xyz = {}; and @xyz = (); What do these mean?
Message-Id: <MPG.111c2263b8b5d5359899e3@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <78tahf$h2f@yuggoth.ucsb.edu> on Fri, 29 Jan 1999 21:51:53 
GMT, R. Nottrott <RNott@LTERnet.edu> says...
> Having done most of my programming in C and Java, I am somewhat shaky
> with certain Perl constructs.  Would someone out there please help by
> explaining the meaning following declarations (or if they are not
> declarations what are they ?).  Both occur at the beginning of a perl
> script:
> 
> @xyz = {};

This makes @xyz an array with one element, which is a reference to an 
empty anonymous hash.

> @uvw = ();

This makes @uvw an empty array (no elements).
 
> They look like arrays, but what about the {} versus ()?

There's also:

  @foo = [];

which makes @foo an array with one element, which is a reference to an 
empty anonymous array.

Read perldata for more.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 30 Jan 1999 01:55:04 GMT
From: perlgirl <perlgirl@my-dejanews.com>
Subject: Re: Can someone give me information as to where i could find a perl version for windows 3.1
Message-Id: <78topl$mb9$1@nnrp1.dejanews.com>

I've not seen (nor have I looked for) Perl for 16-bit Windows.	The source I
use for the most recent news of ports is http://www.perl.com/PAN/ports .  The
READMEs (at which I glanced a couple of moments ago) do not make mention of
Win 3.1 specifically, but you may find info of value.

Barb

In article <36AF4DE0.3955@hotmail.com>,
  siv <shivapal@hotmail.com> wrote:
> Hai,
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 30 Jan 1999 03:04:18 +0100
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: converting %20 to spaces, etc
Message-Id: <m3yamlzfbx.fsf@joshua.panix.com>

Jonathan Feinberg <jdf@pobox.com> writes:

> Get the libwww module suite from the CPAN, and use URI::Escape.

I apologize; the URI modules don't come with libwww.  You must install 
them independently.

  $ perl -MCPAN -e shell

  cpan> install URI

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Fri, 29 Jan 1999 20:16:34 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: converting %20 to spaces, etc
Message-Id: <MPG.111c2773c8e93d209899e4@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <78tmls$koe$1@nnrp1.dejanews.com> on Sat, 30 Jan 1999 
01:19:00 GMT, cliffl@andrew.cmu.edu <cliffl@andrew.cmu.edu> says...
> What's the easiest way to converts a string with non-alphanumeric chars to %xx
> like spaces to %20?
> 
> What I want to do is taking something like:
> 
> //friedrice/mp3/(Chopin) Nocturne in E Flat - Opus 9 No. 2.mp3
> 
> And convert it to a HREF:
> 
> <A
> HREF="//friedrice/mp3/%28Chopin%29%20Nocturne%20in%20E%20Flat%20-%20Opus%209%2
> 0No.%202.mp3"><IMG ALIGN=absbottom BORDER=0 SRC="internal-gopher-unknown">
> (Chopin) Nocturne in E Flat - Opus 9 No. 2.mp3</A>

First you have to decide what are 'non-alphanumeric chars' that you want 
to convert.  In your own example, you do not convert '/' '-' or '.' 
which most people would consider to be non-alphanumeric.

Having decided that, either by enumeration of the characters to convert 
or those not to convert, it is easy (and you don't need a module :-).

    s#([^\w./-])#sprintf '%%%.2X', ord $1#eg;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 29 Jan 1999 23:43:37 -0500
From: "Bik Dhaliwal" <bik@benton.com>
Subject: Re: Deleting dupes with Perl
Message-Id: <36b28d78.0@news.cgocable.net>

If you are not adverse to sending the data to a file and then
performing the following on it:.

sort filename|uniq

Works nicely and is very quick.


aqumsieh@matrox.com <@l@> wrote in message
<78r8t9$gc4$1@nnrp1.dejanews.com>...
>In article <78km8q$ss6$1@nnrp1.dejanews.com>,
>  jxdub@my-dejanews.com wrote:
>
>> I've written enough
>> to send a report out with all the users names, but now I need to delete
the
>> duplicates...  Could anyone tell me a good way to do this? The file would
>> look like this:
>>
>> jonesfw
>> smithjd
>> jonesfw
>> doejf
>> smithjd
>>
>> And I need to send a report with only:
>>
>> jonesfw
>> smithjd
>> doejf
>
>Well, my first suggestion would be to read the file, line by line, and
store
>each name in a hash. Of course, the names would be the keys of the hash.
>
>while (<>) {
> chomp;
> $hash{$_} = 1;
>}
>
>Then you can retrieve the unique names simply by:
>
>@names = keys %hash;
>
>My second suggestion would be to read the FAQs (actually that should've
been
>my first one .. )
>
>From perlfaq4:
>
>     How can I extract just the unique elements of an array?
>
>Several nice methods are outlined there.
>
>Hope this helps,
>
>Ala
>$monger->{montreal}->[0]
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own




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

Date: Sat, 30 Jan 1999 05:37:55 GMT
From: hemantp@duettech.com
Subject: Embedding a perl interpreter in C
Message-Id: <78u5ri$10l$1@nnrp1.dejanews.com>

Hi,
        I am embedding perl interpreter in my C program as :

/************************************************************/
#include <stdio.h>
#include <EXTERN.h>
#include <perl.h>
static PerlInterpreter *usePerlInterpreter;

main(int argc, char** argv)
{
    usePerlInterpreter = perl_alloc();
    perl_construct(usePerlInterpreter);
    perl_parse(usePerlInterpreter,NULL,argc,argv,(char**)NULL);
    perl_run(usePerlInterpreter);
    perl_destruct(usePerlInterpreter);
    perl_free(usePerlInterpreter);
}
/*******************************************************/

when compiled suppose it created executable with name "myinterpreter"
I am running it like
        % > myinterpreter my1.pl my2.pl my3.pl

        where my1.pl,my2.pl and my3.pl are my perl scripts which I
want to run through the interpreter.

But It only runs the first script my1.pl and comes out.
Is it possible in perl to parse all the scripts given to the program
at once and run them later one by one.

The purpose I am doing this is later on my application program would call one
perl subroutine which may be in one perl script and would call another perl
subroutine which could be in another perl script given on the command line.

Assume I would be knowing the subroutine names beforehand and
I would use perl_call_pv to call these.

If it is possible can you please tell me how ?

Best Regards,
Hemant


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 30 Jan 1999 03:56:25 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Fixed width, but varying # of fields - better way?
Message-Id: <36B274D9.E92AEA17@ngb.se>

Terry Haroldson wrote:
> Is there an easier way to do this?  It seems cumbersome, although it
> does it work.

It seems more natural to use substr.

Staffan


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

Date: Sat, 30 Jan 1999 00:39:45 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Fixed width, but varying # of fields - better way?
Message-Id: <hf9u87.7l2.ln@magna.metronet.com>

Terry Haroldson (tharoldson@home.com) wrote:
: Is there an easier way to do this?  It seems cumbersome, although it
: does it work.


   unpack()


: How can I parse out this data that is somewhat fixed in length, but not
: all fields are always present.  My data looks something like this:

: BAD PAIR        ---      ---      -                     *2R201/237

[snip]

: I want to get the data in an array, so I put it out in comma-delimited
: format, so I would like to see:

: BAD PAIR,---,---,-,,*2R201/237	-- note 2 successive commas are important

: It may not be clear above, 


   No it isn't.

   It is clear below though  :-)


: but I know what the start column of each
: field is (ie: 1,17,26,35,41,55,69,83,97).


: Like I say, this does work, but thought there may be an easier way.
: :
: Elsif
: (/^(.{16})(.{9})(.{9})(.{6})(.{0,14})(.{0,14})(.{0,14})(.{0,14})(.{0,14})/) 
: {    
:       @data = ($1,$2,$3,$4,$5,$6,$7,$8,$9);
:       for ($i = 0; $i <=8; $i++) {

   You are writing C code with Perl there.

   You don't _need_ access to the subscripts.


:         $data[$i] =~ s/^\s+//;		# remove leading spaces
:         $data[$i] =~ s/\s+$//;		# remove trailing spaces
:       }
:       $a = join(",", @data);
:       print LOG "$a\n";


   You don't need the temp variable either.



      @data = unpack "a16 a9 a9 a6 a14 a14 a14 a14 a14", $_;
      foreach (@data) {
         s/^\s+//;          # remove leading spaces
         s/\s+$//;          # remove trailing spaces
      }
      print join(',', @data), "\n";


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 29 Jan 1999 21:43:03 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Getting the last number in an IP addr with a regex.
Message-Id: <36B27FC7.6157D7EC@mediaone.net>

Actually, it's too close to call, in this simplest of all contexts ;)

D:\PERL5\TMP>mds.plx
Benchmark: timing 1000000 iterations of anchor, greedy...
    anchor: 24 wallclock secs (18.52 usr +  4.55 sys = 23.06 CPU)
    greedy: 22 wallclock secs (19.02 usr +  4.00 sys = 23.01 CPU)

#!d:/perl5/5.00502.egcs/MSWin32-x86/perl.exe -w
use Benchmark;
timethese (1000000, {
        'greedy' => q{
			for (<DATA>) {
				/.*\.(\d+)/;
			}
        },
        'anchor' => q{
			for (<DATA>) {
				/\.(\d+)$/;
			}
        },
});

exit 0;

__DATA__
123.231.213.12
245.543.109.234
4.5.6.7
8.9.0.1
23.45.67.89
012.3.145.255
9.01.234.6
78.201.53.199
155.155.6.159
144.156.170.137


Steve Alpert wrote:
> 
> Ala Qumsieh <aqumsieh@matrox.com> wrote:
> 
> >"Kim Saunders" <kims@tip.net.au> writes:
> >
> >> could someone please help me with a regex to give me the last number in an
> >> IP address with a regex???
> >
> >If that is all that you need then:
> >
> >my $ip = '127.0.0.1';
> >
> >my ($last_no) = ($ip =~ /\.(\d+)$/);
> 
> how 'bout:
> 
> perl -e " $x = '1.4.2.8.9'; $x =~ /.*\.(\d+)/; print $1;"
> 
> put greed to your advantage!

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "


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

Date: Thu, 28 Jan 1999 15:13:31 -0000
From: "Rob Blake" <rblake@brookes.ac.uk>
Subject: Help a newbie Please.
Message-Id: <78purb$b81$1@cs3.brookes.ac.uk>

I need some help, I've just downloaded the BNBFORM script however when I try
to compile it I get an error.

Can't find string terminator "__W9__" anywhere before EOF at bnbform.cgi
line 140.

I've tried to comment this line out then I get loads of extra errors, if
anyone would be able to help me I would be grateful,


Rob
rblake@brookes.ac.uk




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

Date: 29 Jan 1999 18:19:58 -0800
From: gerg@shell1.ncal.verio.com (Greg Andrews)
Subject: Re: Help on deleting an item in an array?
Message-Id: <78tq8e$c46$1@shell1.ncal.verio.com>

"Chris Denman" <c-denman@dircon.co.uk> writes:
>I need to do this, but it is obviously wrong:
>
>undef $fred[6];
>
>$fred[6] needs to be completely erased, and all others shifted down.
>
>Any ideas anyone?
>

The other folks have pointed you to the splice command.

One other note:  If you're going to delete more than one
element of an array, then you will probably want to delete
from the last element to the first.  I.e. delete them
backwards.

For example, if you want to delete $fred[6], $fred[9],
and $fred[13], then you want to delete $fred[13] first,
then $fred[9], and $fred[6] last.

The reason is, after you delete a low-numbered element,
the higher-numbered ones shift down.  After that, $fred[9]
has become $fred[8].  When you try to delete $fred[9], you'll
delete the wrong one.  When you go backwards, you won't have
that problem.

Hope this helps,

  -Greg


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

Date: Sat, 30 Jan 1999 00:08:16 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with RE for separate Perl codes and comments
Message-Id: <gk7u87.7l2.ln@magna.metronet.com>

Bruce McEachern (brucem@library.ucdavis.edu) wrote:
: >Tad McClellan wrote:...
: >  :
: >  :
: > : Jerry Chen <016781c@acadiau.ca> writes:
: > : > 
: > : > I have some difficulties to parse Perl code to identify
: > : > the source part and comment part using regular expression...
: >  :
: >  :
: >    There are other uses for # though...
: > 
: >       s#</a>##;  # so long anchor end tags...
: >
: >    That leaves the single character 's' for the example line above.
: > 
: >    Jerry heard right. It is difficult....

: Tad,

: Sorry to reply to you, but you provided the most astute example of
: the difficulties here. 


   I belive Greg Ward's followup was the most astute.

   He both invoked TomC's "only perl can parse Perl" saying
   and gave a pointer into perl's source.

   The reason the saying lives on is that it pretty much sums
   it up. If you can live with sub-perfect parsing, then have
   at it. But that seems unsatisfying...


: And, sorry to resurrect this ancient thread
: (1 week!) but this is exactly why I came up to Usenet this time
: around. Hasn't anybody done this in a comprehensive fashion and
: posted it in CPAN? (I haven't found anything, does anybody know of
: such?)


   Yes.

   They call it perl.


: It seems to me the crux of the problem is that we have to except
: all quotish type situations and, perhaps, some functionals (eg,
: eval() ). 

: I know little about it, but I believe a finite state
: table-driven parse should do it--and I think it may be fairly
: easy to construct in Perl. It's just that I'd just as soon not
: re-invent the wheel. (Not to mention that I didn't major in CS,
: so I never got any formal training in doing such things as
: table-driven parsers.)


   There are hundreds of Perl folks that _do_ have formal training
   in these things, yet it remains undone.

   That in itself seems a powerful insight into the difficulty
   of what you propose...


: If you, or anyone, can point me in a direction to find out about
: anything already done in this regard, I'd appreciate it. Maybe
: some help from Larry on how Perl parses Perl. Thanks for anything,


   If you are adventurous, perl's source is there for the looking.

   When you get it written, a good test might be to use no
   comments in your code, and ensure that it leaves things
   unchanged when you run it against itself  :-)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 30 Jan 1999 13:11:10 +0800
From: Shashank Tripathi <mkshanx@ust.hk>
Subject: Help: POST doesnt work!!!
Message-Id: <Pine.GSO.3.95L.990130130855.15727A-100000@uststf1>

Hello, 

My ISP is nonplussed about something: all my CGI scripts that have the
ACTION=GET in their forms work, but the method POST doesnt work, it gives
a server error, sometimes also that "Post is not supported on this
server". 

I hope this is not the wron place to ask about this. I would appreciate
what I can do/who I can contact/which group I should post to to find out
what changes I need to do, or my ISP needs to do to have the ACTION=POST
running. 

Thanks very much for your time. 

Best regards,
Shanx



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

Date: Sat, 30 Jan 1999 03:52:31 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: how to pass scalars AND variables to a sub?
Message-Id: <36B273EF.74369BF4@ngb.se>

Thomas Ruedas wrote:
> Each entry of @all looks like this:
>    9901251819 17.  4.29 N   75.68 W   33  5.8  COLOMBIA
>         @dummy=split(/ /,$_);

If you really mean this, there is an error with the split. 

	@dummy = split(/ +/);

Since there seems to be one _or__more_ spaces between the items above,
the split splits out some empty items to the list. 

HTH
Staffan


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

Date: 30 Jan 1999 05:55:25 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Staffan Liljas <staffan@ngb.se>
Subject: Re: how to pass scalars AND variables to a sub?
Message-Id: <m3ww25z7eq.fsf@joshua.panix.com>

Staffan Liljas <staffan@ngb.se> writes:

> Thomas Ruedas wrote:
> > Each entry of @all looks like this:
> >    9901251819 17.  4.29 N   75.68 W   33  5.8  COLOMBIA
> >         @dummy=split(/ /,$_);
> 
> If you really mean this, there is an error with the split. 
> 
> 	@dummy = split(/ +/);

I think

   split ' ', $_;

or just the default

   split

is preferred, since those will automatically discard inital spaces,
whereas / +/ will give you null initial fields (and also fails to
account for whitespace other than space).

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Sat, 30 Jan 1999 04:07:00 GMT
From: rsarcomo@my-dejanews.com
Subject: Multi Line Print
Message-Id: <78u0h0$sis$1@nnrp1.dejanews.com>

On my Linux box, this works fine:

print <<ENDING;
Hello
World
ENDING

On my NT box running ActiveState Perl, it fails with an error of "Can't find
string terminator "ENDING" anywhere before EOF at test.pl line 1."

Any ideas?

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 29 Jan 1999 21:11:09 -0800
From: Abraham Grief <abey@hill.ucr.edu>
To: rsarcomo@my-dejanews.com
Subject: Re: Multi Line Print
Message-Id: <Pine.LNX.4.05.9901292108280.23718-100000@hill.ucr.edu>


On Sat, 30 Jan 1999 rsarcomo@my-dejanews.com wrote:

> On my Linux box, this works fine:
> 
> print <<ENDING;
> Hello
> World
> ENDING
> 
> On my NT box running ActiveState Perl, it fails with an error of "Can't find
> string terminator "ENDING" anywhere before EOF at test.pl line 1."
> 
> Any ideas?

You might have extra spaces or other characters after the last ENDING,
possibly because you typed the file in Unix and windows isn't reading
newlines properly.  Maybe try retyping it in a windows text editor.  Also,
http://language.perl.com/newdocs/pod/perlfaq4.html might give you clues
about the possible problem.

HTH



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

Date: Sat, 30 Jan 1999 00:01:19 -0500
From: "George" <gpace@i-2000.com>
Subject: Parsing FTP Directory listing
Message-Id: <78u3lu$kpg$1@news2.i-2000.com>

To all,

I am doing some work on using FTP and trying to pull out the Date, Size and
Filename from a directory listing.  While a very simple first program, I
have learned a lot already (for instance ls -l gives a time instead of a
year if < 6 months).

However when I use the following split:

   @fields = split(/ /, $file);

I get some interesting results in @fields.  I think it has to do with the
extra blank spaces in the directory listing itself.  What I would really
like to do, is have split work on a string, but in REVERSE.  Is this doable
?

As an example, I want to strip out the FileName, the Date and the Size.






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

Date: 30 Jan 1999 06:45:17 GMT
From: joejoeinmb@aol.com (JoeJoeInMB)
Subject: Perl 4 question
Message-Id: <19990130014517.01062.00001088@ng-cr1.aol.com>


I am running "WebAdverts" banner exchange program using Perl4 and I am having a
problem.  For the most part, everything runs correctly, but every once and a
while I click on a banner and it takes me to another banner's URL.  I suspect
this is caused because I am running the script under Perl4 instead of Perl5.

The HTML code to call a banner is as follows ( the "< >"'s have been changed to
a "[ ]" so you can read it):

[A HREF="http://www.jerkoff-joe.com/swap/ads.pl?advert=NonSSI&page=04"]
[IMG SRC="http://www.jerkoff-joe.com/swap/ads.pl?ID=JerkOffJoe&page=04"][/A]

I think the problem is in the "gotoad" sub listed below ... I know there was
some change in the if{} else{} formats, but I do not know enough about Perl to
modify the script.

If anyone can explain how to fix this problem, please let me know.  If you need
full source codes, feel free to email me.

Thanks in advance,
JoeJoeInMB@aol.com


sub gotoad {
	if ($displayad eq "NonSSI") {
		$ADVlockerror = &ADVLockFile("nonssi.log");
		if ($ADVlockerror) {
			undef (@nonssi);
		}
		else {
			open (NONSSILOG,"<$adverts_dir/nonssi.log");
			@nonssi = <NONSSILOG>;
			close (NONSSILOG);
			&ADVUnlockFile("nonssi.log");
		}
		@reversenonssi = reverse (@nonssi);
		$ADVremote = "NA";
		if ($ENV{'REMOTE_HOST'}) {
			$ADVremote = $ENV{'REMOTE_HOST'};
		}
		$logcheck = "$ADVremote $displaypage $advertzone";
		foreach $nonssiline (@reversenonssi) {
			if ($nonssiline =~ /^\d* $logcheck \| (.*)$/) {
				$displayad = $1;
				last;
			}
		}
		if ($displayad eq "NonSSI") {
			&BadRef;
			return;
		}
	}
	$ADVlockerror = &ADVLockFile("$displayad.txt");
	if ($ADVlockerror) {
		&BadRef;
		return;
	}
	open (ADVDISPLAY, "+<$adverts_dir/$displayad.txt");
	@ADVdisplaylines = <ADVDISPLAY>;
	foreach $ADVline (@ADVdisplaylines) {
		chop ($ADVline) if ($ADVline =~ /\n$/);
	}
	$ADVdisplaylines[2] += 1;
	unless (@ADVdisplaylines < 1) {
		seek(ADVDISPLAY, 0, 0);
		foreach $ADVline (@ADVdisplaylines) {
			print ADVDISPLAY ("$ADVline\n");
		}
		truncate (ADVDISPLAY, tell(ADVDISPLAY));
	}
	close (ADVDISPLAY);
	&ADVUnlockFile("$displayad.txt");
	$ADVlockerror = &ADVLockFile("$displayad.log");
	unless ($ADVlockerror) {
		if (-e "$adverts_dir/$displayad.log") {
			open (DAILYLOG,"+<$adverts_dir/$displayad.log");
		}
		else {
			open (DAILYLOG,">$adverts_dir/$displayad.log");
		}
		$ADVaccess = "$ADVmday $ADVmon $ADVyear C";
		$ADVlocation = tell DAILYLOG;
		while ($ADVline = <DAILYLOG>) {
			if (($ADVacc,$ADVlogstring) = ($ADVline =~
			  /^(\d\d\d\d\d\d\d\d\d\d) (\d\d \d\d \d\d\d\d C)$/)) {
				if ($ADVaccess eq $ADVlogstring) {
					last;
				}
			}
			last if ($ADVaccess eq $ADVlogstring);
			$ADVlocation = tell DAILYLOG;
			$ADVacc = 0;
		}
		$ADVacc++;
		seek (DAILYLOG, $ADVlocation, 0);
		$ADVlongacc = sprintf("%010.10d",$ADVacc);
		print DAILYLOG "$ADVlongacc $ADVaccess\n";
		close (DAILYLOG);
		&ADVUnlockFile("$displayad.log");
	}
	if ($ADVLogIP) {
		$ADVlockerror = &ADVLockFile("$displayad.ips");
		unless ($ADVlockerror) {
			if (-e "$adverts_dir/$displayad.ips") {
				open (DAILYLOG,"+<$adverts_dir/$displayad.ips");
			}
			else {
				open (DAILYLOG,">$adverts_dir/$displayad.ips");
			}
			@ADVips = <DAILYLOG>;
			seek(DAILYLOG, 0, 0);
			foreach $ADVline (@ADVips) {
				($ADVip,$ADVother) = split (/\s/, $ADVline);
				unless (($ADVtime-$ADVip) > 86400) {
					print DAILYLOG $ADVline;
				}
			}
			print DAILYLOG "$ADVtime - $ADVhour:$ADVmin - C - ";
			print DAILYLOG "$ENV{'REMOTE_HOST'}\n";
			truncate (DAILYLOG, tell(DAILYLOG));
			close (DAILYLOG);
			&ADVUnlockFile("$displayad.ips");
		}
	}
	print "Status: 302 Found\n";
	print "Location: $ADVdisplaylines[3]\n\n";
}




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

Date: 30 Jan 1999 05:14:09 GMT
From: thapliyal@aol.com (Thapliyal)
Subject: Perl and OO   :Someone help !!
Message-Id: <19990130001409.28749.00001418@ng110.aol.com>

Hi,
I'm trying to use set up an oo based framework in perl and am having problems
implementing the following OO basics-->

1.Pure virtual methods in Perl ?
2. Reflection work in Perl ?

Anyone out there who knows ??



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

Date: Fri, 29 Jan 1999 21:10:05 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Perl Criticism [summary]
Message-Id: <36B2780D.7D298414@mediaone.net>


topmind@technologist.com wrote:
> 
> So spelling and grammar are related to one's programming experiece.

For once, I agree with topmind !!!

> (P.S. When I am done fixing programming languages, I am going
> to replace english with a TRUE FONETIC system, so we are not
> stuck with illogical rules given to us by bad history.
> You probably cannot even recognize Englishes' illogical
> rules because you seem to lack the ability to stand back from
> what you are used to.)

How many Englishes would possess illogical rules?  Again, and again, sir
topmind insists on changing things for which he himself has no command.

What is this argument: I must change things that I do not understand so
that I need not take time to master them?

> Ran out of insults, eh? Resorting to attacking grammar instead
> of merit and concepts that are related to the topic.

As you so eloquently pointed out above, and I quote, ``spelling and
grammar are related to one's programming experiece.''

Kindly mean what you say }:-^

> > nothing to say in any other thread. maybe he could actually post some
> > code or comments in a reply to a real perl question. then we can see the
> > true genius of his unobsfucated code.
> 
> To test my Perl knowledge, or to see why Perl is flawed?

Either will satisfy my jaded curiosity ;)

Can you write functional Perl code?  Actually, I'd be of a kinder,
gentler mind if I saw *any code* from topmind in *any language* that did
*anything* more complex than `hello, world.'

Shall we hold our breaths?

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "


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

Date: Fri, 29 Jan 1999 20:57:42 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Perl Criticism
Message-Id: <36B27526.5F4D4B6A@mediaone.net>


topmind@technologist.com wrote:
> 
> Yes, they confused me, and I am NOT A DUMB PERSON!

Debatable; but, definitely *not* worth the bandwidth }:-^

> If they confuse me, I guarentee they will confuse a good many
> programmers, perhaps a majority.

Even if we accept `majority,' what does that have to do with the
integrity of Perl?  Assembler is complex, confusing and beyond most
modern programmers -- yet, some of those who use it build things that
*no* other language can touch in terms of efficiency, size and
all-out-speed.

Would you criticize assembler?  Is it rendered useless simply because
*you* cannot use it?  Are you in any position to tell the assembler
programmer that they are wrong for using assembler, *because* it
confuses you?

Not once have you responded to my pragmatic issues of CONTEXT,
PROFICIENCY and USABILITY.

Care to comment?

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "


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

Date: 30 Jan 1999 06:20:50 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: Perl Threads
Message-Id: <78u8c2$8ls$1@news.NERO.NET>

Nuno Leitao <nuno.leitao@uk.uu.net> wrote:

:   Hello,

:   as anyone used multithreading in Perl 5.005 in a serious way ?
:   How stabe is it ?

Through 5.005_02, it's reasonably unstable. Or, rather, there's a large
chunk of perl that's not threadsafe and will die if you use it. 5.005_03
should be a lot better (as should the 5.006 development releases)

: Also, is there a way to do thread cancelation ?

Nope. There should be a form of it in 5.006, but it won't be full
cancellation.

					Dan


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

Date: Fri, 29 Jan 1999 23:38:46 -0500
From: "Bik Dhaliwal" <bik@benton.com>
Subject: Re: Simple Perl Function Question for ya
Message-Id: <36b28c53.0@news.cgocable.net>

Is this what you're looking for??

$rc = 0xffff & system("/usr/sbin/ping $hostname");
if ( $rc ){
    ...complain....
}

KC wrote in message ...
>I want to call the ping command from inside
>my perl script, then capture ONLY the return value, and
>use it.  I dont want ping to output anything - just
>return the exit value into $value. This will be used for
>a web page showing multiple machines' status after
>being pinged.
>
>If you can answer my question, you are the man! (or woman!)
>THANKS
>
>kris collins
>ITS - University of Colorado




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

Date: 30 Jan 1999 01:04:50 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: strange behaviour with tr///
Message-Id: <x7lnilqosd.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@fnx.com> writes:

  A> Uri Guttman (uri@home.sysarch.com) wrote on MCMLXXVII September MCMXCIII
  A> {} 
  A> {}   t>     tr/a-mA-Mn-zN-Z/n-zN-Za-mA-M/;
  A> {} 
  A> {} Otherwise, if the REPLACEMENTLIST is shorter than the SEARCHLIST, the
  A> {} final character is replicated till it is long enough.

  A> So, where are there less characters, between a-m andr a-m? Or between
  A> n-z and n-z? Or does capitalization on the replacement part yield
  A> less characters than on the search list?

someone else caught that mistake of mine. the original poster says the
problem went away with a retyping of the code. maybe a mysterious extra
char caused a length difference?!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sat, 30 Jan 1999 00:14:19 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: substr() Assistance still needed
Message-Id: <rv7u87.7l2.ln@magna.metronet.com>

Danny Paxton (paxtond@ix.netcom.com) wrote:

: MLR is the name assigned to the string coming
: from the HTML FORM.


:                                 if substr($FORM{'MLR', 1, 1} eq B) {


   Your code and your verbage do not match.

   $FORM{MLR} is how you access the hash element with key 'MLR'.

   Upper case variable names are yucky, BTW.


: open(FILE,">>test1.txt"); # Where test1.txt is the name of the file

   You should *always* check the return value of open() calls:

   open(FILE,">>test1.txt") || die "could not open 'test1.txt'  $!";


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 30 Jan 1999 05:27:37 GMT
From: Phraktyl <phraktyl@home.com>
Subject: Sys::Syslog trouble...
Message-Id: <36B2999B.B11D2C2E@home.com>

I am having some trouble getting Sys::Syslog to work.  I have looked
this up on DejaNews, and read all the FAQ's I could find, but didn't get
anywhere.  I keep getting this error message:

Constant subroutine __need___va_list undefined at
/usr/local/lib/perl5/site_perl/5.005/i686-linux-thread/stdarg.ph line 7.

I believe I have converted all the header files (h2ph) - or at least
perl doesn't complain about them anymore.  I also tried commenting out
the offending line in stdarg.ph.  The program executed without any
problems, but no output was sent to syslog.

I am using:
RedHat Linux 5.2 w/ kernel 2.0.36
perl 5.005.02 w/ multi-threaded support.  (Not using threads here,
though...)

Thanks,
Wyatt



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

Date: Sat, 30 Jan 1999 03:45:16 GMT
From: Wyatt Draggoo <phraktyl@home.com>
Subject: Test... Ignore...
Message-Id: <917668254.339703380@news.omhaw1.ne.home.com>

Just a test... Please ignore...


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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