[13297] in Perl-Users-Digest
Perl-Users Digest, Issue: 707 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 2 23:07:20 1999
Date: Thu, 2 Sep 1999 20:05:09 -0700 (PDT)
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, 2 Sep 1999 Volume: 9 Number: 707
Today's topics:
Re: -F/foobar/ on #! line (elephant)
Re: Binary to Text <alaly@inlink.com>
Re: Case insensitive SQL query (elephant)
Re: Case insensitive SQL query <rick.delaney@home.com>
Re: darndest regex thing <bwalton@rochester.rr.com>
Re: darndest regex thing <ltl@rgsun40.viasystems.com>
Re: darndest regex thing <rick.delaney@home.com>
Re: END blocks and STDERR <rick.delaney@home.com>
Re: glob w/spaces in dir names (elephant)
Help Please: reading email (Ronald E Jeffries)
Re: Help Please: reading email (Martien Verbruggen)
Re: Life span of other modules variables <rick.delaney@home.com>
Re: null character kills CGI script on NT <rick.delaney@home.com>
Re: Perl ds question <rick.delaney@home.com>
Re: Perl wrapper on NT (elephant)
Re: Porting 'select' system call from UNIX to NT (elephant)
Problems accessing child package variables (T. Alex Beamish)
Re: progressive display of CGI output <pmikal@cisco.com>
Re: reference to a partial array, and magic Lvalue!!! <johnlin@chttl.com.tw>
Re: Simulating Carriage Returns (Ilya Zakharevich)
Re: String Length (Martien Verbruggen)
Re: String Length <uri@sysarch.com>
Re: String Length <meowing@banet.net>
Re: symbolic reference (elephant)
Re: symbolic reference <rick.delaney@home.com>
Re: That Cargo Date Code ( was Re: Y2K) <wyzelli@yahoo.com>
Re: Using split on a variable (Sam Holden)
Re: write to a file in a loop (Martien Verbruggen)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 3 Sep 1999 11:43:46 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: -F/foobar/ on #! line
Message-Id: <MPG.1239d2dc866ce91989caa@news-server>
Colin R. DeVilbiss writes ..
>I've been trying to get a short script using the -wanF// command line
> options on the shebang line to work, but everything after the -F
> seems to be swallowed no matter what I try:
>
>#!/usr/bin/perl -wanF/(\s+)/
I had problems with the -F in the shebang .. I thought it was a Win32
problem at the time (couldn't be bothered testing it for long) .. moved
it outside the script to the real command line and everything worked
fine
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Thu, 2 Sep 1999 21:12:01 -0500
From: "Michael Alaly" <alaly@inlink.com>
Subject: Re: Binary to Text
Message-Id: <7qnart$dak$1@ash.prod.itd.earthlink.net>
I am also having a problem converting from binary to text, but in a
different situation. I am sending a series of 8bit bytes to a com port and
expecting a string of 8bit bytes in return. Originally I thought I could
just send the data and then use a sysread to check for a response, but that
didn't work for me so this is what I am trying now:
----------------------------
open(test,"+>com1") or die "Can't open COM1: $!";;
print test "\x02\x1d\x02\x05\x04\x19"; #byte output
while(<test>) {
if (length($_) != 0) {
open(file,">>temp.dat");
$decimal = pack('B8', '$_');
print file $decimal;
close file;
}
}
close test;
---------------------
The problem is that I am getting a file that consists of the string
"@@@@@@@@" instead of my expected output. I must be using the pack function
incorrectly. I read the docs but they just confused me even more.
Are there better ways of checking for input from the port and then
converting the input back into hex, or integers so that I can use it to
generate another string of data to send to the port?
Any help would be much appreciated,
Thanks,
Michael Alaly
------------------------------
Date: Fri, 3 Sep 1999 11:08:30 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Case insensitive SQL query
Message-Id: <MPG.1239ca95d000a93f989ca7@news-server>
Lauren Smith writes ..
>mrbog@my-deja.com wrote in message <7qmsva$7na$1@nnrp1.deja.com>...
>>
>>I still contest that SQL IS tangentially related to perl, given that as
>>much as 30 to 40% of people who program perl for a living have to write
>>code that consults a database. That's in the "duh" category.
>
>
>I'm pretty sure this is on topic for this group. Could someone help me
>with typing? I figure that if you program, you have at least a little
>experience with keyboard layout and typing techniques.
yes .. I believe 99.999982% of all computer programmers will use a
keyboard at some stage in their job
>Likewise, I've been having problems lately turning on the lights in my
>house. I used to use candles, but now that I've moved into a new house
>with electricity, I am having trouble with the light switches. Can
>someone send me more information?
I believe that 100% of all computer programmers will use electricity at
some stage in their job .. now that's what I call a tangential
connection (because apparently the threshold is only 30% *B^)
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Fri, 03 Sep 1999 01:18:54 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Case insensitive SQL query
Message-Id: <37CF21ED.1CF67BE@home.com>
[posted & mailed]
Lauren Smith wrote:
>
> I'm pretty sure this is on topic for this group. Could someone help me
> with typing? I figure that if you program, you have at least a little
> experience with keyboard layout and typing techniques.
>
> Likewise, I've been having problems lately turning on the lights in my
> house. I used to use candles, but now that I've moved into a new house
> with electricity, I am having trouble with the light switches. Can
> someone send me more information?
Certainly, but you should have been able to find it yourself. While
your questions are on topic, I'm afraid they're FAQs.
perldoc perlfaq3
How do I do (anything)?
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Thu, 02 Sep 1999 21:26:33 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: darndest regex thing
Message-Id: <37CF23C9.C00BEFD1@rochester.rr.com>
Jonathan Mayer wrote:
> I'm trying to make a smart parser that tokenizes a string, but treats
> anything between
> two quotes as a single token. You would think this would do the trick:
>
> $_ = qq!first second "the third token" fourth!;
> @a = m/(?:\"(.+?)\")|(\S+)/g;
Note: \" is not needed above -- could be just "
>
> for ($i = 0; $i <= $#a; $i++) { print "$i: <$a[$i]>\n"; }
>
> and yet the output is:
>
> 0: <>
> 1: <first>
> 2: <>
> 3: <second>
> 4: <the third token>
> 5: <>
> 6: <>
> 7: <fourth>
>
> Why on earth is my regex matching the null strings in the 0, 2, 5, and 6
> positions?
...
Jonathan, *each* set of grouping parens in your regular expression returns a
value each time a match occurs. For that reason, since you matched a total
of four times and your regular expression contains two sets of grouping
parens, a total of eight array elements are returned. Because of the nature
of your pattern, half of them are null. Here is how you can get *almost*
what you want:
@a = m/(".+?"|\S+)/g;
That works, except that the " characters are included in the quoted tokens.
You could run through your array elements eliminating the " if you want with
something like:
for(@a){s/^"(.*)"$/$1/}
or
@a=map {if(/^"(.*)"$/){$1}else{$_}} @a;
Also, you might consider the module Text::ParseWords that mostly does the
hard stuff for you.
------------------------------
Date: 3 Sep 1999 02:02:09 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: darndest regex thing
Message-Id: <7qna71$knl$1@rguxd.viasystems.com>
Jonathan Mayer <jmayer@earthling.nospam.com> wrote:
:>I'm trying to make a smart parser that tokenizes a string, but treats
:>anything between
:>two quotes as a single token. You would think this would do the trick:
:>$_ = qq!first second "the third token" fourth!;
:>@a = m/(?:\"(.+?)\")|(\S+)/g;
:>for ($i = 0; $i <= $#a; $i++) { print "$i: <$a[$i]>\n"; }
:>and yet the output is:
:>0: <>
:>1: <first>
:>2: <>
:>3: <second>
:>4: <the third token>
:>5: <>
:>6: <>
:>7: <fourth>
:>Why on earth is my regex matching the null strings in the 0, 2, 5, and 6
:>positions?
Because you have 2 thingies in parens above. On each match one
of them is populated and the other is null. If you look at
the order of your results, it will make sense. Or alternatively
if you run you match in a loop instead of assigning in list
context then look at $1 and $2 on each iteration of the loop
you could see what is happening.
:>Any ideas? Please cc: your response to me in email -- USENET is big and
:>scary.
Get over your fear. I answer here.
This regexp does much of what you want, but neither your solution
nor mine are really very good.
@a=m/((?<=").+?(?=")|[^" ]+)/g;
Have you looked at Text::ParseWords? This is a problem that has
already been solved for most applications.
--
// Lee.Lindley /// Programmer shortage? What programmer shortage?
// @bigfoot.com /// Only *cheap* programmers are in short supply.
//////////////////// 50 cent beers are in short supply too.
------------------------------
Date: Fri, 03 Sep 1999 02:59:46 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: darndest regex thing
Message-Id: <37CF3990.FACD8A84@home.com>
[posted & mailed]
Jonathan Mayer wrote:
>
> $_ = qq!first second "the third token" fourth!;
> @a = m/(?:\"(.+?)\")|(\S+)/g;
> for ($i = 0; $i <= $#a; $i++) { print "$i: <$a[$i]>\n"; }
Bob Walton has already explained why you get the output you do. One
other way to fix it would be to change the second line to
push @a, $+ while m/(?:\"(.+?)\")|(\S+)/g;
perldoc perlvar and read up on the rarely seen $+.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 03 Sep 1999 02:46:14 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: END blocks and STDERR
Message-Id: <37CF3664.2FD8CC16@home.com>
[posted & mailed]
Bill Moseley wrote:
>
> 1) Can I easily capture all STDERR messages (e.g. warnings) into my
> $log_message? I guess I'd have to tie STDERR somehow. (pointers,
> please?)
perldoc perltie
perldoc Tie::Handle
But that probably wouldn't work very well. It would be easier to set up
$SIG{__WARN__}.
perldoc perlvar
That is, unless you're trying to capture stderr for stuff other than
perl messages.
> 2) Should I open() and flock() my file in the END block, or would it be
> better to open() the file in a BEGIN and then flock and write
> $log_message in the END block. This would be to catch any STDERR
> messages that I couldn't capture during the execution of the program.
You can usually get by without locking if your file is opened in append
mode. It should be sufficient for an error log unless you get lots of
long errors.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 3 Sep 1999 13:00:00 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: glob w/spaces in dir names
Message-Id: <MPG.1239e4b8866fe751989cac@news-server>
Brian Williams writes ..
> I'm trying to get a list of files in this directory with:
>
>if ($s eq "Some Folder" )
>{
> @MORE = glob( "$s\\*" );
> print "@MORE\n";
>}
>
> It just prints "Some\n". It works great if I take the space out of the
>dir name, but I think this should work... Am I missing something? I've got
>ActiveState perl on WinNT.
I can confirm that this happens for me too (Perl 5.005_03 build 519
WinNT SP4) .. I'd go so far as to say that this is a bug with the Win32
port of glob() .. I'll leave the reporting up to you (I've never used
glob in my life)
C:\>dir "Program Files\Windows*"
Volume in drive C is system
Volume Serial Number is ACBC-DBA2
Directory of C:\Program Files
01/05/99 14:45 <DIR> Windows Media Player
01/05/99 14:45 <DIR> Windows Messaging
01/05/99 14:45 <DIR> Windows NT
3 File(s) 0 bytes
120,540,672 bytes free
C:\>perl
print 'For the glob -> Program Files\\Windows*', "\n";
print "$_\n" for glob( 'Program Files\\Windows*');
print "\n";
# and just in case I misunderstood the way glob works
print 'For the glob -> "Program Files\\Windows*"', "\n";
print "$_\n" for glob( '"Program Files\\Windows*"');
print "\n";
# but with the DOS name
print 'For the glob -> progra~1\\Windows*', "\n";
print "$_\n" for glob( 'progra~1\\Windows*');
__END__
For the glob -> Program Files\Windows*
Program
For the glob -> "Program Files\Windows*"
For the glob -> progra~1\Windows*
progra~1\Windows Media Player
progra~1\Windows Messaging
progra~1\Windows NT
C:\>
btw .. long directory names work .. it's just the ones with spaces in
them that need their DOS names to be used
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Fri, 03 Sep 1999 01:11:12 GMT
From: ronERASEjeffries@ERASEacm.org (Ronald E Jeffries)
Subject: Help Please: reading email
Message-Id: <37cf1fcc.86005997@news.det.ameritech.net>
I'm looking for a perl script that will read email from my mailhost,
given the host name, user name, password, etc. I haven't been able to
find anything that will work.
Pointers to the right place in the documentation will be appreciated
... actual working code would be wonderful.
Thanks!
Ron Jeffries
http://www.XProgramming.com
Disclaimer: I could be wrong -- but I'm not.
(Eagles, "Victim of Love")
------------------------------
Date: Fri, 03 Sep 1999 01:24:49 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help Please: reading email
Message-Id: <BrFz3.209$Of6.6005@nsw.nnrp.telstra.net>
In article <37cf1fcc.86005997@news.det.ameritech.net>,
ronERASEjeffries@ERASEacm.org (Ronald E Jeffries) writes:
> I'm looking for a perl script that will read email from my mailhost,
> given the host name, user name, password, etc. I haven't been able to
> find anything that will work.
If your mail can be retrieved with POP3, Net::POP3 might be something
to have a look at. It's available from any CPAN archive:
http://www.perl.com/CPAN
> Pointers to the right place in the documentation will be appreciated
http://www.perl.com/CPAN/modules
> ... actual working code would be wonderful.
Net::POP3 works fine.
Martien
--
Martien Verbruggen |
Interactive Media Division | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd. | crops where there ain't no crops.
NSW, Australia |
------------------------------
Date: Fri, 03 Sep 1999 02:05:09 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Life span of other modules variables
Message-Id: <37CF2CC5.10F30384@home.com>
[posted & mailed]
T. Alex Beamish wrote:
>
> I am using $#dograph::NewSymbol to find the index of the last element
> of @NewSymbol in dograph .. I believe that's the correct syntax ..
Yep.
> there should be stuff in there, but the array (and the other
> variables) appear to be empty.
This is pretty hard to diagnose without code. See if you can make a
_small_ example that duplicates the problem and post that. The only
thing I can suggest without code is using -w to catch typos.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 03 Sep 1999 01:29:39 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: null character kills CGI script on NT
Message-Id: <37CF2471.34E2BFA6@home.com>
Corey Edwards wrote:
>
> I have written a CGI script which opens a file, often times an image,
> and prints that data out to the browser. First, I wrote it on UNIX, and
> it worked great. No problems. Then they wanted me to port it to NT, so I
> did. Then comes the problem of null characters in the file. Whenever one
> is reached and I try to print it, the script will die as in:
> open (FILE, "sample.gif");
Check return of open.
perldoc -f binmode
[snip character at a time which you don't want to do]
> #get rid of nulls
> @data = grep {!/[\0x00]/} @data;
Do you just want to get rid of x's and 0's as well? /\0/ would be
sufficient.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 03 Sep 1999 01:43:19 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Perl ds question
Message-Id: <37CF27A5.F13CD0D8@home.com>
[posted & mailed]
sxbktm@my-deja.com wrote:
>
> I have a list of items such as,
>
> LEFT MID RIGHT
> ---- --- -----
>
> ABCD 5 aa
> MNOP 5 bb
> MNOP 4 dd
> ABCD 4 ff
> MNOP 5 gg
> ABCD 6 hh
>
> If any of the items on the left is greater than 10, I want to repeat it
> again. But I would like to see the outputs on the right being
> reflected correspondingly too. By that I mean, I want to produce the
> output in the following way:
>
> LEFT MID RIGHT
> ---- --- -----
>
> ABCD 9 aa
> ff
> ABCD 6 hh
> MNOP 10 bb
> dd
> MNOP 5 gg
>
> I am newbie to the data structures of Perl, although I tried using
> HashofList{LEFT},but the problem with this approach is that it only
> gives unique values, ABCD and MNOP, as opposed to the above output.
Use the items under LEFT as your hash keys. Store a hash ref as the
value with one field being total of MID and the other being a reference
to an array of RIGHTs. Something like:
%struct = (
ABCD => {
MID => 9,
RIGHT => ['aa', 'ff'],
},
MNOP => {
MID => 9,
RIGHT => ['bb', 'dd'],
},
);
Whenever the MID count exceeds 10, you can print what you've got or push
it onto an array for later processing. Then overwrite what's there with
new values.
See perldsc and perlref for more on how to populate and print this
structure.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 3 Sep 1999 11:24:22 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Perl wrapper on NT
Message-Id: <MPG.1239ce4df00e0438989ca8@news-server>
Wyzelli writes ..
>elephant <elephant@squirrelgroup.com> wrote in message
>news:MPG.12389b1551efe422989ca2@news-server...
>
>> in NT there's no DOS Prompt .. there's no DOS .. if you want to know
>> more about this - then you should probably ask in another forum - this
>> is completely unrelated to Perl
<my own signature snipped from quote>
>There is however a command prompt which is loosely equivalent, and for the
>purposes of running the bat file mentioned, functions the same (ie start -
>run - command)
you're talking about command.com ?? .. this is not where you should be
running your perl programs on NT .. you should be using the default
command interpreter in NT (ie. cmd.exe) .. command.com is (in
Microsoft's own words) only provided to provide batch file compatibility
with MS-DOS for batch files that call command.com
I don't really know what your point here is .. but anyway...
permit me to grab a little context here to this discussion .. my
comments were said in relation to the following question from the
originator (I've included my comment below and your response as well)
>>>5) Since I will run perl scripts from the DOS prompt, does that mean I
>>>only get 16 bit performance, or do I get 32 bit performance?
>>
>>in NT there's no DOS Prompt .. there's no DOS .. if you want to know
>>more about this - then you should probably ask in another forum - this
>>is completely unrelated to Perl
>
>There is however a command prompt which is loosely equivalent, and for the
>purposes of running the bat file mentioned, functions the same (ie start -
>run - command)
you do realise that the batch file mentioned runs from cmd.exe as well
don't you ? .. and that none of this has anything to do with 16 bit vs.
32 bit performance ? .. and nor does the question of whether the NT
version of command.com (or in fact the Windows version) is 16 or 32 bit
.. or the question of whether or not cmd.exe is 16 or 32 bit .. or how
this would affect performance of the Perl interpreter
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Fri, 3 Sep 1999 11:34:35 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Porting 'select' system call from UNIX to NT
Message-Id: <MPG.1239d0b665d1032e989ca9@news-server>
Lokesh Setia writes ..
>I recently wrote a perl tcp/ip server in unix, which i have to now
>port to agghhh... Windows NT. Most of the perl portion is portable
>except for these three (at least):
>
>1. Since the server handles multiple connections at the same time, i
> chose to multiplex sockets using select() system call. What's the
> equivalent in NT?
you haven't said .. so I'll assume that you're using ActiveState's port
of perl
you should find that select() works with sockets on NT .. at least in
5.005_03 it does .. in fact this is the only way to build a socket
server on NT because there's no fork()ing
I'm guessing that you haven't tried this yet .. go away and try it and
then post here
oh - before you do .. read the perlport documentation .. and all the
Win32 FAQs included from ActiveState
also read the perlwin32.html - especially the "Bugs and Caveats" section
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Fri, 03 Sep 1999 02:44:28 GMT
From: talexb@tabsoft.on.ca (T. Alex Beamish)
Subject: Problems accessing child package variables
Message-Id: <37cf34a7.109847469@news1.on.sympatico.ca>
Hello,
My ISP is having problems accessing newsgroups so I am relying on
E-Mail responses .. otherwise I would response to postings that have
been made to me in this ng. Aplogoies for the inconvenience.
The parent script:
#! /usr/bin/perl -w
# Parent package .. test code
use Child qw ( Array );
{
# $Child::Array[0] = "This is a test!";
# $Child::Array[1] = "Second line of test!";
Child::One ( "Hit me with your rhythm stick!" );
print "First element is $Array[0].\n";
print "Second element is $Array[1].\n";
}
and the child package:
#! /usr/bin/perl -w
# Child package .. test code
package Child;
use Exporter();
@ISA = qw ( Exporter );
my @Array;
@EXPORT = qw ( Array );
sub One
{
my ( $Word ) = @_;
print "Child: Handling word $Word.\n";
push ( @Array, $Word );
push ( @Array, "Hey ho" );
print "Child: Array is now @Array, returning now.\n";
}
1;
I expect @Array (by which I mean @Child::Array) to have been changed
by the call, so I would get
Child: Handling word Hit me with your rhythm stick!.
Child: Array is now Hit me with your rhythm stick! Hey ho, returning
First element is Hit me with your rhythm stick!
Second element is Hey, ho
but I don't. I get
Child: Handling word Hit me with your rhythm stick!.
Child: Array is now Hit me with your rhythm stick! Hey ho, returning
now.
Use of uninitialized value at parent.pl line 15.
First element is .
Use of uninitialized value at parent.pl line 16.
Second element is .
What have I missed?
I will try to get newsgroup access up by badgering my ISP, but if
someone feels like E-Mailing & posting, I would apprecaiate it.
Thanks!
T. Alex Beamish -- TAB Software
Toronto, Ontario -- www.tabsoft.on.ca
------------------------------
Date: Thu, 02 Sep 1999 18:25:07 -0700
From: Web Database Developer <pmikal@cisco.com>
Subject: Re: progressive display of CGI output
Message-Id: <37CF2372.596E8095@cisco.com>
Use NPH (No-Parse-Headers) for your CGI scripts. NPH is the mechanism by
which CGI programs can
return HTTP header information directly to the client.
http://www.w3.org/Protocols/
-philip
krubba@my-deja.com wrote:
> Just wondering if anybody knows how to have a
> cgi script feed it's output to the browser one
> line at a time. I tried some buffer flushing
> techniques, with little success, i.e. setting
> STDOUT-autoflush(1) and calling flush() after
> each line, but obviously that didn't work.
>
> I'm guessing it has more to do with how cgi
> passes its output to server which queues it up,
> then serves it to the browser. Is there any
> way to get around this? I noticed metacrawler
> feeds it 1 line at a time (www.metacrawler.com).
>
> Any ideas?
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: Fri, 3 Sep 1999 09:28:47 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: reference to a partial array, and magic Lvalue!!!
Message-Id: <7qn851$hob@netnews.hinet.net>
>> Can we get a reference to a partial array?
>No. You can get a reference to one scalar element of an array,
>but that won't help you.
Hey, I've got an idea. Since the following code works
@a=('a'..'z');
@a[7..10]=('J','I','H','G'); # magic Lvalue!!!
I think it won't be too difficult for Perl to do
$reference= \@a[7..10]; # Sorry, currently not available
@$reference=('J','I','H','G');
I hope Perl would consider enabling this in the next version.
Hey, what about dangling reference problem?
Currently the following code works,
$x=5;
$reference= \$x;
undef $x;
print $$reference;
so I think it won't be too difficult.
What do you think about it? Do you hope to have
magic Lvalue in a reference variable?
It could become a very useful feature in Perl.
Thank you for your advice.
John Lin
------------------------------
Date: 3 Sep 1999 01:12:48 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Simulating Carriage Returns
Message-Id: <7qn7ag$kmm$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Alan Curry
<pacman@defiant.cqc.com>],
who wrote in article <ahCz3.559$MP6.29772@typ11.nn.bcandid.com>:
> >OSes and have 32-bit time_t. It is unsigned, but 32-bit. Of course,
> >being based on gcc, EMX *could* make it long long.... Go figure...
>
> Not if they cared about C89 conformance.
Well, if C89 mandates 32-bitness of time_t, thus y2038 bug (such
stupidity I would not expect even from a standard committee), IMO: the
hell with C89.
Ilya
------------------------------
Date: Fri, 03 Sep 1999 01:08:41 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: String Length
Message-Id: <tcFz3.208$Of6.6005@nsw.nnrp.telstra.net>
In article <37cf1c4a.0@news.pacifier.com>,
Jason Hurst <variant@pacifier.com> writes:
> Ok, i'm sure there is a very simple solution to this and i'll feel real
> stupid when someone tells me, but i can't figure out how to get the length
> of a string.
The function is called length. Whenever you want to find functions,
you should consult the perlfunc documentation:
# perldoc perlfunc
# perldoc -f length
# perldoc perl
# perldoc perldoc
The ActiveState versions have this, as well as HTML versions of the
documenation installed on your hard disk. You'd do well if you spent
a day just browsing through it.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: 02 Sep 1999 21:12:43 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: String Length
Message-Id: <x7d7w0u7as.fsf@home.sysarch.com>
>>>>> "JH" == Jason Hurst <variant@pacifier.com> writes:
JH> Ok, i'm sure there is a very simple solution to this and i'll feel
JH> real stupid when someone tells me, but i can't figure out how to
JH> get the length of a string. Someone told me about a count
JH> function, but it didn't seam to work for me. I'm using perl in a
JH> win32 invirontment, if that makes any differance, but i wouldn't
JH> think so. Any help would be appreciated. Thanks!
your answer in in your question. just try looking up various terms in
your question in the perl docs and you will smack you head when you find
out the name of the function you desire.
and next time, try reading the docs as you will discover a wealth of
perl knowledge.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: 02 Sep 1999 21:17:19 -0400
From: meow <meowing@banet.net>
Subject: Re: String Length
Message-Id: <87671srdy8.fsf@slip-32-100-244-251.ma.us.ibm.net>
Jason Hurst <variant@pacifier.com> wrote:
> Ok, i'm sure there is a very simple solution to this and i'll feel real
> stupid when someone tells me,
Yeah, you're gonna feel stupid.
> but i can't figure out how to get the length of a string.
length($foo)
I told you wou were going to feel stupid.
For some reason that one trips up lots of people. It sometimes seems
like everything in Perl has to have some sort of insanely clever trick
to it, and the last thing that comes to mind is to look for the dead
obvious =)
------------------------------
Date: Fri, 3 Sep 1999 11:50:07 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: symbolic reference
Message-Id: <MPG.1239d4568ec0ed9d989cab@news-server>
scmpoper writes ..
>I would like to know is there a dereference happen or just a normal
>variable assigment in the code below:
>
>${identifier} = 1;
normal assignment .. the {}s just delimit the variable name from
surrounding text .. generally you only use them in situations like the
following
my $x = 'abc';
my $xyz = 'def';
# I want to print out 'abcyz' so I try
print "$xyz\n";
# but that gives me 'def' so instead I use
print "${x}yz\n";
# which gives me my desired 'abcyz'
HTH
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Fri, 03 Sep 1999 01:56:55 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: symbolic reference
Message-Id: <37CF2AD5.3AA52D63@home.com>
[posted & mailed]
scmpoper wrote:
>
[from the Camel:]
> ${identifier}; # same as $identifier
> ${"identifier"}; # also $identifier, but treated as symbolic
> reference.
>
> I would like to know is there a dereference happen or just a normal
> variable assigment in the code below:
>
> ${identifier} = 1;
As it says in the excerpt above, it is just a normal variable assignment
(same as $identifier).
You can--and should--avoid the problems of symbolic references by
*always* putting 'use strict' at the top of your programs. This will
warn you when you accidentally use a symbolic reference. It will also
force you to declare all variables with my() which can be annoying for
beginners but you will find it very useful when your programs stop
fitting on one screen.
It's not too hard to get in the habit, though. Just put 'my' in front
of your variables where they are first used. So in this case,
my $identifier; #1
${"identifier"}; #2 will give you an error
${identifier} = 1;#3 this is fine since it's the same var as #1
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 3 Sep 1999 12:16:42 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: That Cargo Date Code ( was Re: Y2K)
Message-Id: <lEGz3.1$Op5.756@vic.nntp.telstra.net>
Martien Verbruggen <mgjv@comdyn.com.au> wrote in message
news:DXEz3.204$Of6.6005@nsw.nnrp.telstra.net...
> Besides that, I have found that most of the well organised Open Source
Well organised is the key. Open source certainly seems to be free of many
of the political and marketing imperatives which plague commercial 'crap'.
People doing what they like doing because they are good at it and like the
result is better than people doing it for a 'career' or because you have to.
> projects produce much better code than any commercial product I've
> ever seen. Believe me, I work with both here, and the only things
I have to say I pretty much agree with the rest of your comments.
Wyzelli
------------------------------
Date: 3 Sep 1999 02:56:03 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Using split on a variable
Message-Id: <slrn7sue63.lj7.sholden@pgrad.cs.usyd.edu.au>
On Thu, 02 Sep 1999 03:14:14 -0500, George Taylor <cain@datasync.com> wrote:
>Ordering the books now. Thanks
I wasn't refering to any books, although a good book is almost priceless in
learning a programming language. I meant the huge amounts of documentation
that comes with perl. 'perldoc -f split' for example should give you
some information about split.
<snip jeopardy quote including sig>
Please don't do that... only quote the relevant parts...
--
Sam
I took the initiative in creating the Internet.
--Al Gore
------------------------------
Date: Fri, 03 Sep 1999 01:05:05 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: write to a file in a loop
Message-Id: <59Fz3.207$Of6.6005@nsw.nnrp.telstra.net>
In article <37ce2827.859916140@news.dtu.dk>,
lg@kt.dtu.dk (Lars Gregersen) writes:
> # do do this> open DAT ">File_Name";
Don't do just that, check the return code of the open as well. And
make sure you don't use the same file name all the time.
Martien
--
Martien Verbruggen |
Interactive Media Division | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 707
*************************************