[8281] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1898 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 14 12:09:25 1998

Date: Sat, 14 Feb 98 09:00:24 -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           Sat, 14 Feb 1998     Volume: 8 Number: 1898

Today's topics:
    Re: Arrgh! :-0  Syntax problems? (Jonathan Stowe)
    Re: clueless in Columbus (John C. Randolph)
    Re: Decryptable crypt? (Clay Irving)
    Re: FAQless Forays (was: Code Example Needed) (Gabor)
    Re: formating a text file (hard returns)? <ebohlman@netcom.com>
    Re: formating a text file (hard returns)? (Clay Irving)
        FTP-Help <Rauch@netway.at>
    Re: FTP-Help (Reilly Shea)
        Help request: Running perl under OS/2 (Scott A. McClare)
    Re: help: Question on hash ref <beans@bedford.net>
        Help:how to get ftp response into $var (Marko Sunjic)
    Re: Help:how to get ftp response into $var (Reilly Shea)
        How to substitue Control characters . <kramsey@worldnet.att.net>
    Re: Killfile Triage (Robert Collier)
        Novice: 6 - Can't figure out how to read input from the (Marek Jedlinski)
    Re: PC vs PC vs PC (was: Multithreaded servers and comm (John C. Randolph)
    Re: retrieving html files <peter.edlund@capgemini.se>
    Re: RFC about "Matt's Script Archive" (Gabor)
        Sort help please! (Burt Lewis)
        Substituing Ctrl characters <kramsey@worldnet.att.net>
    Re: Substitution in perl for newbie (Jonathan Stowe)
        The meaning of sort <genew@rom.on.ca>
    Re: The meaning of sort <khuber@yuck.net>
    Re: what does "deprecate" mean? (Jonathan Stowe)
    Re: what does "deprecate" mean? (Frank D. Cringle)
    Re: Where to start. (Jonathan Stowe)
        Why does this crash Perl 5.004_02 under Win NT?... <nospam--webmaster@hsv.com.au>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 14 Feb 1998 09:37:53 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Arrgh! :-0  Syntax problems?
Message-Id: <34e55648.4987464@news.btinternet.com>

On Fri, 13 Feb 1998 21:04:26 -0700, Jess Askey
<jess@links.magenta.com> wrote:

>Hello,
>  I have the following sniplet of code that I can't get to work..
>
>> open (FOO, "-|") || exec 'find /a/gamearchive -ctime -7 ' , '%p\n';
>> @pages = <FOO>;
>> foreach $page (@pages) {
>>    @out=split(/\.\//,$page);
>>    $tmp=join('/','',$out[1]);
>>    $new=substr($tmp,0,length($tmp)-1);
>>    print("<a href=",$new,">",$new,"</a><br>\n");
>> }
>
>I can run "find /a/gamearchive -ctime -7" and it works fine from the
>command line,
>so Im guessing that Im getting really confused with the way that exec is
>set up.
>

I think that you have the wrong idea about exec.
You dont really want to be running find at all.  If you run 

   find2perl /a/gamearchive -ctime-7 -print

at the shell prompt it will spit out a perl program that would do the
same thing - probably something like this (perl invocation removed to
protect the guilty):

require "find.pl";

# Traverse desired filesystems

&find('/a/gamearchive');

exit;

sub wanted {
    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    (int(-C _) < 7) &&
    print("$name\n");
}

You can then modify sub wanted to do what you want with the filenames
bearing in mind that the "-ctime -7" is being done in that line.

/J\


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

Date: 14 Feb 1998 15:21:28 GMT
From: jcr.remove@this.phrase.idiom.com (John C. Randolph)
Subject: Re: clueless in Columbus
Message-Id: <6c4cpo$cav$3@news.idiom.com>

 Greg Wallace may or may not have said:
->   Advice will be greatly appreciated.

My advice:  Ask the question in an NT group. This is not a Perl problem.

-jcr

--
John C. Randolph (408) 358-6732  NeXT mail preferred.
Chief Technology Officer, WARPnet Incorporated.
"Only in a police state is the job of a policeman easy." - Orson Welles



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

Date: 14 Feb 1998 08:49:21 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Decryptable crypt?
Message-Id: <6c47d1$9fk@panix.com>

In <6c28vv$g2v@bgtnsc02.worldnet.att.net> "Michael R. Harper" <mikihasa@worldnet.att.net> writes:

>Newbie question:

>The Unix man page says that crypt is a one-way street.  I am looking for
>an encryption command for which there is an inverse operation
>(decrypt?).  The Camel book suggested the possibility of using a PGP
>module.

>I was only able to find one post to this group that mentioned PGP.  Can
>someone steer this newbie in the right direction?  I currently only need
>the ability to encrypt and decrypt data, so I guess I do not need
>anything fancy.

Check: Perl Reference: security
       http://reference.perl.com/query.cgi?security

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: 14 Feb 1998 14:17:25 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: FAQless Forays (was: Code Example Needed)
Message-Id: <slrn6eb9nl.gtf.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Chip Salzenberg <chip@mail.atlantic.net> wrote :
# According to gabor@vmunix.com (Gabor):
# >local ($/) = undef;
# 
# Two nits.  First, parens on local and my are not required if there's
# only one variable.  Thus:
# 
#     local $/ = undef;

I know that.  I always put my variables declared with 'my' or 'local'
into parens, well most of the time.  It looks better to me. ;-)
TMTOWTDI

# Second, "local ... = undef" is redundant; the initial localized
# value of any scalar is undef.  Thus:
# 
#     local $/;

I know that, too.  I guess I like it being more explicit. :-)

gabor.
--
    Be consistent.
        -- Larry Wall in the perl man page 


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

Date: Sat, 14 Feb 1998 09:42:06 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: formating a text file (hard returns)?
Message-Id: <ebohlmanEoD4A6.Ap8@netcom.com>

Martin Vorlaender <martin@RADIOGAGA.HARZ.DE> wrote:
: John Davidson Highfill (davidson@unity.ncsu.edu) wrote:
: : I have been trying to make up a perl script
: : (I am VERY new to perl, and programing in general)(If it makes a diff
: : i am using linux slackware) that would atuomatically format a text file 
: : so that is is say 70 char long bout would not cut off words (rather hard 
: : return and put them on the next line).

: Have a look into CPAN, the Comprehensive Perl Archive Network, at
: http://www.perl.com/CPAN/ . In the modules section, you'll find
: Text::Wrap.

Text::Wrap should come with the standard Perl distribution, but it's 
worth going over to CPAN and looking at the recently-released 
Text::Format, which provides a superset of Text::Wrap's functionality and 
fixes a couple bugs.



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

Date: 14 Feb 1998 08:55:16 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: formating a text file (hard returns)?
Message-Id: <6c47o4$9u9@panix.com>

In <34e5358e.524144494f47414741@radiogaga.harz.de> martin@RADIOGAGA.HARZ.DE (Martin Vorlaender) writes:

>John Davidson Highfill (davidson@unity.ncsu.edu) wrote:
>: I have been trying to make up a perl script
>: (I am VERY new to perl, and programing in general)(If it makes a diff
>: i am using linux slackware) that would atuomatically format a text file 
>: so that is is say 70 char long bout would not cut off words (rather hard 
>: return and put them on the next line).

>Have a look into CPAN, the Comprehensive Perl Archive Network, at
>http://www.perl.com/CPAN/ . In the modules section, you'll find
>Text::Wrap.

Even better -- Text::Wrap is included in recent Perl distributions.

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Sat, 14 Feb 1998 15:27:48 +0100
From: Roland Rauch <Rauch@netway.at>
Subject: FTP-Help
Message-Id: <34E5A9E3.403A@netway.at>

Hi...

I haven't done a lot with perl now and I have a q.

I've written a script that is very similar to the free4all link exchange
script. Ok, that wasn't the problem. The script should now send the
changed linklist to another server by ftp.

I have no idea how this works, so if anyone could help me...?

Thanx


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

Date: Sat, 14 Feb 1998 15:13:36 GMT
From: traveler@rust.net (Reilly Shea)
Subject: Re: FTP-Help
Message-Id: <34e5b315.393607@news.rust.net>

On Sat, 14 Feb 1998 15:27:48 +0100, Roland Rauch <Rauch@netway.at>
wrote:

>Hi...
>
>I haven't done a lot with perl now and I have a q.
>
>I've written a script that is very similar to the free4all link exchange
>script. Ok, that wasn't the problem. The script should now send the
>changed linklist to another server by ftp.
>
>I have no idea how this works, so if anyone could help me...?
>
>Thanx

Hi Roland,
 I just went thru a similar exercise, and was told to use a module
called NET::FTP by some others that contribute to this group. I did a
little reading, but still haven't coded anything using it. It
certainly seems like it's got the needed features.
  If you'd like to look at the responses I got, look for the posting
"FTP as filehandle"
   Hope this helps.
Reilly Shea


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

Date: 14 Feb 1998 13:14:11 GMT
From: cj871@FreeNet.Carleton.CA (Scott A. McClare)
Subject: Help request: Running perl under OS/2
Message-Id: <6c45b3$2pn@freenet-news.carleton.ca>


Hi all.

I am running - well, trying to run, actually - perl patchlevel 4.036 under
OS/2 Warp version 3.  (Why I'm running this, rather than version 5, is
beside the point, but I hope to upgrade in the near future.)

I'm not a regular perl user by any stretch; I don't know the language at
all, and I use it only to run weblint at this time.  My problem is this:
although the perl executable resides in a directory in my path, it cannot
find the perl library - in particular, newgetopt.pl and find.pl, which
weblint needs.  So at this time, I have to keep moving those two files
around to the current directory if I want weblint to work at all.

Is it possible to tweak either some environment variables, or the physical
location of the perl files, so that I can just leave everything in one
place?  I found nothing about this in the documentation, although I might
not have seen it.

Replies by email are preferred, as I'm not a regular reader of this ng,
but I'll check in every so often.

Scott

--
Scott A. McClare                     SP 4      Men never do evil so completely
cj871@freenet.carleton.ca          GGBC #42    and  cheerfully as when they do
PGP: 1024/E7950B29 on key servers              it  from  religious conviction.
or finger cj871@freenet.carleton.ca                           -  Blaise Pascal


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

Date: 14 Feb 98 13:43:12 GMT
From: "TomH" <beans@bedford.net>
Subject: Re: help: Question on hash ref
Message-Id: <01bd394d$925438a0$199163ce@beans.bedford.net>


Dan Boorstein <danboo@negia.net> wrote in article
<34E51CDF.A4E22CDC@negia.net>...
> TomH wrote:
> > 
> > "my" makes the variable %TEST out of scope inside the RetVal
subroutine.
> > 
> [snip] 
> > >
> > > #!/usr/local/bin/perl
> > > # This script does not work
> > > my %TEST= ( "FIRST" => 1, "SECOND" => 2 );
> > > my %TEST2= ( "WHITE" => "FFFFFF", "BLACK" => "000000" );
> > > my $VAL= &RetVal( ARRAY => "TEST", POS => "FIRST" );
> > > print $VAL;    # exactly equal to print $TEST{FIRST};
> > >
> > > sub RetVal {
> > >   my %Q= @_;
> > >   $A= $Q{ARRAY};
> > >   return $$A{$Q{POS}};
> > > }
> 
> are you sure about that? so are you saying that this won't print
'potato'?
> try it.
> 
> my $myVar = 'potato';
> print &RetVal;
> 
> sub RetVal {
>   return $myVar;
> }
> 
> 
> --
> danboo rstein
> 

The perl I have (WIN32 5.004.02) prints potato and carrot, but no tomato.
Switch the "my" to the TEST1 (which I did before posting my original
response) and I get "tomato" but no "potato".

It looks to me like $myVar should also be out of scope in RetVal2, where's
Tom C when you need him? Is this a known bug? My, my, my.

-Tom H

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

$\ = "\n";

   %TEST  = ( "FIRST" => "potato");
my %TEST1 = ( "FIRST" => "tomato");

my $myVar = 'carrot';

print &RetVal( ARRAY => "TEST",  POS => "FIRST" );
print &RetVal( ARRAY => "TEST1", POS => "FIRST" );
print &RetVal2;

sub RetVal {
  my %Q= @_;
  $A= $Q{ARRAY};
  return $$A{$Q{POS}};
}

sub RetVal2 {
  return $myVar;
}


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

Date: 14 Feb 1998 14:47:31 GMT
From: markos@student.math.hr (Marko Sunjic)
Subject: Help:how to get ftp response into $var
Message-Id: <6c4aq3$e0i@bagan.srce.hr>

   I need size and date of the file on remote ftp server.
   There are ftp commands size and modtime that do it
   but how can i store thaeir response into $something?
   Here's code....
 	open(FTP, "| ftp");
	print FTP "open $host\n";
	print FTP "verbose\n";
	print FTP "cd $dir\n";
	print FTP "bin\n";
	print FTP "hash\n";
#	chop($name=<STDOUT>);
        print FTP "modtime $file\n"; I need this response!
	print FTP "get $file\n";
	print FTP "verbose\n";
	print FTP "quit\n";
	close(FTP);




     
     
     
     ***************************************************************
      /                                                             /
      /  Marko Sunjic University of Zagreb Department of mathematics/ 
      /  e-mail markos@student.math.hr                              /
      /  URL http://student.math.hr:80/~markos/                     / 
      /                                                             /
      ***************************************************************
   "I don't have a drinking problem,except when I can't get myself a drink"	


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

Date: Sat, 14 Feb 1998 15:17:55 GMT
From: traveler@rust.net (Reilly Shea)
Subject: Re: Help:how to get ftp response into $var
Message-Id: <34e5b57a.1006141@news.rust.net>

On 14 Feb 1998 14:47:31 GMT, markos@student.math.hr (Marko Sunjic)
wrote:

>   I need size and date of the file on remote ftp server.
>   There are ftp commands size and modtime that do it
>   but how can i store thaeir response into $something?
>   Here's code....
> 	open(FTP, "| ftp");
Hi Marko,
 I just went thru a similar exercise, and was told to use a module
called NET::FTP by some others that contribute to this group. I did a
little reading, but still haven't coded anything using it. It
certainly seems like it's got the needed features.
  If you'd like to look at the responses I got, look for the posting
"FTP as filehandle"
   Hope this helps.
Reilly Shea


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

Date: Sat, 14 Feb 1998 11:08:17 -0500
From: "Kathleen Ramsey" <kramsey@worldnet.att.net>
Subject: How to substitue Control characters .
Message-Id: <6c4goh$a0c@bgtnsc01.worldnet.att.net>

I have a bunch of DOS files that are one line long and have (Ctrl Z)'s (Ctrl
P)'s and (Ctrl Q)'s.  ( they are old Office Writer Word Processor Files that
I need to convert in to flat text)

open (IN,"filename);
binmode (IN);
$CtrlZ = \026 ;
$CtrlP = \016;
$CtrlQ = \017;
$Line = <IN> ;
$Line =~ s/$CtrlZ/ \n /g;
$Line =~ s/$CtrlP/\t /g;
$Line =~ s/$CtrlQ/\t/g;
print $Line;

I also tried $CtrlZ = "^Z";  where ^Z is put in to the file with vi using
Ctrl V Ctrl Z.

Any Clues will help Thanks,
Kathy




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

Date: Sat, 14 Feb 1998 12:46:46 GMT
From: rrc@bofh.org.uk (Robert Collier)
Subject: Re: Killfile Triage
Message-Id: <34e5915c.2058553@news.ftech.net>

On 13 Feb 1998 11:12:12 -0800, rone+usenet@ennui.org (boar dome) wrote:

>In article <34e1a3b3$1$fuzhry$mr2ice@news1.mnsinc.com>,
>Shmuel (Seymour J.) Metz  <spamtrap@library.lspace.org> wrote:
[snip Shmuels posting]

>If you use a valid email address that looks like an invalid email
>address, it's your own fault if people choose to ignore it.

Especialy when they have never asked permission to use that particular
e-mail address <significant look at shumel>.

	- Robert "root@library.lspace.org"

Followups set.

-- 
Robert Collier  (rrc@bofh.org.uk, rune@ftech.net)


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

Date: Sat, 14 Feb 1998 14:04:06 GMT
From: eristic@lodz.pdi.net (Marek Jedlinski)
Subject: Novice: 6 - Can't figure out how to read input from the keyboard.
Message-Id: <34e5a42c.8015580@news.nask.org.pl>
Keywords: If this makes sense to you, you have a big problem...

This, after "Seven Levels of Perl Mastery" by Tom Christiansen:
if I get over this one hurdle, I'll be 'Initiate" already :)

Well, I've given up on fancy input line objects I could create
from scratch in 20 minutes in TPascal. I've given up on trying to
read 'extended' keys like F12... I've given up on reading
keypresses without waiting for <CR>... But not being able to read
a single key properly is, um, a bit too much. I wouldn't be
asking otherwise...


It's the (latest) activestate port of perl running on win95. My
program is building an array of queries to be run later, and I
want an option to iterate over the array, asking the user if the
particular query should be accepted or skipped, allowing only
Y(es), N(o), A(ll) and Q(uit) responses. Here's a minimalist
version of what I'm trying to do:

-------------------------------------------------------
@tmp = ('one', 'two', 'three', 'four', 'five' );

foreach $item (@tmp) {
   print "\nWanna do \"$item\"?\n";
   $reply = &get_reply();
   #...and do other stuff depending on $reply
}

sub get_reply {
   my $keypress = " ";
   while ( $keypress !~ /[YNAQ]/i ) { 
      # allow only Yes, No, All or Quit responses
      print "(Y/N/A/Q) "; 
      $keypress = getc;
      chomp $keypress; # doesn't help, see below
   }
   return $keypress;
}
-------------------------------------------------------

And here's this gem of wizardry in action:

-------------------------------------------------------
Wanna do "one"?
(Y/N/A/Q) y

Wanna do "two"?
(Y/N/A/Q) (Y/N/A/Q) y

Wanna do "three"?
(Y/N/A/Q) (Y/N/A/Q) n

Wanna do "four"?
(Y/N/A/Q) (Y/N/A/Q)            # ...Grr, Ctrl-C! :(
-------------------------------------------------------


You see the problem. The first time &get_reply() is called, it
works fine. After that, it always executes the "while" block
twice, once magically feeding the getc() with a keypress
I-don't-know-where-from, and only reading the keyboard properly
on the second lap.

Okay, the perlfunc page says:

>getc Returns the next character from the input file attached to 
>     FILEHANDLE, or a null string at end of file. If FILEHANDLE 
>     is omitted, reads from STDIN. This is not particularly efficient. 
>     It cannot be used to get unbuffered single-characters, however.

Which isn't very helpful, except for stating the obvious. It
follows with a routine that I can't, unfortunately, parse (based
on determining whether the STDIN works in "BSD_STYLE", I don't
suppose win32 would know what to make of /dev/tty anyway) and a
pointer to Term::ReadKey module which is not distributed with the
activestate port. In fact, I'd rather not use external modules if
I can help it. ($rationale="at this point I wouldn't understand
what the module is doing and I do not like it that way. OTOH, if
I reinvent the wheel, I'll KNOW the wheel.")

In fact, I have found a way to make &get_reply() work, but
(a) it's ugly: (b) it requires a superfluous scalar; (c) it still
prints the prompt twice when an "incorrect" key is entered; (d) I
don't want to use something I don't quite understand:

-------------------------------------------------------
sub get_reply {
   my $keypress = " ";
   my $dummy;
   while ( $keypress !~ /[YNAQ]/i ) {
      print "(Y/N/A/Q) ";
      $keypress = getc;
      chomp $keypress;
   }
   $dummy = $keypress;
   $keypress = getc; # swallow whatever is lurking there
   return $dummy;
}
-------------------------------------------------------

I also tried extracting the first, single character from
$keypress using substr, but no dice. 

 .marek


PS. In the above routine, will it be safe to use splice to remove
items from the array while iterating over it? The FAQ says it's
unhealthy for hashes, but doesn't mention regular arrays. Can I
legally do something like:

-------------------------------------------------------
@tmp = ('one', 'two', 'three', 'four', 'five' );
my $item;

for ( $i=0; $i<($#tmp+1); $i++ ) {
   print $i, " $tmp[$i]\n";
   if ($item =~ /foo/) { splice @tmp, $i, 1; }
}
-------------------------------------------------------

This *runs*, but the result is rather messy, as I'd expected. 

-- 
"This is all very interesting, and I daresay you already
see me frothing at the mouth in a fit; but no, I am not;
I am just winking happy thoughts into a little tiddle cup."
(Vladimir Nabokov)



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

Date: 14 Feb 1998 15:44:59 GMT
From: jcr.remove@this.phrase.idiom.com (John C. Randolph)
Subject: Re: PC vs PC vs PC (was: Multithreaded servers and communicating object processes (proper))
Message-Id: <6c4e5r$ed2$1@news.idiom.com>


To me, the abbreviation in question means:

1) Printed Circuit (a technique for etching wiring patterns into a copper 
sheet which is bonded to an insulating material, such as phenolic or 
fiberglass.)  E.G: PC Board.

2) Program Counter (a register in a processor which holds the address of the 
binary instruction which the computer is either about to execute, or is in 
the middle of executing. )

All other definitions I ignore.


--
John C. Randolph (408) 358-6732  NeXT mail preferred.
Chief Technology Officer, WARPnet Incorporated.
"Only in a police state is the job of a policeman easy." - Orson Welles



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

Date: Sat, 14 Feb 1998 13:57:10 +0100
From: Peter Edlund <peter.edlund@capgemini.se>
Subject: Re: retrieving html files
Message-Id: <34E594A6.10C51A3D@capgemini.se>

Ernst wrote:
> 
> Hi
> 
> I think this is a simple question:
> How do I get a file from a remote webserver, without using the LWP
> module (I am not allowed to install this module on our server).
> 
> reg
> Ernst

The basic socket functions of Perl are enough to socket-connect to the
port (80 usually) and sending an HTTP request ('GET /The/File/You/Want
HTTP/1.0...') for the file in question.

For documentation check the perldocs on bind(), socket() and connect().
If you still need an example after reading some docs, mail me.

//peter.

---------------------------------
Peter Edlund
UNIX developement consultant
Cap Gemini Sweden
peter.edlund@capgemini.se


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

Date: 14 Feb 1998 14:35:45 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <slrn6ebaq2.gtf.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Mark Kramer <c28f62@world.std.com> wrote :
# In article <34E33BB0.8A9ACBE6@mail.uca.edu>,
# Cameron Dorey  <camerond@mail.uca.edu> wrote:
# >Unfortunately, I am sure there are people out there trying to do just
# >that. I know, because I was once one of them (for about a week). Coming
# 
# Can anyone reading this thread, where Matt has been referred to as
# either evil or bad, wonder why people don't jump up and down with glee
# at the thought of giving their code to this group?

But people do contribute.  Bad code is worse than no code at all, in
my opinion.  If someone knowledgable criticizes what you've done,
maybe you ought to listen.

gabor.
--
    There are still some other things to do, so don't think if I didn't
    fix your favorite bug that your bug report is in the bit bucket.
    (It may be, but don't think it.  :-)
        -- Larry Wall in <7238@jpl-devvax.JPL.NASA.GOV>


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

Date: 14 Feb 1998 14:51:48 GMT
From: burt@ici.net (Burt Lewis)
Subject: Sort help please!
Message-Id: <6c4b24$72n$1@bashir.ici.net>

Hi,

Once again I'm confused with sorting, thought I had it but gues not.

Appreciate any help.

This is my text data:

1"Hugo"Brown"12 Apple St.
5"Barnie"Lewis"765 Boulder St.
7"Mickey"Mantle"123 Red Rd.
9"Suzy"Burger"89 Appleton St.
10"Fred"Winston"910 Jump St.
11"Norman"Rockwell"102 Poplar Dr.
12"Doris "Lewis"199 Greenfield St.
13"Dee"Brown"88 Nashua St.

All I want to do is to be able to sort by any field (column).
What I'm trying to do below is sort by field #2 (first names).

This is what i have so far:

open (FILE,"$infile" ) || die "can't open $indexurl: $!\n";
@order = (<FILE>);

foreach(@order)
{
($number, $fname, $lname, $address1) = split /"/;
}
@sorted=
      map { $_->[0] }
      sort { $a->[1] <cmp> $b->[1]}
      map { [ $_, (split)[1, 3] ] } #######What this is doing??
  @order;
foreach(@sorted)
{
($number, $fname, $lname, $address1) = split /"/;
print "<tr><td bgcolor=silver><b>First Name</tr></td>";
print "<td bgcolor=gold><b>$number$fname</td></tr>";
		
print "<tr><td bgcolor=silver><b>Last Name</tr></td>";
print "<td bgcolor=gold><b>$lname</td></tr>";
print "<tr><td bgcolor=silver><b>Address 1</tr></td>";
print "<td bgcolor=gold><b>$address1</td></tr>";
print "<tr><td></tr></td>";
print "<td><b></td></tr>";
   }
print "</table>";   
print "</body></html>";
close (FILE);

Thanks!

Burt Lewis

 .




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

Date: Sat, 14 Feb 1998 11:28:23 -0500
From: "Kathleen Ramsey" <kramsey@worldnet.att.net>
Subject: Substituing Ctrl characters
Message-Id: <6c4gok$a0c@bgtnsc01.worldnet.att.net>

How can I substitute Ctrl characters in a file.  I have tons of Office
Writer file I need to convert to flat text.  All the info is on one line and
there are ^P and ^Q are tabs and ^Z is a CR LF.

I have tried (On a Dos Box. Maybe I should move it to a UNIX Box)

open (IN,"Filename");
binmode (IN);
$CtrlZ = \026;
$CtrlP = \016;
$CtrlQ = \017;

$line = <IN>;
$line =~ s/$CtrlZ/\n/g;
$line =~ s/$CtrlP/\t/g;
$line =~ s/$CtrlQ/\t/g;
print $line;


This does not do the substitution.  I tried  using $CtrlZ ="^Z";  where ^Z
was inputted in vi with
Ctrl V Ctrl Z. That did not seen to work either

Any Clues would be appreciated
Thanks,
Kathy




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

Date: Sat, 14 Feb 1998 09:37:56 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Substitution in perl for newbie
Message-Id: <34e55b30.6052020@news.btinternet.com>

On Sat, 14 Feb 1998 05:41:56 GMT, nospam@nospam.com (Jerry) wrote:


>I'm going to get the remote address ip, say 205.213.42.193.  I know
>how to do that(amazing).  However I want to basically cut off the last
>part of the address so it will be 205.213.42 and that's it.  Easy
>right?
>

$ip="205.213.42.193";
$ip=~ s/\.\d+$//;

/j\


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

Date: Sat, 14 Feb 1998 13:31:11 +0000
From: Gene Wilburn <genew@rom.on.ca>
Subject: The meaning of sort
Message-Id: <34E59C9F.81F1202C@rom.on.ca>

I have a Perl script that, when it sorts an array of terms
foreach $term (sort @terms) returns:

	Events, Archived
	Events, Coming
	Events

When I experimented, changing the commas to 'space - space' I still got:

	Events - Archived
	Events - Coming
	Events

There are no trailing spaces in the terms. Other than these related
terms, the rest of the terms sort properly.

I find this an unusual definition of sorting. The standard definition of
sort says that nothing comes before something and the output should
read:

	Events
	Events, Archived
	Events, Coming

Can anyone offer comments, elucidations or exegeses?

Gene Wilburn
genew@rom.on.ca


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

Date: Sat, 14 Feb 1998 15:36:59 GMT
From: Kevin Huber <khuber@yuck.net>
Subject: Re: The meaning of sort
Message-Id: <uj2u3a2w63o.fsf@bambi.visi.com>

A simple isolated test:
#!/usr/bin/perl

@terms=('Events - Coming','Events','Events - Archived');

foreach $term(sort @terms) {
   print $term,"\n";
}

prints the terms in the order you were expecting.  Trailing spaces (or
control characters) wouldn't affect the sort order.  There must be
something else going on.

Please post code which demonstrates the sorting error.

-Kevin

"Gene" == Gene Wilburn <genew@rom.on.ca> writes:

Gene> I have a Perl script that, when it sorts an array of terms
Gene> foreach $term (sort @terms) returns:

Gene> 	Events, Archived Events, Coming Events

Gene> When I experimented, changing the commas to 'space - space' I
Gene> still got:

Gene> 	Events - Archived Events - Coming Events

Gene> There are no trailing spaces in the terms. Other than these
Gene> related terms, the rest of the terms sort properly.

Gene> I find this an unusual definition of sorting. The standard
Gene> definition of sort says that nothing comes before something and
Gene> the output should read:

Gene> 	Events Events, Archived Events, Coming

Gene> Can anyone offer comments, elucidations or exegeses?

Gene> Gene Wilburn genew@rom.on.ca



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

Date: Sat, 14 Feb 1998 09:37:49 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: what does "deprecate" mean?
Message-Id: <34e54ebf.3091508@news.btinternet.com>

On Sat, 14 Feb 1998 08:33:28 GMT, dkoch@amcity.com (Daniel Koch)
wrote:

<snip>
>"Depreciated" is not commonly used in the context of programming
>languages.  

Except in such a context as : "The value of dBase <insert a language
of your choice> programming skill has depreciated over recent years"

/J\


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

Date: Sat, 14 Feb 1998 12:05:55 GMT
From: fdc@cliwe.ping.de (Frank D. Cringle)
Subject: Re: what does "deprecate" mean?
Message-Id: <vtg1lmgzmk.fsf@cliwe.ping.de>

doswald@xmission.com (David Oswald) writes:
> On 13 Feb 1998 14:32:03 -0500, kcohen@julius.ling.ohio-state.edu
> (Kevin B Cohen) wrote:
> 
> >okay, i *know* what it means to "deprecate" in english, but what does
> >it mean in perlish?  here are some examples of usage (hope i'm not
> >violating any laws of copyright...):
> >
> >"This usage is vaguely deprecated, and may be removed in some future
> >version of Perl."  (camel, 2nd ed., pg. 72)
> >
> >"Use of $* is now deprecated, and is allowed only for maintaining
> >backwards compatibility with older versions of Perl."  (camel, 2nd
> >ed., pg. 129)
> 
> "Depreciated" in this context begins by meaning discouraged or
> disapproved of.

But he asked about "deprecate", not "depreciate".  They are different
words.  Don't people use dictionaries anymore?

The english usage of "deprecate" and the perl/camel/
software-in-general usage are the same: "to plead earnestly against;
to express earnest disapproval of" (Shorter Oxford English Dictionary).

-- 
Frank Cringle,      fdc@cliwe.ping.de
voice: (+49 2304) 467101; fax: 943357


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

Date: Sat, 14 Feb 1998 09:37:52 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Where to start.
Message-Id: <34e551cc.3872377@news.btinternet.com>

On Fri, 13 Feb 1998 18:11:33 -0500, Brad Atkins <brad@liquid-web.com>
wrote:

>Hi,
>
>I want to try and learn Perl programming, CGI whatever you want to call
>it. Anyone have any good online tutorials, or have seen some?!
>
Brad, brad,brad,

You should have received by now an E-Mail from Nathan Torkington with
the subject line of WELCOME to comp.lang.perl.misc.

This is not junk mail.  I (and no doubt many others ) would suggest
reading this before making any further posts to this group.

/J\ 


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

Date: Sat, 14 Feb 1998 23:09:05 +1100
From: "Andrew Quested" <nospam--webmaster@hsv.com.au>
Subject: Why does this crash Perl 5.004_02 under Win NT?...
Message-Id: <6c41ra$g49$1@nswpull.telstra.net>

I have tried running this script on two NT machines, each running Perl
5.004_02 (the Standard version). In all cases, Perl crashes with a Dr.
Watson error. Can anyone tell me if there is anything I can do about this?
(I know ther is a 5.004_04 version of Perl, but the 5.004_02 verison seems
to be the most recent NT port in CPAN.)

use LWP::Simple;
$fullpage=get
    'http://racetime.com.au/racedata/s9802/r05res.htm';
$fullpage=~/<table.*>((.|\n)*)<\/table>/;
$table=$1;

I don't know if the problem is with Perl, with LWP, with NT or something
else. I have tried using different URLs in there, and it has had the same
result.

Thanks to anyone who can help.

Andrew.




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

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

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