[11194] in Perl-Users-Digest
Perl-Users Digest, Issue: 4794 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 1 01:07:21 1999
Date: Sun, 31 Jan 99 22:00:17 -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, 31 Jan 1999 Volume: 8 Number: 4794
Today's topics:
Re: A little help, thanks. <eugene@snailgem.org>
Re: A little help, thanks. <eugene@snailgem.org>
Re: CGI form processing <olivierf@worldnet.att.net>
Re: code to recurse directories (Tad McClellan)
Re: DBI and Win32::ODBC - build or download???? <Richard.Walker@west-server.com>
Re: Dial up Networking and PERL <matt@shoggoth.org>
Re: File Testing Problem (Ronald J Kimball)
Re: Freelance Work Postings? (Tad McClellan)
Re: Help with "Malformed header" error <eugene@snailgem.org>
Re: How can ??-pattern matching be used? <eugene@snailgem.org>
Re: how to code a between() with regex? (Ronald J Kimball)
Re: Need Tutorial <eugene@snailgem.org>
Re: Need Tutorial (Ronald J Kimball)
Re: Newbie question on regular expressions (Tad McClellan)
Re: Newbie question on regular expressions <eugene@snailgem.org>
Re: Newbie question on regular expressions (Ronald J Kimball)
Re: ok please don't shoot me for this question <uri@home.sysarch.com>
Re: Perl script doesn't execute, instead displays conte (Ronald J Kimball)
Re: Regexp problem [possible] (Ronald J Kimball)
Re: simple database (Tad McClellan)
Re: What text editors are you using for Perl? (Tad McClellan)
Re: What text editors are you using for Perl? <info@purco.qc.ca>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 31 Jan 1999 20:57:23 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
Subject: Re: A little help, thanks.
Message-Id: <36B50A03.C56C7651@snailgem.org>
STEVEN T HENDERSON wrote:
>
> kinda depends on what is stored in the file, but this works fine for me.
>
> # Find user name left by the login script
> if(! open(ATHLETE, "< $HOME_DIR/_$ENV{'REMOTE_ADDR'}"))
> {
> # Could not find file, bummer.
> printf("ERROR: Cannot read temporary athlete file");
> &EarlyExit;
> }
This is Perl spoken with a foreign accent ;-------------)
See below.
> # Otherwise...
> $athlete = <ATHLETE>;
> chop($athlete);
> close(ATHLETE);
$file = "/path/to/textfile";
open (ATHLETE, $file) or die "Can't open $file: $!);
#chop ($athlete); #you don't need this; should be 'chomp' anyway
$athlete = <ATHLETE>;
close ATHLETE;
> Justin Saul wrote in message <792m7q$866@bgtnsc02.worldnet.att.net>...
> >Hi,
> > I am kind of new at this stuff, but I learn quickly and have one quick
> >problem I need fixed. Please tell me how I can manage the following
> problem:
> >
> >I want to open a file that has data in it and make it into a variable. For
> >example file X.dat has my data and I want to have the data from that file
> >become variable $x, so that later I can use $x as a printible object.
> >
> >Thanks,
> >Justin Saul
> >
> >
--
Eugene
"Light is the all-exacting good,
That dry, forever virile stream
That wipes each thing to what it is,
The whole, collage and stone, cleansed
To its proper pastoral."
Alvin Feinman
------------------------------
Date: Sun, 31 Jan 1999 21:45:49 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
Subject: Re: A little help, thanks.
Message-Id: <36B5155D.2C8E044E@snailgem.org>
Eugene Sotirescu wrote:
>
> $file = "/path/to/textfile";
> open (ATHLETE, $file) or die "Can't open $file: $!);
> #chop ($athlete); #you don't need this; should be 'chomp' anyway
> $athlete = <ATHLETE>;
> close ATHLETE;
>
Ahem...:
open (ATHLETE, $file) or die "Can't open $file: $!");
^
--
Eugene
"Light is the all-exacting good,
That dry, forever virile stream
That wipes each thing to what it is,
The whole, collage and stone, cleansed
To its proper pastoral."
Alvin Feinman
------------------------------
Date: Sun, 31 Jan 1999 23:07:56 -0500
From: "Olivier" <olivierf@worldnet.att.net>
Subject: Re: CGI form processing
Message-Id: <36b52903.0@news.one.net>
Sorry Konstantyn,
but this question IS PERL specific since I am asking whether this can be
done in PERL or not. If you had a bad day please take out it on somebody
else. Maybe you should not read newsgroups if your first reaction is such a
negative one.
Olivier
Kostyantyn Chromyak wrote in message ...
> Hi!
>
> First of all, this question is not perl-specific
>and therefore this group is not the best place to
>post it. You need web-programming and it is *not*
>exactly perl (however perl can be used and frecuently
>is used for this purpose). You should look for help
>in (for example) comp.infosystems.www.authoring.cgi
>or comp.lang.javascript rather then comp.lang.perl.misc.
>
> Secondly, the answer is *yes*, you can do it
>with perl using CGI or any other server-side
>technology, and can do the job with client-side
>programming too; what is the best for you,
>depends on your biases ;-) and (alas!) details
>about the error you want to be processed.
>For example, if your user have forgotten
>to type his address in mail order form,
>you can detect this error in situ, and process it
>locally, without quering a server; javascript
>or vbscript or (if your browser support it!!!)
>client-side perl all are appropiate for this
>purpose; this way you win the performance.
>But if the problem is that (for example) your
>database can't save the duplicate record, you
>probably don't know about this error before submit
>the data to server-side script. This way you
>could process the first error (empty field) too.
>Server-side processing is much more universal,
>secure and flexible. But you pay for it by
>loosing the performance.
>What I am trying to say you is that the optimal
>solution depends on many details and in many cases
>the best way is to combine the server-side and
>client-side processing for different errors.
>
> You can find a lot of books in virtually
>every bookstore; there are a lot of tutorials
>in web; you have to search for CGI or javascript.
>And of course you have to write this short
>script in language of your choice.
>
> If you will need the professional help,
>(i.e. to outsource this job), let me know.
>It is simple and therefore is not expensive.
>But I'll need more details.
>
> Good luck. Kostyantyn.
>
>
>--
>
>__________________________________
>The best solutions in programming, physics,
>electronics and automatic control.
>
>To reply delete ".NOSPAM" from reply address.
>I don't read (filter!) letters from well-known spammers.
>I don't read(filter) anything @yahoo.com
>
>e-mail: <chromyak@usa.net.NOSPAM>
>________________________________
>ICQ 13497907, tel. (54-11) 4811-7913
>(ukranian, spanish, english, russian)
>Kostyantyn Chromyak
>________________________________
>Olivier escribis en mensaje <36b3ec40.0@news.one.net>...
>>Hello,
>>
>>I am new to PERL. I am lookng to process a form . I found a lot of
>>freeware but nothing that does what I want. Usually when there is some
>>error checking done on the form input, the error message appears on a
>>separate HTML page which end by " please go back, etc...". I'd like to
>>generate my error message at the top of the actual form which would
>still
>>contain the answers previously given by the user. Is this doable in
>PERL ?
>>If so is there any code out there I could start from ?
>>
>>Thank you for any help,
>>
>>Olivier
>>
>>
>
>
------------------------------
Date: Sun, 31 Jan 1999 21:45:36 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: code to recurse directories
Message-Id: <018397.tp7.ln@magna.metronet.com>
sysop (grynberg@hotmail.com) wrote:
: Hi. I am trying to write a program to print all the files on my hard
: drive, with their complete paths. I was wondering if anyone has
: anything like this.
: I do not want to use modules,
Why not?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 31 Jan 1999 23:52:18 -0500
From: Richard Walker <Richard.Walker@west-server.com>
Subject: Re: DBI and Win32::ODBC - build or download????
Message-Id: <36B53302.B94B0B67@west-server.com>
I don't know if this helps at all, but here is some code I am using to
write to a database using ADO. I have the standard install of
ActivePerl 509 (except that I ran PPM to install libnet).
I think that this code would port to the ODBC equiv without too much
grief. Hope it helps.
# Write To Database Subroutine
sub write_database {
# the below connect string should be changed to
# the DSN for your SQL Server database
$strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=".$dbfile;
use OLE;
$Conn = CreateObject OLE "ADODB.Connection";
$RS = CreateObject OLE "ADODB.Recordset";
#connect to the database
$Conn->Open(strConnect);
#open the table, with optimistic locking
$RS->Open("ForumLookup",$Conn,3,3,2);
if(!$RS) {
$Errors = $Conn->Errors();
print "Errors:\n";
foreach $error (keys %$Errors) {
print $error->{Description}, "\n";
}
die;
}
$RS->AddNew();
$RS->Fields('title')->{value}=$subject;
$RS->Fields('sender')->{value}=$name;
$RS->Fields('email')->{value}=$email;
$RS->Fields('url')->{value}=$msg_url;
$RS->Fields('urltext')->{value}=$msg_url_title;
$RS->Fields('body')->{value}=$body;
$RS->Update();
$RS->Close;
$Conn->Close;
}
Tom Williamson wrote:
>
> I am working on a Perl project on Windows NT, trying to connect to
> MS-SQL Server. (I know this is going over great with the Solaris and
> Oracle folks.) Anyway, I have never worked with Perl before. I have
> inherited some legacy code from the previous programmer which uses
> DBI::W32ODBC and Win32::ODBC modules, neither of which I have.
>
> I downloaded and installed Perl from ActiveState and have the basic Perl
> 5 modules. The previous programmer on the project swears that DBI came
> with his Perl installation and that he was able to download and install
> a pre-built version of Win32::ODBC.
>
> I am already way behind on this project from having to come up to speed
> on Perl itself. I am really hoping that I can download and install
> these modules from someplace, and avoid having to build them from
> scratch. Is there anyone out there who can point me to a location where
> I can get pre-built DBI and Win32::ODBC?????? Or, to put it more
> bluntly - HELLLLLLP!
>
> Thanks - Tom
> tomw@action.cnchost.com
--
Feel Lost In Email? Get Answers Quick On The HOT ASP Discussion Forum
http://www.aspalliance.com/richardwalker/forum/
------------------------------
Date: Sun, 31 Jan 1999 23:51:49 -0500
From: "Matt Wiseman" <matt@shoggoth.org>
Subject: Re: Dial up Networking and PERL
Message-Id: <793bus$l7l$1@news0-alterdial.uu.net>
I've seen cases where a Porn Site uses javascript to cause a change to the
default DUN file and causes the computer to redial the new 1-900 ISP I don't
particularly find this sort of activity very moral. . .. what are you
planning on doing with this code??
gary robson <gary@altmedia.freeserve.co.uk> wrote in message
news:791jp8$81p$1@news4.svr.pol.co.uk...
>Can anybody tell me how to connect and hangup and windows Dial up
Networking
>account from perl.
> Cheers Gary
>
>
------------------------------
Date: Mon, 1 Feb 1999 00:31:04 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: File Testing Problem
Message-Id: <1dmitwh.10e9xxpsaqi4gN@bay2-160.quincy.ziplink.net>
[posted and mailed]
<beach9000@hotmail.com> wrote:
> $dateStamp=`date +.%m_%d_%y.%H:%M:%S`; $outfile .= $dateStamp;
You forgot to chomp() the newline.
--
_ / ' _ / - 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: Sun, 31 Jan 1999 21:49:58 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Freelance Work Postings?
Message-Id: <698397.tp7.ln@magna.metronet.com>
Stoic (stoic@my-dejanews.com) wrote:
: Would this forume be suitable for freelance work postings
No.
This newsgroup is for discussing programming in Perl.
There are other newsgroups for job postings.
: or would
: another list be more appropriate?
Any newsgroup with 'jobs' in its name would be appropriate.
There are also a bunch of web sites where you can seek
freelancers.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 31 Jan 1999 20:30:35 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
To: Jeff <jeff909@hotmail.com>
Subject: Re: Help with "Malformed header" error
Message-Id: <36B503BB.9A06FAE4@snailgem.org>
Jeff wrote:
>
> Hi, I am very new to perl and have been tryint to write a script that will
> open a passwords file and check a name and password a user woudl eneter
> against the names and pwords in the file. I THINK I have written the
> script correctly but I keep getting an error message "Malformed header" but
> it doesn't tell me which eader is malformed. Here is an example of the
> script can someone tell me what the issue is? Thanks for any help.
>
> #!/usr/bin/perl
> require "cgi-lib.pl";
> &ReadParse;
> &PrintHeader;
> open(FILE,"passcodes.pl") || die "Can't open file\n";
> @indata = <FILE>;
> $name = $in{name};
> $password = $in{password};
> close(FILE);
> print "<HTML>";
> print "<HEAD>";
> print "<TITLE>Checking passwords</TITLE>";
> foreach $i(@indata)
> {
> chop($i);
> ($Pname,$Ppassword)=split(/\|/,$i);
>
> if($name == $Pname && $password == $Ppassword)
> {
> print "<P>Welcome</P>";
> }
> else
> {
> print "<P> No access </P>";
> }
>
> }
> print "</HEAD></HTML>";
1.You probably want:
$name eq $Pname && $password eq $Ppassword
(your values are strings, not numbers, right?)
2.I'd check what your PrintHeader subroutine does - I assume it's
responsible to put in the HTTP header.
--
Eugene
"Light is the all-exacting good,
That dry, forever virile stream
That wipes each thing to what it is,
The whole, collage and stone, cleansed
To its proper pastoral."
Alvin Feinman
------------------------------
Date: Sun, 31 Jan 1999 21:43:21 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
Subject: Re: How can ??-pattern matching be used?
Message-Id: <36B514C9.9AA577CF@snailgem.org>
Jan Garefelt wrote:
>
> In various kinds of Perl documentation I am told that:
>
> ?pattern?
>
> works just like
>
> /pattern/
>
> ...except that it matches only once between calls to the
> reset-operator. It doesn't work that way, at least not for me.
>
> Where can I find info or code examples that shows how to use
> ??-searching? I have really tried searching the web, but not found any
> examples...
>
Can we see the code that doesn't work?
--
Eugene
"Light is the all-exacting good,
That dry, forever virile stream
That wipes each thing to what it is,
The whole, collage and stone, cleansed
To its proper pastoral."
Alvin Feinman
------------------------------
Date: Mon, 1 Feb 1999 00:31:05 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: how to code a between() with regex?
Message-Id: <1dmitz0.1cxdbdd64kakqN@bay2-160.quincy.ziplink.net>
Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:
> Of course by the look of your code which is contains at least one obvioud perl
> syntax error on each line you mightn't understand that.
That's a rather uncalled-for remark, considering that the code was
clearly labelled as pseudo-code.
--
_ / ' _ / - 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: Sun, 31 Jan 1999 20:38:27 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
Subject: Re: Need Tutorial
Message-Id: <36B50593.C30755ED@snailgem.org>
the Tupper's wrote:
>
> Can any good programmers out there tell me what they used to learn perl. If
> you used any tutorials off the net just post the address. I don't really
> want to buy a $70 book so don't bother giving me titles to books unless it
> is absolutely the best thing you could ever get.
I suggest first looking up the words 'please' and 'thank you' in a Basic
Decency tutorial.
--
Eugene
------------------------------
Date: Mon, 1 Feb 1999 00:31:06 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Need Tutorial
Message-Id: <1dmiu50.73tsk6135l34aN@bay2-160.quincy.ziplink.net>
the Tupper's <ktupper1@maine.rr.com> wrote:
> Can any good programmers out there tell me what they used to learn perl. If
> you used any tutorials off the net just post the address. I don't really
> want to buy a $70 book so don't bother giving me titles to books unless it
> is absolutely the best thing you could ever get.
I believe the definitive thread on this subject is "Poll: How Did You
Learn Perl?".
http://www.dejanews.com/dnquery.xp?search=thread&recnum=%3c360923EC.8E99
19D0@min.net%3e%231/1&svcclass=dnserver
You will mention of a couple books that are indeed the best thing you
could ever get, and they only cost $30-40.
--
_ / ' _ / - 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: Sun, 31 Jan 1999 21:35:10 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie question on regular expressions
Message-Id: <ed7397.tp7.ln@magna.metronet.com>
Ulrich Petri (UloPe@hotmail.com) wrote:
: here is my problem:
: i tried to negate a regular expression. but...
: like:
: if ("www.blah.com " !=~ /http:/i)
^ ^
You shouldn't use double quotes if you don't want or need
the extra stuff above what single quotes will get you.
1)
if ('www.blah.com ' =! /http:/i)
2)
unless ('www.blah.com ' =~ /http:/i)
3)
if ( ! 'www.blah.com ' =~ /http:/i)
Your call.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 31 Jan 1999 21:39:25 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
To: Ulrich Petri <UloPe@hotmail.com>
Subject: Re: Newbie question on regular expressions
Message-Id: <36B513DD.87EC62EF@snailgem.org>
Ulrich Petri wrote:
>
> Hi everyone,
>
> here is my problem:
> i tried to negate a regular expression. but...
>
> my code looks like:
>
> if ("hTtP://www.blah.com" =~ /http:/i)
> {
> <do something>
> }
>
> that works quite nice
>
> but actual i want to do the exact opposite
>
> like:
>
> if ("www.blah.com " !=~ /http:/i)
>
> and now this doesn'T work
>
> if anyone have any answers i would be very glad
>
> Cu Ulrich
if ("www.blah.com " !=~ /http:/i)
will never work:
1.There's no such thing as !=~
>From perldoc perlop:
"Binary "!~" is just like "=~" except the return value is negated in the
logical sense."
So:
if ("www.blah.com " !~ /http:/i)
(which will always be true, BTW).
2.unless ("hTtP://www.blah.com" =~ /http:/i)
--
Eugene
"Light is the all-exacting good,
That dry, forever virile stream
That wipes each thing to what it is,
The whole, collage and stone, cleansed
To its proper pastoral."
Alvin Feinman
------------------------------
Date: Mon, 1 Feb 1999 00:31:07 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Newbie question on regular expressions
Message-Id: <1dmiu9t.8mkyew1fp4aN@bay2-160.quincy.ziplink.net>
Tad McClellan <tadmc@metronet.com> wrote:
> 1)
> if ('www.blah.com ' =! /http:/i)
> [...]
> Your call.
Hint: Don't pick number one. ;-)
ITYM !~.
--
_ / ' _ / - 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: 01 Feb 1999 00:07:58 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: ok please don't shoot me for this question
Message-Id: <x7ognepv81.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@fnx.com> writes:
A> ## It's called the CPAN. There are dozens of mirrors all around
A> the world. ## Find your closest using the redirector at
A> www.perl.com/CPAN/, or just ## hop to www.cpan.org.
A> Uhm, CPAN/scripts/CGI is depressingly empty.
there are sites which have lots of perl scripts. someone posted one
about cgi recently and i browsed it. it seems to have a fair of perl
scripts (it's search claims 123 links). it is organized somewhat but
there is no to tel what you have without going to each site
individually. i bet most of those script sites are connected to
cpan. there are other cgi and non-cgi script sites (and i don't mean
matt!) which are useful but they are scattered and not coordinated. cpan
seems to attract the modules but not the scripts. this is an issue to
raise on cpan email lists and maybe advocacy.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Mon, 1 Feb 1999 00:31:08 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl script doesn't execute, instead displays contents of file.
Message-Id: <1dmiud9.1hgrncx1i6126fN@bay2-160.quincy.ziplink.net>
Seshubabu Pasam <seshu@cs.wpi.edu> wrote:
> Why doesn't my perl script run. When I view the file from browser it
> displays the contents of the file, instead of displaying the result.
Contact your system administrator, and find out what you need to do to
run CGI scripts on your web server.
--
_ / ' _ / - 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: Mon, 1 Feb 1999 00:31:09 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Regexp problem [possible]
Message-Id: <1dmiuf4.1mv1nquxcccqN@bay2-160.quincy.ziplink.net>
<hdiwan@diwanh.stu.rpi.edu> wrote:
> while (<IN>) { tr /^Starting//; tr /^No//;tr /second$//;
> tr /^Nmap\brun\bcompleted//;}
Is this your real code? Those tr/// commands are effectively no-ops.
I think you meant to use s///.
> @now = split / /,$_;
> my @iptemp = split /\b/, $now[-35];
> $ip = $iptemp[1].$iptemp[2].$iptemp[3].$iptemp[4].$iptemp[5].$iptemp[6].
> $iptemp[7];
>
> Problem arises when I'm finished with certain subnets, instead of grabbing the
> IP #, it grabs the word Interesting and a bunch of blanks.
Perhaps the section you want isn't always at index -35. It seems rather
odd to count from the end of the array rather than the beginning in this
context. Particularly because you split on a single space, so if the
number of spaces between each column is not constant, then you're
screwed. Maybe you meant split(' '), which is a special case that
splits on runs of whitespace.
But I really don't think you want to use split for this.
($ip) = /Interesting ports on (\S+)/;
--
_ / ' _ / - 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: Sun, 31 Jan 1999 21:44:16 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: simple database
Message-Id: <gu7397.tp7.ln@magna.metronet.com>
Cim (cim@online.ee) wrote:
: I have a simple database:
: item1: $type|$description|$name|$email
: item2: $type|$description|$name|$email
: I need to manipulate this database. Would hashes be the best in this
: case. If yes, then how would i use them.
What is "best" kinda depends on the set of queries you expect
to run most often. You haven't shared that with us.
: problem1:
: i need to sort items by $type and then $description. (there are only a
: few types at $type ).
That isn't a problem. That's a Frequently Asked Question
(that is, it is an already solved problem):
Perl FAQ, part 4:
"How do I sort an array by (anything)?"
: problem2:
: need to search the database and then print an item if $name eq
: $namegiven & $email eq $emailgiven, and if nothing is found print
: "Sorry" or something like that.
sub search { # UNTESTED!
my($namegiven, $emailgiven, @db) = @_;
foreach (@db) {
my($name, $email) = (split /\|/)[2,3];
print, return if $name eq $namegiven && $email eq $emailgiven;
}
print qq("Sorry" or something like that\n);
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 31 Jan 1999 21:58:17 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What text editors are you using for Perl?
Message-Id: <po8397.tp7.ln@magna.metronet.com>
Leon Stepanian (info@purco.qc.ca) wrote:
: OK. This may be a dumb question but it is really getting on my nerves.
: "#!/usr/bin/perl". When I send this script back to my ISP and activate
^^^^^^^^^^^
Try sending it in ASCII (sometimes called "text") mode
instead of binary mode.
: the script from my HTML, I'm getting a Server error. When I send the
: original script, it works fine.
: So, what is happening is the editor is adding this musical note
: character before my end of line character and perl is seeing this as an
: illegal character. I simply can't understand why this is happenning.
I don't understand why it happens either.
An application should not try and "read your mind" and then
silently do what it is sure it is that you would want to
do.
It should wait for you to ask to do something before it
does something.
Windows does that sort of thing a lot. But consumers often
need more "help" than programmers, and Windows wasn't
designed for programmers.
It should wait for you to ask to do something before it
does something.
Windows does that sort of thing a lot. But consumers often
need more "help" than programmers, and Windows wasn't
designed for programmers.
: Is there an editor that is 100% simple character based which does not
: add such things to the file, or does anyone have an explanation. I'm
: going crazy because I can't edit my older Perl files to update the code.
Here's the explanation:
Unix, DOS, and Mac all use different encodings to mean
"the end of a line".
Unix uses a single ASCII Linefeed character (often called
"newline" nowadays)
Mac uses a single Carriage Return character.
DOS, et al, use a Carriage Return followed by a Linefeed.
To convert DOS style to Unix style:
perl -p -i -e 's/\r//g' filename
To convert Unix style to DOS style:
perl -p -i -e 's/\n/\r\n/g' filename
It is probably easiest to just use the correct FTP mode, and
it will handle translating the line endings.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 31 Jan 1999 23:57:32 -0500
From: Leon Stepanian <info@purco.qc.ca>
Subject: Re: What text editors are you using for Perl?
Message-Id: <36B5343C.201C758B@purco.qc.ca>
Hi again;
Thank you both for your information which has helped. I have downloaded
UltraEdit (just typed UltraEdit in my browser's Location field) and have
surprisingly seen my old files re-saved with less bytes. It seems that
UltraEdit is talking all these stray characters out of the files.
I then sent my perl script to my ISP and accessed it and IT WORKS.
By the way, I'm using WIN98. Perl files were created in WIN 3.1 and 95.
Also thank you for the explanation on why this could be happenning. But
I am very surprised to see this happen with "ED for Windows" since this
is a multi-platform editor for programmers. I really liked the way it
sorted the script in it's color schemes, which made things easier to
read. But this adding of "phantom characters" to lines is a no-no so out
it goes.
If anyone else has input on editors and their experiences, I am sure
others would be interested in learning more, since not everyone will
realize that their text editor could be creating perl scripts which
result in server error messages, which are not specifically code
related.
Leon Stepanian wrote:
>
> Hi;
> OK. This may be a dumb question but it is really getting on my nerves.
>
> I have written Perl programs wth various editors such as ED and Wordpad
> (in text mode).
>
> But now, when I retrieve an old Perl script and simply do a save without
> doing any editing, the file size has grown considerably.
>
> When I view the file with Ztree in DUMP mode, I have noticed that before
> each carriage return character (which is symbolized by a shadded square
> with a letter "o" inside, there is a "musical note" (can't find this
> character) . Especially after the first all important line
> "#!/usr/bin/perl". When I send this script back to my ISP and activate
> the script from my HTML, I'm getting a Server error. When I send the
> original script, it works fine.
>
> So, what is happening is the editor is adding this musical note
> character before my end of line character and perl is seeing this as an
> illegal character. I simply can't understand why this is happenning.
>
> Is there an editor that is 100% simple character based which does not
> add such things to the file, or does anyone have an explanation. I'm
> going crazy because I can't edit my older Perl files to update the code.
------------------------------
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 4794
**************************************