[11053] in Perl-Users-Digest
Perl-Users Digest, Issue: 4653 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 14 16:03:29 1999
Date: Thu, 14 Jan 99 13:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 14 Jan 1999 Volume: 8 Number: 4653
Today's topics:
Re: @ARGV and $_ Question <Brad.Askins@autodesk.com>
[Q] how to check the existence of ^M in a text file on (EXCHANGE:SKPK:1N51)
Advance Data Structure of Perl 5.0 <gibsonc@aztec.asu.edu>
Re: Another RegExp. <dropzone@mail.utexas.edu>
Re: Confusion with hashes and undef (Greg Bacon)
Re: Data Structure Notation <dgris@moiraine.dimensional.com>
difference in Perl of Win98/Unix ? jkang@nyph.org
Re: difference in Perl of Win98/Unix ? <ebohlman@netcom.com>
Re: Dynamic HASHES :-(( (Greg Bacon)
Re: Is mod_perl an option? <ask@netcetera.dk>
Re: Is mod_perl an option? <ask@netc.dk>
Re: Looking for Perl programmer in NYC area <ebohlman@netcom.com>
Re: Looking for Perl programmer in NYC area <uri@ibnets.com>
Mapping NT drives within PERL mirak63@my-dejanews.com
Perl 5.005_2 fails op/pack test 9 on DEC OSF1 (Donald L. Nash)
Re: Perl/NT and Long Dir Names?? (Larry Rosler)
Re: Project Assistance <thomas@x-tekcorp.com>
Re: reading and returning data from a file (Larry Rosler)
Re: reading and returning data from a file (Mike O'Brien)
Reading and Writing Files <floydw@centuryinter.net>
Re: Search engine help <eugene@snailgem.org>
Re: sort 2-dim array (Greg Bacon)
Re: Which Perl reference book? <uri@ibnets.com>
Re: Which Perl reference book? (Ilya Zakharevich)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 Jan 1999 15:04:36 -0500
From: "Brad Askins" <Brad.Askins@autodesk.com>
Subject: Re: @ARGV and $_ Question
Message-Id: <77ligg$3kd@autodesk.autodesk.com>
Tom -
You may be right. Maybe I should apologize for my comments to Andre. But
don't you think a suggestion, such as you gave, would have been more
friendly? It is very hard, as you know, to get the tone of an email message
or a newsgroup post. Instead of posting what I guess was suppose to be some
kind of humor, a tip or suggestion would have served a much more useful
purpose.
I was in Tech. Support for years; I have used the term RTFM many times.
Although, sometimes the manual or the documentation leaves a little bit to
be desired. Or, sometimes things just need to be explained in a different
way by a person. That was the source of my problem. I needed someone to get
me another example other than what was in the documentation.
I have moderated many newsgroups and agree there are a lot of bad and some
stupid and easy questions asked. But the people who post the questions it
never think it's stupid or easy, only the people who know the answers think
that. Everybody needs help at some point in learning. That is the point of
the newsgroups.
I got a great email from someone this morning who also suggested reading
perldoc perlvar, but also went on to give me great examples of both @ARGV
and $_. I couldn't have asked for anymore.
If I have offended anyone, I'm sorry. I felt like Andre was quick to judge
me and maybe I was to quick to judge Andre and for that I am sorry. But I
don't think that making me feel belittled over what appeared to be a simple
question is the answer either.
Brad
Tom Briles wrote in message <369E0B96.68A9BE7F@austin.ibm.com>...
Brad wrote:
That was incredible help...Thank you so much for answering my question! I
never thought of reading the documentation...how stupid of me?!
Don't you think I read the documentation and still didn't quite understand?
Or are you just some kind of a smart-ass? If you aren't going to be of any
help just stay out of newsgroups. You aren't helping me or anyone else who
might have the same question or having the same problem.
You must be some kind of expert and if that is the case maybe you should be
writing the documentation or spending your time more wisely by writing code.
Maybe to feel good about yourself by putting other people down or by stating
the obvious. I wish you many years of good fortune.
Once again, cheers Andre, your the best.
Brad
Andre L. wrote in message ...
In article <77j8bf$kgg$1@news.monad.net>, "Brad" <roclimb@yahoo.com> wrote:
Could someone give me a good definition of these two items and a couple
good
examples? Or point me in the direction where I can find good definition
and
examples.
How about... the documentation? :)
Andre
Brad -
What documentation did you read?
Did you try "perldoc perlvar"? That gives a very reasonable definition of
both
"$_" and "@ARGV".
If you did read that entry, and still have questions, you need to be more
specific about what parts of the definition(s) are unclear to you.
It's always a good idea to "lurk" in a group for a bit before posting. If
you
had, you would have seen that this particular newsgroup is a stickler for
reading the documentation. The reasoning is simple...Perl has terrific
on-line
documentation, so try there first - always.
Andre's response was much friendlier than the responses you could have
gotten
(and may well still get) from other regular posters to this newsgroup. And
it
was also a very valid post, by the way. You owe him an apology.
- Tom
------------------------------
Date: Thu, 14 Jan 1999 14:52:29 -0500
From: "Wang, Liming (EXCHANGE:SKPK:1N51)" <wangli@americasm01.nt.com>
Subject: [Q] how to check the existence of ^M in a text file on Unix
Message-Id: <369E4AFD.673F4860@americasm01.nt.com>
Hi all,
I am wondering if someone out there can give me a hint on how to detect
whether a text file on Unix contains "^M" (i.e., the Control-M
character). This happens if you use Notepad on NT and save the file,
store it on Unix.
Thanks for any suggestions.
------------------------------
Date: Thu, 14 Jan 1999 13:30:09 -0700
From: "gip" <gibsonc@aztec.asu.edu>
Subject: Advance Data Structure of Perl 5.0
Message-Id: <77ljr9$4kg@bmw.hwcae.az.Honeywell.COM>
# Below is the structure I want to use, based off page 273-274 of
Programming Perl.
# I want to know how to assign members' values. For example, the following
is my first try, which doesn't work. What I want to know is how to set up
an assignment statement that would set the fields for a members.
# Thanks for your time.
# $structures{abc}{size}{members}=>(name{"1"}, type{"int32"});
# Here I'm initializing the structure, just for fun and clarity:
%structures = (
DUMODE_T => {
structureName => "DUMODE_T",
size => "8",
members => [
name => "enum",
type => "enum",
range => "IBIT, SBIT, DEBUG, OPERATIONAL",
default => "0",
res => "null",
size => "4",
},
],
},
AIRGROUNDLOGIC_T => {
structureName => "AIRGROUNDLOGIC_T",
size => "8",
members => [
{
name => "enum",
type => "enum",
range => "ONGROUND, INAIR",
default => "0",
res => "null",
size => "4",
},
],
},
DUIOIPCDISCA_T => {
structureName => "DUIOIPCDISCA_T",
size => "8",
members => [
{
name => "busSelect",
type => "uint8",
range => "null",
default => "0",
res => "null",
size => "1",
},
{
name => "rawDiscreteIn",
type => "uint32",
range => "null",
default => "0",
res => "null",
size => "4",
},
{
name => "rawDiscreteOut",
type => "uint16",
range => "null",
default => "0",
res => "null",
size => "2",
},
],
},
);
$structures{abc} = "abc";
$structures{abc}{size} = "123";
## $structures{abc}{size}{members} => (name{"1"}, type{"int32"});
# @members = ();
# $members{name} = "a";
# $members{type} = "1";
# $structures{abc}{members} = @members;
# display the contents
foreach $struct (keys %structures) {
print "\nName of structure: $struct\n";
print "Total size of structure: $structures{$struct}{size}\n";
for $who ( @{ $structures{$struct}{members} } ) {
print " member name: '$who->{name}' type: '$who->{type}' size:
'$who->{size}'\n";
}
}
print "\n" if $DEBUG ;
$structures = {}; # clear structure
------------------------------
Date: Thu, 14 Jan 1999 14:31:26 -0600
From: Forrest Reynolds <dropzone@mail.utexas.edu>
Subject: Re: Another RegExp.
Message-Id: <369E541E.C030ACA@mail.utexas.edu>
I have some questions:
What is that first "?" doing in the regex?
If you wanted to weed out the '<a href="mailto:' and the
'">' at the end, couldn't you just put them in the match
part outside of the parens so they wouldn't get captured?
ex:
$goal =~ s/(<a href="mailto:)?( good stuff here)(">)?/
$2/i;
No offense, but is this a spam generator?
Hope to help, Forrest
> This is what I have so far:
>
> while (($message =~ /(?:[\w\-.]+?\@[\w\-.]{3,}\.[a-zA-Z]{2,3}(?!\w))/gi) and
> ($` !~ /(<a (.)*>|mailto:)$/i)) {
> substr($message,length($`),length($&)) = <a href=\"mailto:$&\">$&</a>";
> }
>
> That should make sure that "email.address@domain.suf" and
> email.address@domain.suf get made into links, but things like the addresses
> in <a href="mailto:email.address@domain.suf">email.address@domain.suf</a>
> don't. If the last two did it's lead to garbage like:
>
> <a href="mailto:<a
> href="mailto:email.address@domain.suf">email.address@domain.suf</a>"><a
> href="mailto:email.address@domain.suf">email.address@domain.suf</a></a>
>
> which could /really/ mess things up.
>
> Thanks in advance,
>
> -Paul.
------------------------------
Date: 14 Jan 1999 19:21:19 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Confusion with hashes and undef
Message-Id: <77lg3f$7ij$3@info.uah.edu>
In article <op1r9sxbuq1.fsf@kannews.newbridge.com>,
Brad Warkentin <bradw@kannews.newbridge.com> writes:
: I am confused by how undef interacts with hashes. Consider the
: following code snippet:
[snip snippet]
: It produces:
:
: the hash ref is : HASH(0xc8c50)
: the new hash ref is : HASH(0xc8c50)
: hash be gone
:
: My confusion is why I can get a reference to a hash that I have just
: undefined.
The hash didn't go away. You just cleared the values stored in it.
: The data that was stored in it is gone, and the hash itself
: is not defined, but I can still reference it.
Did you read the perlfunc documentation on defined?
You may also use defined() to check whether a subroutine exists, by
saying defined &func without parentheses. On the other hand, use of
defined() upon aggregates (hashes and arrays) is not guaranteed to
produce intuitive results, and should probably be avoided.
: Does the fact that I
: have created another reference to it, keep in around and if so how can
: I destroy it such that it cannot be referenced (I am not talking about
: destroying the data copy that may still exist in memory, just the
: ability to reference the hash by its "name")?
You have a couple of options. The first is to let it go out of scope
like
{
my %hash = ( "bob" => 1, "joe" => 2, "harry" => 3 );
# do some things...
}
# %hash no longer visible
Note the ``naked block'' around where we're using %hash. Those curly
braces tell perl that we only need to use %hash in that one particular
lexical region. Your other option is to create a reference to a hash
and then undef the scalar that holds the reference when you're done
like
my $hash = { "bob" => 1, "joe" => 2, "harry" => 3 };
# do some things...
# now get rid of the hash (provided there are no other references
# to %$hash sitting around)
undef $hash;
Hope this helps,
Greg
--
Join the Army: travel to exotic distant lands; meet exciting, unusual people,
and kill them.
------------------------------
Date: 14 Jan 1999 13:40:17 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Data Structure Notation
Message-Id: <m3u2xt37wu.fsf@moiraine.dimensional.com>
Jerome O'Neil <jeromeo@atrieva.com> writes:
> First let me say that you have put together some fantastic images.
> However, I am really looking for something I can embed in my code, so,
> ASCII is the media of choice.
As much as I'd like to, I can't take credit for perlguts illustrated.
It is solely the responsibility of Gisle Aas, and he has done a
wonderful job making perl's internals understandable. I was just
providing his work as an example of the power of visual data
representations.
> I think I have decided that as long as I represent the data type
> accurately, and use good names and a consistent blocking method, I'll be
> OK.
Yes, I would think that this will be fine so long as your structures
don't become too complicated. Problems arise as your data structures
become more complex, mostly because the notation itself becomes
confusing. Here's an example of what I usually do (this is drawn from
a system that indexes and archives mailing lists that I am subscribed
to)-
##########
#
# Data Structures
#
# %p_index = lists => [ %p5p, %p6p, %linux-kernel, ... ],
# authors => [ %authors ]
# messages => [ %messages ]
#
# %LISTNAME = folder => $folder_name,
# msgcount => $count,
# rules => [ @regexes ]
#
# %authors = name => $name,
# address => [ @addresses ]
# lists => [ %p5p, %p6p, %linux-kernel, ... ],
<snip much more>
The main benefits this gives me are
0- pseudo perl notation is easy for me to read and understand
1- The actual code only uses a single variable ($p_index) which is a
reference to a large set of anonymous arrays, hashes, and
subroutines. It helps me to give mental names to the elements of
the structure, though, even if the names are never actually used
in the program.
Unfortunately, this quickly becomes unwieldy. As nice as it looks for
shallow data structures, it actually makes things much harder when
your data becomes complex. Imagine using the above to try and
describe a a hash of hashes containing arrays of references to
subroutines which return data structures equally as complex (including
more anonymous subs that can also return these sorts of data
structures). Not surprisingly, I've started to adopt this style-
## Data Structures
#
# see http://some.place.on.my.intranet/devel/data.html
# for documentation of the data structures used herein.
:-)
> Anyway, what did you use to create the images in your page? I have *no*
> talent for imaging, so things like that have never been easy for me.
Like I said, it's not my page, and I'm not sure what was used to
create those particular images. I have been using the Gimp for
my work. It isn't particularly difficult to create boxes with
text in them. :-)
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Thu, 14 Jan 1999 19:57:49 GMT
From: jkang@nyph.org
Subject: difference in Perl of Win98/Unix ?
Message-Id: <77li7n$hv8$1@nnrp1.dejanews.com>
Hi, All.
Here is a Perl/newbie's code in Windows 98.
###
print "enter three lines of strings : \n" ;
@STRINGS = <STDIN> ;
print @STRINGS ;
print "@STRINGS" ;
print reverse (@STRINGS) ;
the code above produce this output with input of "first", "second", "third"
on separate lines ending with fourthline of ^Z.
omitting line 1 and 2 from the code above,
second
third
second
third
third
second
first
You would notice there is a initial space character for line 3 and 4.
Aren't they supposed to produce the same output? And Why the $STRINGS[0]
is omitted in the output and not omitted in the reversed array?
Are these related to the fact that DOS returns \n\r instead of \n
with Pressing Enter key? Does ^Z have anything to do with this?
Maybe I should use linux to learn Perl....
Thanks in advance.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 14 Jan 1999 20:27:58 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: difference in Perl of Win98/Unix ?
Message-Id: <ebohlmanF5KGuM.L58@netcom.com>
jkang@nyph.org wrote:
: Here is a Perl/newbie's code in Windows 98.
: ###
: print "enter three lines of strings : \n" ;
: @STRINGS = <STDIN> ;
: print @STRINGS ;
: print "@STRINGS" ;
: print reverse (@STRINGS) ;
: the code above produce this output with input of "first", "second", "third"
: on separate lines ending with fourthline of ^Z.
: omitting line 1 and 2 from the code above,
: second
: third
: second
: third
: third
: second
: first
: You would notice there is a initial space character for line 3 and 4.
As there should be, since Perl appends a spacer string (a single space by
default) to all but the last element of an array when that array is
interpolated into a double-quoted string.
: Aren't they supposed to produce the same output? And Why the $STRINGS[0]
: is omitted in the output and not omitted in the reversed array?
There's a bug in the Win32 console routines that causes the first line of
output from a console-mode program to get overwritten under certain
circumstances. The line was actually output (as you can see by
redirecting the output into a file).
: Are these related to the fact that DOS returns \n\r instead of \n
: with Pressing Enter key? Does ^Z have anything to do with this?
Nope.
------------------------------
Date: 14 Jan 1999 19:10:34 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Dynamic HASHES :-((
Message-Id: <77lffa$7ij$2@info.uah.edu>
In article <369E2B51.C2DAD817@cec.be>,
Stefan Nonneman <stefan.nonneman@cec.be> writes:
: Is it possible to append data pairs to existing hashes when a key is not
: found?
: From the documentation it is not clear to me.
Would something like
if (exists $hash{$key}) {
warn "$key is already present.\n";
}
else {
$hash{$key} = $value;
}
do what you're looking for?
Greg
--
Words are the most powerful drug used by mankind.
-- Rudyard Kipling
------------------------------
Date: 14 Jan 1999 21:10:17 +0100
From: Ask Bjoern Hansen <ask@netcetera.dk>
Subject: Re: Is mod_perl an option?
Message-Id: <m3zp7lobti.fsf@ratatosk.netcetera.dk>
"The Smiths" <smiths@erols.com> writes:
> I am running ActivePerl build 508 and Apache 1.3.3 on Win95. Is mod_perl an
> option in this configuration? I didn't see it available as a module for
> this flavor of Perl but wasn't sure.
Maybe you can get it to work if you have a compiler.
I guess it's easier to just fetch:
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/JBAKER/perl-5.005_02+apache1.3.3+modperl-1.16-bin-bindist1-i386-win32-vc5.zip
which is Jeffrey Bakers precompiled apache/modperl/embperl etc
package for Win32. (Don't know if it works on Win95 tough).
hth,
ask
--
ask bjoern hansen - <http://www.netcetera.dk/~ask/>
------------------------------
Date: 14 Jan 1999 21:03:23 +0100
From: Ask Bjoern Hansen <ask@netc.dk>
Subject: Re: Is mod_perl an option?
Message-Id: <m31zkxpqpg.fsf@ratatosk.netcetera.dk>
"The Smiths" <smiths@erols.com> writes:
> I am running ActivePerl build 508 and Apache 1.3.3 on Win95. Is mod_perl an
> option in this configuration? I didn't see it available as a module for
> this flavor of Perl but wasn't sure.
Maybe you can get it to work if you have a compiler.
I guess it's easier to just fetch:
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/JBAKER/perl-5.005_02+apache1.3.3+modperl-1.16-bin-bindist1-i386-win32-vc5.zip
which is Jeffrey Bakers precompiled apache/modperl/embperl etc
package for Win32. (Don't know if it works on Win95 tough).
hth,
ask
--
ask bjoern hansen - <http://www.netcetera.dk/~ask/>
------------------------------
Date: Thu, 14 Jan 1999 20:02:11 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Looking for Perl programmer in NYC area
Message-Id: <ebohlmanF5KFno.796@netcom.com>
Robert Watkins <r-watkins@worldnet.att.net> wrote:
: First let me point out that we are offering money as compensation, not free
: hosting!
: We are looking for a solid Perl programmer to do a couple of jobs I don't have
: time to tackle. We need someone who is also good at HTML and, preferrably, has
: some pubishing-related experience.
^^^^^^^^^
"Second let me point out that we are offering money as compensation, not
free hosting or free sex!"
------------------------------
Date: 14 Jan 1999 15:24:11 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Looking for Perl programmer in NYC area
Message-Id: <397lup4n84.fsf@ibnets.com>
>>>>> "bdf" == brian d foy <comdog@computerdog.com> writes:
bdf> you might try the nyc-perl-jobs list:
bdf> send to: majordomo@hfb.pm.org
bdf> in body: subscribe nyc-perl-jobs
bdf> brought to you by the New York Perl Mongers :)
hey brian,
what about creating more jobs lists for other pm's? or a open one for
telework? and how can we get those lists some publicity?
this is another reason for a jobs related perl newsgroup. we do seem to
get 1 or 2 requests a day now. and if we had a group there would be more
as well as positions wanted or contractor available. maybe it should be
moderated to keep out the spam and body shops.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Thu, 14 Jan 1999 20:30:40 GMT
From: mirak63@my-dejanews.com
Subject: Mapping NT drives within PERL
Message-Id: <77lk5g$joq$1@nnrp1.dejanews.com>
I have been unsuccessfully trying to map to an NT network drive using the
following syntax... system("net use t: \\\$server\\d$");
My question, How do I map to a NT server when the server name is a variable? I
know how to make this work with a static server ID ie...
system('net use t: \\SERVER\d$'); but I can't figure out when
the ID is a variable. Also, If mapping to an administrative share (d$) is the
dollar sign going to cause problems?
Sorry, I've only got Perl for Dummies and know of no one else who has any
experience.
Thanks,
Mirak.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 14 Jan 1999 14:04:07 -0600
From: D.Nash@utexas.edu (Donald L. Nash)
Subject: Perl 5.005_2 fails op/pack test 9 on DEC OSF1
Message-Id: <D.Nash-1401991404070001@bubba.ots.utexas.edu>
I've built Perl 5.005_2 on Digital Unix 4.0E, using all the default
answers in Configure. I didn't build for threading or anything else that
requires a special invocation of Configure; this is just plain vanilla
Perl. When running the regression tests, test 9 in op/pack.t fails with
this:
not ok 9 1.84467440737096e+19
Has anyone seen this before?
I did some digging and experimenting. Here is the test in question:
print +($x = unpack("I",pack("I", 0xFFFFFFFF))) == 0xFFFFFFFF
? "ok 9\n" : "not ok 9 $x\n";
It works fine for 0 - 0x7fffffff and fails for 0x80000000 - 0xffffffff, so
something's happening when the sign bit gets set. Further, the following
code returns some interesting results:
$x = unpack("I", pack("I", 0xffffffff));
print "native = $x\n";
printf " float = %.14e\n int = 0x%x\n", $x, $x;
Here's the output:
native = 1.84467440737096e+19
float = 1.84467440737096e+19
int = 0xffffffff
So it looks like something is making Perl think the unpacked value is a
float rather than an int. It looks like a matter of interpretation, not
of getting the value itself correct.
If anyone knows how to fix this, I'd appreciate hearing from you.
--
Donald L. Nash, <D.Nash@utexas.edu>, PGP Key ID: 0x689DA021
The University of Texas System Office of Telecommunication Services
------------------------------
Date: Thu, 14 Jan 1999 12:31:07 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl/NT and Long Dir Names??
Message-Id: <MPG.1107f3eabf7a21cc98998d@nntp.hpl.hp.com>
In article <rNnn2.631$pP1.5171887@news2.voicenet.com> on Thu, 14 Jan
1999 10:08:01 -0500, Reno <rmanno@voicenet.*nospam*.com> says...
...
> while (defined($nextname = <'${filestodelete}'>)) {
...
> I imagine the $filestodelete is not being interpretted correctly, but as I
> said, when I print it out it looks fine!
It is not being interpreted properly because of those single quotes,
that specify that you do not want interpolation of variables. Try
leaving them out (and the curly brackets around ${filestodelete} are not
needed, though they do no harm), and everything should work.
This assumes that all your file activities are on absolute path names,
or that the current directory is set appropriately if you are using
relative path names.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 14 Jan 1999 14:04:03 -0600
From: Thomas Rock <thomas@x-tekcorp.com>
Subject: Re: Project Assistance
Message-Id: <369E4DB3.3A7CB2CB@x-tekcorp.com>
Wow! Tough school. They *kill* you if you don't
complete your senior project?! :-)
juldex@yahoo.com wrote:
>
>It's a life and death situation. Thank you Dexter Winter
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
Thomas Rock
X-Tek Corporation
www.x-tekcorp.com
------------------------------
Date: Thu, 14 Jan 1999 12:39:27 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: reading and returning data from a file
Message-Id: <MPG.1107f5d7e0b7e10b98998e@nntp.hpl.hp.com>
In article <lg8l77.a8b.ln@magna.metronet.com> on Thu, 14 Jan 1999
11:11:49 -0600, Tad McClellan <tadmc@metronet.com> says...
> Mike O'Brien (mikeob@itas.net) wrote:
...
> : How can I search a text file for | , return the numeric position, search
> : for | again,return the position subtract the two and then return the
> : lenght of the data inbetween the two |'s. Depending on the data's length
> : I want to read it in to an scalar.
>
> perldoc -f index
That (subtract the result of two 'index'es) works fine if the file is
small enough to be read into a single scalar. If the file is so large
that it has to be read line by line, then a combination of sums over
'length's between the two 'index'es would be needed.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 14 Jan 1999 20:57:21 GMT
From: mikeob@itas.net_nospam (Mike O'Brien)
Subject: Re: reading and returning data from a file
Message-Id: <369e59df.29298519@news.mtt.net>
I have the file open, and I have found the position of the | , how do
I set the current position in that file? and then to read whats
between then continue?
------------------------------
Date: Thu, 14 Jan 1999 13:51:32 -0600
From: "William Floyd" <floydw@centuryinter.net>
Subject: Reading and Writing Files
Message-Id: <MYrn2.4561$w91.1887166@newsread1-mx.centuryinter.net>
Hi,
I am new to Perl but I picking up on it pretty good so far, I have 2
questions about reading and writing files in Perl. Say you have a file that
you use as a database. You want to add and delete from this file regularly.
I have done this and it works fine.
My question: Is it better to read the file into an array and then make
adjustments (ADD or DELETE) and rewrite to the same file name, Or read one
file name and write to another and then rename that file to the original.
Ok if I have already done this why am I asking this question, if this file
gets very large, what are the limits on an array? Is an array faster that
writing to a new file is the file is very large? I realize the size of an
array will probably depend on the memory the server has that is running on,
but if this file takes up to much space will it not slow the server down.
What I am looking for is the optimal way to code this for speed. This file
will probably get into the Megabytes long.
Thanks for any help in advance,
Mark Floyd
leonardz@geocities.com
------------------------------
Date: Thu, 14 Jan 1999 15:13:33 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
Subject: Re: Search engine help
Message-Id: <369E4FED.4458081B@snailgem.org>
Mind Logic wrote:
> I'm using the Simple Search Perl script
> from http://www.worldwidemart.com/scripts/ and have encountered a problem.
> I've successfully chmoded everything, and have changed all the variables (or
> at least I think I have) to reflect the server. Here's my variables.
>
> $basedir = '/htdocs';
> $baseurl = 'http://209.240.134.108/';
> @files = ('*.shtml','*.html');
> $title = "Mind Logic";
> $title_url = 'http://209.240.134.108/';
> $search_url = 'http://209.240.134.108/search.html';
>
> The URL for the script is at http://209.240.134.108/search.html (you can use
> multistandard.com too but the domain names isn't supposed to clear for
> another 7 hours about).
>
> There's currently only two files on the server at
> http://209.240.134.108/index.shtml and http://209.240.134.108/test.html but
> when I type in something like test nothing shows up in the search results.
>
> Anyone know a solution to this?
Oy.
------------------------------
Date: 14 Jan 1999 19:07:38 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: sort 2-dim array
Message-Id: <77lf9q$7ij$1@info.uah.edu>
In article <369E2975.71D0D2E0@iiic.ethz.ch>,
Andreas Stauder <astauder@iiic.ethz.ch> writes:
: can everybody explain me how to sort the columns of a 2-dim array?
That depends on how you define sorted for your particular array.
The following produces the desired output:
#! /usr/bin/perl -w
use strict;
my @array = (
[ 4, 'four', 'red' ],
[ 2, 'two', 'green' ],
[ 3, 'three', 'blue' ],
[ 1, 'one', 'white' ],
);
my @sorted = sort { $a->[0] <=> $b->[0] } @array;
for (@sorted) {
print join("\t", @$_), "\n";
}
Notice that you're really just sorting an array of array references
based on the first elements of the referent arrays. (Say that five
times fast. :-) If you have different sorting criteria, then you
need to address that in your sort comparison function.
Greg
--
Fools rush in where fools have been before.
------------------------------
Date: 14 Jan 1999 14:45:05 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Which Perl reference book?
Message-Id: <39aezl4p1a.fsf@ibnets.com>
>>>>> "bdf" == brian d foy <comdog@computerdog.com> writes:
bdf> it's a really good cheat sheet for the various things you'll want to
bdf> look up without carrying around a laptop or Camel, such as
bdf> * the file test operators
bdf> * regex syntax
bdf> * special variable meaning
command line options
precedence (rarely do i break it but woe when i do!)
bdf> and so on. there is very little commentary. i, as Uri has, have
bdf> sprinkled them liberally whereever i might be doing Perl :)
i agree, i keep them next to my monitor at work and home. i use it for
those little syntax things that i can't remember and i don't feel like
searching a big book or reading the right perl pod file (even with
perldoc).
i wish i had studied mine before the perl quiz and i might have gotten a
few missed questions.
i also have had the fortunate luck of not having to have paid for my 3
copies. i acquired one from an previous employer and i got 2 more
(including the most recent edition) free from the perl conference 2.0
for filling out a survey.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: 14 Jan 1999 20:09:18 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Which Perl reference book?
Message-Id: <77lite$iue$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Uri Guttman
<uri@ibnets.com>],
who wrote in article <39aezl4p1a.fsf@ibnets.com>:
>
> precedence (rarely do i break it but woe when i do!)
Any yacc gurus? Is it possible to have a "floating" precedence?
"This thing has precedence floating between this and that. If this
causes ambiguities, complain."
Ilya
------------------------------
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 4653
**************************************