[16709] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4121 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 18:06:03 2000

Date: Thu, 24 Aug 2000 15:05:23 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967154722-v9-i4121@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 24 Aug 2000     Volume: 9 Number: 4121

Today's topics:
    Re: A Good Challenge<was Just another silly post> (BUCK NAKED1)
    Re: A Good Challenge<was Just another silly post> <smerr612@mailandnews.com>
        ActiveState Perl NT Install Problem coder3555@my-deja.com
    Re: Beginner/intermediate programmer looking to volunte (Jon S.)
        Better understanding of Win32:PerfLib cluemein@hotmail.com
    Re: Can I call a C-function in an existing dynamic libr <tim@ipac.caltech.edu>
    Re: Check array for an element <tim@ipac.caltech.edu>
        Compiling Perl Modules (Sven Khatri)
    Re: Configure problem <doughera@lafayette.edu>
    Re: database for large number of keys? (Mark-Jason Dominus)
    Re: Environment variable SNAFU <care227@attglobal.net>
    Re: File handling and manipulation from function, help  (Soren Andersen)
    Re: File handling and manipulation from function, help  <tim@ipac.caltech.edu>
        format and padding <jmarsan@my-deja.com>
        Free Perl compiler ? stanley.shapiro@wcom.com
        From metacharacter and back again <travis.cox@itron.com>
    Re: help with simple regexp - does my head in (Jynx)
    Re: help with simple regexp - does my head in (Abigail)
        How do I insert a carriage return? <perrin@lacis.com>
    Re: How do I insert a carriage return? (Greg Bacon)
    Re: How do I insert a carriage return? <russ_jones@rac.ray.com>
    Re: How do I insert a carriage return? <perrin@lacis.com>
    Re: how to round ? <tim@ipac.caltech.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Aug 2000 13:24:27 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: A Good Challenge<was Just another silly post>
Message-Id: <202-39A5685B-51@storefull-245.iap.bryant.webtv.net>

Sounds like a fair and reasonable challenge to me. If I had a clue, I'd
be spitting out some code for you. Should be interesting though to see
if someone can write code without using a module or just telling how it
should be done. :-)

I look forward to seeing who can write the best code for this
application.

Regards,
Dennis



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

Date: Thu, 24 Aug 2000 19:38:19 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: Re: A Good Challenge<was Just another silly post>
Message-Id: <8o3tj8$bmh$1@nnrp1.deja.com>

In article <202-39A5685B-51@storefull-245.iap.bryant.webtv.net>,
  dennis100@webtv.net (BUCK NAKED1) wrote:
> Sounds like a fair and reasonable challenge to me.

A challenge maybe, but what's the point?  We know we can do it, it'll
never come up in our regular work with Perl and it's not even really
stretching our abilities, just making us conform to a bunch of pointless
rules.

> If I had a clue, I'd
> be spitting out some code for you. Should be interesting though to see
> if someone can write code without using a module or just telling how
it
> should be done. :-)

Of course someone _can_ do it, but they've learned nothing new about
designing algorithms, they haven't stretched their own abilities,
nothing really useful could come out of this "challenge."  All we've
done is taken a trivial problem and made it as difficult as possible,
but in the end it's still a trivial problem.  An elegant solution to a
trivial problem is a waste of time.
It's a decent challenge for a newbie, they'll have to look up all kinds
of ways to pack commands in together and all kinds of stuff like that,
but since we're trying to get away from teaching people that Perl looks
like line noise, why do it?

> I look forward to seeing who can write the best code for this
> application.

What application?  There is no use for such code, no need at all.  Just
the "pride" you'd feel from solving a trivial problem under unrealistic
and contrived constraints.  The kind of person who would think of this
as an interesting challenge probably enjoys trying to learn to touch
type with their toes, even though there's nothing wrong with their
hands.  They they flaunt it, "Look what I can do!" The rest of us say
"ooh, neat" and go back to doing something useful.

Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 21:54:19 GMT
From: coder3555@my-deja.com
Subject: ActiveState Perl NT Install Problem
Message-Id: <8o45i8$kim$1@nnrp1.deja.com>

Hi, I've got a problem trying to install Active State's Perl for NT
implementation v5.6.  Here's the scenario:

I had Windows NT v4.0 SP3 installed.  I downloaded the two files:

  InstMsi.exe
  ActivePerl-5.6.0.616-MSWin32-x86-multi.msi

And then ran the InstMsi.exe from Explorer.

Well, I didn't read the ActiveState install instructions first, which
state I need at *least* SP4.  rtfm, right?  Okay, so I installed SP5 and
re-did the install.

The Windows Installer states that it completed sucessfully, but in fact
it did not install anything.  I tried to remove registry entries related
to Perl and tried to reinstall to no avail.

Can anybody help me?  Have you run into the same type of problem?

I'm running a Dell GX1 450Mhz 128MB RAM 6.4G DASD, Windows NT Client
v4.0 SP5.




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 21:25:47 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Beginner/intermediate programmer looking to volunteer...
Message-Id: <39a592e7.13263744@news.earthlink.net>

On Wed, 23 Aug 2000 20:50:28 GMT, Mike Cameron <mcameron@mirusweb.com>
wrote:

>I am a 31 year old Mortgage Banker who has been a hobby programmer for
>several years (VB, JS, HTML, Perl). I have really learned a lot of Perl
>in that time and would like to make a career move.  Problem is I have no
>Computer Science formal education and can't afford to take the pay cut
>that would be required to take an entry level position so I would like
>to start building my programming portfolio via volunteer work part
>time.  Any suggestions on where to start?

Non-profit groups are always needing people to help them.  For
instance, a group like Habitat for Humanity has people who volunteer
as secretaries, etc. as opposed to just building houses.  Try calling
around and seeing if anyone needs a helping hand.

Jon


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

Date: Thu, 24 Aug 2000 18:12:06 GMT
From: cluemein@hotmail.com
Subject: Better understanding of Win32:PerfLib
Message-Id: <8o3oh3$596$1@nnrp1.deja.com>

  I'm using Activeperl 5.6 on NT.  I've made my own code which is very
similar to the example given in the perldoc, and it works..  But I
still don't follow it fully..so if you don't mind reading my ramble I'd
appreciate corrections/explanations.

First you Win32::PerfLib::GetCounterNames($server, \%hash)

  This hash contains a bunch o' numbers as keys, and text labels as
values.  The example in the doc shows reversing the hash so you can get
the numeric index from using the text label as a key to the hash.  Do
these numbers have a significance other than just being numeric
identifiers(indexes)?  Each of these is a monitorable item on a
system?

So once you have the # of what you're looking for you use:
  $perflib=Win32::PerfLib::new
to create a "perflib" object, and then:
  $perflib=GetObjectList($id_you_got_with_the_reversed_hash, \%
counter_list)

The %counter_list just populated..what is it, what can I do with it?
In the docs they do:

 $instance_ref = $proc_ref->{Objects}->{$process_obj}->{Instances};

So $instance_ref is a ref to a hash of instances...how does one know to
do this...do you need a windows programming book to understand this
structure, and translate it yourself into perl??

Anything that'll help me better understand would be great.

thanks
  marc


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 12:51:31 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Can I call a C-function in an existing dynamic library from Perl?
Message-Id: <39A57CC3.F5B9B996@ipac.caltech.edu>

Roel Verbunt wrote:
> I want to call a C-function in an existing shared library (.sl on HP-UX)
> from Perl. Is this possible? Another problem is that we only have the .sl
> file. So we don't have the C-sources.
> I read something about XS-modules, but I did not really understand it. Is
> there more doc about this than on CPAN.

% perldoc -q h2xs
=head1 Found in /usr/local/lib/perl5/5.6.0/pod/perlfaq3.pod
=head2 Where can I learn about linking C with Perl? [h2xs, xsubpp]

In addition, there are modules on CPAN whos purpose is to make linking with C
and C++ easier than XS. Look at

http://search.cpan.org/Catalog/Language_Interfaces/

At a quick glance, it looks like C::DynaLib is a good possibility.


--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Thu, 24 Aug 2000 12:57:08 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Check array for an element
Message-Id: <39A57E14.4EAD2B9B@ipac.caltech.edu>

Hermann FASS wrote:
> 
> Not that there is no workaround, but I would like to
> know an elegant way to check wether an element is
> already contained in an array or not.
> E.g. when parsing an access-log for making a list of authenticated
> users:
> ($ip, $user) = /([\d\.]+\s+.*(\w+|-)..../;
> if (! &alreadyPresent($user,@allUsers) ) {
>   push(@allUsers,$user);
> }
> The question is:
> Did anybody write a good &alreadyPresent-subroutine,
> which does not go through the complete @allUsers to
> compare each singel element agains the current $user,
> which seems time-consuming.

% perldoc -q contains
=head1 Found in /usr/local/lib/perl5/5.6.0/pod/perlfaq4.pod
=head2 How can I tell whether a list or array contains a certain element?


--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: 24 Aug 2000 20:40:59 GMT
From: skhatri@cds.caltech.edu (Sven Khatri)
Subject: Compiling Perl Modules
Message-Id: <8o418r$dtc@gap.cco.caltech.edu>

I have a perl module, foobar.pm, that I'm trying to compile.
so I run perlcc foobar.pm. This generates a share object,
foobar.so. I move the shared object to auto/foobar/ and
write a perl wrapper around the shared object using DynaLoader
and bootstrap. This perl wrapper replaces the original foobar.pm.
This code works fine.


When I modify the original foobar.pm to specify a namespace,
  
package baz::foobar;

and repeat the above when I call foobar it can't find the shared
object so I move the shared object to:

/usr/lib/perl5/site_perl/5.005/i386-linux/auto/baz/foobar/

which is where all the other perl .so files reside. At this point
I get the following error:

Can't find 'boot_baz__foobar' symbol in 
/usr/lib/perl5/site_perl/5.005/i386-linux/auto/baz/foobar/foobar.so


Any ideas of what I'm doing wrong? How things are different when
a namespace is specified? Pointer to a good reference for how to
compile perl modules? 

thanx...

Sven

--
Sven  		http://www.cco.caltech.edu/~skhatri/khatri.html
4.28171817154095	Shark Heart Villain
_______________________________________________________________________________


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

Date: Thu, 24 Aug 2000 15:33:03 -0400
From: Andy Dougherty <doughera@lafayette.edu>
Subject: Re: Configure problem
Message-Id: <Pine.SOL.4.10.10008241523120.10355-100000@maxwell.phys.lafayette.edu>

On Mon, 21 Aug 2000, Sarah Officer wrote:

> Help! Configure for perl 5.6.0 says gdbm_open is NOT FOUND on some
> of my machines.
> 
> I have gdbm installed under /proj/include/gdbm.h and
> /proj/lib/IRIX6.5/libgdbm.a and /proj/lib/SOLARIS5.8/libgdbm.a.  The
> libraries are appropriate for the architectures listed in the
> paths.  It is version -Dlocincpth=/proj/include
> -Dloclibpth=/proj/lib/$MACHINE where MACHINE is set to IRIX6.5 or
> SOLARIS5.8 depending on where I'm compiling.  
> 
> I put this in a script, so I'm using the same logic over and over. 
> I compiled successfully on 2 solaris boxes & 1 irix box, but my 2nd
> irix box fails to find gdbm_open, so doesn't create the gdbm
> module.  I can run 'nm' on the library path and grep for gdbm_open,
> and it is defined.

Since it works on 2 solaris boxes and 1 irix box, I suspect that you
are using Configure correctly and that Configure is working
"correctly" but that there is some problem on the second irix box.

Here's the relevant section from Configure:

    : see if gdbm.h is available
    set gdbm.h t_gdbm
    eval $inhdr
    case "$t_gdbm" in
    $define)
	    : see if gdbm_open exists
	    set gdbm_open d_gdbm_open
	    eval $inlibc
	    case "$d_gdbm_open" in
	    $undef)
		    t_gdbm="$undef"
		    echo "We won't be including <gdbm.h>"
		    ;;
	    esac
	    ;;
    esac
    val="$t_gdbm"
    set i_gdbm
    eval $setvar  
    
The intent is to include the GDBM_File extension only if both the
gdbm.h header and the libgdbm.{a,so} library are correctly installed
and available.

$inlibc is a shell routine to check if a particular function (in this
case gdbm_open) is indeed present in the libraries selected by
Configure.  It either uses nm or else compiles a small test program
for each function.

I can think of several possibilities to check on the 2nd Irix box:

1.  Check to make *sure* that -lgdbm is included in $libs in config.sh

2.  Check to make sure that /proj/lib/MACHINE/libgdbm.a exists, and
*is the only libgdbm* on the system.  Perhaps you're somehow picking
up a different, broken libgdbm?

3.  Try re-running Configure without using the nm-scan.  That is,

	make distclean
	sh Configure -Uusenm [other options]


Hope this helps,

-- 
    Andy Dougherty		doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042



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

Date: Thu, 24 Aug 2000 20:25:24 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: database for large number of keys?
Message-Id: <39a584b4.656e$3bb@news.op.net>

In article <8o12ga$sv$1@nnrp1.deja.com>,  <nejeian@my-deja.com> wrote:
> use DB_File;
> tie %DB, "DB_File", "db" or die "Cannot open file 'db': $!\n";
> while (<TXTFILE>)
> {
>  chomp ($key = $_);
>  $DB{$key} = 1;
> }

Try using CDB_File instead.  CDB_File can construct large databases
very quickly.  It has a special feature that constructs the initial
database all at once, whereas DB_File constructs it one key at a time
and has to keep rearranging the data every time a new key comes in.

CDB_File's lookups are probably faster than DB_File's also.

Drawback: CDB_File files are read-only.  If you want to add data to a
CDB_File, you have to throw away the database and start over. 

This may be a better match for your application than DB_File, however.




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

Date: Thu, 24 Aug 2000 15:59:22 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Environment variable SNAFU
Message-Id: <39A57E9A.DC479149@attglobal.net>

Larry Rosler wrote:
> 
> In article <39A54014.5881D546@harris.com> on Thu, 24 Aug 2000 11:32:36 -
> 0400, Phil Barone <pbarone@harris.com> says...
> >
> > I have a perl script that creates a file that will contain environment
> > variables and their settings.
> > The file is similar to your average .cshrc file.
> >
> > The question is how do I make use of variables set in this ".cshrc" file
> > from other scripts I want to execute AFTER I write this file out. The
> > scripts that I will execute may be perl or bourne or c shell.
> 
> This isn't really a Perl question.  Here is the complete answer from
> perlfaq8:
> 
> I {changed directory, modified my environment} in a perl script. How
> come the change disappeared when I exited the script? How do I get my
> changes to be visible?
> 

Now I figured that the OP wanted to write a sort of configuration
file for use by other programs, not necessarily to preserve the 
environment for that particular invocation of the shell.  I wonder
if he'll clarify his question.


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

Date: 24 Aug 2000 20:03:07 GMT
From: soren@spmfoiler.removethat.wonderstorm.com (Soren Andersen)
Subject: Re: File handling and manipulation from function, help please?
Message-Id: <8o3v1r$37u$1@slb6.atl.mindspring.net>

ptomsic@my-deja.com wrote in <8o3a45$ith$1@nnrp1.deja.com>:

>Could someone please help me with the following:
>
>Open a file, and pass it to a function and when
>it's in the function, run thru the file and strip
>out predesignated text, and return the desired
>text...like the following:
>(this is what I've got, but it's not working)

{snip}

Quicky answer: from the description, what you are trying to do sounds
like what Damian Conway's IO::Filtered will do. I read it in the book
_Object Oriented Perl_ (Manning, 2000, ISBN 1-884777-79-1). It isn't
on CPAN. It's license is clear, however. I think it is OK for me to
post it here since it is "freely redistributable". So here you go (Please
buy the excellent, invaluable book when finances allow).
Watch out for wrapping!

--- cut here -----------

package IO::Filtered;
$VERSION = 1.00;

use strict;
use Carp;
use Symbol;

sub _no_filter { return $_[0]; }

sub TIEHANDLE
{
	my ($class, %args) = @_;
	my $handle = gensym();
	my $impl = bless { handle => gensym() }, $class;
	$impl->OPEN(%args);
	return $impl;
}

sub OPEN
{
	my ($impl, %args) = @_;
	open $impl->{handle}, $args{file}
		or croak "Could not open '$args{file}'";
	$impl->{in_filter}	= $args{in}  || \&_no_filter,
	$impl->{out_filter}	= $args{out} || \&_no_filter,
}

sub SEEK
{
	my ($impl, $position, $whence) = @_;
	return sysseek($impl->{handle}, $position, $whence);
}

sub WRITE
{
	my ($impl, $buffer, $length, $offset) = @_;
	$buffer = $impl->{out_filter}->($buffer);
	syswrite($impl->{handle}, $buffer, $length, $offset||0);
}

sub PRINT
{
	my ($impl, @data) = @_;
	my $filter = $impl->{out_filter};
	@data = map { $filter->($_) } @data;
	print { $impl->{handle} } @data;
}

sub PRINTF
{
	my ($impl, $format, @data) = @_;
	my $filter = $impl->{out_filter};
	print { $impl->{handle} } $filter->(sprintf $format, @data);
}

sub READ
{
	my ($impl, $data, $length, $offset) = @_;
	my $result = sysread($impl->{handle}, $data, $length);
	substr($_[1],$offset||0,$length) = $impl->{in_filter}->($data);
	return $result;
}

sub GETC
{
	my ($impl) = @_;
	$impl->{in_filter}->(getc $impl->{handle});
}

sub READLINE
{
	my ($impl) = @_;
	$impl->{in_filter}->(scalar readline *{$impl->{handle}});
}

 sub CLOSE
{
	my ($impl) = @_;
	close $impl->{handle};
}

sub new
{
	my ($class, %args) = @_;
	my $self = gensym();
	tie *{$self}, $class, %args;
	bless $self, $class;
}

sub AUTOLOAD
{
	use vars qw( $AUTOLOAD );	# Keep use strict happy 
	my ($self, @args) = @_;
	$AUTOLOAD =~ s/.*:://;
	$AUTOLOAD =~ tr/a-z/A-Z/;
	tied(*{$self})->$AUTOLOAD(@args);
}


no strict;

sub encrypt
{
	$_[0] =~ s/(.)/rand(2)<1 ? uc($1) : lc($1)/eg;
	return $_[0];
}

$tiedfile = \*FILE;
tie *{$tiedfile}, "IO::Filtered", file=>">passwd", out=>\&encrypt;

$blessedfile = IO::Filtered->new(file=>">passwd", out=>\&encrypt);

print $tiedfile "sEcrEtpAsswOrd";
print $blessedfile "sEcrEtpAsswOrd";


$blessedfile->print("sEcrEtpAsswOrd");


# $tiedfile->print("sEcrEtpAsswOrd");

$blessedfile->PRINT("sEcrEtpAsswOrd");




#########################################################################
#                                                                       #
#  Copyright (C) 1999 by Manning Publications Co. All Rights Reserved.  #
#                                                                       #
#  This code is free software. It may be used, redistributed            #
#  and/or modified under the terms of the Perl Artistic License         #
#  (see http://www.perl.com/perl/misc/Artistic.html).                   #
#                                                                       #
#########################################################################


--------- cut --------------------
HTH,
   soren andersen


-- 
Using PNG-format images as Web BACKGROUNDs without
"breaking your Site" for silly older browsers:
http://www.wonderstorm.com/techstuff/
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Thu, 24 Aug 2000 13:49:24 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: File handling and manipulation from function, help please?
Message-Id: <39A58A54.EB2B7B4A@ipac.caltech.edu>

ptomsic@my-deja.com wrote:
> Open a file, and pass it to a function and when
> it's in the function, run thru the file and strip
> out predesignated text, and return the desired
> text...like the following:
> (this is what I've got, but it's not working)

There are many ways to do what you want that are much simpler than what you're
doing. But I'll stick to your code. You can improve it later after it works. 

First, did you test it? What happened? Tell us. More info (compactly presented)
is better than "it's not working." Also, 'perldoc perlstyle' is a fine read.
Take it to bed with you one night.

>#!/usr/local/bin/perl

Add '-w' to that, and 'use strict;'. I.e.

#!/usr/local/bin/perl -w
use strict;

> open(TEST, "text.txt");

Add an 'or die "$!"' to that. Always test for errors. 

perldoc -f open
perldoc -f die
perdoc perlvar (and look for $!)

open(TEST, "text.txt") or die "$!";

> $string = <TEST>;

perldoc perlop (search for 'I/O Operators')

Pay attention to the discussion of 'context'. Your context above is scalar. So
how many lines of your file are you reading with your code? What happens if you
do this instead?

my $string = join("",<TEST>);

(I'm assuming your file is short and is thus safe to slurp in all at once.)

perldoc -f my
perldoc -f join

> close(TEST);

Errors can occur on the close too, so put an 'or die ...' here as well. 

> print "\ncontents of file:$string";
> &subCall($string);  # looking to pass file to sub

A test on the contents of $string may be helpful in case you read the wrong
file. E.g.

warn "Empty text" if ! length $string;

> print "\nnew contents:$string:";
> exit(1);

You're exiting with an error code. According to standard *NIX-ish practice, a
non-zero return code means failure. (The explicit exit isn't really necessary
anyway.)

> sub subCall {
> my($filename) = @_;
> #get the text contained within a <!-BEGIN-><!-END-> tag
> $filename =~ s/\n//g;

There's no real need to remove newlines (see perlre and the 's' and 'm'
modifiers), but if you want to, you should probably replace them with spaces,
not nothing. How 'bout

$filename =~ s/\n+/ /sg;

(I asume you don't have to worry about carriage returns (\r)?)

> $filename =~ s/<!-BEGIN->|<!-END->/|/ig; #case insensitive for the tags

I have no idea why you thought this would work. Better pour over perlre again.
What does '|' do? Why do you put it on the right side? What are you matching,
and what are you replacing it with? What if the match fails completely? Wouldn't
you like to know that? How 'bout this:

$filename =~ s/^.*<!-BEGIN->(.*)<!-END->.*$/$1/i
	or die "No tags";

(This will work if there's only one pair of tags and neither tag  occurs within
the desired text.)

> #hoping to return the contents within the tags back to the caller
> return $filename
> }

Hope springs eternal!

--

-- Tim Conrow         tim@ipac.caltech.edu


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

Date: Thu, 24 Aug 2000 18:45:47 GMT
From: JMarsan <jmarsan@my-deja.com>
Subject: format and padding
Message-Id: <8o3qgk$7lg$1@nnrp1.deja.com>

Hi all,

I need to create a format. I have a problem with padding. I looked in
my o'reilly Perl books but could not find any solution to my problem.
Here is my format:

format ORDER =
---------------------------------------------------------------------
Order Reference: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                 $orderref
Last Name: @<<<<<<<<<<<<<<<<<<<<<<<   First Name: @<<<<<<<<<<<<<<<<<<

 .

Now my problem is that I can not find a way to avoid the padding with
white spaces when the last name is shorter than the field. For example,
I would like to have this output:

Order Reference: 5192227876
Last Name: Evans   First Name: Mary

 ... and not this one:

Order Reference: 5192227876
Last Name: Evans                      First Name: Mary


Thanks in advance,

--
J. Marsan
Technician, IT
N.S.D.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 21:23:26 GMT
From: stanley.shapiro@wcom.com
Subject: Free Perl compiler ?
Message-Id: <8o43nv$irn$1@nnrp1.deja.com>

Where can I find a perl compiler for Win-NT ?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 14:17:04 -0700
From: TEC <travis.cox@itron.com>
Subject: From metacharacter and back again
Message-Id: <39A590D0.6E1940C3@itron.com>

I have a database table that contains information on how to create a
file. My problem is I want to be able to put metacharacters in the table
such as \n or \t and then have my Perl script interpolate it as a "new
line" instead of a string containing "\n". I have done this temporarily
by doing this: $rs =~ s/\\n/\n/ but I was hoping I wouldn't have to do
this for all possible values. Any ideas would be appreciated.



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

Date: 24 Aug 2000 18:20:00 GMT
From: X@Y.Z.net (Jynx)
Subject: Re: help with simple regexp - does my head in
Message-Id: <slrn8qapqf.26c.X@animas.frontier.net>

On Thu, 24 Aug 2000 02:13:12 GMT, Martien Verbruggen scribbled:
>
>I doubt that Abigail doesn't know what it means. I could be wrong, but
>I doubt that as well. Maybe you are incorrect in assuming that Abigail
>thought what you think she thought. Maybe I am incorrect in assuming
>that Abigail knew what I think she knew. But again, I doubt that.

I'll have to save this!

Jonesy
-- 
Marvin L Jones         |  jonz             |  W3DHJ     |  OS/2
 Gunnison, Colorado    |   @               |  Jonesy    |  linux    __
  7,703' -- 2,345m     |    frontier.net   |  DM68mn                SK


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

Date: 24 Aug 2000 20:08:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: help with simple regexp - does my head in
Message-Id: <slrn8qb04l.tj3.abigail@alexandra.foad.org>

Ren Maddox (ren.maddox@tivoli.com) wrote on MMDL September MCMXCIII in
<URL:news:m3bsyi7kdc.fsf@dhcp11-177.support.tivoli.com>:
-: abigail@foad.org (Abigail) writes:
-: 
-: Benchmark: timing 10000000 iterations of -1, 1...
-:         -1: 12 wallclock secs (12.85 usr +  0.02 sys = 12.87 CPU)
-:              @ 777000.78/s (n=10000000)
-:          1:  9 wallclock secs ( 9.12 usr +  0.02 sys =  9.14 CPU)
-:              @ 1094091.90/s (n=10000000)
-: 
-: > (And note that in my benchmark, the speed difference is about 15%).
-: 
-: A difference that seems worth noting, rather than focusing on the
-: absolute difference of 355 nanoseconds.  After all, if one version
-: took 1 nanosecond, and the other took 356 nanoseconds, that would
-: still be a very small difference -- until you run it millions of
-: times.  The percent difference seems more important.

If you run it 3 million times, the difference is still only about
1 second. In your case, you ran it 10 million times, for a difference
of just over 3.5 seconds.

It would be a very odd program were you're indexing an 2 element array
10 million times, were 3.5 seconds of difference is significant,
were the indexing is the bottle neck in your program, and were the
program couldn't be better written using 2 variables instead.

Please provide us with a useful, non-trivial program were use of 1 vs -1
does make a significant difference.



Abigail
-- 
BEGIN {$^H {join "" => ("a" .. "z") [8, 13, 19, 4, 6, 4, 17]} = sub
           {["", "Just ", "another ", "Perl ", "Hacker"] -> [shift]};
       $^H = hex join "" => reverse map {int ($_ / 2)} 0 .. 4}
print 1, 2, 3, 4, "\n";


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

Date: Thu, 24 Aug 2000 11:50:52 -0700
From: Perrin Kliot <perrin@lacis.com>
Subject: How do I insert a carriage return?
Message-Id: <39A56E8C.912E839F@lacis.com>

Hi,

I have a long string that is taken from a <textarea> field and I want to
insert a carriage return every 60 to 70 characters where there is a " ",
I want to do this so when the string is printed is will wordwrap instead
of being one long string. How can I do this.

Please be kind I'm a Perl rookie
Perrin



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

Date: Thu, 24 Aug 2000 19:12:44 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: How do I insert a carriage return?
Message-Id: <sqastcl5t91151@corp.supernews.com>

In article <39A56E8C.912E839F@lacis.com>,
    Perrin Kliot  <perrin@lacis.com> wrote:

: I have a long string that is taken from a <textarea> field and I want to
: insert a carriage return every 60 to 70 characters where there is a " ",
: I want to do this so when the string is printed is will wordwrap instead
: of being one long string. How can I do this.

The standard Text::Wrap module can help you.

Greg
-- 
The balance of power is the scale of peace.  The same balance would be
preserved were all the world destitute of arms, for all would be alike;
but since some will not, others dare not lay them aside . . .
    -- Thomas Paine, "Thoughts on Defensive War"


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

Date: Thu, 24 Aug 2000 14:13:06 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: How do I insert a carriage return?
Message-Id: <39A573C2.A37EB639@rac.ray.com>

Perrin Kliot wrote:
> 
> I have a long string that is taken from a <textarea> field and I want to
> insert a carriage return every 60 to 70 characters where there is a " ",
> I want to do this so when the string is printed is will wordwrap instead
> of being one long string. How can I do this.
> 


perldoc Text::Wrap

Works pretty good.
-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


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

Date: Thu, 24 Aug 2000 14:22:34 -0700
From: Perrin Kliot <perrin@lacis.com>
Subject: Re: How do I insert a carriage return?
Message-Id: <39A5921A.D18AD43@lacis.com>

Thanks for the tip on Text::Wrap, unfortunatly I can't figure out how to get
it to work. I found several examples online such as the one below but I can't
get them to wrap the text. Is there something special I should know about
using the module??

use Text::Wrap;

$Text::Wrap::columns = 20;
$pre1 = "\t";
$pre2 = "";

print wrap( $pre1, $pre2, "Hello, world, it's a nice day, isn't it?\n" );


Greg Bacon wrote:

> In article <39A56E8C.912E839F@lacis.com>,
>     Perrin Kliot  <perrin@lacis.com> wrote:
>
> : I have a long string that is taken from a <textarea> field and I want to
> : insert a carriage return every 60 to 70 characters where there is a " ",
> : I want to do this so when the string is printed is will wordwrap instead
> : of being one long string. How can I do this.
>
> The standard Text::Wrap module can help you.
>
> Greg
> --
> The balance of power is the scale of peace.  The same balance would be
> preserved were all the world destitute of arms, for all would be alike;
> but since some will not, others dare not lay them aside . . .
>     -- Thomas Paine, "Thoughts on Defensive War"



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

Date: Thu, 24 Aug 2000 12:45:06 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: how to round ?
Message-Id: <39A57B42.13897C41@ipac.caltech.edu>

Adam Skora wrote:
> 
> Does exist any function to round floating-point numbers ?

% perldoc -q round

=head1 Found in /usr/local/lib/perl5/5.6.0/pod/perlfaq4.pod

=head2 Does Perl have a round() function?  What about ceil() and floor()?  Trig
functions?


--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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


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