[10902] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4503 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 27 23:07:33 1998

Date: Sun, 27 Dec 98 20:00:18 -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           Sun, 27 Dec 1998     Volume: 8 Number: 4503

Today's topics:
    Re: Basic Perl DOS/Win95 + WWW + CGI course for Newbies (Groovy94)
    Re: Best Perl Book for a "Not Yet" Perl Programmer (Jeff Iverson)
    Re: Do I need a web server to practice Perl in my compu (Groovy94)
    Re: Is Perl as multifunctional as I've heard\read? <ajonsson@csi.com>
        LWP Tutorial <debot@xs4all.nl>
    Re: LWP Tutorial <gellyfish@btinternet.com>
    Re: Mail from PERL using variable mail address <peter@berghold.net>
    Re: need help (Groovy94)
    Re: need help <ajonsson@csi.com>
    Re: Pacman anyone? <gellyfish@btinternet.com>
    Re: Pacman anyone? <ajonsson@csi.com>
    Re: problem with specific language characters ("=?ISO-8 <gellyfish@btinternet.com>
    Re: removing "Tk" from Perl/Tk under Win <gellyfish@btinternet.com>
    Re: Retrospective on comp.lang.perl.moderated? (John Stanley)
    Re: Retrospective on comp.lang.perl.moderated? (Leslie Mikesell)
    Re: Script for Paradox? <gellyfish@btinternet.com>
    Re: searching for pattern in a file <ajonsson@csi.com>
    Re: simple code needed to determine date to print on a  (Groovy94)
    Re: simple code needed to determine date to print on a  (Groovy94)
    Re: sorting <peter@berghold.net>
        Splitting multiple |'s (Groovy94)
    Re: Splitting multiple |'s <rick.delaney@home.com>
    Re: Splitting multiple |'s (Matthew Bafford)
    Re: Splitting multiple |'s <gellyfish@btinternet.com>
    Re: Uninitialized value error (Ronald J Kimball)
    Re: Uninitialized value error <gellyfish@btinternet.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 28 Dec 1998 02:54:25 GMT
From: groovy94@aol.com (Groovy94)
Subject: Re: Basic Perl DOS/Win95 + WWW + CGI course for Newbies , Christmas free offer .
Message-Id: <19981227215425.08423.00001983@ng-fu1.aol.com>

I would like to help with the course and learn some, as I am an amatuer
programmer, but know quite a bit. Please also contact me if you get this
newsgroup together.
Regards,
Gil Hildebrand, Jr.
Dynamic Scripts

Email: groovy94@aol.com
ICQ UIN: 16678754


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

Date: Mon, 28 Dec 1998 01:21:45 GMT
From: j5rson@frontiernet.net (Jeff Iverson)
Subject: Re: Best Perl Book for a "Not Yet" Perl Programmer
Message-Id: <3690dcf0.118636014@news.frontiernet.net>

Here are some book suggestions:

Programming Perl (2nd Edition)
http://www.amazon.com/exec/obidos/ASIN/1565921496/iversonsoftwarecA

Learning Perl (2nd Edition)
http://www.amazon.com/exec/obidos/ASIN/1565922840/iversonsoftwarecA

Perl Cookbook
http://www.amazon.com/exec/obidos/ASIN/1565922433/iversonsoftwarecA

On 25 Dec 1998 17:45:03 GMT, kjphilbr13@aol.com (KJPhilbr13) wrote:

>Background in C, C++, Visual Basic, sh, ksh, etc...
>
>What is the best book to start?  Need to understand program structure, language
>references, hints/examples, etc.
>
>Thanks in advance...Kevin P. in Charlotte, NC

Kind Regards,
Jeff Iverson
-- 
Iverson Software Co.  507-235-9209 - voice
418 N. State St. #7   507-235-8835 - fax
Fairmont MN  56001    http://www.iversonsoftware.com/


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

Date: 28 Dec 1998 03:42:04 GMT
From: groovy94@aol.com (Groovy94)
Subject: Re: Do I need a web server to practice Perl in my computer?
Message-Id: <19981227224204.00796.00002732@ng-fv1.aol.com>

If you do decide to get a web server, I reccomend Website Pro, from The
O'Reilly Institute. It works great with the Windows Platform and has many extra
functions and an easy configuration with no knowledge of servers required. You
can check it out more at http://website.ora.com


Regards,
Gil Hildebrand, Jr.
Dynamic Scripts

Email: groovy94@aol.com
ICQ UIN: 16678754


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

Date: Sun, 27 Dec 1998 20:47:02 -0600
From: "AJ" <ajonsson@csi.com>
Subject: Re: Is Perl as multifunctional as I've heard\read?
Message-Id: <OK0#SxgM#GA.266@nih2naab.prod2.compuserve.com>

Perl could be thought of as a cross between 'C' and Unix shell programming,
using the best of each and doing away with the
cruft.  Perl is most at home on Unix flavors, but does system commands so
well that it works on whatever platform it is installed on.
The book you have (Win32) has some great stuff on NT admin (like Registry
tweaking). I work on Win95, NT, HP-UX and Linux and use Perl on all the
platforms. A cool example. I once downloaded a huge directory full of linked
HTML pages (a tutorial) only the links didn't work because they identified
each link as "[whatever].html" but MS
doesn't like long extensions, so it couldn't resolve the links, so I wrote a
Perl program that went into each file and changed each link reference from
".html" to "htm". and after that the links all worked perfectly, saving a
boring session of file-by-file editing.  We use perl on our HP-9000 for text
processing extensively, and I frequently bring home projects that a work out
on my pc, and then port the code back to the HP server to do the work.  I
also write a lot of little routines that our Unix admin plugs into his shell
scripts, the Perl often being a bit more elegant that its Unix shell
equivilent. My impression is that C/C++ is still the best for optimal coding
(e.g. Perl is written in C, I think) but for most day-to day Perl is alot
easier to design with and code. I do alittle VB for MSAccess, and I can tell
you that text manipulation in VB doesn't compare to Perl at all.
I'm beginning to sound like a commercial, so I'll quit, but I thinks it's
the best general language.

AJ


sp wrote in message <01be2eff$408a5ba0$606084a9@nec>...
>I have always had an interest in programming, but I am a tech support\net
>admin person
>primarily.  I have been looking for a language that would span between
>different computer
>disciplines.  It seems as though Perl more than any other language is able
>to do this.
>I've read that it could be used for network admin, web\internet
>programming, Unix\mainframe,
>graphics purposes, databases, etc.
>
>Perl seems very related to C\C++, but my impression is that C\C++ is not as
>versatile
>and is more complex.
>
>Could this be the best language to learn if you want to "do a little of
>everything"?
>How does it compare to C\C++, Visual Basic, or Java?   Is this a very
>useful language for
>network administration purposes, especially in regards to NT?
>
>I'm no programming expert, so I'm seeking the advice of those who are.
>Thanks for any feedback.
>I've bought the O'Reilly book "Learning Perl for Win32 Systems" and I think
>it's great.
>
>




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

Date: Mon, 28 Dec 1998 02:01:20 +0100
From: Frank de Bot <debot@xs4all.nl>
Subject: LWP Tutorial
Message-Id: <3686D860.BE60B6FD@xs4all.nl>

Does anyone know a tutorial of LWP on the internet? I just can't find
any.



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

Date: 28 Dec 1998 02:04:57 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: LWP Tutorial
Message-Id: <766p09$31a$1@gellyfish.btinternet.com>

On Mon, 28 Dec 1998 02:01:20 +0100 Frank de Bot <debot@xs4all.nl> wrote:
> Does anyone know a tutorial of LWP on the internet? I just can't find
> any.
> 

You might try looking at the LWP homepage at 
<URL:http://www.sn.no/libwww-perl/> for starters - there are a number of
useful links there.

However the lwpcook.pod document that comes with the LWP distribution is
a fairly good first tutorial on the subject.  If you have not got this file
then you can download the source from CPAN, unpack it and examine the file
using perldoc.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Mon, 28 Dec 1998 03:00:37 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: Mail from PERL using variable mail address
Message-Id: <3686F44F.EB2731A3@berghold.net>

nemanij@hotmail.com wrote:

>
> open(MAIL, '|mail "$address"') || die" unable to mail $!\n";
>         print MAIL <<"endofmail";
>         text
>         endofmail
> close(MAIL) || die "error closing mail $!\n";
>

OK.. First off this is a real FAQ.  Be that as it may, I will answer your
question anyway...

Your trouble with the above code stems from your use of the single quote to
embrace your string in the open statement.  The way I'd solve the problem would
be to build the string from pieces something like this:

$mailString = "mail ";
$mailString .= "-s $subject" if $subject;
$mailString .= $address if $address;

if ( $address ) {
    open(MAIL, "| $mailString") or die "Couldn't open pipe to mail.\n$!\n";
} else {
    die "I need an address to mail to!\n";
}

print MAIL <<endofmail ;
This is mail going out of the mail pipe.
endofmail

No doubt there are more elegant ways of doing this.  How abou this code sniglet
for instance?

use Net::SMTP;

$mailhost="mailhost";   # Fill in your real mailer's address
$addr='someone@net.com';  # Note the use of single quotes here!  Keeps perl
happy!
$subject="Something to say";

$smtp = Net::SMTP->new($mailhost);
$smtp->to($addr);

@lines=<DATA>;

$smtp->data();
$smtp->datasend("From: me");  # you can do better than that...
$smtp->datasend("Subject: $subject");
$smtp->datasend("To: $addr");

foreach $line(@lines){
    $smtp->datasend($line);
}

$smtp->quit

__END__
This set of lines will be sent as EMAIL by the above code.
Remember two things:

    1. The __END__ directive tells the translator to stop translating.
    2.  The DATA file handle is anything after the __END__

--------8< snip 8<----------------------------------------------------------

Hope this helps....




--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Peter L. Berghold                               Peter@Berghold.net
"Those who fail to learn from history           http://www.berghold.net
are condemned to repeat it."                       ICQ# 11455958




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

Date: 28 Dec 1998 00:21:16 GMT
From: groovy94@aol.com (Groovy94)
Subject: Re: need help
Message-Id: <19981227192116.08200.00002447@ng-fb1.aol.com>

I have found that the best way to learn something is by example. Try working on
an already made perl script and improving on it. I also reccomend reading the
Llama. (The Llama is a perl programmer's nick for "Learning Perl", a book by
Randal L. Schwartz and some other guys)

 URL to buy it or for more info:
http://www.amazon.com/exec/obidos/ASIN/1565922840/ref=sim_books/002-646546
1-0985401            

that's all the advice I have, good luck.
Regards,
GIl Hildebrand, Jr.
Email: groovy94@aol.com
ICQ UIN: 16678754


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

Date: Sun, 27 Dec 1998 20:18:28 -0600
From: "AJ" <ajonsson@csi.com>
Subject: Re: need help
Message-Id: <#xWLWhgM#GA.318@nih2naab.prod2.compuserve.com>

According to the Guys at www.perl.com one of the best things you can do is
throw away "Perl 5 for Dummies." (I actually have it too.)   I recommend
either the O'Reilly "Learning Perl" or "Learning Perl on Win 32 systems"
depending on your platform.  These books do assume some degree of
programming experience, and as the Wall, Schwaratz and others point out, the
'P' in Perl is refering to the fact that Perl was designed for programmers.
I only point that out to mean that Perl can be obscure if you don't have
programming experience.
(And if you do, it is one of the easiest languages there is.).

Check out the perl website, click on "Perl News", and 1/2 way down the page
"Camel Critiques".  This page reviews many Perl books. (That's where I swa
that they didn't care for the 'dummies" book too much. And you will see why)
>From this you can choose the book that suits your background and goals.

AJ

Ian Falcone wrote in message ...
>Hi all,
>I am interested in learning how to program with Perl, but I have no
>experience with programming at all. I bought a book on the Internet called
>Perl5 for Dummies and read the first 5 chapters so far and this really is
>fascinating to me.  I am interested in some feedback from more experienced
>Perl people who can lead me in the right direction.  If anyone has any
>helpful recommendations as far as what is the best way to learn Perl, I am
>all ears.
>Thanks,
>Ian F
>iflynx@blazenet.net
>
>
>




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

Date: 28 Dec 1998 02:49:11 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Pacman anyone?
Message-Id: <766rj7$36e$1@gellyfish.btinternet.com>

On Sun, 27 Dec 1998 17:40:24 -0600 Scott Allen Zsori <zsoris@post.uwstout.edu> wrote:
>                  Has anyone else ever actually used a programming
> command in a non-programming sentence (I greped a friend's last sentence
> by accident once :)?  

Yeah I use 'use','require','do','for','if','else','map','sort','while',
'until','unless' all the time :)

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 27 Dec 1998 20:20:23 -0600
From: "AJ" <ajonsson@csi.com>
Subject: Re: Pacman anyone?
Message-Id: <eCgrZigM#GA.318@nih2naab.prod2.compuserve.com>

Yes, yes, yes, yes and yes.

AJ
Scott Allen Zsori wrote in message
 . Does "chomp" remind anyone else of this wonderful little
>character? :)  Does anyone else dream in whatever language their current
>projects are in? Has anyone else ever actually used a programming
>command in a non-programming sentence (I greped a friend's last sentence
>by accident once :)?  Or am I the only crazy one?




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

Date: 28 Dec 1998 02:36:34 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: problem with specific language characters ("=?ISO-8859-1?Q?=F6,=E4,=FC,=DF?=")
Message-Id: <766qri$368$1@gellyfish.btinternet.com>

On Sun, 27 Dec 1998 14:48:31 +0100 Martin Schager <martin.schager@vienna.at> wrote:
> If someone submits information via a form, that contains v,d,|,_, I get
> strange %something instead of these characters, when I process the form.
> Is there any solution to this problem?
> 

This is due to the fact that certain 'unsafe' characters are escaped 
before transmission in an HTTP request and therefore have to be decoded
accordingly by the server software. This escaping is described in RFC 1738.

I am assuming that you are handrolling your form processing code instead
of using some module (as is generally recommended here).  You can use the
URI::Escape module (part of the libwww-perl package available from CPAN) to
decode the string or alternatively you could use something like CGI.pm
that will take care of all of that nastiness for you transparently.

If however you really do insist on using your own method to decode your
form data then you will need to use some code as follows (this is
actually adapted from the code in the CGI.pm module ):

sub unescape {
    my $todecode = shift;
    return undef unless defined($todecode);
    $todecode =~ tr/+/ /;       # pluses become spaces
    $todecode =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
    return $todecode;
}

If you dont understand what is going on in the above then you should
check out the perlre and perlop manpages and the perlfunc entry for pack.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 28 Dec 1998 02:52:35 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: removing "Tk" from Perl/Tk under Win
Message-Id: <766rpj$36i$1@gellyfish.btinternet.com>

On Thu, 24 Dec 1998 17:39:18 GMT uncle_remus@my-dejanews.com wrote:
> Does anyone know how to remove the "Tk" icon (and replace it with s.t. else)
> from windows generated under Perl/Tk on Windows??
> 

You could always take some Windows resource editor that will deal with .exe
files to the appropriate file(s) and change it ... I fear that is the only
recourse you have.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 28 Dec 1998 01:15:24 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Retrospective on comp.lang.perl.moderated?
Message-Id: <766m3c$c7v$1@news.NERO.NET>

In article <ylogopf8qh.fsf@windlord.stanford.edu>,
Russ Allbery  <rra@stanford.edu> wrote:
>John Stanley <stanley@skyking.OCE.ORST.EDU> writes:
>
>> I was not aware that having a "considerably lower traffic load" sans any
>> other distinguishing factor (e.g. better discussions, higher S/N) was a
>> valid reason for creating a new USENET newsgroup.
>
>I think it is in some circumstances.

Perhaps those who wish to form such groups would agree with you. I think
historical precedent in news.groups would not. 

Let's put it this way. If you want lower traffic load, stop carrying the
group. Sans any other "distinguishing factor", you get what you want and
you don't create more traffic for others.

>> I would consider such a group to be a failure. You can achieve the same
>> effect by simply selecting only every 5th or 8th article from the
>> original group.
>
>No, you can't, because then you wouldn't get coherent threads.  And if you
>picked every 5th or 8th thread, you would get threads that would be too
>long for your patience.  

You mean like this "year end assessment" thread which has been going on
unhindered in .moderated? I guess picking every 5th or 8th thread gives
the same results, then.

>> Can we end this "year end evaluation" nonsense?
>
>Sure.  You and I seem to be the only people still talking about it.  

Other than Larry and the other people who were talking about it, I guess
you are right. We are the only ones who participated.

>I generally don't follow up to myself.  So stop responding to me.  :)

My pleasure.



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

Date: 27 Dec 1998 19:15:36 -0600
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: Retrospective on comp.lang.perl.moderated?
Message-Id: <766m3o$frf$1@Mars.mcs.net>

In article <MPG.10e56c1c512e52a3989966@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>I crossposted this submission as shown below:
>  Newsgroups: comp.lang.perl.moderated, comp.lang.perl.misc
>It has appeared in ...moderated, but not in ...misc!  Isn't that a 
>surprise?
>
>With apologies to those who have seen it before, here is the question:
>
>With year-end-assessment time rapidly approaching, would anyone care to 
>comment on how comp.lang.perl.moderated has performed over its life of 
>six months or so, relative to the hopes and expectations of its 
>proponents?
>
>A cost-benefit analysis at this time might be enlightening.

It started about as I expected, mostly uninteresting topics
and questions.   After a few months I tried to answer something
and was put off by the automated rejection.  Later I accidentally
unsubscribed and didn't miss it enough to go back and find it.
There is a reason for the FAQ nature of the questions on
clpm and the same reason makes the answers interesting to
most of the people reading it...

   Les Mikesell
    les@mcs.com


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

Date: 28 Dec 1998 02:56:59 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Script for Paradox?
Message-Id: <766s1r$36l$1@gellyfish.btinternet.com>

On Thu, 24 Dec 1998 15:36:06 GMT John <John@melon17.freeserve.co.uk> wrote:
> Is there a perl script taht will enable you to search a
> Paradox database via SQL?

You will have to use Win32::ODBC or DBD::ODBC with the appropriate DSN set
up to do this - I dont believe that there is anything that will go
directly to the Paradox files.  I am using this kind of setup for a 
project at work where I dont have any choice about what kind of database
I use - I would post a small example but I am not in work until Thursday
I'm afraid.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 27 Dec 1998 21:01:09 -0600
From: "AJ" <ajonsson@csi.com>
Subject: Re: searching for pattern in a file
Message-Id: <OQT1L5gM#GA.266@nih2naab.prod2.compuserve.com>

Use Perl's "grep" function, substring out the number of characters you need
and then cat the result using the "." operator.
quick and sloppy, I make no excuse for errors or inelegence:
@this = [TheStringThatHasMyData];
$that = [TheValueThatINeed];
$foo = grep(/$that/,@this.);
$bingo=substr($foo,0,10); # gets the first part of you IP string
$result=$bingo."[LastThreeNumbers];"
AJ
(BXTC) wrote in message <3681796B.29E6C8BE@forfree.at>...
>Hi, I am very new to perl and am tring to learn by doing as well as
>reading.  I am writing a small program annd I need it to be able to get
>an IP out of a file. example:
>
>system "netstat -n >> .netstat";
>
>so now I need to search for a string in the .netstat file.  I know that
>the IP will start with 209.195.11.***. so I was thinking somehow I'd
>search like this:
>
>open (NTST, ".netstat");
> now how do I look inside the file now that it is open?
>I need to search for something like  /209\.195\.11\..../ but have it
>fill in the last 3 ...'s with the real numbers and then save it to a
>string.
>
>I think this should be pretty easy, and standard, but tring to find it
>in "Learning Perl" by o'riley & associates has gotten me this far but I
>am missing the actual part that does something.  Thanks for your help
>and I appologize for posting this really basic problem.  John




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

Date: 28 Dec 1998 00:37:19 GMT
From: groovy94@aol.com (Groovy94)
Subject: Re: simple code needed to determine date to print on a web page.
Message-Id: <19981227193719.08200.00002462@ng-fb1.aol.com>

A much simpler solution to your problem is with SSI. One tag can do all that.
<!-/- #flastmod file="filename or url" -->
Regards,
Gil Hildebrand, Jr.
Dynamic Scripts

Email: groovy94@aol.com
ICQ UIN: 16678754


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

Date: 28 Dec 1998 00:56:10 GMT
From: groovy94@aol.com (Groovy94)
Subject: Re: simple code needed to determine date to print on a web page.
Message-Id: <19981227195610.08218.00002556@ng-fb1.aol.com>

My apologies, please take out the \. It should be:

<!-- #flastmod file="filename or absolute path" -->


Regards,
Gil Hildebrand, Jr.
Dynamic Scripts

Email: groovy94@aol.com
ICQ UIN: 16678754


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

Date: Mon, 28 Dec 1998 02:45:36 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: sorting
Message-Id: <3686F0CC.8182619E@berghold.net>

>

Tabo,

I'm not quite sure what you are trying to accomplish, but the code that you
posted looks inconsistant to me.  Here is a code sniglet that I *think*
will do what you want it to do:

---------------9< snip
9<-------------------------------------------------------------------

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

$filename="file2sort.txt";
$tmpfile="outfile.$$.txt";

open(FIN,"< $filename)
   or die "Couldn't open $filename for reading.\n$!\n";
@stuff=<FIN>;
close FIN or die "Uh Oh! Couldn't close the file!\n$!\n";

chomp(@stuff);

@stuff = sort @stuff;

open(FOUT,"> $tmpfile)
  or die "Couldn't open the workfile.\n$!\n";
printf "%s\n",join("\n",@stuff);

close FOUT
   or die "Hmmm... couldn't close the workfile.\n$!\n";

rename($tmpfile,$filename);

1;
--------8< snip 8<-----------------------------------------------------

This is certainly not the only way to do things, but one of many ways to
accomplish your goal.




--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Peter L. Berghold                               Peter@Berghold.net
"Those who fail to learn from history           http://www.berghold.net
are condemned to repeat it."                       ICQ# 11455958




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

Date: 28 Dec 1998 00:28:49 GMT
From: groovy94@aol.com (Groovy94)
Subject: Splitting multiple |'s
Message-Id: <19981227192849.08200.00002458@ng-fb1.aol.com>

I am trying to split multiple "|" characters into seperate variables. I have
one line in a database for a person, containing all their information, and I am
trying to sort it into variables, so I can work with it. Here is the code I
have, but it only split's the first "|".

$id,$first_name,$last_name,$address,$city,$state,$postal_code,$country,$em
ail,$url,$password) = split('|', $reseller);

an example of what a line I am trying to work with would look like is below:

12|Bob|Smith|2738 Bob Lane|New
Orleans|LA|70554|US|bob@bobsite.com|http://www.bobsite.com|sdsdskldhs(encr
ypted)

Regards,
GIl Hildebrand, Jr.
Email: groovy94@aol.com
ICQ UIN: 16678754


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

Date: Mon, 28 Dec 1998 00:56:41 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Splitting multiple |'s
Message-Id: <3686D912.D84532CE@home.com>

[posted & mailed]

Groovy94 wrote:
> 
> I am trying to split multiple "|" characters into seperate variables. 
> I have one line in a database for a person, containing all their 
> information, and I am trying to sort it into variables, so I can work 
> with it. Here is the code I have, but it only split's the first "|".

[split '|' snipped]

Actually it splits on "" or "".  The first argument to split is a regex,
which means that if you want to split on characters that have special
meaning in a regex, you have to escape them.

Try:

    @fields = split /\|/, $record;

perldoc -f split

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Sun, 27 Dec 1998 20:00:04 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Splitting multiple |'s
Message-Id: <MPG.10f0a223ff6161398976f@news.scescape.net>

In article <19981227192849.08200.00002458@ng-fb1.aol.com>, 
groovy94@aol.com says...
=> I am trying to split multiple "|" characters into seperate variables. I have
=> one line in a database for a person, containing all their information, and I am
=> trying to sort it into variables, so I can work with it. Here is the code I
=> have, but it only split's the first "|".
=> 
=> $id,$first_name,$last_name,$address,$city,$state,$postal_code,$country,$em
=> ail,$url,$password) = split('|', $reseller);

That is a syntax error.

=> an example of what a line I am trying to work with would look like is below:
=> 
=> 12|Bob|Smith|2738 Bob Lane|New
=> Orleans|LA|70554|US|bob@bobsite.com|http://www.bobsite.com|sdsdskldhs(encr
=> ypted)

Anyway, since the first argument to split is a regex, you need to escape 
the |:

split /\|/,  $reseller;
split /[|]/, $reseller;
split /\Q|/, $reseller;

=> Regards,

HTH!

=> GIl Hildebrand, Jr.

--Matthew


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

Date: 28 Dec 1998 01:18:44 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Splitting multiple |'s
Message-Id: <766m9k$2se$1@gellyfish.btinternet.com>

On 28 Dec 1998 00:28:49 GMT Groovy94 <groovy94@aol.com> wrote:
> I am trying to split multiple "|" characters into seperate variables. I have
> one line in a database for a person, containing all their information, and I am
> trying to sort it into variables, so I can work with it. Here is the code I
> have, but it only split's the first "|".
> 
> $id,$first_name,$last_name,$address,$city,$state,$postal_code,$country,$em
> ail,$url,$password) = split('|', $reseller);
> 

Infact this is not even doing what you think it is - because the first
argument to 'split' is a regular expression and the '|' character has special
meaning in a regular expression as the alternation character in this case you
are asking to split on nothing or nothing so what happens is that the first
eleven characters of your data get split into your variables.  What you need
to do is to escape the '|' in order that it should lose its special meaning
in this context: 

split(/\|/, $reseller);

You must bear in mind that split treats its first argument as a regular
expression irrespective of how it is quoted - it is probably safer to use the
usual // notation if you (or anyone who might need to maintain the code) is
apt to forgot that.

You might want to check out the perlfunc and perlre manpages if you are
uncertain about any of this.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 27 Dec 1998 21:23:38 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Uninitialized value error
Message-Id: <1dkpsfy.15kh5b41ilhy2sN@bos-ip-1-48.ziplink.net>

Tim Hicks <tim.hicks@iname.com> wrote:

> >    Use of uninitialized value at search.pl line 30, <TOURN2> chunk 18.
> 
> That line is, the one which says:
> 
> >    if ($record[$col] =~ /$word/i) {
> 
> Could anyone enlighten me as to the problem please?

perldiag:

  Use of uninitialized value

    (W) An undefined value was used as if it were already defined.  It
    was interpreted as a "" or a 0, but maybe it was a mistake.  To
    suppress this warning assign an initial value to your variables.

Either $word, $col, or $record[$col] contains the undefined value.

This occurs after the 18th read from the filehandle TOURN2.  Perhaps
line 18 in that file is short a few columns?

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 28 Dec 1998 02:46:01 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Uninitialized value error
Message-Id: <766rd9$36b$1@gellyfish.btinternet.com>

On Sun, 27 Dec 1998 21:31:32 -0000 Tim Hicks <tim.hicks@iname.com> wrote:
> Hello all,
> 
> I have written the following, basic script to see if I can produce some sort
> of search engine.  It all seems to work as I expect, except that as well as
> doing what it is supposed to do, it produces the following error message 4
> times:
> 
>>    Use of uninitialized value at search.pl line 30, <TOURN2> chunk 18.
> 
> That line is, the one which says:
> 
>>    if ($record[$col] =~ /$word/i) {
> 

I would suggest that the most likely explanation for this is that you have
some empty fields in your data file - you should check that line 18 of your
file has all of the fields filled in (the chunk 18 bit refers to the
number of bits of file read by the <> operator).  You could also add a 
check like:

    if ($record[$col] && $record[$col] =~ /$word/i) {
 ...

It actually just occurred to me that it seems like you are assuming that
the subscript of @record starts at 1 whereas infact it starts at 0 - you
should take 1 away from the user input to $col. *That* probably *is* the
probably.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

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


Administrivia:

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

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

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 4503
**************************************

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