[8418] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2035 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 5 17:16:55 1998

Date: Thu, 5 Mar 98 14:00:34 -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           Thu, 5 Mar 1998     Volume: 8 Number: 2035

Today's topics:
    Re: $1 ? (Tom Grydeland)
    Re: BIG integers <uri@sysarch.com>
    Re: Calling a CGI inside another CGI <garethr@cre.canon.co.uk>
    Re: constants as keys in hashes (Dave Wolfe)
    Re: Help with perl, immediate answers wanted! (Michael J Gebis)
        i know it didn't do what i wanted... but what DID it do (Kevin B Cohen)
    Re: Is there a cron written in perl for Win32? <rothd@xrxoxtxhx.xnxextX>
        Length of an array? <miller@bigsky.net>
    Re: Length of an array? (Aaron B. Dossett)
    Re: Length of an array? <steve@prilnari.com>
    Re: Length of an array? <cmargoli@world.northgrum.com>
    Re: Log Stats  Looking for program <mishra.aditya@emeryworld.com>
        New Wording for Co-Branding digitalstars@yahoo.com
        New Wording for Co-Branding digitalstars@yahoo.com
        NT trusted connection ODBC <a-dhaner@microsoft.com>
    Re: NT trusted connection ODBC <rothd@xrxoxtxhx.xnxextX>
    Re: padding a file -- Better way?? <uri@sysarch.com>
    Re: Pattern matching? <quentin@jihad.amd.com>
    Re: Pattern matching? (Jim Allenspach)
    Re: Pattern matching? <joneil@cks.ssd.k12.wa.us>
        Perl FAQ Error... <steve@prilnari.com>
    Re: Perl file mode? <dvermes@emerald.tufts.edu>
    Re: Perl QRG(Quick Reference Guide) (David Wall)
        Question on Perl Ascoc. Arrays <apeterso@ctberk.com>
        Quoting ^M? <object01@cc.gatech.edu>
    Re: Quoting ^M? <steve@prilnari.com>
    Re: Stripping (Most) HTML tags <jdporter@min.net>
    Re: What is PERL? Learn JAVA instead? <evan@garrett.hpl.hp.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 5 Mar 1998 21:35:15 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: $1 ?
Message-Id: <slrn6fu6kj.aaj.Tom.Grydeland@mitra.phys.uit.no>

On Wed, 04 Mar 1998 15:37:04 -0600,
Jeff Stewart <object01@cc.gatech.edu> wrote:
> What are the read-only variables $1, $2, $3, etc.?  How are they
> populated?

Whenever you find yourself wondering about such things, let your
itchy typing fingers relieve themselves on the keyboard with the
following incantation:

man perlvar


> Jeff S.

hth, hand,
-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 05 Mar 1998 16:27:23 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: BIG integers
Message-Id: <x7vhtsx1z8.fsf@sysarch.com>

Jeff Hay <jrhay@lanl.gov> writes:

> I'm working on a reporting system based in Perl, for which I need to add
> really big integers - the results of these additions overflow the
> integer range of my version of Perl (running on SunOS).  Does anybody
> know of a module, etc, for handling BIG integer numbers with Perl?
> Would be good...
> 
it is called appropriately BigInt (sp?) and is located at your favorite
CPAN site. check out www.perl.com for CPAN

uri
-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: Thu, 5 Mar 1998 20:27:16 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Calling a CGI inside another CGI
Message-Id: <sibtvk289n.fsf@cre.canon.co.uk>

fealvar@ctc.cl wrote:
> I want a CGI in machine X to call a CGI in machine Y.

You can either ask the client to connect to machine Y using HTTP's
"redirect" feature, or pass the request on yourself.

If you have the CGI::* modules from CPAN, then you can do something like

   $q = new CGI::Base;
   $q->redirect($url);

to redirect the client to another URL, or

   $q = new CGI::Base;
   $q->pass_thru($host, $port);

to forward the request yourself.

-- 
Gareth Rees


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

Date: 5 Mar 98 19:38:27 GMT
From: dwolfe@miaow.sps.mot.com (Dave Wolfe)
Subject: Re: constants as keys in hashes
Message-Id: <dwolfe.889126707@talos4>

[ Courtesy Cc of this post mailed to original poster ]

In <34FDA64E.71712819@acm.org> Oerjan Nygaard Austvold <orjana@acm.org> writes:

>use constant FOO => "bar";
>my %Hash = ( @{ [ FOO ] } => "foobar" );

>This works fine and declares Hash as ( bar => "foobar" ), but isn't
>there an easier way of reffering to a constant as a key in a hash?

It's really just a sub, treat is as such:

    my %Hash = ( &FOO => "foobar" );
    my %Hash = ( FOO() => "foobar" );

But see "Constant Functions" in perlsub.

-- 
 Dave Wolfe


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

Date: 5 Mar 1998 20:25:34 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Help with perl, immediate answers wanted!
Message-Id: <6dn1nu$mk6@mozo.cc.purdue.edu>

abigail@fnx.com (Abigail) writes:

}Brandon Blum (bblum@earthlink.net) wrote on 1646 September 1993 in
}<URL: news:34FD8F46.A5FF9B1F@earthlink.net>:
}++ Hi all, I was wondering if anyone could help me with a problem, well not
}++ really problem but an answer. I wanted to write a form or something that
}++ uses a form, i test them out on my machine with ms dos. Is there anyway
}++ I could use html in that so I could see the form and enter stuff, or do
}++ I need to put it on a webserver which I don't have. If anyone does have
}++ one or a place I could put the scripts I could definetly make out some
}++ kind of deal if you did let me use it!

}What makes you think comp.lang.perl.misc is a more appropriate forum to
}ask then say, rec.pets.flees?

}Your question has *NOTHING* to do with Perl. Absolutely nothing.

There's a question in there?

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 5 Mar 1998 16:37:37 -0500
From: kcohen@julius.ling.ohio-state.edu (Kevin B Cohen)
Subject: i know it didn't do what i wanted... but what DID it do??
Message-Id: <6dn5v1$dqb@julius.ling.ohio-state.edu>

while trying to define a hash, a did a typo... well, actually a
brain-o... and put curly braces where i should have put parentheses:

%letters = { 
	'a' => 'eI',
	'b' => 'bi',
	'c' => 'si',
etc.

that did not make me a hash named %letters;  e.g., if i had a variable
$char = 'c' and tried to assign $phon = $letters{$char}, i got
nothing.  once i changed the curly braces to parentheses, my problems
disappeared.

my question is, what DID i do when i used the curly braces?  it
compiled just fine (no, i wasn't using -w).  looks kinda like an
anonymous array on the right hand side, but what's the left?

kevin




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

Date: 5 Mar 1998 20:47:44 GMT
From: "Dave Roth" <rothd@xrxoxtxhx.xnxextX>
Subject: Re: Is there a cron written in perl for Win32?
Message-Id: <01bd4878$46349b10$0101a8c0@main2>



Kevin Hawley <cchkxh@ARCO.com> wrote in article
<34FB014C.FF6589BC@ARCO.com>...
> Hi, I'm looking for cron/crontab functionality for Win32.
 I have used
> perl quite a bit for UNIX system administration, and now
I am going to
> manage
> some Windows 95/NT systems. I have checked the CPAN, but
I did not
> see what I was looking for, any suggestions?

You could use the Scheduler service that comes standard for
NT (assuming this is an NT box you will use). The
Win32::AdminMisc extension has functions that let you
manage (both remotely and locally) the Scheduler service.
	http://www.roth.net/perl/adminmisc.htm
dave
-- 
============================================================
====
Dave Roth                               ...glittering
prizes and
Roth Consulting                     endless compromises,
shatter
rxoxtxdxxrxoxtxhx.xnXeXt               the illusion of
integrity

 My email address is disguised to fool automailers. Remove
the
                      X's to send me email.
************************************************************
****
Use of  this message or  email address  for commercial 
purposes
(including "junk" mailings) is strictly prohibited and
protected
under  current  international  copyright laws  and United
States
Code, Title 47, Chapter 5, Subchapter II.



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

Date: Thu, 05 Mar 1998 13:11:30 -0700
From: "Keith L. Miller" <miller@bigsky.net>
Subject: Length of an array?
Message-Id: <34FF06F2.BBD8C16F@bigsky.net>

If I have a string stored in $_ and I split it into an array, how can I
know what the length of the array (how many fields there are in the
array)?

eg: $_ = This is a test!
     @fields = split (/ /, $_);

      In this case there are four fields, but if the sentance had five,
six, or more words how can I tell perl to detect this?



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

Date: 5 Mar 1998 20:26:53 GMT
From: aarond@alpha.ewl.uky.edu (Aaron B. Dossett)
Subject: Re: Length of an array?
Message-Id: <6dn1qd$q7f$1@service3.uky.edu>

Keith L. Miller (miller@bigsky.net) wrote:
> If I have a string stored in $_ and I split it into an array, how can I
> know what the length of the array (how many fields there are in the
> array)?
> 
> eg: $_ = This is a test!
>      @fields = split (/ /, $_);
> 
>       In this case there are four fields, but if the sentance had five,
> six, or more words how can I tell perl to detect this?
> 

$length = scalar(@fields);

That's one of many ways...

Aaron
-- 
Aaron B. Dossett   |   Finger aarond@london.cslab.uky.edu for PGP key
dossett@bigfoot.com|      
Comp. Sci. Senior  |         http://www.ewl.uky.edu/~aarond
    University of Kentucky    1996 NCAA Basketball Champions


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

Date: Thu, 05 Mar 1998 20:39:08 GMT
From: Steve Wells <steve@prilnari.com>
To: "Keith L. Miller" <miller@bigsky.net>
Subject: Re: Length of an array?
Message-Id: <34FF0EE8.6DE905A8@prilnari.com>

You should read the FAQ but since this is so easy...

$length = @fields; 

holds the value of the array, in this case 4
Please check out http://www.perl.com/ and read 
down the list before you post something here,
it can prove very helpful.

Better yet get the learning perl book at:
http://www.ora.com/

STEVE

Keith L. Miller wrote:
> 
> If I have a string stored in $_ and I split it into an array, how can I
> know what the length of the array (how many fields there are in the
> array)?
> 
> eg: $_ = This is a test!
>      @fields = split (/ /, $_);
> 
>       In this case there are four fields, but if the sentance had five,
> six, or more words how can I tell perl to detect this?


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

Date: Thu, 5 Mar 1998 20:51:42 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Length of an array?
Message-Id: <34FF105E.4199@world.northgrum.com>

Keith L. Miller wrote:
> 
> If I have a string stored in $_ and I split it into an array, how can I
> know what the length of the array (how many fields there are in the
> array)?
> 
> eg: $_ = This is a test!
>      @fields = split (/ /, $_);
> 
>       In this case there are four fields, but if the sentance had five,
> six, or more words how can I tell perl to detect this?

Read about using an array in scalar context in the perldata man page.

If you are concerned about controlling the number of items returned
by split, read about the LIMIT parameter of the split function in
perlfunc.

-- 
Charles G. Margolin                   DSSD Internal Information Services
cmargoli@world.northgrum.com          Northrop Grumman Corp. 0624/23
margolin@acm.org                      Hawthorne, California 90250-3277


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

Date: Thu, 5 Mar 1998 11:35:54 -0800
From: "Mishra, Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: Log Stats  Looking for program
Message-Id: <6dmsr9$1jhq@ljcqs003.cnf.com>

Logfile package on CPAN
Adi




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

Date: Thu, 05 Mar 1998 15:45:56 -0600
From: digitalstars@yahoo.com
Subject: New Wording for Co-Branding
Message-Id: <6dn6do$l0e$1@nnrp1.dejanews.com>

I recently created a post on Co-Branding my web site for others, and
unfortunatley presented the question in a disorganized matter.  I was rushing
to get it done, and received the conseqeunces because of it, my mistake :-)

I will try to explain my question a little better, and the reason why I am
posting it here is because I believe  the solution is Perl/CGI orientated.  I
might be mistaken.  Well, here it goes anyways.

I have a web site that some individuals or businesses might find useful.  What
I would like to do have the ability to co brand it, by creating a similar
site, using the same information, however displaying this client's logo on the
site as well.  And possibly placing the information into the look and feel of
the client's site.

Why I would like to do this is for promotional/marketing reasons.  By
providing my co branded web site for this individual or business, they have an
additional resource to offer to their users.  In return, I benefit from this
as well, by receiving additional advertising through their web site, as it not
only would display their logo, but the original sites logo as well.  When the
client's users go to use this service provided by myself, they would find
this to be useful information, and hopefully return.  Naturally, the web site
providing my services would not want to offer free advertising for my site,
unless, however, it is co branded to the look and feel of their site, with
links that lead back to their site as well. I hope this is making some sense.

Classifieds 2000 offers a similar service, which many web sites have taken
part in, WhoWhere? and Infoseek for example.  In fact, I first discovered
Classifieds2000 through one of their co branded web sites, it was through
Bigfoot I believe.  http://www.bigfoot.com  They might have a better
explanation of this type of service, and what I am trying to accomplish here:

http://www.classifieds2000.com/cgi-cls/display.exe?c2k+network+network

This pretty much explains exactly what I would like to do.  I have no
intention of using a script like this to steal someone elses site ideas, by
simpily replacing their logo with mine.  In fact, to offer this type of
service, the co branded site would have to be hosted on the originals.  I
understand why I might have offened some with this quote, "In other words,
create an entire new site without the work."  I would be too.  I mis worded
the phrase.

Anyways, is there a script out there to do this?  I believe it is CGI
orientated because all CO Branded sites I've seen are located in the CGI-BIN.

Hope this clears things up. - Cheers!

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 05 Mar 1998 15:48:33 -0600
From: digitalstars@yahoo.com
Subject: New Wording for Co-Branding
Message-Id: <6dn6i3$l4s$1@nnrp1.dejanews.com>

I recently created a post on Co-Branding my web site for others, and
unfortunatley presented the question in a disorganized matter.  I was rushing
to get it done, and received the conseqeunces because of it, my mistake :-)

I will try to explain my question a little better, and the reason why I am
posting it here is because I believe  the solution is Perl/CGI orientated.  I
might be mistaken.  Well, here it goes anyways.

I have a web site that some individuals or businesses might find useful.  What
I would like to do have the ability to co brand it, by creating a similar
site, using the same information, however displaying this client's logo on the
site as well.  And possibly placing the information into the look and feel of
the client's site.

Why I would like to do this is for promotional/marketing reasons.  By
providing my co branded web site for this individual or business, they have an
additional resource to offer to their users.  In return, I benefit from this
as well, by receiving additional advertising through their web site, as it not
only would display their logo, but the original sites logo as well.  When the
client's users go to use this service provided by myself, they would find
this to be useful information, and hopefully return.  Naturally, the web site
providing my services would not want to offer free advertising for my site,
unless, however, it is co branded to the look and feel of their site, with
links that lead back to their site as well. I hope this is making some sense.

Classifieds2000 offers a similar service, which many web sites have taken
part in, WhoWhere? and Infoseek for example.  In fact, I first discovered
Classifieds2000 through one of their co branded web sites, it was through
Bigfoot I believe.  http://www.bigfoot.com  I just realized this, but
DejaNews also has a co branded Classifieds2000 web site.

http://gp.dejanews.com/gtplacer?site=dn&location=link.home.class2000&cid=06415
2155

Classifieds2000 might have a better explanation of this type of service, and
what I am trying to accomplish here:

http://www.classifieds2000.com/cgi-cls/display.exe?c2k+network+network

This pretty much explains exactly what I would like to do.  I have no
intention of using a script like this to steal someone elses site ideas, by
simpily replacing their logo with mine.  In fact, to offer this type of
service, the co branded site would have to be hosted on the originals.  I
understand why I might have offened some with this quote, "In other words,
create an entire new site without the work."  I would be too.  I mis worded
the phrase.

Anyways, is there a script out there to do this?  I believe it is CGI
orientated because all CO Branded sites I've seen are located in the CGI-BIN.

Hope this clears things up. - Cheers!

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 5 Mar 1998 12:04:14 -0800
From: "David Haner" <a-dhaner@microsoft.com>
Subject: NT trusted connection ODBC
Message-Id: <6dn0jp$7s@news.microsoft.com>

Does anyone know if you can use perl to connect to a SQL database using a
trusted connection (with or without ODBC) on an NT network?

I'd much appreciate any ideas, or even a direction to be steered in.

(I'm sorry I work at Microsoft, please don't be mean)

David Haner - Volt Computer
a-dhaner@microsoft.com
Software Design Engineer in Test
Visual Studio 98

--
The opinions expressed in this message are my own personal views
and do not reflect the official views of the Microsoft Corporation.




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

Date: 5 Mar 1998 20:19:45 GMT
From: "Dave Roth" <rothd@xrxoxtxhx.xnxextX>
Subject: Re: NT trusted connection ODBC
Message-Id: <01bd4874$5d602470$0101a8c0@main2>



David Haner <a-dhaner@microsoft.com> wrote in article
<6dn0jp$7s@news.microsoft.com>...
> Does anyone know if you can use perl to connect to a SQL
database using a
> trusted connection (with or without ODBC) on an NT
network?
> 
> I'd much appreciate any ideas, or even a direction to be
steered in.
> 
> (I'm sorry I work at Microsoft, please don't be mean)

Yes, it works fine with both trusted and non-trusted (even
mixed) security models. Make sure you are using the newest
ODBC drivers! :)
dave

-- 
============================================================
====
Dave Roth                               ...glittering
prizes and
Roth Consulting                     endless compromises,
shatter
rxoxtxdxxrxoxtxhx.xnXeXt               the illusion of
integrity

 My email address is disguised to fool automailers. Remove
the
                      X's to send me email.
************************************************************
****
Use of  this message or  email address  for commercial 
purposes
(including "junk" mailings) is strictly prohibited and
protected
under  current  international  copyright laws  and United
States
Code, Title 47, Chapter 5, Subchapter II.



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

Date: 05 Mar 1998 16:21:26 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: padding a file -- Better way??
Message-Id: <x7yayox295.fsf@sysarch.com>

Douglas Cordero <dcordero@giss.nasa.gov> writes:

> 	I wrote a subroutine to space pad a variable length
> text array to 80 left justified characters.  
> Does it look OK?  Is there a better way?  

no, yes.

> Is there a module or something that has this built-in?  

there is no built or module as it is too simple.
> 
> sub padder {
>     my( @val ) = @_;
>     my( @paddedval );
>     @paddedval = ();
>     foreach (@val) {
>             @paddedval = (@paddedval, sprintf "%-80.80s", $_ );

this is just plain silly.  you are needlessly recopying @paddevel each time.
look at the push function.

>     }
>     return @paddedval;
> }

map to the rescue!

@padded = map { sprintf "%-80.80s", $_ } @unpadded ;

there are MANY ways to do the actual pad operation, sprintf being one of
the more well known.

you can do 

	$_ .= ' ' x (80 - length($_)) ;

and many more!


uri

-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: 05 Mar 1998 13:57:30 -0600
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: Pattern matching?
Message-Id: <xim3egw6hcl.fsf@jihad.amd.com>



From: "Keith L. Miller" <miller@bigsky.net>
    Okay, I can not figure this out.  Below is a snippet of code form a
    script I'm writing.  it searches throught the shadow password file for a
    specific string (stored in $FORM{'USER'}).  For the most part, it works
    great, however there is one little snag.

    Let's say the user name is miller.  It will search through and ignore
    names such as:
    gmiller
    klmiller
    vnmiller1

    but, it returns
    miller
    j-miller

    open(PASS, "/etc/passwd");
    while (<PASS>) {
	@fields = split(/:/, $_);
	if (/\b$FORM{'USER'}\b/) {
	    print "$_<BR>";
	}
    }
    close (PASS);
    print @user;

Keith - the user name is not properly matched /\b$FORM{'USER'}\b/.

\b matches word boundaries - such as ^$ \t:. (among others).  Lines in
the passwd file (not the shadow passwd file) look like this:

	miller:x:37:4:Network Admin:/home/miller:/bin/rc

miller is properly matched by:

	^$FORM{USER}:

More info available at perlre.

-- 
Quentin Fennessy			AMD, Austin Texas


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

Date: 5 Mar 1998 14:01:21 -0600
From: jima@MCS.COM (Jim Allenspach)
Subject: Re: Pattern matching?
Message-Id: <6dn0ah$4dp@Mercury.mcs.net>

>Let's say the user name is miller.  It will search through and ignore
>names such as:
>   gmiller
>   klmiller
>   vnmiller1

>but, it returns
>   miller
>   j-miller

>Does anyone know why?

	Uh, because you told it to?

>            if (/\b$FORM{'USER'}\b/){

	This is the line you should be looking at. What does "\b" do again?
(You'll find the answer in your Perl documentation, under regular
expressions. That's the perlre section of the online docs, if you've got
'em. And if not, why not?)
jma

-- 
Jim Allenspach            Laziness. Impatience. Hubris.
jima at mcs dot com
Chicago IL                It's great to be a Perl programmer.



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

Date: Thu, 05 Mar 1998 12:38:00 -0800
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
To: "Keith L. Miller" <miller@bigsky.net>
Subject: Re: Pattern matching?
Message-Id: <34FF0D27.B7AFAC80@cks.ssd.k12.wa.us>

Keith L. Miller wrote:

> but, it returns
>    miller
>    j-miller
>
> Does anyone know why?
>

You  are being punished for not checking your exit status, ow using -w.

> ------------------------------------
>
>



>    open(PASS, "/etc/passwd");
>

open(PASS, "/etc/passwd") or die "A Long Horrible Painful Death Occured:
$!\n";# This will make many people happy.

>          while (<PASS>){
>             @fields = split(/:/, $_);

Why do you split $_, but not use the results of that in your match?

>             if ($fields[0] =~ /$FORM{'USER'}/o){
>                print "$_<BR>";
>             }

\b is causing a match on the j-, a word character followed by a non word
character.  use the /o to prevent the regex from recompiling every
iteration.

This is described in detail in the blue camel, and I'm sure is a FAQ as
well.

Jerome



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

Date: Thu, 05 Mar 1998 20:51:32 GMT
From: Steve Wells <steve@prilnari.com>
Subject: Perl FAQ Error...
Message-Id: <34FF11D0.F4684FE2@prilnari.com>

It is taking some real guts to post this but...

On the sort page:

in: http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq4/
at: perlfaq4/How_do_I_sort_an_aray_by_anyth.html

----
"...a trick that's come to be known as the Schwartzian Transform: "
    @sorted = map  { $_->[0] }
              sort { $a->[1] cmp $b->[1] }
              map  { [ $_, uc((/\d+\s*(\S+) )[0] ] } @data;

-----
When I tried to run this I got some errors and noticed that it
should read:
-----
    @sorted = map  { $_->[0] }
              sort { $a->[1] cmp $b->[1] }
              map  { [$_, uc((/\d+\s*(\S+)/)[0])] } @data;
-----
The last line doesn't have an closing / or an ending ).

If I should have posted this someplace else please let me
know.

Humbly, 
STEVE


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

Date: 5 Mar 1998 21:21:50 GMT
From: Doug Vermes <dvermes@emerald.tufts.edu>
Subject: Re: Perl file mode?
Message-Id: <6dn51e$vi5$1@news3.tufts.edu>

Doug Vermes <dvermes@emerald.tufts.edu> wrote:
: When you use the stat command to get information on a file, one of the
: values it returns is the file mode ($mode). I'm having a hard time making
: sense of this number. It certainly isn't the normal UNIX permissions. For
: example, a file with UNIX permission 600 comes back as 33152. How do I
: translate from one to the other?

Thanks to all the people who responded to my original post. I've got it
all figured out now. :) 
     - Doug

==========================================
Doug Vermes  --  dvermes@emerald.tufts.edu
Tufts University
==========================================




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

Date: Thu, 05 Mar 1998 21:05:43 GMT
From: dkw0@cdc.gov (David Wall)
Subject: Re: Perl QRG(Quick Reference Guide)
Message-Id: <6dn4cm$mkl4@cdc4.cdc.gov>

In article <wl34t1d1sv1.fsf@plume.nl.compuware.com>, JVromans@Squirrel.nl (Johan Vromans) wrote:
>> ---------------------------- author info -----------------------------
>> Johan Vromans                                     jvromans@squirrel.nl
>> Squirrel Consultancy                          Haarlem, the Netherlands
>> http://www.squirrel.nl                  http://www.xs4all.nl/~jvromans
>> ----------------------------------------------------------------------
>> 
>> I just tried and failed to connect to that web site.  I don't remember
>> where I got the original (www.perl.org?)
>
>Both web sites should be functional. Please let me know if you have
>problems connecting.
>
>For more information about the reference guide, see 
>http://www.squirrel.nl/people/jvromans/perlref.html

I just bought two copies of that last night: one for work, and one for 
home.  I've already used it quite a bit today.  Glad to put some money (I 
hope) in your pocket.  :-)

David Wall
(Yea, I know, it's free on the net, but I don't have a postscript printer, 
and I'm too lazy to print it some other way when there's such a cute little 
booklet available.)


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

Date: Thu, 05 Mar 1998 12:55:28 -0800
From: Arvid Peterson <apeterso@ctberk.com>
Subject: Question on Perl Ascoc. Arrays
Message-Id: <34FF113F.EBE5936@ctberk.com>

I've got a program handlind multi-file processing which breaks each value of a file line
into an associative array based on the infile reference as follows...

%FILEHASH = ('FILE1','FILENAME1.EXT','FILE2','FILENAME2.EXT',...);

with the resulting arrays being

$FILE1{$line,$element};
and...
$FILE2{$line,$element};

what I want to do, for testing, is have a foreach loop which prints array elemets for all
files processed by a file reading and array building subroutine as

foreach $temploop (keys(%FILEHASH)) {
   foreach $temploop2 (keys(%$temploop)) { #should point to array FILE1, FILE2, etc.
      print "$temploop >> $temploop{$temploop2}\n";
   }
}

but this loop doesn't work. How can I do this???
Replies gratefully welcome.

Arvid



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

Date: Thu, 05 Mar 1998 14:28:29 -0600
From: Jeff Stewart <object01@cc.gatech.edu>
Subject: Quoting ^M?
Message-Id: <34FF0AED.941@cc.gatech.edu>

This probably isn't precisely Perl related, but can I use regular
expressions to wipe out all occurrences of ^M in a text file?  I'm
writing a Perl script in vi, and tried using regexp's to get rid of all
these ^M controls that appeared after uploading, but vi told me it
couldn't find the ^M character.  I tried both SHIFT+6+M and CTRL+M in
the regexp.  ^M didn't work, and CTRL+M terminated command mode.  Tried
backslashing ^M, that didn't work either.

Can this be done?

Jeff S.


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

Date: Thu, 05 Mar 1998 20:54:02 GMT
From: Steve Wells <steve@prilnari.com>
To: Jeff Stewart <object01@cc.gatech.edu>
Subject: Re: Quoting ^M?
Message-Id: <34FF1265.4ADCFB3@prilnari.com>

Jeff Stewart wrote:
> 
> This probably isn't precisely Perl related, but can I use regular
> expressions to wipe out all occurrences of ^M in a text file?  I'm
> writing a Perl script in vi, and tried using regexp's to get rid of all
> these ^M controls that appeared after uploading, but vi told me it
> couldn't find the ^M character.  I tried both SHIFT+6+M and CTRL+M in
> the regexp.  ^M didn't work, and CTRL+M terminated command mode.  Tried
> backslashing ^M, that didn't work either.
> 
> Can this be done?
> 
> Jeff S.

Jeff - 

  try: s/\cM//g;

STEVE


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

Date: Thu, 05 Mar 1998 16:33:22 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Stripping (Most) HTML tags
Message-Id: <34FF1A22.1D94@min.net>

Jon Drukman wrote:
> 
> John Porter <jdporter@min.net> wrote:
> :   $p->parse( <> ); # slurps all files at once
> 
> it doesn't work if you specify multiple files on the
> command line. 

You sound pretty sure of yourself.  Have you tried it?

> also, there's no way to tell which file you're in.

"There's no way"...  Those words tend to rub a perl
programmer the wrong way.
I'll grant there may not be a trivially simple way.

John Porter


package MyParser;  @ISA=qw(HTML::Parser);

  # print current input file name when we
  # encounter a tag which is likely to be there.
  sub start {
    my $self = shift;
    print "In file $ARGV\n"  if ( $_[0] eq 'body' );
    $self->SUPER::start( @_ );
  }

package main;
my $p = new MyParser;
$p->parse(<>);


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

Date: 05 Mar 1998 12:25:45 -0800
From: Evan Kirshenbaum <evan@garrett.hpl.hp.com>
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <v9hk9a8nauu.fsf@garrett.hpl.hp.com>

Wolfgang Denk <wd@uebemc.siemens.de> writes:

> Evan Kirshenbaum <evan@garrett.hpl.hp.com> writes:
> 
> >   - Work with cyclic structures.  (AFAIK, Perl still uses
> >     reference counting rather than true garbage collection, and so
> >     cannot reclaim them automatically.)
> 
> Your knowledge is completely wrong.

Ok.  Then please explain why the following script got through 1525
iterations before running out of memory (the process grew to 344MB): 

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

    package A;
    $n = 0;

    sub new
    {
	my $self = bless {"num" => $n++,
			  "y" => [1..10000]
			  };
	$self->{"x"} = \$self;  # remove this line and everything
                                # works fine.
	print "Creating $self->{num}\n";
	return $self;
    }

    sub DESTROY {
	my $self = shift;
	print "destroying $self->{num}\n";
    }

    package main;

    for ($j=0; $j < 10000; $j++)
    {
	$a = new A;
    }
    print "dying\n";

According to the trace, the destructor was never called before memory
was exhausted.  I do admit that my memory was faulty in that I had
forgotten that there is a mark/sweep that takes place when the process
exits (and to its credit, the 1525 objects created were destroyed
then), but for realistic programming with circular structures, this is
less than useful.  I'd hardly call this "completely wrong".

-- 
Evan Kirshenbaum                       +------------------------------------
    HP Laboratories                    |Well, if you can't believe what you
    1501 Page Mill Road, Building 1U   |read in a comic book, what can you
    Palo Alto, CA  94304               |believe?!
                                       |           Bullwinkle J. Moose
    kirshenbaum@hpl.hp.com
    (650)857-7572

    http://www.hpl.hp.com/personal/Evan_Kirshenbaum/


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

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

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