[10389] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3982 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 15 13:08:02 1998

Date: Thu, 15 Oct 98 10:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 15 Oct 1998     Volume: 8 Number: 3982

Today's topics:
    Re: a camel? <Ian_Lowe@fanniemae.com>
    Re: Are there any "perl.newbie" group or forum? droby@copyright.com
    Re: Are there no PERL experts out there?? Is there no o <aqumsieh@tigre.matrox.com>
    Re: Arrays of UDTs? How to do this? (Abigail)
    Re: Batch-changing URL case in HTML pages with perl <rootbeer@teleport.com>
    Re: command line regexp replace question <ajohnson@gatewest.net>
    Re: command line regexp replace question <tgray@smlny.com>
        Compile Perl on As400 ? lars.miettunen@mandator.se
    Re: Continuing s/// from the last position. <jdporter@min.net>
    Re: Continuing s/// from the last position. <uri@camel.fastserv.com>
    Re: Equivalent of "unload" after "require"? <jdporter@min.net>
    Re: Extracting from text files - Please help! <rootbeer@teleport.com>
    Re: how to remove trailing spaces? <merlyn@stonehenge.com>
        Implementing an ordered queue (Matt Knecht)
    Re: Looking for Network Monitoring Scripts <rootbeer@teleport.com>
    Re: matching problems <aqumsieh@tigre.matrox.com>
    Re: Newbie ;) <murrayb@vansel.alcatel.com>
    Re: newbie at array parsing <murrayb@vansel.alcatel.com>
    Re: newbie at array parsing (Larry Rosler)
        Newbie Loop Help (Erik A Belknap)
    Re: Newbie needs help transposing two words in a file <aqumsieh@columba.matrox.com>
        Perl sendmail and binary files <edgar@insidewire.com>
    Re: perl.newbie <murrayb@vansel.alcatel.com>
    Re: problem with "use lib" <merlyn@stonehenge.com>
    Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has regi <eashton@bbnplanet.com>
    Re: Sorry <eashton@bbnplanet.com>
    Re: Sorry (Chris Russo)
    Re: Sorry <jdporter@min.net>
    Re: sorting file entries by time <lee@juno.ltd.uk>
        sorting sonigopi@hotmail.com
    Re: sorting (Larry Rosler)
    Re: sorting <uri@camel.fastserv.com>
    Re: sorting (David Alan Black)
    Re: splitting on meta chars <aqumsieh@tigre.matrox.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 15 Oct 1998 12:32:28 -0400
From: Ian Lowe <Ian_Lowe@fanniemae.com>
Subject: Re: a camel?
Message-Id: <3626239C.FAFC9E1C@fanniemae.com>

Ed wrote:
> 
> Why are there camels on so many perl pages, and on my O'Rielly book. I
> would consider a mollusk like an Oyster to have more relevance.


Page 2 of the camel book:  "The camel has evolved to to be relatively
self-sufficient".  So has perl :)

Ian


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

Date: Thu, 15 Oct 1998 15:56:07 GMT
From: droby@copyright.com
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <7055un$3er$1@nnrp1.dejanews.com>

In article <36253B69.FDE918C0@bbnplanet.com>,
  Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:
>
> Hmm...true, maybe the campaign for Perl should include getting CS
> Chairmen to consider offering more Perl classes in their undergraduate
> curricula. This would increase awareness, usage after graduation and
> perhaps less 'clueless newbies'. Food for thought.
>

Do you think many of those 'clueless newbies' have CS degrees?	I hope not. 
;-)

I have seen Perl taught in a "Programming Languages" class alongside Lisp and
some functional languages.

--
Don Roby

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


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

Date: Thu, 15 Oct 1998 10:51:39 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: Are there no PERL experts out there?? Is there no one who can solve this??
Message-Id: <Pine.SUN.3.96.981015105042.5370A-100000@tigre.matrox.com>

On Wed, 14 Oct 1998, Martien Verbruggen wrote:

    > Subject: Re: Are there no PERL experts out there?? Is there no one who can solve this??
    > 
    > That might be the snottiest subject line I've seen in a while.

I think s/he's just trolling.

--
Ala Qumsieh               email: aqumsieh@matrox.com
ASIC Design Engineer      phone: (514) 822-6000 x7581
Matrox Graphics Inc.      (old) webpage :
Montreal, Quebec          http://www.cim.mcgill.ca/~qumsieh



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

Date: 15 Oct 1998 16:17:22 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Arrays of UDTs? How to do this?
Message-Id: <70576i$dhc$1@client3.news.psi.net>

buckybeaver73@yahoo.com (buckybeaver73@yahoo.com) wrote on MDCCCLXXI
September MCMXCIII in <URL:news:703k7f$2ei$1@nnrp1.dejanews.com>:
++    Hi all... I am attempting something like this:
++ 
++ $smonths = ("Jan|31 Feb|28 Mar|31 Apr|30 May|31 Jun|30 Jul|31 Aug|31 Sep|31
++ Oct|31 Nov|30 Dec|31");

Sep has 31 days?

++ 
++ $cnt = 1;
++ @temp1 = split(/ /, $smonths);
++ foreach $i (@temp1) {
++ #print "$i<br>\n";
++         ($mname, $numdays) = split(/\|/, $i);
++         $montharray = {
++                 name => $mname,
++                 days => $numdays
++         };
++         push $montharray, @mmontharray;
                ^^^^^^^^^^^^^^^^^^^^^^^^^^    Switch this.
++ # for testing... print the name of the month just added...
++ print $montharray[$cnt]=>name, "<br>\n";
                          ^^^^^^   Should be -> {name}
++         $cnt++;
++ }
++ 
++ But it doesn't seem to work... What I want is an array indexed by the month #,
++ with a name field of the month name, and a days field consisting of the # of
++ days in that month. Can anyone see what I am doing wrong? I am fairly new to
++ PERL and this problem is running me in circles. Any help is appreciated.


You can of course do it all at once:

@mmontharray = map {{name => $_ -> [0],
                     days => $_ -> [1]}} 
                     [Jan => 31], [Feb => 28], [Mar => 31], [Apr => 30],
                     [May => 31], [Jun => 30], [Jul => 31], [Aug => 31],
                     [Sep => 30], [Oct => 31], [Nov => 30], [Dec => 31];
  


Abigail
-- 
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'


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

Date: Thu, 15 Oct 1998 15:35:26 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Batch-changing URL case in HTML pages with perl
Message-Id: <Pine.GSO.4.02A.9810150833230.26848-100000@user2.teleport.com>

On 14 Oct 1998, Lloyd Zusman wrote:

> URL's are case sensitive when being sent to web servers which do
> case-sensitive filename matching.  Web servers running on Microsoft
> boxes do not do case-sensitive filename matching.

The case-sensitivity of filename matching has nothing to do with it. URLs
can point to other things than files, of course. I can set up a webserver
on a Microsoft box which does use case-sensitive URLs. But this has
nothing to do with Perl. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 15 Oct 1998 11:29:22 -0500
From: Andrew Johnson <ajohnson@gatewest.net>
Subject: Re: command line regexp replace question
Message-Id: <362622E2.4D873984@gatewest.net>

Tim Gray wrote:
!
! Hi there
!     I am trying to remove lines that look like the one below from a
! bunch of html files.  The only thing that changes is the number after
! tsld.
! 
! <A HREF="tsld005.htm"><IMG SRC="text.gif" BORDER=0 ALT="Text"></A>
! 
! I didn't want to screw up my files so I tried to test by just
! printing matching lines first with this (note, I am using double
! quotes because this is Win32 perl).
! 
! perl -pe "print if m/<A HREF=.tsld*A>/ =~ $_;" *.htm
! 
! But that ends up printing every line.

First:
-p means print: as in the description in the perlrun manpage
it wraps your script in:

    while (<>) {
        ...             # your script goes here
    } continue {
        print or die "-p destination: $!\n";
    }

you had intended to only print matching lines, right? well, as you
can see, your script (if there weren't other problems) would print
matching lines twice, once in the while, and again in the continue.

Second: 
You've got your pattern matching backwards, it should be

print if $_ =~ m/pattern/

or, more concisely: print if m/pattern/

Third:
There are some problems with your pattern itself. In a perl regular
expression *  is a quantifier and is not the same as wildcard
expansion like *.htm on the command line. Hence, d* means match a 'd'
zero-or-more times. You probably wanted something more like:
m/<A HREF=.tsld.*A>/

and if the line you mention above that you want to match is really
the only thing on the line, you probably want to anchor this
expression as:
m/^<A HREF=.tsld.*A>$/

also, note that this will match any line that begins with
'<A HREF=.tsld' and ends with 'A>', which is not quite the
same as your specification above to match only lines that are
the same as your complete example and differ only in the digits
following 'tsld'. You might want to use the whole example line
as the pattern and use \d+ to allow for changing digits.

see the perlre manpage for details on *, \d+ and other things.
see the perlrun manpage for details on command line switches.
see the perlop manpage for details on the ~= binding operator.

! So I would imagine that the code I wanted to run
! 
! perl -pe "s/<A HREF=.tsld*A>//;" *.htm
! 
! Would end up erasing the entire file rather than just the line I am
! interested in.

In this case, this would effectively erase the offending lines, if
they matched the expression (see above), in the output (but still
leave the newline) ... it would *not* do anything to the file itself
since you are not using the -i switch for inplace editing. Again see
the perlrun manpage for the -i switch, and use it with an extension
to backup your files before changing them.

hope this helps
regards
andrew


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

Date: Thu, 15 Oct 1998 12:16:27 -0400
From: "Tim Gray" <tgray@smlny.com>
Subject: Re: command line regexp replace question
Message-Id: <gapV1.219$v_3.906873@newse1.twcny.rr.com>

Thanks to all who replied.

My regexp was bad, my operands were switched and my switches were wrong.

I guess I have to keep in practice more to keep my perl skills from
atrophying.






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

Date: Thu, 15 Oct 1998 16:17:53 GMT
From: lars.miettunen@mandator.se
Subject: Compile Perl on As400 ?
Message-Id: <70577i$4tc$1@nnrp1.dejanews.com>

Hi!

Have anyone tried to compile Perl 5.004 or higher on an As400 ?
There is a precompiled version..but it's only 5.003.

/Lars M

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


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

Date: Thu, 15 Oct 1998 12:35:00 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Continuing s/// from the last position.
Message-Id: <36262434.3B488874@min.net>

Uri Guttman wrote:
> 
> >>>>> "MR" == Michal Rutka <erhmiru@erh.ericsson.se> writes:
> 
>   MR> Uri Guttman <uri@camel.fastserv.com> writes:
>   >> well, you are right that /g and \G only work with m// and you want to
>                                  ^^^
> do you see this word             ^^^
> 
>   >> use s///.
> 
>   MR> Where do you found that /g works only with m//??? You can look on the p.72
>   MR> of the Camel book you see that s/// can use /g if you want. Even there
>   MR> is an example on the next page with s///g. Please check your sources.
> 
> i really resent your comments here and below. i said /g AND \G. this is
> english for the same as perl && but without the short circuiting.

Quite wrong, Uri, quite wrong.

"Larry and Tim only work on Fridays."

Does this mean Larry might work on other days?
Of course not.  It means 
"Larry only works on Fridays, and Tim only works on Fridays."

Michal was understandably confused.  So was I.
But I read and re-read your post, eventually concluding that it was
simply poorly worded.

-- 
John "Many Jars" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: 15 Oct 1998 12:41:05 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: Continuing s/// from the last position.
Message-Id: <sar1zo9rd5q.fsf@camel.fastserv.com>

>>>>> "JP" == John Porter <jdporter@min.net> writes:

  JP> Uri Guttman wrote:
  >>  >>>>> "MR" == Michal Rutka <erhmiru@erh.ericsson.se> writes:
  >> 
  MR> Uri Guttman <uri@camel.fastserv.com> writes:
  >> >> well, you are right that /g and \G only work with m// and you
  >> want to ^^^ do you see this word ^^^
  >> 
  >> >> use s///.
  >> 
  MR> Where do you found that /g works only with m//??? You can look on
  MR> the p.72 of the Camel book you see that s/// can use /g if you
  MR> want. Even there is an example on the next page with s///g. Please
  MR> check your sources.
  >>  i really resent your comments here and below. i said /g AND
  >> \G. this is english for the same as perl && but without the short
  >> circuiting.

  JP> Quite wrong, Uri, quite wrong.

  JP> "Larry and Tim only work on Fridays."

how true! :-)


  JP> Does this mean Larry might work on other days?  Of course not.  It
  JP> means "Larry only works on Fridays, and Tim only works on
  JP> Fridays."

it could mean they only work together on fridays but that might be
reading too much into it.

  JP> Michal was understandably confused.  So was I.  But I read and
  JP> re-read your post, eventually concluding that it was simply poorly
  JP> worded.

but remember i am the only one who posted working code to solve the
original problem. the poster even tried and liked it. so i can be
forgiven for my slightly ambiguous english as interpeted by rutka. i
could have said "/g and \G only work as a combination with m//" but that
fact that \G is only in m// may imply that i meant that. the original
poster commented on the fact that \G didn't work with s/// and i was
following that line of thought. if rutka had seen the full thread he
would not have been confused about my statement, as he had said such
later.

uri, whose first language was PL/I and then english! talk about ambiguity! :-)


-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Thu, 15 Oct 1998 12:40:54 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Equivalent of "unload" after "require"?
Message-Id: <36262596.79FB19F7@min.net>

Randal Schwartz wrote:
> 
> >>>>> "Tom" == Tom Christiansen <tchrist@mox.perl.com> writes:
> 
> Tom> 4)  use Module is like require Module, except the former:
> Tom>    4.1: loads the module at compile time, not run-time.
> Tom>    4.2: imports symbols and semantics from that package to the current one.
> 
> ... for a *normal* "import()" class method.  Nothing can be said for
> non-standard import() methods, which may merely invoke NetHack with
> the given arguments, if any.

I know it's a stretch, but couldn't that be considered the
importation of "semantics" into the calling package?

no NetHack;  # kill the nethack session

-- 
John "Many Jars" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: Thu, 15 Oct 1998 15:59:32 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Extracting from text files - Please help!
Message-Id: <Pine.GSO.4.02A.9810150856200.26848-100000@user2.teleport.com>

On Wed, 14 Oct 1998, webbert wrote:

> Subject: Extracting from text files - Please help!

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I have a huge text file with entries in the form:
> 
> ***
> Record 1
>         Name: John Smith
>         Address:  Street 123
>                        One Tree Road
>                        Apartment 123

[ remainder snipped ]

> Has anyone already written a script to extract these information into
> an array where the fields would be $record,$name, $address,
> $telephone,$directory?

Probably not, no matter what that sentence means. :-)  But it would be
relatively easy to parse that data using Perl. The Llama book has similar
exercises; see the perlbook manpage for more info. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 15 Oct 1998 16:20:45 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: how to remove trailing spaces?
Message-Id: <8c1zo9bxuu.fsf@gadget.cscaper.com>

>>>>> "Antti-Jussi" == Antti-Jussi Korjonen <Antti-Jussi.Korjonen@sonera.fi> writes:

Antti-Jussi> Mark Cain wrote:

>> try this:
>> #  search for zero or more of the space character juxtaposed to the EOL
>> #  and replace it with nothing
>> $temp =~ s/ *$//;

Antti-Jussi> that worked, thank you very much!

But it works too often!

You really want s/ +$//, or better, s/\s+$//;

The * can match zero times, so you'll do a null-change (successfully)
even on lines without ending whitespace.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 15 Oct 1998 16:29:08 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Implementing an ordered queue
Message-Id: <oppV1.8926$wV1.5858922@news2.voicenet.com>


I need to create a sorted queue in real time.  I'll be sorting on Unix
timestamps.  The data will come in arbitrary order, and I need to keep
my queue in strict chronological order (So I can always pluck the
oldest record off the end).

In C, I'd implement this as a doubly linked list, or perhaps a Btree.
Trying to implement this in Perl is giving me headaches, though.  Using
a hash for each node, and having a reference to another is pretty slow
(I'd like this to be as fast as possible, while still keeping it in
Perl).

I've searched CPAN for a binary tree module, and came up with nothing.
Currently I'm looking at the code[0] Abigail has for dealing with a
Btree.  Does anyone have experience with this?

Is there a better way to do this?  Should I be looking at writing an
XSUB?

[0] http://cthulhu.mandrake.net/%7Eabigail/Perl/CLR/Tree/Binary.pm

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: Thu, 15 Oct 1998 16:01:39 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Looking for Network Monitoring Scripts
Message-Id: <Pine.GSO.4.02A.9810150901240.26848-100000@user2.teleport.com>

On Thu, 15 Oct 1998, Stephan Gross wrote:

> Subject: Looking for Network Monitoring Scripts

If you're wishing merely to _find_ (as opposed to write) programs,
this newsgroup may not be the best resource for you. There are many
freeware and shareware archives which you can find by searching Yahoo
or a similar service. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 15 Oct 1998 10:17:32 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: matching problems
Message-Id: <Pine.SUN.3.96.981015101342.4778A-100000@tigre.matrox.com>

On Wed, 14 Oct 1998, Troy Bull wrote:

    > Date: Wed, 14 Oct 1998 09:32:56 -0500
    > From: Troy Bull <troy.bull@uni.edu>
    > Newsgroups: comp.lang.perl.misc
    > Subject: matching problems
    > 
    > I have a small program that does a search of the form
    > 
    > s/(\w{3}):(\w{3})/wrap stuff around $1 and $2/g
    > 
    > the problem is that it matches one case that I need for it not to
    > ___:___ needs to not match  this is the only case that needs to
    > fail, if any one of the six underscores is a [a-zA-Z0-9] it should
    > match.  I am stuck on this one, if anyone has any ideas I would
    > appreciate the help.
    > thanks in advance

You can check whether $1 (or $2?) is equal to "___" first ... like so:

s/(\w{3}):(\w{3})/$1 eq "___" ? "$1:$2" : wrap stuff around $1 and $2/eg;

There are other ways to do it using look-ahead (which might be actually
faster), but this should work fine.

--
Ala Qumsieh               email: aqumsieh@matrox.com
ASIC Design Engineer      phone: (514) 822-6000 x7581
Matrox Graphics Inc.      (old) webpage :
Montreal, Quebec          http://www.cim.mcgill.ca/~qumsieh



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

Date: 15 Oct 1998 08:43:30 -0700
From: Brad Murray <murrayb@vansel.alcatel.com>
Subject: Re: Newbie ;)
Message-Id: <u67dl96fx.fsf@vansel.alcatel.com>

bantam@freenet.edmonton.ab.ca () writes:

> I am just another newbie with a few q'n to the mongers. 
> 1) When I have a line in the script saying require 'something.pl'; does it
> mean I have to place something.pl into the same directory as script.pl? 

No.  It can be in @INC.  perldoc -f require for information.

> 2) What is a *.pm file exactly? Something like an include file or rather
> a library? 

perldoc perlmod for information about modules.  There was also a good
description of the differences in comp.lang.perl.moderated a short time
ago.  You might want to read up a bit before proceeding.

> 3) Is there a good d/l page for *.pl and *.pm files? (I seem to need some
> pretty weird ones, which do not come w/ the PERL distribution...)

http://www.CPAN.org will point you in the right direction.

-- 
Brad Murray      "This is one of the reasons you're such big hits at
Software Analyst  your parents' parties: being a good conversationalist
Alcatel Canada    is really what a liberal arts education is all about."


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

Date: 15 Oct 1998 08:11:17 -0700
From: Brad Murray <murrayb@vansel.alcatel.com>
Subject: Re: newbie at array parsing
Message-Id: <u7ly197xm.fsf@vansel.alcatel.com>

"Marcus J. Foody" <marx@idiom.com> writes:

> Hello, I'm trying to pull out a specific value(field) inside the
> array($line).  Is this possible?  Below  is my output. I'm trying to
> pull out the value |709|.  If you have a suggestion on this matter it
> would be much appreciated.
> 
> |BUSINESS UNIT #709|REC BATCH|19980707|709|HPC INVOICE
> MEMOS|INVOICE|3|USD|5500.00

I think you want to look at the man page for split.  I would, for example,
use this (assuming $line is set to the above):

@record = split /\|/, $line;
$field = "|$record[5]|";

Notice I'm gluing the pipes on either side manually.  This is because I'm
not convinced you really want them, so I refuse to extract them from the
file.  :)

-- 
GAT$ d+(---) s: a C(++++) U++++$ P+++$ L++ E+ W+ N+ !o !K w--- O++$ M+
V PS++ PE Y+ PGP t-- 5 X-- !R tv- b+++ DI++ !D G+ e* h- r+++ y+++


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

Date: Thu, 15 Oct 1998 09:49:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie at array parsing
Message-Id: <MPG.108fc76a82b35b069898bb@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <u7ly197xm.fsf@vansel.alcatel.com> on 15 Oct 1998 08:11:17 -
0700, Brad Murray <murrayb@vansel.alcatel.com> says...
! "Marcus J. Foody" <marx@idiom.com> writes:
! 
! > Hello, I'm trying to pull out a specific value(field) inside the
! > array($line).  Is this possible?  Below  is my output. I'm trying to
! > pull out the value |709|.  If you have a suggestion on this matter 
it
! > would be much appreciated.
! > 
! > |BUSINESS UNIT #709|REC BATCH|19980707|709|HPC INVOICE
! > MEMOS|INVOICE|3|USD|5500.00
! 
! I think you want to look at the man page for split.  I would, for 
example,
! use this (assuming $line is set to the above):
! 
! @record = split /\|/, $line;
! $field = "|$record[5]|";
                     ^
                     3

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


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

Date: 15 Oct 1998 16:44:04 GMT
From: ebelknap@runet.edu (Erik A Belknap)
Subject: Newbie Loop Help
Message-Id: <7058ok$6v3@newslink.runet.edu>

Hi I have a problem getting this program to read the entire data file:
I took out the loop it runs but the it needs to read the 9500 lines of a
data file.  The lines consist of comments and blank lines.  How do I get
it to loop until end of file.  I tried the eof and didnt get it to work.
I tried the $line eq "" and that exits the loop when it finds a blank
line.  Please help I am just getting started with perl and this doesnt
seem that hard of a task but I cant find any other resources.  Here is the
code I have that works:

 if ($valid) {
   open (INFILE, $infile) || die ("You Suck");
   chop($line = <INFILE>);
   while ($line =~ /[#^]/ || $line eq "") {
    chop($line = <INFILE>);
   }
   @data = split(/ /, $line);
   @ip = split(/\./, $data[0]);
    if ($ip[2] eq $input{subnetnumber}) {
     print "$data[0]<BR>";
    }

thanks in advance!
Erik ebelknap@runet.edu


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

Date: Thu, 15 Oct 1998 11:15:55 -0400
From: Ala Qumsieh <aqumsieh@columba.matrox.com>
Subject: Re: Newbie needs help transposing two words in a file
Message-Id: <Pine.SUN.3.96.981015111415.20087A-100000@columba.matrox.com>


    > Now that statement is bogus .. I am not trying to hide myself by any
    > means .. I have actually received many emails from people posting to
    > this group. Let me give you a taste of your own medicine now ..
    > Did you even try to email me before stating the above statement ?? Did
    > you "think before you posted" ? ;)
    > I am really curious to know how you came to this conclusion!

Just a clarification:
I did not mean to imply that Larry doesn't test before he posts.
The truth is that I thought that the email address supplied by my
newsreader (aqumsieh@tigre.matrox.com) was actually fine. That is why I
questioned the truth of Larry's claim (which is indeed true). I apologize
for any misunderstanding this might have caused.

Regards,
Ala
--
Ala Qumsieh               email: aqumsieh@matrox.com
ASIC Design Engineer      phone: (514) 822-6000 x7581
Matrox Graphics Inc.      (old) webpage :
Montreal, Quebec          http://www.cim.mcgill.ca/~qumsieh






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

Date: Thu, 15 Oct 1998 12:19:41 -0400
From: "Edgar Sigal" <edgar@insidewire.com>
Subject: Perl sendmail and binary files
Message-Id: <36262077.0@diana.idirect.com>

A quick question concerning sending a binary file as an attachment from a
perl script.

The script works fine when the file in question (to be attached) is a plain
text file, however when it is a file such as a word document. the script
executes but sendmail doesn't send anything.

I guess this may be more a sendmail issue than perl but if anyone can help I
would appreciate it.

open mail and stuff ....

print MAIL "--=====================_$TimeStamp==_\n";
print MAIL "Content-Type: application/bin;\n";
print MAIL "Content-Disposition: attachment; filename=\"$upfile\"\n\n";

$File_Handle = "$resumetemp/$upfile";
binmode(TFILE3);
open (TFILE3,"$File_Handle")||print "couldn't open the data file";
        while ($Bytes = read(TFILE3,$Buffer,1024)) {
            print MAIL $Buffer;
       }
close (TFILE3);

print MAIL "\n--=====================_$TimeStamp==_--\n";
close MAIL;



--
-Edgar

edgarnospam@insidewire.com




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

Date: 15 Oct 1998 08:49:46 -0700
From: Brad Murray <murrayb@vansel.alcatel.com>
Subject: Re: perl.newbie
Message-Id: <u4st5965h.fsf@vansel.alcatel.com>

David Barnard <D.M.Barnard@ncl.ac.uk> writes:

> I am a newbie. I intend to learn Perl as a second language. My first is
> Pascal: you can't get more structured than Pascal. Pascal (I usually use
> Delphi) code looks pretty, reads easily, compiles fast. I'm hoping that Perl
> will just run fast.

Actually, my experience so far has been that the major virtue of Perl is
that it lets you get work done.  When you need to make things run, and you
need to do it now, Perl is your friend and ally.  It's like carrying a
mulit-plier and duct tape around---they don't provide the perfect, final
solutions to all problems, but the sure cover a lot of ground handily.

> There are more one liners in Perl than anywhere else. I suspect that the
> difference between Unix and Windows is - Unix programmers have a whole lot
> more fun.

This is, I think, one of the reasons for my obeservation  above: Perl gets
work done atleast in part because it's fun, and it's fun for the same
reasons that Unix is.  It's flexible, tool-oriented, and gives you enough
rope to shoot yourself in the foot with, to remix a metaphor.

-- 
Brad Murray       "The mysterious VMS C Standard I/O Package and RMS
Software Analyst   may interact to modify file contents unexpectedly."
Alcatel Canada                      ---Omen Technologies


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

Date: Thu, 15 Oct 1998 16:17:57 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: problem with "use lib"
Message-Id: <8c4st5bxzi.fsf@gadget.cscaper.com>

>>>>> "Tom" == Tom Christiansen <tchrist@mox.perl.com> writes:

Tom> Or just:

Tom>     BEGIN { $MY_LIB = "/u/lib/perl" }
Tom>     use lib $MY_LIB;

Or even

	use constant MY_LIB => /u/lib/perl;
	...
	... time passes ...
	... little puppies turn into full grown dogs ...
	...
	use lib MY_LIB;

Look ma! No mysterious "BEGIN". :)

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 15 Oct 1998 16:20:17 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <36261E3F.3A1E0CA9@bbnplanet.com>

John Klassa wrote:

> If you're interested, send me some mail (klassa@ipass.net)...  If you
> know of a suitable place for the first meeting (i.e. someplace readily
> accessible, and more importantly free :-)), *please* let me know.  I'm at a
> loss for where to have this thing...

What?! Raliegh doesn't have any pubs? :) Welcome to the fray.

/me wonders what a 'camel pub' would be like....hmmmmm.

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: Thu, 15 Oct 1998 16:01:38 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Sorry
Message-Id: <362619E0.6B961879@bbnplanet.com>

I R A Aggie wrote:

> + Q: Why do universities have both libraries and instructors?
> +
> + A: Because it is not always sufficient that a given piece of information
> + be archived somewhere.
> 
> Because both are storehouses of information. The instructor simply
> hasn't formalized their information enough to be placed in the library.

Both are valuable _resources_ for the enquiring mind. Libraries are the
most amazing places, filled with so many wonderful things including the
librarians. CPAN is the library of Perl. 

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: Thu, 15 Oct 1998 08:55:36 -0700
From: news@russo.org (Chris Russo)
Subject: Re: Sorry
Message-Id: <news-1510980855360001@buzz.hq.alink.net>

In article <rlb-1510980825150001@204.112.166.151>, rlb@intrinsix.ca (Lee
Brandson) wrote:

>Q: Why do universities have both libraries and instructors?
>
>A: Because it is not always sufficient that a given piece of information
>be archived somewhere.

Poor analogy.  University educations are paid for.  As a student, you can
rightfully expect help, since you've shelled out the cash for it.

USENET is cooperative.  Respect from question askers (by doing some
legwork) will yield respect from question answerers.  Presumption will
yield rudeness.

Regards,

Chris Russo

-- 
Chris Russo
news@russo.org
http://www.russo.org


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

Date: Thu, 15 Oct 1998 12:50:53 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Sorry
Message-Id: <362627ED.C42390AC@min.net>

Larry Wall wrote:
> 
> Perl is worse than Python because people wanted it worse.

Meaning "wanted it more badly", I take it?

-- 
John "Many Jars" Porter


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

Date: Thu, 15 Oct 1998 17:14:07 +0100
From: Lee Musgrave <lee@juno.ltd.uk>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: sorting file entries by time
Message-Id: <36261F4F.ADBA2A98@juno.ltd.uk>

hi,
not very far,
i've been experimenting, and i've ended up reading in the entire file
line by line,
splitting each line into an array and taking out the required array
entry, this is
added to a string. The string is then split into an array, which gets
sorted. i can
sort the time fine this way, now i have to figure out how to get the
sorted entries
to grab their original lines and print to a file.

the code i'm using is below, i just have it printing to STDOUT for
checking at
the moment, but i'm quite sure the entire code is inefficient and
convuluted
i.e.  crap  ;(


while ($line ne "") {
         @arrayline = split(/ +/, $line);
         $timestring = "@arrayline[5]  ";
         @arraytime = split(/:/, $timestring);
         $t1 = @arraytime[0];
         $t1 .= @arraytime[1];
         $t1 .= @arraytime[2];
         $array .= $t1;
         $line = <T>;
}

@time = split(/ +/, $array);
@list = sort num (@time);

sub num {
     my ($num_a, $num_b);
     $num_a = $a =~ /^[0-9]/;
     $num_b = $b =~ /^[0-9]/;
     if ($num_a && $num_b) {
              $retval = $a <=> $b;
     } elsif ($num_a) {
              $retval = 1;
     } elsif ($num_b) {
              $retval = -1;
     } else {
              $retval = $a cmp $b;
     }
     $retval;
}

foreach $time (@list) {
         print ("$time\n")
}


well, i never claimed to be a programmer....

lee.



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

Date: Thu, 15 Oct 1998 15:58:05 GMT
From: sonigopi@hotmail.com
Subject: sorting
Message-Id: <70562d$3g7$1@nnrp1.dejanews.com>



  Is there a way to evaluate a string in SORT routing. For Example,

  @sorted = sort{$a->{age}<=>$b->{age} || $a->{name} cmp $b->{name}}@unsorted
;  NOERROR

  But, say

  $condition = "\$a->{age} <=> \$b->{age || \$a->{name} cmp \$b->{name}}" ; 
2)  @sorted =  sort { $condition } @unsorted ;	ERROR

  The problem is I have 15 list and I need to sort them by one or  more key.
  So I created a structure and copied all values associated with index of
  lists to this structure . Know the problem is that sorting contitions can
  dynmically change depends on how user wants lists to be sorted. For example,
  user may want to sort by Birthday and then by name when multiple people have
  same Birthday. Another user may want sort by Birthday and then by name and
  then by age when multiple people have same Birthday , name , and age.

  I am using perl sort functions and it works great if I hard code the
  condition but like I said, conditions are dynamically changing.

  Need help ..

  Thanks
   soni

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


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

Date: Thu, 15 Oct 1998 09:29:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sorting
Message-Id: <MPG.108fc2c2d87abb0f9898ba@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <70562d$3g7$1@nnrp1.dejanews.com> on Thu, 15 Oct 1998 
15:58:05 GMT, sonigopi@hotmail.com <sonigopi@hotmail.com> says...
>   Is there a way to evaluate a string in SORT routing. ...

This was discussed here last week (October 10).  Look for this thread 
using DejaNews:

sort with dynamic sort expression help

My posting is at:

http://x11.dejanews.com/getdoc.xp?AN=399735031&CONTEXT=908468602.4932895
32&hitnum=0
 
-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 15 Oct 1998 12:35:03 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: sorting
Message-Id: <sar3e8prdfr.fsf@camel.fastserv.com>

>>>>> "s" == sonigopi  <sonigopi@hotmail.com> writes:

  s>   Is there a way to evaluate a string in SORT routing. For Example,

  s>   @sorted = sort{$a->{age}<=>$b->{age} || $a->{name} cmp
  s> $b->{name}}@unsorted ; NOERROR

  s>   But, say

  s>   $condition = "\$a->{age} <=> \$b->{age || \$a->{name} cmp
  s> \$b->{name}}" ; 2) @sorted = sort { $condition } @unsorted ; ERROR

  s>   The problem is I have 15 list and I need to sort them by one or
  s> more key.  So I created a structure and copied all values
  s> associated with index of lists to this structure . Know the problem
  s> is that sorting contitions can dynmically change depends on how
  s> user wants lists to be sorted. For example, user may want to sort
  s> by Birthday and then by name when multiple people have same
  s> Birthday. Another user may want sort by Birthday and then by name
  s> and then by age when multiple people have same Birthday , name ,
  s> and age.

  s>   I am using perl sort functions and it works great if I hard code
  s> the condition but like I said, conditions are dynamically changing.

a good idea would be to build the compare string wrapped in a sub and
eval it. that value can be used as a sub call in the sort block. since
you seem to know what each user wants as a set of sort keys, this is
easily done.

hth,

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: 15 Oct 1998 12:50:19 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: sorting
Message-Id: <70594b$h0j$1@pilot.njin.net>

Hello -

sonigopi@hotmail.com writes:

>  Is there a way to evaluate a string in SORT routing. For Example,

>  @sorted = sort{$a->{age}<=>$b->{age} || $a->{name} cmp $b->{name}}@unsorted
>;  NOERROR

>  But, say

>  $condition = "\$a->{age} <=> \$b->{age || \$a->{name} cmp \$b->{name}}" ; 
>2)  @sorted =  sort { $condition } @unsorted ;	ERROR

>  The problem is I have 15 list and I need to sort them by one or  more key.
>  So I created a structure and copied all values associated with index of
>  lists to this structure . Know the problem is that sorting contitions can
>  dynmically change depends on how user wants lists to be sorted. For example,
>  user may want to sort by Birthday and then by name when multiple people have
>  same Birthday. Another user may want sort by Birthday and then by name and
>  then by age when multiple people have same Birthday , name , and age.


You could create a hash of comparison subroutines, and then stack them
as needed/requested:

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

my %sr = (  age    => sub { $a->{age}  <=> $b->{age} },
            name   => sub { $a->{name} cmp $b->{name} },
         );

my @people = ( { name => "David",    age => 39 },
               { name => "Someone",  age => 38 },
               { name => "Same Age", age => 39 },
            );


# By age, then name:
   print map { "$_->{age}  $_->{name}\n" }
         sort { &{$sr{age}} } sort { &{$sr{name}} } @people;


It has the merit of developer efficiency, at least....

David Black
dblack@pilot.njin.net


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

Date: Thu, 15 Oct 1998 10:32:56 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
To: valis@pacbell.net
Subject: Re: splitting on meta chars
Message-Id: <Pine.SUN.3.96.981015103109.4778B-100000@tigre.matrox.com>

On Wed, 14 Oct 1998 valis@pacbell.net wrote:

    > I'm parsing a file that has a varying column delimiter.
    > I have to split the records depending on the delimiter which could be any  meta char (\, $, |, etc)
    > I have some code that uses eval but doesnt work
    > Can someone help me write the code that takes care of all possiblilities?
    > Help greatly appreciated.
    > Kal.

You need to use \Q and \E .. read perlre (at least).

$delim = '|';
@fields = split /\Q$delim/, $line;

Hope this helps,
--
Ala Qumsieh               email: aqumsieh@matrox.com
ASIC Design Engineer      phone: (514) 822-6000 x7581
Matrox Graphics Inc.      (old) webpage :
Montreal, Quebec          http://www.cim.mcgill.ca/~qumsieh



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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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