[31803] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3066 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 7 18:09:42 2010

Date: Sat, 7 Aug 2010 15:09:06 -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           Sat, 7 Aug 2010     Volume: 11 Number: 3066

Today's topics:
    Re: [OT] Memory architecture [not only] Perl <hjp-usenet2@hjp.at>
    Re: Extract variable length numbers (tab delimitered) f <sherm.pendley@gmail.com>
    Re: Extract variable length numbers (tab delimitered) f <hjp-usenet2@hjp.at>
    Re: Extract variable length numbers (tab delimitered) f <cartercc@gmail.com>
    Re: Extract variable length numbers (tab delimitered) f sln@netherlands.com
        perl programming language <robin1@cnsp.com>
    Re: Question re calling subroutines <hjp-usenet2@hjp.at>
    Re: sysopen failures <jwkrahn@example.com>
    Re: sysopen failures <marc.girod@gmail.com>
    Re: sysopen failures <hjp-usenet2@hjp.at>
    Re: sysopen failures <hjp-usenet2@hjp.at>
    Re: sysopen failures <jwkrahn@example.com>
    Re: Thank you Rakudo-Star (and question about SciTE for <szabgab@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 7 Aug 2010 14:58:55 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: [OT] Memory architecture [not only] Perl
Message-Id: <slrni5qm4g.jq5.hjp-usenet2@hrunkner.hjp.at>

On 2010-08-03 21:51, Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> On 2010-08-03, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>>> They do on OS/2: the DLL's-related memory is loaded into shared
>>> address region.  (This way one does not need any "extra"
>>> per-process-context patching or redirection of DLL address accesses.)
>
>> Sounds a bit like the pre-ELF shared library system in Linux.
>
> No, there is a principal difference: on Linux (and most other flavors
> of Unix), you never know whether your program would be "assembled"

There are a lot more principal differences, some of which are even
slightly relevant to the current topic, which is address space usage.


>> Of course that was designed when 16 MB was a lot of RAM and
>> abandoned when 128 MB became normal for a server (but then I guess
>> the same is true for OS/2).
>
> No, it was designed when 2M was a lot of RAM. ;-) On the other hand,
> the architecture was designed by mainframe people, so they may have had
> different experiences.
>
>> I'd still be surprised if anybody ran an application mix on OS/2 where
>> the combined code size of all DLLs exceeds 1 GB.
>
> "Contemporary flavors" of OS/2 still run confortably in 64MB systems.

And users of 64 MB systems load 1 GB of DLLs into their virtual memory? 

Sorry, but that's just bullshit. The combined code size of all DLLs on a
64MB system is almost certainly a lot less than 64 MB, or the system
wouldn't be usable[1]. So by moving code from a general "code+data"
address space to a special code address space, you free up at most 64 MB
in the data address space - a whopping 3% of the 2GB you already have.


> (Of course, there is no FireWire/Bluetooth support, but I do not
> believe that they would add much - IIRC, the USB stack is coded with
> pretty minimal overhead.)
>
>> the kernel. But of course making large changes for a factor of at most 2
>> doesn't make much sense in a world governed by Moore's law, and anybody
>> who needed the space moved to 64 bit systems anyway.
>
> I do not believe in Moore's law (at least not in this context).  Even
> with today's prices on memory, DockStar has only 128MB of memory.

The users of systems with 128 MB of memory don't benefit from a change
which increases the virtual address space from 2GB to 4GB. The only
people who benefit from such a change are those for whom 2GB is too
small and 4 GB is just enough. These are very likely to be the people
for whom next year 4 GB will be too small and the year after 8 GB will be
too small. An architectural change which just increases the usable
address space by a factor of two just isn't worth the effort, as the
people who need it will run into the new limit within a year or two. If
you make such a change you have to make it large enough to last for at
least a few years - a factor of 16 (8080 -> 8086, 8086 -> 80286, 80386
-> x86/PAE) seems to be just large enough to be viable. 

> So Moore's law works both ways; low-memory situation does not
> magically go out of scope.

Nobody claimed that.

	hp

[1] Yes, it's possible that you load a 1MB DLL just to use a single 
    function. But it's unlikely.


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

Date: Fri, 06 Aug 2010 23:24:56 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Extract variable length numbers (tab delimitered) from a string?
Message-Id: <m2sk2rrto7.fsf@sherm.shermpendley.com>

ccc31807 <cartercc@gmail.com> writes:

> password beginning with '#' -- the code skipped all lines as comments
> beginning with # so it treated the password as a comment

*Please* dont tell me you're doing eval($password)...?!?!?

sherm--

-- 
Sherm Pendley                <www.shermpendley.com>
                             <www.camelbones.org>
Cocoa Developer


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

Date: Sat, 7 Aug 2010 13:35:57 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Extract variable length numbers (tab delimitered) from a string?
Message-Id: <slrni5qh8u.jq5.hjp-usenet2@hrunkner.hjp.at>

On 2010-08-07 03:24, Sherm Pendley <sherm.pendley@gmail.com> wrote:
> ccc31807 <cartercc@gmail.com> writes:
>> password beginning with '#' -- the code skipped all lines as comments
>> beginning with # so it treated the password as a comment
>
> *Please* dont tell me you're doing eval($password)...?!?!?

How did you get that idea? "#" is a very common comment character in 
config files and code like

    while (<$config_h>) {
        chomp;
        s/#.*//;
        my ($key, $value) = split(/\s*=\s*/, $_, 2);
	next unless $key;
        ...
    }

is a common way to ignore the comments. And now you have a config file
like this:

    # this is a config file for the foo application
    #
    # first define the database connection:
    dsn      = dbi:Oracle:ORCL
    user     = scott
    password = tiger#4
    # then some ui preferences
    background = green
    ...

the password will be truncated from "tiger#4" to "tiger". Oops.

Obviously that's not exactly what happened in Carter's case, because he
mentioned only "lines beginning with #", so he probably has an even simpler
file format where the password stands alone in a line. Maybe something
like "first line is the user name, second line is the password". 

	hp



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

Date: Sat, 7 Aug 2010 05:59:01 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Extract variable length numbers (tab delimitered) from a string?
Message-Id: <7b5b9888-b026-4748-a15a-5be5f740eee2@t2g2000yqe.googlegroups.com>

On Aug 7, 7:35=A0am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> How did you get that idea? "#" is a very common comment character in
> config files and code like
>
> =A0 =A0 while (<$config_h>) {
> =A0 =A0 =A0 =A0 chomp;
> =A0 =A0 =A0 =A0 s/#.*//;
> =A0 =A0 =A0 =A0 my ($key, $value) =3D split(/\s*=3D\s*/, $_, 2);
> =A0 =A0 =A0 =A0 next unless $key;
> =A0 =A0 =A0 =A0 ...
> =A0 =A0 }
>
> is a common way to ignore the comments. And now you have a config file
> Obviously that's not exactly what happened in Carter's case, because he
> mentioned only "lines beginning with #", so he probably has an even simpl=
er

The line of code was:

next if /^#/;

The input file looks like this:

#User's name
username=3DJoe
#User's password
password=3Dsecret

The input file is constructed from user input reading from a script
like this:

print "Enter your user name: ";
chomp($username =3D <STDIN>);
print "Enter your password: ";
chomp($password =3D <STDIN>);

My 'fix' was to make a double sharp (##) the comment character. Some
day, a user will enter a value beginning with a double sharp, and that
will be another 'bug' that testing didn't uncover.

CC.


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

Date: Sat, 07 Aug 2010 09:30:05 -0700
From: sln@netherlands.com
Subject: Re: Extract variable length numbers (tab delimitered) from a string?
Message-Id: <bb2r56pamk6l7spio1jiobni7bam013g2n@4ax.com>

On Sat, 7 Aug 2010 05:59:01 -0700 (PDT), ccc31807 <cartercc@gmail.com> wrote:

>On Aug 7, 7:35 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>> How did you get that idea? "#" is a very common comment character in
>> config files and code like
>>
>>     while (<$config_h>) {
>>         chomp;
>>         s/#.*//;
>>         my ($key, $value) = split(/\s*=\s*/, $_, 2);
>>         next unless $key;
>>         ...
>>     }
>>
>> is a common way to ignore the comments. And now you have a config file
>> Obviously that's not exactly what happened in Carter's case, because he
>> mentioned only "lines beginning with #", so he probably has an even simpler
>
>The line of code was:
>
>next if /^#/;
>
>The input file looks like this:
>
>#User's name
>username=Joe
>#User's password
>password=secret
>
>The input file is constructed from user input reading from a script
>like this:
>
>print "Enter your user name: ";
>chomp($username = <STDIN>);
>print "Enter your password: ";
>chomp($password = <STDIN>);
>
>My 'fix' was to make a double sharp (##) the comment character. Some
>day, a user will enter a value beginning with a double sharp, and that
>will be another 'bug' that testing didn't uncover.
>
>CC.

next if "#User's password" =~ /^#/;   passes

next if "password=#secret" =~ /^#/;   fails

-sln


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

Date: Sat, 7 Aug 2010 00:15:10 -0700 (PDT)
From: Robin <robin1@cnsp.com>
Subject: perl programming language
Message-Id: <9320148c-b339-4d7b-a739-8ad3096377ea@t20g2000yqa.googlegroups.com>

http://www.thevoid1.net -- this is my new programming language written
in perl, the completed version will be posted there some point...

-Robin


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

Date: Sat, 7 Aug 2010 14:31:10 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Question re calling subroutines
Message-Id: <slrni5qkge.jq5.hjp-usenet2@hrunkner.hjp.at>

On 2010-08-06 21:28, Tad McClellan <tadmc@seesig.invalid> wrote:
> HerbF@earthlink.net <HerbF@earthlink.net> wrote:
>> Uri Guttman wrote:
>>>>>>>> "H" == HerbF  <HerbF@earthlink.net> writes:
>>>  H> Should I be using parenthesis at the subroutine, i.e.,
>>>
>>>  H> sub abc (A,B,C) {...}

[...]

> What you have there is called a "prototype",

It isn't even a correct prototype. Perl complains with 

    Illegal character in prototype for main::abc : A,B,C at foo line 3.

if you use warnings at the definition 

and with 

    Malformed prototype for main::abc: A,B,C at foo line 5.

even without warnings and strict when you try to call that sub.

So the OP could have gotten the answer "No" to his question simply by
trying it. 

(I really don't understand people who post some code which doesn't work
and ask "Should I do this?" Well, it doesn't work, so obviously you
shouldn't.)

	hp



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

Date: Fri, 06 Aug 2010 23:40:47 -0700
From: "John W. Krahn" <jwkrahn@example.com>
Subject: Re: sysopen failures
Message-Id: <Pd77o.171$wJ1.53@newsfe08.iad>

Marc Girod wrote:
>
> A script saves mails sent by a crontab--so, there may be bursts...
> It uses sysopen, I assume to make sure it doesn't overwrite existing
> files.
> At times, we get bursts of errors (File exists), which I trace to the
> sysopen call.
> However, I cannot find that all the corresponding files would have
> existed.
> I read the doc and get to:
>
>              In many systems the "O_EXCL" flag is available for opening
> files
>              in exclusive mode. This is not locking: exclusiveness
> means here
>              that if the file already exists, sysopen() fails. "O_EXCL"
> may
>              not work on network filesystems, and has no effect unless
> the
>              "O_CREAT" flag is set as well.
>
> The script does write to a network filesystems (home directory on a
> remote filer, 4 ms round-trip).
>
> Shoud I look for a replacement for sysopen?
> Or for an other theory to explain the problem?
>
> The bit of code doing the open:
>
>    if(defined($mode)? sysopen(FILE, $file, O_EXCL | O_CREAT | O_WRONLY,
> $mode):
>                       sysopen(FILE, $file, O_EXCL | O_CREAT | O_WRONLY))
> {

Your code does not check the return value from sysopen() so the error 
message you are receiving is not related to sysopen().


>      _dump(*FILE, @$r_lines);
>      return close(FILE);
>    }
>    return(0);


John
-- 
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein


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

Date: Sat, 7 Aug 2010 01:55:43 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: sysopen failures
Message-Id: <84b3bad7-6e6f-41f9-a7d0-d10e1dbd1142@14g2000yqa.googlegroups.com>

On Aug 7, 7:40=A0am, "John W. Krahn" <jwkr...@example.com> wrote:

> Your code does not check the return value from sysopen() so the error
> message you are receiving is not related to sysopen().

Doesn't it?
The block is an if block.
If the condition (the return from sysopen) is false, the function
returns 0 unconditionally.

Besides, the error I get from $!, at the time of reporting in the
calling function is, as I wrote it, 'File exists'.

And last: it is not *my* code.
Marc


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

Date: Sat, 7 Aug 2010 13:56:54 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: sysopen failures
Message-Id: <slrni5qig6.jq5.hjp-usenet2@hrunkner.hjp.at>

On 2010-08-07 08:55, Marc Girod <marc.girod@gmail.com> wrote:
> On Aug 7, 7:40 am, "John W. Krahn" <jwkr...@example.com> wrote:
>> Your code does not check the return value from sysopen() so the error
>> message you are receiving is not related to sysopen().
>
> Doesn't it?
> The block is an if block.
> If the condition (the return from sysopen) is false, the function
> returns 0 unconditionally.

But you haven't shown where the error is reported. We could only guess
that it's the next thing after “return 0”.

> Besides, the error I get from $!, at the time of reporting in the
> calling function is, as I wrote it, 'File exists'.

There may be something between the sysopen and the printing of $! which
causes that error. Since we haven't seen that code we can't tell.
I do agree that it's very likely that “File exists” is set by sysopen in
this case.

> And last: it is not *my* code.

You posted it, so in the context of this thread it's your code. :-P

	hp



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

Date: Sat, 7 Aug 2010 14:10:12 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: sysopen failures
Message-Id: <slrni5qj95.jq5.hjp-usenet2@hrunkner.hjp.at>

On 2010-08-06 17:06, Marc Girod <marc.girod@gmail.com> wrote:
> A script saves mails sent by a crontab--so, there may be bursts...
> It uses sysopen, I assume to make sure it doesn't overwrite existing
> files.
> At times, we get bursts of errors (File exists), which I trace to the
> sysopen call.
> However, I cannot find that all the corresponding files would have
> existed.
> I read the doc and get to:
>
>             In many systems the "O_EXCL" flag is available for opening
> files
>             in exclusive mode. This is not locking: exclusiveness
> means here
>             that if the file already exists, sysopen() fails. "O_EXCL"
> may
>             not work on network filesystems, and has no effect unless
> the
>             "O_CREAT" flag is set as well.

If the network filesystem doesn't support O_EXCL, then the open will
succeed even though it shouldn't (or it will fail every time with
EINVAL), it won't fail when the file doesn't exist.


> The script does write to a network filesystems (home directory on a
> remote filer, 4 ms round-trip).
>
> Shoud I look for a replacement for sysopen?

No. sysopen is the closest you can get to the OS. If sysopen reporte
EEXIST, then the OS really thinks the file exists at the time.

> Or for an other theory to explain the problem?

Yes. Most likely causes are IMHO:

 * The file really exists at the time. You have to find out why 
   (maybe your script is supposed to remove the file before it
   terminates and it either doesn't do it or a previous invocation
   hasn't finished yet). If you know why the solution is probably 
   obvious.
 * The file did exist and has already been removed at the time the
   script runs, but the information about the file's existence is still
   cached by the OS. In this case you should check the configuration of
   the file system (on both the client and the server).

	hp


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

Date: Sat, 07 Aug 2010 10:40:56 -0700
From: "John W. Krahn" <jwkrahn@example.com>
Subject: Re: sysopen failures
Message-Id: <JUg7o.44476$Zp1.7687@newsfe15.iad>

Marc Girod wrote:
> On Aug 7, 7:40 am, "John W. Krahn"<jwkr...@example.com>  wrote:
>
>> Your code does not check the return value from sysopen() so the error
>> message you are receiving is not related to sysopen().
>
> Doesn't it?
> The block is an if block.
> If the condition (the return from sysopen) is false,

Or true.

> the function returns 0 unconditionally.

Correct.

> Besides, the error I get from $!, at the time of reporting in the
> calling function is, as I wrote it, 'File exists'.

By that time $! could have been changed by some other system function.

You need to capture or print the value of $! immediately after the 
system function that sets it, for example:

sysopen my $FILE, $file, O_EXCL | O_CREAT | O_WRONLY, $mode or do {
     warn "Cannot open '$file' $!";
     return 0;
     };


*Note that "$mode" is really the permissions field, and the MODE field 
is actually "O_EXCL | O_CREAT | O_WRONLY".




John
-- 
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein


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

Date: Sat, 7 Aug 2010 00:16:09 -0700 (PDT)
From: Gabor Szabo <szabgab@gmail.com>
Subject: Re: Thank you Rakudo-Star (and question about SciTE for Perl 6)
Message-Id: <28445118-4ee4-401e-ba8a-27ef61ccc711@v41g2000yqv.googlegroups.com>

On Jul 30, 5:02=A0pm, Dilbert <dilbert1...@gmail.com> wrote:
> ...does anybody know whether there is a project that integrates Perl 6
> syntax for the SciTE editor (http://www.scintilla.org/SciTE.html) ?
> (I am currently using SciTE for Perl 5 and it works perfectly)

I don't know about that but in Padre - which is also based on
Scintilla - we use the STD.pm for syntax highlighting Perl 6. It is
rather slow now but at least you have decent highlighting.

http://padre.perlide.org/

Gabor


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 3066
***************************************


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