[24052] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6249 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 12 11:05:45 2004

Date: Fri, 12 Mar 2004 08:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 12 Mar 2004     Volume: 10 Number: 6249

Today's topics:
    Re: [OT] Re: Spreadsheet::WriteExcel - Excel 97 install <rbin.kor901209@in.bosch.com>
    Re: [OT] Re: Spreadsheet::WriteExcel - Excel 97 install <usenet@morrow.me.uk>
    Re: [OT] Re: Spreadsheet::WriteExcel - Excel 97 install <rbin.kor901209@in.bosch.com>
    Re: IO::Pipe::close returns wrong value (Charles DeRykus)
    Re: Parsing from file <tadmc@augustmail.com>
        reading command line arguments user@domain.invalid
    Re: reading command line arguments <usenet@morrow.me.uk>
    Re: reading command line arguments <rbin.kor901209@in.bosch.com>
    Re: reading command line arguments <chatiman@free.fr>
    Re: reading command line arguments <tadmc@augustmail.com>
    Re: reading command line arguments <bmb@ginger.libs.uga.edu>
    Re: Regex doesn't match - what am I doing wrong? <usenet@morrow.me.uk>
    Re: Regex doesn't match - what am I doing wrong? <usenet@morrow.me.uk>
        removing trailing spaces (Ollie)
    Re: removing trailing spaces <david@tvis.co.uk>
    Re: removing trailing spaces <chatiman@free.fr>
    Re: removing trailing spaces <chatiman@free.fr>
    Re: removing trailing spaces <tore@aursand.no>
    Re: removing trailing spaces <david@tvis.co.uk>
    Re: removing trailing spaces <bmb@ginger.libs.uga.edu>
    Re: Spreadsheet::WriteExcel - Excel 97 install problem <rbin.kor901209@in.bosch.com>
    Re: Text editor implemented in Perl <david@tvis.co.uk>
    Re: Text editor implemented in Perl <jurgenex@hotmail.com>
    Re: Text editor implemented in Perl <jkrugman@yahbitoo.com>
    Re: Text editor implemented in Perl <tassilo.parseval@rwth-aachen.de>
    Re: Text editor implemented in Perl <bmb@ginger.libs.uga.edu>
    Re: Tricky Perl Bug (amusing/unamusing) <ThomasKratz@REMOVEwebCAPS.de>
    Re: Tricky Perl Bug (amusing/unamusing) <nobull@mail.com>
    Re: Tricky Perl Bug (amusing/unamusing) <tadmc@augustmail.com>
    Re: Tricky Perl Bug (amusing/unamusing) <david@tvis.co.uk>
    Re: using an assoc. array as a 'set' <bik.mido@tiscalinet.it>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 12 Mar 2004 13:24:41 GMT
From: Bhaskar Reddy <rbin.kor901209@in.bosch.com>
Subject: Re: [OT] Re: Spreadsheet::WriteExcel - Excel 97 install problem
Message-Id: <c2sdmp$jp5$1@ns2.fe.internet.bosch.com>

Thens <thens@NOSPAMti.com> wrote in 
news:20040312161200.6de7e876.thens@NOSPAMti.com:

> On 12 Mar 2004 09:02:08 GMT
> Bhaskar Reddy <rbin.kor901209@in.bosch.com> wrote:
> 
> # MyPrj
> #  |
> #  |----csv2xls.pl  (My pl file which calls the write() method)
> #  |
> #  |----Spreadsheet
> #           |
> #           |----WriteExcel.pm
> #           |----WriteExcel
> #                    |----BIFFwriter.pm
> #                    |----Big.pm
> #                    |----Format.pm
> #                    |----Formula.pm
> #                    |----OLEwriter.pm
> #                    |----Utility.pm
> #                    |----Workbook.pm
> #                    |----WorkbookBig.pm
> #                    |----Worksheet.pm
> 
> Bhaskar, 
> 
> Do you have a perl script/utility that generates this kind of a tree
> structure or was this hand created. Just out of curiosity !!
> 
> Regards,
> Thens.

Hi Thens,

 this is made manually. But the idea of a tool is good. I just implemented 
it in java and it works!!. The java tool that I wrote generates the tree 
structure, but does not sort directories and files..generated sample looked 
like this..and has problems when the folder has access restrictions..I will 
to make it more robust and send if you are interested..

# MyPrj
#  |
#  |
#  |----Spreadsheet
#           |
#           |----WriteExcel.pm
#           |----WriteExcel
#                    |----BIFFwriter.pm
#                    |----Big.pm
#                    |----Format.pm
#                    |----Formula.pm
#                    |----OLEwriter.pm
#                    |----Utility.pm
#                    |----Workbook.pm
#                    |----WorkbookBig.pm
#                    |----Worksheet.pm
#  |----csv2xls.pl  (My pl file which calls the write() method)

-- 
TIA & Best Regards
Bhaskar Reddy

reddy dot bhaskar at bosch dot com


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

Date: Fri, 12 Mar 2004 15:10:35 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: [OT] Re: Spreadsheet::WriteExcel - Excel 97 install problem
Message-Id: <c2sjtb$k89$1@wisteria.csv.warwick.ac.uk>


Quoth Bhaskar Reddy <rbin.kor901209@in.bosch.com>:
> Thens <thens@NOSPAMti.com> wrote in 
> news:20040312161200.6de7e876.thens@NOSPAMti.com:
> 
> > Do you have a perl script/utility that generates this kind of a tree
> > structure or was this hand created. Just out of curiosity !!
> > 
> > Regards,
> > Thens.
> 
>  this is made manually. But the idea of a tool is good. I just implemented 
> it in java and it works!!. The java tool that I wrote generates the tree 
> structure, but does not sort directories and files..

Just 'cos I'm bored... (and I bet it's simpler than your Java one :):

#!/usr/bin/perl -l

# (c) 2004 Ben Morrow <ben@morrow.me.uk>
# This program is in the public domain.

use warnings;
use strict;

use subs qw(dirtree indent);

use constant INDENT => '|' . (' ' x 4);
use constant NOMORE => ' ' x 5;
use constant BRANCH => '|' . ('-' x 3) . ' ';
use constant LAST   => '+' . ('-' x 3) . ' ';

sub indent {
    return map { $_ ? INDENT : NOMORE } @_;
}

sub dirtree {
    my $dir = shift;
    my $nldone;

    my @items = sort grep !/^\./, do {
        opendir my $DIR, $dir or do {
            print indent(@_), "ACCESS DENIED";
            print indent(@_);
            return 1;
        };
        readdir $DIR;
    };

    while (defined($_ = shift @items)) {
        my ($mark, $recurse);
        no warnings 'uninitialized';
        
        if (-l "$dir/$_") {
            $mark .= ' -> ' . readlink "$dir/$_";
            -e "$dir/$_";          
        }
        elsif (-d _) { $recurse = 1 }
        -d _           and $mark .= ' /';
        -p _           and $mark .= ' |';
        -S _           and $mark .= ' =';
        (-c _ or -b _) and $mark .= ' #';
        -x _ and -f _  and $mark .= ' *';
        
        print indent(@_), (@items ? BRANCH : LAST), $_, $mark;
        $recurse and $nldone = dirtree "$dir/$_", @_, @items ? 1 : 0;
        @items or $nldone or print indent(@_) and return 1;
    }
    return $nldone;
}

my $dir = shift || '.';
-d $dir or die "$dir: not a directory\n";
print $dir;
dirtree $dir;

__END__

Output like:

Acme-Abuse-0.02
|--- Changes
|--- MANIFEST
|--- META.yml
|--- Makefile.PL
|--- README
|--- SIGNATURE
|--- lib /
|    +--- Acme /
|         +--- Abuse.pm
|
+--- t /
     |--- 0-signature.t
     |--- 1-Acme-Abuse.t
     +--- Acme /
          +--- Abuse /
               +--- Test.pm *

The grep !/^\./ is a bit unixy: you may want to replace it with
!/\.\.?/; and for proper portability I should have used File::Spec, but
that makes such a mess of things :).

Ben

-- 
And if you wanna make sense / Whatcha looking at me for?          (Fiona Apple)
                            * ben@morrow.me.uk *


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

Date: 12 Mar 2004 15:36:47 GMT
From: Bhaskar Reddy <rbin.kor901209@in.bosch.com>
Subject: Re: [OT] Re: Spreadsheet::WriteExcel - Excel 97 install problem
Message-Id: <c2slef$n9g$1@ns2.fe.internet.bosch.com>

Ben Morrow <usenet@morrow.me.uk> wrote in
news:c2sjtb$k89$1@wisteria.csv.warwick.ac.uk: 

> Quoth Bhaskar Reddy <rbin.kor901209@in.bosch.com>:
>> Thens <thens@NOSPAMti.com> wrote in 
>> news:20040312161200.6de7e876.thens@NOSPAMti.com:
>> 
>> > Do you have a perl script/utility that generates this kind of a
>> > tree structure or was this hand created. Just out of curiosity !!
>> > 
>> > Regards,
>> > Thens.
>> 
>>  this is made manually. But the idea of a tool is good. I just
>>  implemented 
>> it in java and it works!!. The java tool that I wrote generates the
>> tree structure, but does not sort directories and files..
> 
> Just 'cos I'm bored... (and I bet it's simpler than your Java one :):
> 


I am new to perl and hence prefered java..I was trying it in perl 
too..but you already posted it..thanks..

-- 
TIA & Best Regards
Bhaskar Reddy

reddy dot bhaskar at bosch dot com


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

Date: Fri, 12 Mar 2004 13:19:27 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: IO::Pipe::close returns wrong value
Message-Id: <HuGt0F.Mx7@news.boeing.com>

In article <40519459$0$29350$3b214f66@usenet.univie.ac.at>,
Heinrich Mislik <Heinrich.Mislik@univie.ac.at> wrote:
>In article <HuG2rG.KvC@news.boeing.com>, ced@bcstec.ca.boeing.com says...
>
>>I'm confused when you mention:
>>
>> "Truth is, that IO::Pipe has it's own close, which doesn't return the 
>>  code from waitpid." 
>>
>>A quick glance at the code seems to indicate that's not the case.
>>IO::Pipe subclasses IO::Handle within its inner class IO::Pipe::End
>>and inherits its close method which is from waitpid.
>>
>
>This is from IO/Pipe.pm:
>    ...
>    146     my $fh = shift;
>    147     my $r = $fh->SUPER::close(@_);
>    148
>    149     waitpid(${*$fh}{'io_pipe_pid'},0)
>    150         if(defined ${*$fh}{'io_pipe_pid'});
>    151
>    152     $r;
>    153 }
>..
>The returned code from waitpid is ignored.

Ah, I misinterpreted your statement about IO::Pipe having
its own close...

However, IO::Handle says:

   See the perlfunc manpage for complete descriptions of each
   of the following supported "IO::Handle" methods, which are
   just front ends for the corresponding built-in functions:
   ...
   $io->close

And from perldoc -f close:

  Closing a pipe also waits for the process executing on the pipe 
  to complete, in case you want to look at the output of the pipe 
  afterwards, and implicitly puts the exit status value of that  
  command into "$?".

To verify:

   close $pipe or warn "command @prog filed";
   print "\$? from pipe close = $?\n";        #----- prints 512
   ...
   $pipe->close or warn "command @prog filed";
   print "\$? from pipe close = $?\n";        #---- prints 512


I'm not positive what that extra waitpid does --- possibly 
cleanup from the fork which occurs if args are passed to the 
reader/writer method.

--
Charles DeRykus


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

Date: Fri, 12 Mar 2004 07:05:05 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Parsing from file
Message-Id: <slrnc53dc1.5nn.tadmc@magna.augustmail.com>

Toni <ante.cepic@siemens.com> wrote:

>   open INPUT, $config_file;


You should always, yes *always*, check the return value from open():

   open INPUT, $config_file or die "could not open '$config_file'  $!";


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 12 Mar 2004 15:20:54 +0200
From: user@domain.invalid
Subject: reading command line arguments
Message-Id: <c2sdfn$qi3$1@ctb-nnrp2.saix.net>

I am currently extending someone else's code (I wont even get credit for 
it). The code already has parts the read command line arguments, but i 
just ca't get my head around it. Which leads me to my problem: how do I 
read command line aruguments that are passed to a script? For example, 
from :

   perl myscript -t test -e now

How can I get that "-t" is "test" and so on.



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

Date: Fri, 12 Mar 2004 13:24:28 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: reading command line arguments
Message-Id: <c2sdmc$fd1$1@wisteria.csv.warwick.ac.uk>


Quoth user@domain.invalid:
> I am currently extending someone else's code (I wont even get credit for 
> it). The code already has parts the read command line arguments, but i 
> just ca't get my head around it. Which leads me to my problem: how do I 
> read command line aruguments that are passed to a script? For example, 
> from :
> 
>    perl myscript -t test -e now
> 
> How can I get that "-t" is "test" and so on.

Getopts::Std

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality.  [Samuel Butler, paraphrased]       ben@morrow.me.uk


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

Date: 12 Mar 2004 13:34:14 GMT
From: Bhaskar Reddy <rbin.kor901209@in.bosch.com>
Subject: Re: reading command line arguments
Message-Id: <c2se8m$k27$1@ns2.fe.internet.bosch.com>

user@domain.invalid wrote in news:c2sdfn$qi3$1@ctb-nnrp2.saix.net:

> I am currently extending someone else's code (I wont even get credit for 
> it). The code already has parts the read command line arguments, but i 
> just ca't get my head around it. Which leads me to my problem: how do I 
> read command line aruguments that are passed to a script? For example, 
> from :
> 
>    perl myscript -t test -e now
> 
> How can I get that "-t" is "test" and so on.
> 
> 

$ARGV

contains the name of the current file when reading from <>. 

@ARGV

The array @ARGV contains the command line arguments intended for the 
script. Note that $#ARGV is the generally number of arguments minus one, 
because $ARGV[0] is the first argument, NOT the command name. See ``$0'' 
for the command name. 

-- 
TIA & Best Regards
Bhaskar Reddy

reddy dot bhaskar at bosch dot com


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

Date: Fri, 12 Mar 2004 14:35:11 +0100
From: "chatiman" <chatiman@free.fr>
Subject: Re: reading command line arguments
Message-Id: <4051bc96$0$295$626a14ce@news.free.fr>


<user@domain.invalid> a écrit dans le message de news:
c2sdfn$qi3$1@ctb-nnrp2.saix.net...
> Which leads me to my problem: how do I
> read command line aruguments that are passed to a script?

You could look at the following modules:
- Getopt::Std
- Getopt::Long which supports long options (--option) and is more powerfull






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

Date: Fri, 12 Mar 2004 07:38:41 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: reading command line arguments
Message-Id: <slrnc53fb1.5qp.tadmc@magna.augustmail.com>

user@domain.invalid <user@domain.invalid> wrote:

> my problem: how do I 
> read command line aruguments that are passed to a script? 


Perl reads them for you, they are available in the @ARGV array.

You might also consider letting a module, such as Getopt::*
handle the command line args for you.


>    perl myscript -t test -e now
> 
> How can I get that "-t" is "test" and so on.


   print "first arg is $ARGV[0]\n";
   print "second arg is $ARGV[1]\n";


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 12 Mar 2004 10:22:50 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: reading command line arguments
Message-Id: <Pine.A41.4.58.0403121010470.14112@ginger.libs.uga.edu>

On Fri, 12 Mar 2004 user@domain.invalid wrote:

> I am currently extending someone else's code (I wont even get credit for
> it). The code already has parts the read command line arguments, but i
> just ca't get my head around it. Which leads me to my problem: how do I
> read command line aruguments that are passed to a script? For example,
> from :
>
>    perl myscript -t test -e now
>
> How can I get that "-t" is "test" and so on.

This answer may not serve your purposes, as it requires a slightly
different execution syntax.  As you've seen in other replies, you can use
one of the Getopts modules, and they have very robust options.  However,
Perl comes with an -s switch of it's own that might also serve (see
perldoc perlrun).

--------------------------------------
% cat myscript
print "-t=$t -e=$e\n"

% perl -s myscript -t=text -e=now
-t=text -e=now
--------------------------------------

If you use strict, as you should, then you'll need to declare $t and $e
using 'our':

--------------------------------------
% cat myscript
use strict;
use warnings;

our( $t, $e );

print "-t=$t -e=$e\n"
--------------------------------------

Finally, with perl on the "shebang" line in your script, just put the -s
switch there:

--------------------------------------
% cat myscript
#!/usr/bin/perl -s
use strict;
use warnings;

our( $t, $e );

print "-t=$t -e=$e\n"

% myscript -t=text -e=now
-t=text -e=now
--------------------------------------

TMTOWTDI,

Brad


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

Date: Fri, 12 Mar 2004 12:04:08 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Regex doesn't match - what am I doing wrong?
Message-Id: <c2s8vo$bsd$1@wisteria.csv.warwick.ac.uk>


Quoth Roel van der Steen <roel-perl@st2x.net>:
> On Fri, 12 Mar 2004 at 06:42 GMT, Sriram wrote:
> > The regex I was really after
> > is to match strings that start with a digit but don't end with one. I
> > tried this and it doesn't work for me (the following grep works
> > great):
> > 
> > bash-2.05b:10$perl -e 'while (<>) { if (/^\d(.*)[^\d]$/) {print;}}'
>                                                   ^^^^^
> It's just as you explained yourself: the marked part matches the
> newline character. So either chomp, or include the newline in your
> regex. Both will work:
> 
> 
>   perl -e 'while (<>) { chomp; print "$_\n" if /^\d(.*)[^\d]$/ }'

This will print the lines without newlines in between, though, which may not be
desired.

>   perl -e 'while (<>) { print if /^\d(.*)[^\d]\n$/ }'

An easier solution is to use the -n switch, which provides that while
loop for you, together with -l which will remove the newline before
matching and put it back before printing:

perl -lne'print if /^\d(.*)[^\d]$/'

Ben

-- 
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks]         ben@morrow.me.uk


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

Date: Fri, 12 Mar 2004 12:11:13 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Regex doesn't match - what am I doing wrong?
Message-Id: <c2s9d1$bsd$2@wisteria.csv.warwick.ac.uk>

Quoth Ben Morrow <usenet@morrow.me.uk>:
> 
> Quoth Roel van der Steen <roel-perl@st2x.net>:
> > On Fri, 12 Mar 2004 at 06:42 GMT, Sriram wrote:
> > > The regex I was really after
> > > is to match strings that start with a digit but don't end with one. I
> > > tried this and it doesn't work for me (the following grep works
> > > great):
> > > 
> > > bash-2.05b:10$perl -e 'while (<>) { if (/^\d(.*)[^\d]$/) {print;}}'
> >                                                   ^^^^^
> > It's just as you explained yourself: the marked part matches the
> > newline character. So either chomp, or include the newline in your
> > regex. Both will work:
> > 
> > 
> >   perl -e 'while (<>) { chomp; print "$_\n" if /^\d(.*)[^\d]$/ }'
                                            ^^
> This will print the lines without newlines in between, though, which may not be
> desired.

Yeah, OK, I can't read... sorry.
I haven't even finished my first cup of tea yet... :)

Ben

-- 
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/'                                                 # ben@morrow.me.uk


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

Date: 12 Mar 2004 06:45:32 -0800
From: oamd@yahoo.com (Ollie)
Subject: removing trailing spaces
Message-Id: <82f47a3c.0403120645.2619cbb1@posting.google.com>

I am guessing this is simple one, but am not really a Perl guru, so am
hoping I can get help from someone out here.

I am trying to remove trailing spaces from a string value.

original value          what am looking for
'xxxxxx           ' ==>    'xxxxxx'

I am going to store this value in the database, but I want to remove
the spaces so I can find exert match when am searching for specific
value.


Ollie.


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

Date: Fri, 12 Mar 2004 14:51:22 +0000
From: zzapper <david@tvis.co.uk>
Subject: Re: removing trailing spaces
Message-Id: <bfj3505nrn2vdbv4n3hf6o2rp6a0hrn61e@4ax.com>

On 12 Mar 2004 06:45:32 -0800, wrote:

>I am guessing this is simple one, but am not really a Perl guru, so am
>hoping I can get help from someone out here.
>
>I am trying to remove trailing spaces from a string value.
>
>original value          what am looking for
>'xxxxxx           ' ==>    'xxxxxx'
>
>I am going to store this value in the database, but I want to remove
>the spaces so I can find exert match when am searching for specific
>value.
>
>
>Ollie.
$_="xxxxxx     ";
s/\s+//;
print ;
zzapper (vim & cygwin & zsh)
--

vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?"

http://www.vim.org/tips/tip.php?tip_id=305  Best of Vim Tips


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

Date: Fri, 12 Mar 2004 15:51:42 +0100
From: "chatiman" <chatiman@free.fr>
Subject: Re: removing trailing spaces
Message-Id: <4051ce86$0$306$626a14ce@news.free.fr>


"Ollie" <oamd@yahoo.com> a écrit dans le message de news:
82f47a3c.0403120645.2619cbb1@posting.google.com...
> I am guessing this is simple one, but am not really a Perl guru, so am
> hoping I can get help from someone out here.
>
> I am trying to remove trailing spaces from a string value.
>
> original value          what am looking for
> 'xxxxxx           ' ==>    'xxxxxx'
>

if the value is in the variable $string :
$string =~ s/\s+$//;

> I am going to store this value in the database, but I want to remove
> the spaces so I can find exert match when am searching for specific
> value.
>

You could also use the "LIKE" command but that will be a bit slower






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

Date: Fri, 12 Mar 2004 15:55:21 +0100
From: "chatiman" <chatiman@free.fr>
Subject: Re: removing trailing spaces
Message-Id: <4051cf60$0$311$626a14ce@news.free.fr>


"zzapper" <david@tvis.co.uk> a écrit dans le message de news:
bfj3505nrn2vdbv4n3hf6o2rp6a0hrn61e@4ax.com...
> On 12 Mar 2004 06:45:32 -0800, wrote:
> s/\s+//;

This would replace the first white spaces which are not always the trailing
ones





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

Date: Fri, 12 Mar 2004 16:08:43 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: removing trailing spaces
Message-Id: <pan.2004.03.12.15.08.42.621901@aursand.no>

On Fri, 12 Mar 2004 14:51:22 +0000, zzapper wrote:
>> I am trying to remove trailing spaces from a string value.
>> [...]

> $_="xxxxxx     ";
> s/\s+//;
> print ;

This one doesn't remove only the _trailing_ whitespaces.  You should
instead stick to this one;

  s,\s+$,,;


-- 
Tore Aursand <tore@aursand.no>
"Leadership is doing what is right when no one is watching." -- George
 Van Valkenburg


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

Date: Fri, 12 Mar 2004 15:28:47 +0000
From: zzapper <david@tvis.co.uk>
Subject: Re: removing trailing spaces
Message-Id: <nkl3505ssrf8gcb8h44suj81017bt02m0k@4ax.com>

On Fri, 12 Mar 2004 14:51:22 +0000, wrote:

To be punctillious, if the guy wants a trim function
>>
>>Ollie.
$_="xxxxxx     ";
s/\s+$//;
s/^\s+//;
print ;


zzapper (vim & cygwin & zsh)
--

vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?"

http://www.vim.org/tips/tip.php?tip_id=305  Best of Vim Tips


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

Date: Fri, 12 Mar 2004 10:26:53 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: removing trailing spaces
Message-Id: <Pine.A41.4.58.0403121024471.14112@ginger.libs.uga.edu>

On Fri, 12 Mar 2004, Ollie wrote:

> I am guessing this is simple one, but am not really a Perl guru, so am
> hoping I can get help from someone out here.
>
> I am trying to remove trailing spaces from a string value.
>
> original value          what am looking for
> 'xxxxxx           ' ==>    'xxxxxx'
>
> I am going to store this value in the database, but I want to remove
> the spaces so I can find exert match when am searching for specific
> value.

You could do it like it's described in the FAQ: How do I strip blank space
from the beginning/end of a string?

http://www.perldoc.com/perl5.8.0/pod/perlfaq.html

Regards,

Brad


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

Date: 12 Mar 2004 13:13:00 GMT
From: Bhaskar Reddy <rbin.kor901209@in.bosch.com>
Subject: Re: Spreadsheet::WriteExcel - Excel 97 install problem
Message-Id: <c2sd0s$jfg$1@ns2.fe.internet.bosch.com>


>> reddy dot bhaskar at bosch dot com
> 
> The module File::Temp is a prerequisite to install
> Spreadsheet::WriteExcel, so you have to install it as well. Also,
> where did you get version 0.49.7 from? The latest version available on
> CPAN is 0.42... You might need also:
> Date::Calc
> Date::Manip
> OLE::Storage_Lite
> Parse::RecDescent
> 
> http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-0.42/
> 
> HTH,
> 
> Zoltan Kandi, M. Sc.
> 
> 

Thankyou Mr.Zoltan Kandi. I downloaded the other modules needed and now 
it looks to be working, atleast I am not getting any errors and the cells 
have strings longer than 256 chars. 

I checked with the version and it is 0.42 that I downloaded, but the tar 
file is named as .....0.49.7. this made me think it as version 0.49.

-- 
TIA & Best Regards
Bhaskar Reddy

reddy dot bhaskar at bosch dot com


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

Date: Fri, 12 Mar 2004 11:07:35 +0000
From: zzapper <david@tvis.co.uk>
Subject: Re: Text editor implemented in Perl
Message-Id: <7a63509i3dlp6l3tr3am18qchlvs0soooi@4ax.com>

On Fri, 12 Mar 2004 13:43:39 +1000, wrote:


>> 
>
>Vi & emacs already support regular expressions in searches, and have done
>for 20 years.
>

try http://www.vim.org/

There is also a version of VIM compiled with Perl Support (ie you can
write perl scripts to perform edits)

I also love

http://peter.verhas.com/progs/perl/prep/

Search and replace in multiple files
for Perl programmers.

Using this tool you can edit and change multiple files simultaneously.
The most common usage is global search and replace, but the limits are
only in your imagination.

zzapper (vim & cygwin & zsh)
--

vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?"

http://www.vim.org/tips/tip.php?tip_id=305  Best of Vim Tips


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

Date: Fri, 12 Mar 2004 12:00:45 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Text editor implemented in Perl
Message-Id: <NDh4c.37180$rW6.8639@nwrddc03.gnilink.net>

fifo wrote:
> At 2004-03-12 13:43 +1000, Gregory Toomey wrote:
>> Vi & emacs already support regular expressions in searches, and have
>> done for 20 years.
>
> Yes, but they don't normally have support for arbitrary perl
> expressions in a substitution.

It is fairly easy to write your own emacs extension which can call perl to
execute the substitution. But that is more of a question for the emacs NG.

jue




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

Date: Fri, 12 Mar 2004 11:30:14 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: Text editor implemented in Perl
Message-Id: <c2s706$or1$1@reader1.panix.com>

In <c2qe0q$65f$1@wisteria.csv.warwick.ac.uk> Ben Morrow <usenet@morrow.me.uk> writes:

>The main reason I started was because I got really hacked off with
>elisp: I just can't make any sense of it... Emacs' Unicode support was
>also not how I wanted it to be, so I thought I'd write my own editor in
>Perl.

>Then I learned to use vim... the project's been on hold ever since :).

What makes vim so much better than Emacs?

I've noticed that vi (particularly vim) counts with many customers
in the Perl community, but I honestly don't understand why.  I have
made periodic attempts to learn (some flavor of) vi, but all have
ended in failure.  Maybe my brain and fingers are permanently
deformed from years of Emacs use, but I find the conceptual design
of vi utterly perverse (e.g. inconsistencies such text insertion
sometimes happening before the cursor, sometimes after).  Maybe I
just haven't found the right documentation for the right variant
of vi that would reveal the method to the madness.  For now, I find
vim's popularity totally inexplicable.

jill
-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



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

Date: 12 Mar 2004 12:36:43 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Text editor implemented in Perl
Message-Id: <c2sasr$4u0$1@nets3.rz.RWTH-Aachen.DE>

Also sprach J Krugman:

> In <c2qe0q$65f$1@wisteria.csv.warwick.ac.uk> Ben Morrow <usenet@morrow.me.uk> writes:
> 
>>The main reason I started was because I got really hacked off with
>>elisp: I just can't make any sense of it... Emacs' Unicode support was
>>also not how I wanted it to be, so I thought I'd write my own editor in
>>Perl.
> 
>>Then I learned to use vim... the project's been on hold ever since :).
> 
> What makes vim so much better than Emacs?
> 
> I've noticed that vi (particularly vim) counts with many customers
> in the Perl community, but I honestly don't understand why.  I have
> made periodic attempts to learn (some flavor of) vi, but all have
> ended in failure.  Maybe my brain and fingers are permanently
> deformed from years of Emacs use, but I find the conceptual design
> of vi utterly perverse (e.g. inconsistencies such text insertion
> sometimes happening before the cursor, sometimes after).  Maybe I
> just haven't found the right documentation for the right variant
> of vi that would reveal the method to the madness.  For now, I find
> vim's popularity totally inexplicable.

People will probably be using one or the other, but not both. The one
you start with (and provided you stick with it for a couple of weeks)
will ultimately be your editor.

Both emacs and vim are "functionally complete", in that they both offer
everything that could ever be related with file editing. However, vim
is extremely compact and small whereas the emacs people started to
embrace the idea of a client/server architecture (probably in order to
decrease the start-up time). For vim such tricks have never been
necessary.

Also - and to give this a bit of on-topicness - vim has an excellent
syntax highlighter for Perl code. And this comes as default unlike emacs
which has two different Perl modes.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 12 Mar 2004 10:40:31 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Text editor implemented in Perl
Message-Id: <Pine.A41.4.58.0403121029090.14112@ginger.libs.uga.edu>

On Fri, 12 Mar 2004, J Krugman wrote:
>
> What makes vim so much better than Emacs?

This is a long-standing religious topic.  On the one hand are Emacs users,
and on the other, users of the One True Editor, vi.

Please don't take me seriously.  But you're not likely to EVER get a
decisive answer to your question.  You've discovered for yourself the vi
doesn't "work" with your own mindset.  I think that's a legitimate reason
not to use it.

Ever since IBM destroyed WordStar (for me) by relocating the Ctrl key,
I've had an aversion to Ctrl key combinations--it's a carpal tunnel
problem.  At a key point, I bit the bullet and worked at wrapping my mind
and fingers around vi.  Now it's second nature, and having to edit text
with anything else makes me feel quadriplegic.

Regards,

Brad


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

Date: Fri, 12 Mar 2004 13:03:47 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: Tricky Perl Bug (amusing/unamusing)
Message-Id: <4051a840.0@juno.wiesbaden.netsurf.de>

zzapper wrote:

> Hi Y'All
> ...
> $
> $phone=($phonelocal =~ /\d\d/) ? "$phonelocal":"$phonecentral";
> ...
> 
> In the above code snippet $phone was always being assigned
> SCALAR(0x18ef230) this drove me crazy until I FINALLY noticed the
> STRAY DOLLAR on the previous line (not so easy to spot in 100's of
> lines of code)
> 
> presumably Perl saw this as a process number ie
> 
> $$phone=($phonelocal =~ /\d\d/) ? "$phonelocal":"$phonecentral";
> 
> perl -w did not indicate anything amiss

But using strict would have:

use strict;
use warnings;
my $phone = '1';
my $phonelocal = '2';
my $phonecentral = '3';
$
$phone=($phonelocal =~ /\d\d/) ? "$phonelocal":"$phonecentral";

results in:

Can't use string ("1") as a SCALAR ref while "strict refs" in use at - line 6.

This is assuming you don't have a scalar ref in $phone. You don't I presume?

Thomas

-- 
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</  #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..


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

Date: 12 Mar 2004 12:51:17 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Tricky Perl Bug (amusing/unamusing)
Message-Id: <u98yi66xfe.fsf@wcl-l.bham.ac.uk>

zzapper <david@tvis.co.uk> writes:

> ...
> $
> $phone=($phonelocal =~ /\d\d/) ? "$phonelocal":"$phonecentral";
> ...
> 
> In the above code snippet $phone was always being assigned
> SCALAR(0x18ef230) this drove me crazy until I FINALLY noticed the
> STRAY DOLLAR on the previous line (not so easy to spot in 100's of
> lines of code)
> 
> presumably Perl saw this as a process number ie
> 
> $$phone=($phonelocal =~ /\d\d/) ? "$phonelocal":"$phonecentral";

No it saw it a reference auto-vivification.  (i.e. set $phone to a
reference (pointer) to a new anonymous scalar containing the data).

> perl -w did not indicate anything amiss

Because it was perfectly normal and valid Perl - just not what you
intended.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 12 Mar 2004 07:07:02 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Tricky Perl Bug (amusing/unamusing)
Message-Id: <slrnc53dfm.5nn.tadmc@magna.augustmail.com>

zzapper <david@tvis.co.uk> wrote:

> $phone=($phonelocal =~ /\d\d/) ? "$phonelocal":"$phonecentral";
                                   ^           ^ ^             ^
                                   ^           ^ ^             ^

> critiques welcome


Don't make useless uses of double quotes.

   perldoc -q vars


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 12 Mar 2004 13:55:04 +0000
From: zzapper <david@tvis.co.uk>
Subject: Re: Tricky Perl Bug (amusing/unamusing)
Message-Id: <p7g3501bmffma7v1qb24li74260nuegrbe@4ax.com>

On Fri, 12 Mar 2004 13:03:47 +0100, wrote:


>
>But using strict would have:
>
>use strict;
>use warnings;
>my $phone = '1';
>my $phonelocal = '2';
>my $phonecentral = '3';
>$
>$phone=($phonelocal =~ /\d\d/) ? "$phonelocal":"$phonecentral";

New Years resolution I must stop disabling strict!!!

zzapper (vim & cygwin & zsh)
--

vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?"

http://www.vim.org/tips/tip.php?tip_id=305  Best of Vim Tips


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

Date: Fri, 12 Mar 2004 15:21:06 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: using an assoc. array as a 'set'
Message-Id: <lhg3505cv7ta8ud4gq6hrk7rhc9ajnb2h3@4ax.com>

On 11 Mar 2004 09:33:18 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>Mathematics goes that way.  Starting from sets, "ordered pairs" can
>be defined.  Then mappings, the mathematical counterparts of hashes,

I'd say that I have a mathematically oriented personality: I like and
it is natural for me to think in terms of mathematic concepts of
programming language features and charachteristics...

>are defined as certain sets of ordered pairs.
[snip]
>they aren't sets.  Perhaps when quantum computing makes the
>implementation of sets a snap and voids all efficiency considerations
>we shall see the BOURBAKI computing language :)

I understand that this is a joke, but taking it just a little bit
seriously, I'd say that quantum computing has very few or nothing to
do with this issue...

I made it clear from the start that this was a particular, minor,
concern of *mine*, and I think that Perl's hypothetical support of
sets or similar structures as primitive objects of the language
wouldn't be of any added utility but in a very limited way in just a
very limited bunch of cases, that simply wouldn't be worth the trouble
of adding such a support.

>That said, Perl 6 will have pairs (but not sets) as a primitive, and
>hashes will be based on pairs.

I had already heard that... I'm both very curious about Perl 6 because
of rumors gathered here and there and afraid about some changes
because of the same rumors and especially the reputable opinions of
extraordinaire PH's like Abigail, for example!


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

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:

#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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 6249
***************************************


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