[10611] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4203 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 12 06:07:24 1998

Date: Thu, 12 Nov 98 03:00:21 -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, 12 Nov 1998     Volume: 8 Number: 4203

Today's topics:
    Re: & for subroutines   Was:Re: Perl "Newbie" Needs Hel <dgris@rand.dimensional.com>
    Re: [Q] how to distinguish "0" and 0? (Or: on reading a (Ronald J Kimball)
        Attempting to make my own message board <nope@nope.last.time.i.did.this.i.got.spammed.com>
    Re: Can't use "chomp" dave@mag-sol.com
    Re: Can't use "chomp" (Bart Lateur)
    Re: concurrently writing to a file without doing flock ronald_f@my-dejanews.com
    Re: concurrently writing to a file without doing flock ronald_f@my-dejanews.com
    Re: e-mail massimobalestra@my-dejanews.com
        Error: can't locate loadable module <stephen.kun@is.gaertner.de>
    Re: HELP , I just can figure this out (Ronald J Kimball)
    Re: help explain a regx example?! (Bart Lateur)
    Re: Help please - Testing if a substring in a certain p <sasho@staff.mgu.bg>
    Re: Help please - Testing if a substring in a certain p <gomc0000@stud.uni-sb.de>
    Re: Help please - Testing if a substring in a certain p <gomc0000@stud.uni-sb.de>
    Re: how to add on to an array?? dave@mag-sol.com
    Re: Is this possible using the truncate command (Bart Lateur)
    Re: Not to start a language war but.. <suzuki@ares.fantasy.otsl.oki.co.jp>
        Obtaining CD identification <cavanagh@uvic.ca>
    Re: Obtaining CD identification (Sam Holden)
    Re: operation code for "flock" under HP-UX ronald_f@my-dejanews.com
    Re: percentages (Bart Lateur)
    Re: Perl IDE (Tore Aursand)
    Re: Problem: alternately reading 2+ files in PERL <joeyychen@geocities.com>
    Re: Q: are symbolic refs really needed (was Re: Modific <uri@sysarch.com>
    Re: Q: are symbolic refs really needed (was Re: Modific <zenin@bawdycaste.org>
    Re: Regular expression questions <sasho@staff.mgu.bg>
    Re: Value of <HANDLE> construct can be "0"... <sasho@staff.mgu.bg>
    Re: XQL <msergeant@ndirect.co.uk_NOSPAM>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 11 Nov 1998 23:46:45 -700
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: & for subroutines   Was:Re: Perl "Newbie" Needs Help Debugging Code
Message-Id: <m390hh5rxm.fsf@rand.dimensional.com>

Tk Soh <r28629@email.sps.mot.com> writes:

<snip ucfirst()ing user defined function names and me saying no>

> reasons being?

Religion, partially.  Read Snowhare's response for that.

I can't find many references as to whether upper or lower case is
quantifiably easier to read, although I suspect that lower case is
easier for most people.

The only references I can find are perlstyle[0], which says-

       While short identifiers like $gotit are probably ok, use
       underscores to separate words. It is generally easier to read
       $var_names_like_this than $VarNamesLikeThis, especially for
       non-native speakers of English. It's also a simple rule that
       works consistently with VAR_NAMES_LIKE_THIS.

and an entry from the Jargon File[1]. I'd welcome any other
references anyone cares to provide, either way.

dgris

0- I hope everyone can find this on their own, but here's
a cite- http://language.perl.com/newdocs/pod/perlstyle.html

1- http://earthspace.net/jargon/jargon_22.html#TAG792 
-- 
Daniel Grisinger              dgris@rand.dimensional.com
Supporter of grumpiness where grumpiness is due on clpm.
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Thu, 12 Nov 1998 02:22:04 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: [Q] how to distinguish "0" and 0? (Or: on reading a line from a socket)
Message-Id: <1dicxxo.1u8w756afb16oN@bay1-428.quincy.ziplink.net>

<fis@mpi-sb.mpg.de> wrote:

> is there a way in perl to test the contents of a variable $a for
> beeing 0 but not "0"? The following ideas do not work, i.e. all yield
> true:
> 
> !"0"
> "0" eq 0
> "0" == 0
> !("0" cmp 0)

In general, it doesn't matter.  Perl converts between strings and
numbers as necessary.  If you really need to know whether the current
primary representation of a variable's value is a string or a number,
look into the bitwise operators, which behave differently on numbers and
strings.


>     $line_aux = getc $h;
> 
>     unless ({'$line_aux is 0 but not "0"'}) {  # this goes wrong.

Specifically, in this context your question is irrelevant.  getc() reads
a character from a filehandle; this will always be a one-character
*string*.  There is never a case in which getc() would return a value
represented as a number rather than as a string.  Even with a way to
distinguish between the two, it would not have any utility in this code.

Perhaps you are trying to detect when getc() reaches the end of a file?
The documentation for getc() clearly states that it returns a null
string at EOF.

unless ($line_aux eq '') {

-- 
 _ / '  _      /         - aka -         rjk@coos.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: Wed, 11 Nov 1998 14:29:50 EST
From: "The Wormgod" <nope@nope.last.time.i.did.this.i.got.spammed.com>
Subject: Attempting to make my own message board
Message-Id: <72coje$nm4$1@earth.superlink.net>

I have given up trying to use everybody elses forums because they all suck
(including wwwboard and wwwbbs).
I'm making a forum thats all operated by one quote/comma delimited text
file. The first field is a number given to the message (the number is given
using the same method as wwwboard) the second is the message the message is
dependant upon (for use in threading) the third will probably be something
like it's level in the thread tree. The last fields will probably be things
like the title, name, message, etc.
I have lot's of problems with this (i'll figure most of them out) but the
one i can't seem to figure out is how do i make the messages display the
entire thread...
Are there any other database driven forums that i can look at to see how i
could do this?




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

Date: Thu, 12 Nov 1998 09:43:44 GMT
From: dave@mag-sol.com
Subject: Re: Can't use "chomp"
Message-Id: <72eakg$fpi$1@nnrp1.dejanews.com>

In article <xcom2-1111981600170001@xcom2.dialup.access.net>,
  xcom2@popserver.panix.com (Oliver Moffat) wrote:
> I've checked the FAQ's, carefully re-read Larry, Tom and Randal's Perl
> books and I think I'm losing my mind.
>
> When I try to use chomp any way:

>
> I get this error message:
>
> "chomp" may clash with future reserved word at ./chomper.pl line 17.
> syntax error in file ./chomper.pl at line 17, next 2 tokens "chomp("
> Execution of ./chomper.pl aborted due to compilation errors.
>
> What am I doing wrong?

What you're doing wrong is using Perl 4. Get rid of it immediately and
install a versino of Perl that isn'r prehistoric.

perl -v will show you which version you're using.

hth,

Dave..

--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 12 Nov 1998 10:26:17 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Can't use "chomp"
Message-Id: <364ab778.10009477@news.ping.be>

Serial # 0 wrote:

>>"chomp" may clash with future reserved word at ./chomper.pl line 17.

>Yep, I get the same error message. A few weeks ago I was using the
>same script without problems, but now I'm getting the same error
>message.

Are you sure you're still running the same version of Perl? Try printing
$], that'll tell ya. You need Perl 5.

	Bart.


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

Date: Thu, 12 Nov 1998 08:33:02 GMT
From: ronald_f@my-dejanews.com
Subject: Re: concurrently writing to a file without doing flock
Message-Id: <72e6ft$cmh$1@nnrp1.dejanews.com>

In article <F29LMu.EM4@world.std.com>,
  aml@world.std.com (Andrew M. Langmead) wrote:
> ronald_f@my-dejanews.com writes:
>
> >Perl guarantees that - for unbuffered file handles - the buffer gets flushed
> >automatically at the end of its print statement, so when two Perl processes
do
> >this concurrently, process A tells the operating system to write line A, and
> >process B tells the operating system to write line B. One of these processes
> >must be the first, and since output is unbuffered, the operating system takes
> >either one of these lines and writes it to the file as a piece,
>
> That's assuming that there are no short write() system calls, (a
> situation in which not all of the data is sent to the kernel and the
> remainder has to be sent in a second call) and that the largest amount
> of data sent in a single perl output function is less than the maximum
> allowed by write().
>
> A single write() system call is atomic, but that doesn't mean that
> perl's print() function is, even with command buffering on.

I see - and since the maximum size of a single write depends on the operating
system and/or the C library used by Perl, even knowing this size would make
the program highly unportable.

Thank you for pointing this out.

Ronald
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 12 Nov 1998 08:39:37 GMT
From: ronald_f@my-dejanews.com
Subject: Re: concurrently writing to a file without doing flock
Message-Id: <72e6s8$d1h$1@nnrp1.dejanews.com>

In article <3649CD4F.A5FB22E1@email.sps.mot.com>,
  Tk Soh <r28629@email.sps.mot.com> wrote:
> To get a better understanding, you might want to pick up a book on
> operating system design and look up for the keyword 'mutual exclusion'.
> If you did do it correctlly, then that actually further describe the
> danger of such implementation - it doesn't always happen.

That's not so much a question of OS design - it is obvious that someone must
arrange a mutex lock for accessing the file. The question is, which part of
the task is part of the programmer, and which part is guaranteed by the
underlying implementation. As for example Larry Rosler pointed out earlier in
this thread, correct behaviour *is* guaranteed without locking when the files
are opened for appending (a case that is incidentally applicable to my
situation), but not in general, when they are opened for arbitrary writes.

Ronald
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 12 Nov 1998 08:04:29 GMT
From: massimobalestra@my-dejanews.com
Subject: Re: e-mail
Message-Id: <72e4qd$al6$1@nnrp1.dejanews.com>



> On Wed, 11 Nov 1998 08:13:33 GMT, petra_danielsson@my-dejanews.com
> wrote:
>
> >Hello!
> >
> >I'm using Perl on NT 4 and I have a problem with mailing from Perl. I wrote:
> >open(MAIL, "|mail me\@myserver.com");
> >Is this code only for UNIX users. Can anyone please tell me how I should
write
> >for NT. I'm using Outlook mailprogram.
> >
>

I suggest you to use the Mail::Sendmail module.
It works very well and it is portable.
Example:
use Mail::Sendmail;
%mail = (  To       =>  $to,
           From     =>  $From,
           Subject  =>  $Sbj,
           Message  =>  $Bdy
         );
if (sendmail %mail) { print "Mail sent OK.\n" }
else { print "Error sending mail: $Mail::Sendmail::error \n" }

You can download it from a CPAN.

Bye


--
 Massimo Balestra
 System Engineer
 Torino Italy

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 12 Nov 1998 10:42:22 GMT
From: Stephen Kun <stephen.kun@is.gaertner.de>
Subject: Error: can't locate loadable module
Message-Id: <364ABB8E.21DBC63A@is.gaertner.de>

(Please could you copy any reply to me directly, thanks)
Hello,
I keep getting the error message:
  Can't locate loadable object for module Standard in @INC
My code has the following lines:
  use lib '/usr/perl_local/Standard';
  use Standard;

There is a loadable object for Standard in
/usr/perl_local/Standard/sun-solaris
and everything works fine on another company site with the same
perl version.

Has the problem got to do with @INC?
After the 'use lib', my @INC contains:
/usr/perl_local/Standard

On another company site, the @INC contains:
/usr/perl_local/Standard/sun4-solaris
/usr/perl_local/Standard

Both sites use the same version of perl (5.00502)
Why does the perl on the other site also have
/usr/perl_local/Standard/sun4-solaris?
--------------
Strangely enough, even if I add /usr/perl_local/Standard/sun4-solaris
explicitly to INC I still get the same error message.
Can anyone explain what is happening?
--------------
I've compared the output from 'perl -V' on both sites. The only real
difference is:
my machine: libc=
other site: libc=/lib/libc.so

Thanks for any help.

Stephen Kun

Test program:
#!/usr/local/bin/perl -w
use strict;
print("****** INC before 'use lib'\n", join("\n", @INC), "\n");
use lib '/usr/perl_local/Standard';
print("****** INC after  'use lib'\n", join("\n", @INC), "\n");
-- 
-----------------------------------------------------------------------
  Stephen Kun                   Email:	  stephen.kun@is.gaertner.de
  Kurzekampstr. 10		Tel:      +49 531 237 13 88 (work)
  38104 Braunschweig,		Tel:      +49 531  37 37 28 (private)
  Germany			Web Site: http://www.transeda.com


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

Date: Thu, 12 Nov 1998 02:22:05 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: HELP , I just can figure this out
Message-Id: <1dicyup.zzz5yrkgikxwN@bay1-428.quincy.ziplink.net>

Darrin Edwards <d-edwards@nospam.uchicago.edu> wrote:

> Hmm, perl -w has always given me that warning whenever I've tried
> to use a key that didn't "exist" yet in a hash:

Red herring.  You're not getting the warning from the hash.  You're
getting the warning from printing an unitialized value.

> noise:~>perl -we 'my %Marge; my $Homer = "Mmm"; $Homer = $Marge{lisa};
>     print $Homer, "\n";'  
> Use of uninitialized value at -e line 1.

~> perl -w
my %Marge;
my $Homer = "Mmm";      # $Homer is initialized; value is "Mmm"
$Homer = $Marge{lisa};  # $Homer is unitialized again; value is undef
print $Homer, "\n";     # printing unitialized value gives a warning

Use of uninitialized value at - line 4.


-- 
 _ / '  _      /         - aka -         rjk@coos.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: Thu, 12 Nov 1998 09:57:44 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: help explain a regx example?!
Message-Id: <3652b10c.8365516@news.ping.be>

Dan Baker wrote:

>a while back, Tom C. posted an example that almost does what I need for
>a little subsitution subroutine, but I am struggling with a regx he
>uses. I need to really understand it so I can make the alterations for
>what I'm doing. If you would care to add some annotations on what the
>regx is doing line by line I sure would find it educational...

>here is the section I need help with:
>
>	# replace quoted words with value in %$fillings hash
>	$text =~ s{ %% ( .*? ) %% }		# put a matched quoted word into $1, 
>						# but, in the "( .*? )" why is the ? there?

Minimal matching. Let's take this line as an example:

>    %%username%% logged in %%count%% times, for a total of %%total%%

If you don't it, it'll match everything, as the start of the string is
"%%", and so is the end. $1 would get the value

	username%% logged in %%count%% times, for a total of %%total

which is not what you want. The extra "?" following the star will limit
the match up to the first "%%" encountered:

>	%%username%%

thereby $1 will be "username".

>		  { exists( $fillings->{$1} )	# this expression is killing me...
>			  ? $fillings->{$1}	# what is the significance of using curly {$1}?

Strange question. Why don't you ask what the arrow is for?

The curly braces indicate a lookup in a hash. The arrow indicates that
$fillings is a hashref. Indeed it is, 'cos this is equivalent to the
actual assignment:

	$fillings = \%fields;

so	
	$fillings->{$1}

is (in this case) equivalent to

	$fields{$1}

It could be rewritten as

	${$fillings}{$1}

or (which I find a bit more confusing):
	$$fillings{$1}

As an example: if $1 is "username", then $fillings->{$1} is the value of
$whats_his_name (see the assignment to %fields).

>			  : ""			# and what is the exists()?: doing?

It is a (poor) attempt to disable the warnings if the word you're
substituting isn't in the hash. A better alternative would have been
"defined", as

	%fields = ( username => undef, ...);

would STILL generate a "use of unitialized value" warning for
"username". (It exists, but it is undefined).

>		  }gsex;			# g=global, s=treat as single line, 

If you just disable warnings in your sub, this will do the same, and
just as well:

	local($^W);
	$text =~ s{ %% ( .*? ) %% }{ $fillings->{$1} }gsx;


The code looks a bit like a quick hack. My suggested "improvements":

A) Don't use the same start and end markers in your templates. It's
confusing. I have used "{" and "}" for begin and end markers before, and
I like'em.
B) You might include the obligation to make your variable names whole
words. This makes the minimal matching trick unnecessary.
C) An extra feature is to allow for literal inclusion of begin markers,
if you ever need it.

See if you like this for readability:

    <!-- simple.template for internal template() function -->
    <HTML><HEAD><TITLE>Report for {username}</TITLE></HEAD>
    <BODY><H1>Report for {username}</H1>
    {username} logged in {count} times, for a total of {total} minutes.

And this is my code:

	$text =~ s/{((\w+)|{)}/defined($2) ?
		(defined($fillings->{$2}) ? $fillings->{$2} :
		 do { warn "use of uninitialized value '$2'"; "???" }) :
		$1/ge;

It will give you a warning when using unitialized hash entries, but this
time useful ones: it will tell you WHAT value wasn't initialized. If
tested online, better redirect warnings to the browser for this feature
to be useful.

Use the string "{{}" in your template if you want to insert a bare "{".

HTH,
Bart.


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

Date: Thu, 12 Nov 1998 09:04:52 +0200
From: root <sasho@staff.mgu.bg>
Subject: Re: Help please - Testing if a substring in a certain position is equals  to
Message-Id: <364A8894.8E50CE75@staff.mgu.bg>

Godfrey McLean wrote:

> I would like to test if a substring in a specific position is equals to
> a certain string - i.e. if character 2 and charter 3 = to "hi".  I
> cannot seem to find the right solution.

Try something like this:

  if (substr($x,1,2) eq "hi") { ... }





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

Date: Thu, 12 Nov 1998 07:06:33 +0100
From: Godfrey McLean <gomc0000@stud.uni-sb.de>
Subject: Re: Help please - Testing if a substring in a certain position is equals to
Message-Id: <364A7AE9.582A@stud.uni-sb.de>

Thank you very much - I need practice I think.


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

Date: Thu, 12 Nov 1998 07:06:06 +0100
From: Godfrey McLean <gomc0000@stud.uni-sb.de>
Subject: Re: Help please - Testing if a substring in a certain position is equals to
Message-Id: <364A7ACE.13D6@stud.uni-sb.de>

Thank you so much!  Shall try it today :o)


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

Date: Thu, 12 Nov 1998 09:48:10 GMT
From: dave@mag-sol.com
Subject: Re: how to add on to an array??
Message-Id: <72easq$g41$1@nnrp1.dejanews.com>

In article <364A6D05.CAAC836D@home.com>,
  Justin Park <jjpark@home.com> wrote:
> how can i add new things on to an existing array?

push or unshift

hth,

Dave...

--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 12 Nov 1998 09:57:50 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Is this possible using the truncate command
Message-Id: <364ea0ea.4236584@news.ping.be>

Rafely@xxiname.com wrote:

>I'm making a form that writes the form data to a text file instead of
>e-mailing me the results. But I don't want the file to exceed 25kb.
>What I want to do is write new data at the begin of the file so the
>oldest data will be at the end. When the file exceeds 25kb I want to
>delete a few lines from the bottom of the file (where the old data are
>stored) so that the file is 25kb again. My guestion is, is this
>possible with the truncate command?

Err... sortof. You'll end up with partial lines at the end.

Why not keep the file in order, convert the data to one string, and chop
of whole lines from the start of the string, as long as the length is
longer than say 25000? Untested:

# keep the file open for as short as possible,
# so collect your new data first
$newdata = &Get_new_data; 

# open for R/W
# don't forget to lock the file
open (FILE, "+<text.txt");
flock(FILE,2);
#read in as one string
{ local $/; $_ = <FILE> }
$_ .= $newdata."\n";

while(length > 25000) {
 	s/.*\n?//; # drop first line; "." doesn't match newline
}
#clear diskfile
seek FILE,0,0;
truncate FILE,0;

print FILE;
#don't forget to close it, or it won't be unlocked
close FILE;

HTH,
Bart.


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

Date: 12 Nov 1998 17:44:15 +0900
From: Hisao Suzuki <suzuki@ares.fantasy.otsl.oki.co.jp>
Subject: Re: Not to start a language war but..
Message-Id: <u3lnlh8fmo.fsf@ares.fantasy.otsl.oki.co.jp>

In <729lg7$76$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com writes:
> On the other hand, I frequently find myself wanting python to support
> scheme's or perl's closures so that callbacks can be properly scoped.
> Programmers fluent in python are used to this oversight, but to those of
> us for which closures are an assimilated programming pattern, it grates
> upon us, perhaps needlessly.

Certainly.  But you can use bound methods in Python instead of
closures effectively, though rather wordily.

----------------------------------------------------------------
#!/usr/bin/env python
import sys
from Tkinter import *

def a_test(text):
    class Callback:
	def do(self):
	    if self.i == 5: sys.exit(0)
	    self.i = self.i + 1
	    self.button['text'] = "%s: %d" % (self.text, self.i)
    root = Tk()
    callback = Callback()
    button = Button(root, text="push me", command=callback.do)
    callback.text = text		# here we build the 
    callback.button = button		# environment upon the
    callback.i = 0			# `callback' object.
    button.pack()
    root.mainloop()

if __name__ == "__main__":
    a_test("pushed")
----------------------------------------------------------------
--
SUZUKI Hisao      >>> def fib(n): return reduce(lambda x,y: (x,x
suzuki@otsl.co.jp ... .append(x[-2]+x[-1]))[0],[None]*n,[1L,1L])


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

Date: Thu, 12 Nov 1998 06:49:49 +0000
From: Brad Cavanagh <cavanagh@uvic.ca>
Subject: Obtaining CD identification
Message-Id: <364A850C.53A7FBCD@uvic.ca>

How would I go about determining the CD id code for a CD that's in the
drive?  That's probably not clear, so here's an example.  When I run
xmcd it tells me a "Disc ID" for the CD.  The one that's currently in
there, Dire Straits' "Money For Nothing", had a Disc ID of "b50f8d0c". 
How do I find that ID?  Oh, and this is running under Linux 2.0.35, so
there should be any Win-related oddities.

Many thanks,
 Brad.


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

Date: 12 Nov 1998 07:52:45 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Obtaining CD identification
Message-Id: <slrn74l4ud.74g.sholden@pgrad.cs.usyd.edu.au>

On Thu, 12 Nov 1998 06:49:49 +0000, Brad Cavanagh <cavanagh@uvic.ca> wrote:
>How would I go about determining the CD id code for a CD that's in the
>drive?  That's probably not clear, so here's an example.  When I run
>xmcd it tells me a "Disc ID" for the CD.  The one that's currently in
>there, Dire Straits' "Money For Nothing", had a Disc ID of "b50f8d0c". 
>How do I find that ID?  Oh, and this is running under Linux 2.0.35, so
>there should be any Win-related oddities.

You would look up the specification for the format of audio CDs and 
see how it is encoded and then right a program to extract said information.

Looking at the source of xmcd might help too.

This of course has nothing to do with perl so why don't you ask somewhere
more likely to get a useful response (there's a loinux newsgroup for a
peice of software called cdrecord - someone there might know).

-- 
Sam

 "... the whole documentation is not unreasonably transportable in a
 student's briefcase." - John Lions describing UNIX 6th Edition
 "This has since been fixed in recent versions." - Kernighan & Pike



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

Date: Thu, 12 Nov 1998 08:59:01 GMT
From: ronald_f@my-dejanews.com
Subject: Re: operation code for "flock" under HP-UX
Message-Id: <72e80k$dto$1@nnrp1.dejanews.com>

In article <364A265E.89AB9069@email.sps.mot.com>,
  Tk Soh <r28629@email.sps.mot.com> wrote:
> >    use Fcntl;
> >    flock HANDLE,LOCK_SH; # LOCK_SH exported by Fcntl
> >    flock HANDLE,LOCK_UN;
> >
> > This does not work ("LOCK_SH not numeric") - no surprise, since sys/fcntl.h
> > does not define those constants and Fcntl can only pull out from fcntl.h
> > what is already in it. But sys/fcntl.h has the following definitions:
>
> try this:
>
>     use Fcntl qw(:flock);

Thank  you, this indeed works, and I should have seen it myself - after all,
it is described in bright letters with "perldoc Fcntl". I don't know why
I have not seen it in the first place :-(

I wonder now *how* this works. After all, Fcntl can only provide constants
that are defined in the C header files, but LOCK_SH is not:

    cd /usr/include
    grep LOCK_SH *.h sys/*.h

gives no result. I also checked the code of Fcntl.pm and did not find a
provision for default values. Despite this, LOCK_SH, LOCK_EX and LOCK_UN
do have the correct value. Could you explain the magic behind this, or
point out a place where it is explained?

Ronald
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 12 Nov 1998 09:57:49 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: percentages
Message-Id: <364d9ee1.3715895@news.ping.be>

News wrote:

>if ($gtot < 1000) { $gtot * .025; }

Hold it!

You're multiplying $gtot with 2.5%. Now what to do with this?

	$gtot *= .025

I bet this is wrong. I bet you want either want to ADD this to the price
for smaller values, or subtract it for higher values. So, these are my
stabs:

    if ($gtot < 1000) { $gtot *= 1.025; } #add it for lower prices
or
    if ($gtot > 1000) { $gtot *= .975; }  #subtract it for higher prices

	Bart.


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

Date: Thu, 12 Nov 1998 08:04:48 GMT
From: tore@forumnett.no (Tore Aursand)
Subject: Re: Perl IDE
Message-Id: <364a95ff.660696471@news.online.no>

On Wed, 11 Nov 1998 23:23:37 -0000, "Tim" <oasis@fire.nu> wrote:
> I learnt pascal using Turbo Pascal 7. Is there an IDE like this for Perl?

Turbo Pascal is not an IDE.  Turbo Pascal is an enhanced edition
extracted from the ordinary (and old) Pascal.

And - yes - there are plenty of editors for Perl.  Which one you
should choose, depends on what platform you are running on.

Take a look at <URL:http://reference.perl.com/query.cgi?editors> for
more information on the different editors.


-- 
Tore Aursand
ForumNett Online AS
<URL:http://www.forumnett.no/>


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

Date: Wed, 11 Nov 1998 23:23:22 -0800
From: Joey Chen <joeyychen@geocities.com>
Subject: Re: Problem: alternately reading 2+ files in PERL
Message-Id: <364A8CEA.AAF1F350@geocities.com>

Thanks to all that replied, I found this bit of info in perlop.pod:

     Evaluating a filehandle in angle brackets yields the next
     line from that file (newline included, so it's never false
     until end of file, at which time an undefined value is
     returned).  Ordinarily you must assign that value to a
     variable, but there is one situation where an automatic
     assignment happens.  If and ONLY if the input symbol is the
     only thing inside the conditional of a while loop, the value
     is automatically assigned to the variable $_.  The assigned
     value is then tested to see if it is defined.

So I just did:

$line1=<IN1>;
$line2=<IN2>;

and it worked!

Joey

Sam Holden wrote:

> On Tue, 10 Nov 1998 23:56:28 -0800, Joey Chen <joeyychen@geocities.com> wrote:
> >Hi,
> >
> >How do I go about opening 2 files, and read one line from them
> >alternately:
> >
> >condition1:
> >  read from file1
> >condition2:
> >  read from file2
> >
> >The while(<>) construct seems to only be able to read one file
> >at at time.  Any help would be greatly appreciated.  Thanks.
>
> Read the manual.. you know perlop and perlfunc... The bits that tell
> you how to open files... close files... read from files...
>
> --
> Sam
>
> Basically, avoid comments. If your code needs a comment to be
> understood, it would be better to rewrite it so it's easier to
> understand.     --Rob Pike
> Sam



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

Date: 12 Nov 1998 02:15:18 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Q: are symbolic refs really needed (was Re: Modification of a read-only??)
Message-Id: <x7hfw58jqx.fsf@sysarch.com>

>>>>> "Z" == Zenin  <zenin@bawdycaste.org> writes:

  Z> Uri Guttman <uri@sysarch.com> wrote:
  Z> : that's a good question. maybe use strict 'refs' should be on by
  Z> : default. there might be some odd case but i doubt that you couldn't do
  Z> : it with hashes and maybe typeglobs (the way i did it in perl4! :-).

  Z> 	Dynamically affecting other package's global data, ala some of the
  Z> 	black magic Exporter does:

  Z> 	*{"${PackageName}::$VarName"} = "Some value";

  Z> 	There are non-soft ref ways to do this, but they are much uglier
  Z> 	normally.

this may be one of the few areas, hacking the symbol table. but most
users will never need such tricks. so making use strict 'refs' a default
may be a good idea. you can easily turn it off when doing black magic.

maybe the topaz folks should think about that option.

it's funny, when perl5 came out i thought soft refs were very cool as i
wished i had them in perl4 instead of typeglobs. but regular hash refs
are so much better that i never use soft refs.

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: 12 Nov 1998 07:53:14 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Q: are symbolic refs really needed (was Re: Modification of a read-only??)
Message-Id: <910857246.935338@thrush.omix.com>

Uri Guttman <uri@sysarch.com> wrote:
	>snip<
: this may be one of the few areas, hacking the symbol table. but most
: users will never need such tricks. so making use strict 'refs' a default
: may be a good idea. you can easily turn it off when doing black magic.
:
: maybe the topaz folks should think about that option.

	Personally, I consider it a bug that a full "use strict;" isn't
	in place by default.  Ditto for -w.  It likely would have saved
	us from huge amounts of code that people like to throw back in
	Perl's face as "write once programming".

: it's funny, when perl5 came out i thought soft refs were very cool as i
: wished i had them in perl4 instead of typeglobs. but regular hash refs
: are so much better that i never use soft refs.

	I hated them.  Make a mistake and things just kept on
	trucking...often without so much as a warning.  I'm so glad I
	found use strict before I started doing any major code in 5.x.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Thu, 12 Nov 1998 12:47:15 +0200
From: root <sasho@staff.mgu.bg>
Subject: Re: Regular expression questions
Message-Id: <364ABCB3.36F7F272@staff.mgu.bg>

Dave Rathnow wrote:

> I have a string of characters from which I need to extract the first
> 23 characters.  Everything form the 24 character to the end of
> the line must go.
>
> Could someone tell me what the regular expression for such an
> operation would be?
>
> Thanks,
> Dave.

Try this:   $newstring=substr($oldstring,0,23)
I don't think you need a regexp here...

--
Alexander Avtanski
sasho@staff.mgu.bg



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

Date: Thu, 12 Nov 1998 12:44:03 +0200
From: root <sasho@staff.mgu.bg>
Subject: Re: Value of <HANDLE> construct can be "0"...
Message-Id: <364ABBF2.21A62B55@staff.mgu.bg>

>

If you use the $line=<FILE> construct, really you can get a value of
zero (for example, when reading the last line in a text file, which line
is "0" without "\n" after it).  You can check this that way (supposing
you are running UNIX):

echo 0 | ./test_script            # this should work
echo -n 0 | ./tech_script    # this shouldn't

Instead, you can use defined() that way:

while (defined($line=<FILE>)) { ...

--
Alexander Avtanski
sasho@staff.mgu.bg




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

Date: Thu, 12 Nov 1998 09:31:53 +0000
From: Matt Sergeant <msergeant@ndirect.co.uk_NOSPAM>
Subject: Re: XQL
Message-Id: <364AAB09.4FC1288D@ndirect.co.uk_NOSPAM>

Gustaf Liljegren wrote:
> 
[snip]
> Am I right that XQL is an alternative for Perl?

No. You are wrong. It would be possible to implement an XQL engine in
perl (as there's already an XML-QL engine in perl), but it's certainly
not a replacement for perl. Perhaps you should join the Perl-XML mailing
list - see http://www.activestate.com for details.

-- 
<Matt/>

| Fastnet Software Ltd              |   Perl in Active Server Pages   |
| Perl Consultancy, Web Development |   Database Design   |    XML    |
| http://come.to/fastnet            |    Information Consolidation    |


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 4203
**************************************

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