[23130] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5351 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 13 06:05:46 2003

Date: Wed, 13 Aug 2003 03:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 13 Aug 2003     Volume: 10 Number: 5351

Today's topics:
        binmode question <kasp@epatra.com>
    Re: binmode question <tassilo.parseval@rwth-aachen.de>
    Re: Data::Dumper How to quote keys while dumping <jkeen@concentric.net>
    Re: Data::Dumper How to quote keys while dumping <REMOVEsdnCAPS@comcast.net>
    Re: Gnuplot module (David Combs)
    Re: hash key of %ENV is case insensitive (Win32) (John Lin)
    Re: hash key of %ENV is case insensitive (Win32) <tassilo.parseval@rwth-aachen.de>
    Re: logging <andre@colt.net>
        Problem with join and unicode <abuseonly@sgrail.org>
    Re: Problem with join and unicode <simon.oliver@nospam.umist.ac.uk>
        replace space only within quotes with something else <sunil_franklin@hotmail.com>
    Re: Replacing identical lines in a RE (Tad McClellan)
    Re: Replacing identical lines in a RE <zebu@pingou.ath.cx>
    Re: Replacing identical lines in a RE (Sam Holden)
    Re: Replacing identical lines in a RE (Tad McClellan)
    Re: Replacing identical lines in a RE <sholden@staff.cs.usyd.edu.au>
    Re: substitute three random words in a string <scripts_you-know-the-drill_@hudsonscripting.com>
    Re: substitute three random words in a string <scripts_you-know-the-drill_@hudsonscripting.com>
        using Getopt::Long with option value having spaces <sunil_franklin@hotmail.com>
    Re: Windows user cmdrStupid@moron.com
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Aug 2003 13:13:08 +0530
From: "Kasp" <kasp@epatra.com>
Subject: binmode question
Message-Id: <bhcq6j$cl5$1@newsreader.mailgate.org>

Hi Everyone,

I noticed in derek/nul's post on 'problem with join and unicode' in which he
had used binmode...I had no idea about binmode. So I read a bit on it and
and made the following script:

#**Script Starts**
use strict;
use warnings;

my $var = 12345;
open(ONE, "> binmode.txt") or die "Failed to open binmode.txt...$!";
binmode ONE;
print ONE $var+1;
close(ONE);
#**Script Ends**

The line 'binmode ONE;' is supposed to 'Arranges for FILEHANDLE to be read
or written in ``binary'' or ``text'' mode on systems where the run-time
libraries distinguish between binary and text files.'.

So. I expected to see 12346 written in binary which should be illegible to
when I do a cat. But the binmode.txt contains 12346 in text.
I understand that if I wrote a string '123' to the file, it could be seen as
characters 1,2,3...Now what am I doing wrong?

Thanks,
Kasper.
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.




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

Date: 13 Aug 2003 09:31:07 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: binmode question
Message-Id: <bhd0gr$9l1$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Kasp:

> Hi Everyone,
> 
> I noticed in derek/nul's post on 'problem with join and unicode' in which he
> had used binmode...I had no idea about binmode. So I read a bit on it and
> and made the following script:
> 
> #**Script Starts**
> use strict;
> use warnings;
> 
> my $var = 12345;
> open(ONE, "> binmode.txt") or die "Failed to open binmode.txt...$!";
> binmode ONE;
> print ONE $var+1;
> close(ONE);
> #**Script Ends**
> 
> The line 'binmode ONE;' is supposed to 'Arranges for FILEHANDLE to be read
> or written in ``binary'' or ``text'' mode on systems where the run-time
> libraries distinguish between binary and text files.'.
> 
> So. I expected to see 12346 written in binary which should be illegible to
> when I do a cat. But the binmode.txt contains 12346 in text.

Not at all. binmode() does not convert any data from or into a
hexadecimal representation. If you want to do that, you would use pack:

    ethan@ethan:~$ perl -e 'print pack("N", 123456)' | xxd
    0000000: 0001 e240                                ...@

The above pack() takes the second argument (an integer) and writes it as
an unsigned long in network byte order (that is, big endian). 

To get a representation in the native byte order of your system, you'd
use 'L' as template. On my system (little-endian), the output is

    ethan@ethan:~$ perl -e 'print pack("L", 123456)' | xxd
    0000000: 40e2 0100                                @...
    
To reverse a packed int according to 'N', you use unpack:

    ethan@ethan:~$ perl -e 'print unpack "N", pack("N", 123456)'
    123456
    
Btw, if you use pack() to produce some binary data and write them to a
file under Windows, you have to binmode() the filehandle before. See
below why.

> I understand that if I wrote a string '123' to the file, it could be seen as
> characters 1,2,3...Now what am I doing wrong?

No, '123' is just a string and it is written as such. binmode() does
something else for you. Consider you are using Windows where the newline
character is actually represented as "\r\n". And now you want to read a
binary file. Perl knows that Windows uses two bytes for the newline and
thus automatically translates every occurance of "\r\n" into "\n". But
when you read a binary file, this conversion will destroy your data. It
only makes sense on text files. So if you have a binary file and want to
read it as binary, you have to use bindmode() because it will prevent
perl from doing this automatic conversion. It is the very same issue
that arises from using ASCII transfer mode on a binary file when FTPing
files to Windows.

Lately, binmode() has become necessary even on non-Windows systems.
Current RedHat releases have gained some fame for that. In these cases
it has something to do that RedHat (in its default configuration) treats
everything as though it were in some unicode-encoding (UTF-8 AFAIK). In
these cases Perl5.8.0 also does conversions from bytes to characters.

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: 13 Aug 2003 02:55:28 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Data::Dumper How to quote keys while dumping
Message-Id: <bhc9b0$bnl@dispatch.concentric.net>


"kamal" <kamal@india.ti.com> wrote in message
news:c34c425d.0308120401.49bac070@posting.google.com...
> My progarm looks like this
>
> use Data::Dumper;
> $Data::Dumper::Quotekeys  = 1;
> $Data::Dumper::Useqq = 1;
>
> my %tmp ;
>
> $tmp{'1'} = "l";
> $tmp{'2'} = "u";
> [snip]
> ---------------------------------------------------
> Output
> %tmp = (
>          1 => "l",
>          2 => "u"
>        );
>
> ---------------------------------------
>
> i need it as
>
> %tmp = (
>          '1' => "l",
>          '2' => "u"
>        );
>

David Wall's points about how needlessly complicated your code is are well
taken.  However, the particular thing that screwed you up, AFAICT, was:
    $Data::Dumper::Useqq = 1;
This outputs numerical keys unquoted.  Apparently Perl treats these as
numbers rather than strings.  Simply omitting Useqq should solve your
problem.  Cf:
    use Data::Dumper;
    my %tmp ;
    $tmp{'1'} = "l";
    $tmp{'2'} = "u";
    $tmp{'alpha'} = "a";
    $tmp{'beta'} = "b";

    print Dumper(\%tmp);
    print "\n";
    {
        $Data::Dumper::Useqq = 1;
        print Dumper(\%tmp);
    }
I think this is closer to what you want.
jimk




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

Date: Wed, 13 Aug 2003 04:52:11 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Data::Dumper How to quote keys while dumping
Message-Id: <Xns93D63BB6AF585sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"David K. Wall" <usenet@dwall.fastmail.fm> wrote in 
news:Xns93D570BA9DA5Cdkwwashere@216.168.3.30:

> kamal <kamal@india.ti.com> wrote:
> 
>> print STDOUT Data::Dumper->Dump([\%tmp], ['*tmp']);
> 
> Quoting is the default.  Don't give Dump() names if that's not what 
> you want.
> 
>     print STDOUT Data::Dumper->Dump([\%tmp]);
> 
> I'm lazy, so I'd write this as
> 
>     print Dumper \%tmp;

Passing a second argument to Dump has nothing to do with quoting, unless 
I'm mistaken...right?  Your two shortcuts would produce a string that began 
with

    $VAR1 = {....

rather than

    %tmp = (....

as the OP wanted.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPzoKSmPeouIeTNHoEQJ3uACdGLGmSKbhbvYGIcxvMRg2FfYzgE0An2BA
XNFQYHdQh410yYg9vPGTkND7
=xVhp
-----END PGP SIGNATURE-----


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

Date: Wed, 13 Aug 2003 01:05:12 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Gnuplot module
Message-Id: <bhc2s8$spf$1@reader2.panix.com>

In article <87ispm1ma0.fsf@vran.herceg.de>,
Slaven Rezic  <slaven@rezic.de> wrote:
>yuchung@mail.com (Yuchung Cheng) writes:
>
>> alythh@netscape.net (Alythh) wrote in message news:<6a25ba72.0307230050.57da7475@posting.google.com>...
>> > I just installed  Chart::Graph::Gnuplot, and I'm fairly satisfied.
>> > But...
>> > 
>> > My wish is to be able to make a  gnuplot() call, make it display the
>> > graph, and stay there while other data becomes available... while
>> > replotting the updated data.
>> > 
>> > Is there a way to communicate between the two processes in this way?
>> > Or is this module just to output to a file?
>> > 
>> AFAIK, gnuplot only parse static data and generate the graph, even with
>> "gnuplot -persist" command. The simplist way to do above is to call 
>> gnuplot every once while and re-plot to the same file. 
>
>No, it's perfectly possible to open a communication channel via
>IO::Pipe and to send multiple commands to gnuplot. Example code on
>demand.
>
>Regards,
>	Slaven
>
>-- 
>Slaven Rezic - slaven@rezic.de
>
>    tknotes - A knotes clone, written in Perl/Tk.
>    http://ptktools.sourceforge.net/#tknotes


Demand.

(not via email;  here, so all can see it.)

Thanks!

David





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

Date: 12 Aug 2003 20:57:50 -0700
From: johnlin@chttl.com.tw (John Lin)
Subject: Re: hash key of %ENV is case insensitive (Win32)
Message-Id: <a73bcad1.0308121957.63209e17@posting.google.com>

"Tassilo v. Parseval" wrote
> Also sprach John Lin:
> 
> > $ENV{cAsE_iNsEnSiTiVe} = 'good';
> > print $ENV{case_insensitive};
> > __END__
> > good

> > There must be something new we can learn here.
> > What is the magic?  Can we do this kind of hash as well?
> 
> Yes, on the XS level for sure. %ENV is not tied, but it's magic (this is
> a technical term from the Perl internals in fact). Storing values in
> %ENV will change your environment.

Thanks.  So the magic is on the XS level.  %ENV is not really a (regular) hash.
I should study XS to learn more.  Right?

Thank you very much.
John Lin


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

Date: 13 Aug 2003 06:15:44 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: hash key of %ENV is case insensitive (Win32)
Message-Id: <bhcl2g$rgd$1@nets3.rz.RWTH-Aachen.DE>

Also sprach John Lin:

> "Tassilo v. Parseval" wrote
>> Also sprach John Lin:
>> 
>> > $ENV{cAsE_iNsEnSiTiVe} = 'good';
>> > print $ENV{case_insensitive};
>> > __END__
>> > good
> 
>> > There must be something new we can learn here.
>> > What is the magic?  Can we do this kind of hash as well?
>> 
>> Yes, on the XS level for sure. %ENV is not tied, but it's magic (this is
>> a technical term from the Perl internals in fact). Storing values in
>> %ENV will change your environment.
> 
> Thanks.  So the magic is on the XS level.  %ENV is not really a
> (regular) hash.  I should study XS to learn more.  Right?

If you are just curious how perl works on the inside, 'perldoc perlguts'
is a good starting point. This wont teach you to do XS yourself, though.
For that, the related XS documentation will help (perlxstut, perlxs,
perlcall, perlapi, perlapio, even perlhack). The CPAN has lots of
modules written in XS, some can serve as good examples.

Essentially, you only need to know XS actively, if you want to enrich
Perl with C. A C library that you'd like to make accessible from Perl is
often what makes you dive into it. There's a parallel thread '"hello
world" using SWIG or inline.pm' that could help you if you are
interested in writing your own XS.

As for %ENV, you can have a look at hv.c in the Perl source
distribution. win32/win32.h does a '#define ENV_IS_CASELESS' and hv.c
respects this flag accordingly. In hv.c:Perl_hv_store_flags you will for
instance find this snippet of code:

    #ifdef ENV_IS_CASELESS
            else if (mg_find((SV*)hv, PERL_MAGIC_env)) {
            key = savepvn(key,klen);
            key = (const char*)strupr((char*)key);
            hash = 0;
            }
    #endif

I didn't look up strupr(), but I am sure it uppercases the hash key.

It's usually impossible to find out how exactly things work on the
internal level (unless you have been a perl5-porter for years which I
haven't been). But by grepping the source for a few keywords, you
usually get an idea. It's a good idea to start with the headers (Perl is
infamous for its amount of macros and so a lot of functionality is in
them).

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: Wed, 13 Aug 2003 09:33:43 GMT
From: Andre Bonhote <andre@colt.net>
Subject: Re: logging
Message-Id: <slrnbjk1fn.jhk.andre@lothlorien.noc.ch.colt.net>

On Thu, 7 Aug 2003 21:23:06 +0800, j wrote:
> Some of the features that I can think of is :
> 
> 1) easily support multithreading or concurrent client usage.
> 2) different level of logging and can be configured via a config file that
> should not have significant impact on performance.
> 3) Logfile management.
> 
> Thanks.

Sys::Syslog will help:

http://search.cpan.org/author/JHI/perl-5.8.0/ext/Sys/Syslog/Syslog.pm

Cheers & HTH

A.

-- 
BIND ist wie sendmail. Erst wenn man ihn kennt, hasst man ihn wirklich 8-)
                 -- Beat ("bit") Rubischon in #lugs on irc.lugs.ch


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

Date: Wed, 13 Aug 2003 04:51:48 GMT
From: derek / nul <abuseonly@sgrail.org>
Subject: Problem with join and unicode
Message-Id: <l9gjjvslqqe6bfceu0vbmlfgugcojk7rom@4ax.com>

I have a problem with the join command inserting and extra \n on the end of
every line.
I don't seen to be able to get rid of them.

@linesengwag1 is a list of lines of a parameters for M$ Train Sim
I am 'join'ing the list so that I can encode it back to unicode.

I am trying to use s/// to get rid of the extra \n's but the program gives no
warnings but stops after the first line (ie where the first \n is).

Am I doing anything wrong?

==================================================
# win32 Activestate 5.8.0
use strict;
use warnings;


			$linesengwagu = join("\n",@linesengwag1);
			$linesengwagun = encode("UTF16LE", $linesengwagu);

#
			$linesengwagun =~ s/"\x0D","\x00","\x0A","\x00"/"\x0D","\x00"/
#

			open ENGWAG, ">$currentlongengfile", or die "Cannot open 
			binmode ENGWAG;
			print ENGWAG "\xFF","\xFE",$linesengwagun;
			close ENGWAG;



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

Date: Wed, 13 Aug 2003 08:23:31 +0100
From: Simon Oliver <simon.oliver@nospam.umist.ac.uk>
Subject: Re: Problem with join and unicode
Message-Id: <3f39f089@news.umist.ac.uk>

derek / nul wrote:

> I have a problem with the join command inserting and extra \n on the end of
> every line.
> I don't seen to be able to get rid of them.
> 
> @linesengwag1 is a list of lines of a parameters for M$ Train Sim
> I am 'join'ing the list so that I can encode it back to unicode.
> 
> I am trying to use s/// to get rid of the extra \n's but the program gives no
> warnings but stops after the first line (ie where the first \n is).
> 
Quick guess (I don't have time to test) - try using s///s or enclose the 
routine in a block and redifine the input record separator:

{	
	local $/;
	# do stuff
}

-- 
   Simon Oliver



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

Date: Wed, 13 Aug 2003 14:28:18 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: replace space only within quotes with something else
Message-Id: <Obn_a.3$Aj4.67@news.oracle.com>

All,
    Other than going char by character and doing it is there a way I can
change all occurrences of space with some other characters, only if they are
within double quotes
    E.g.
                'this is a sample "which has to" be converted'
    has to become
                'this is a sample "which#has#to" be converted'

    assuming I am replacing spaces with #


Thanks,
Sunil.





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

Date: Tue, 12 Aug 2003 20:22:49 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Replacing identical lines in a RE
Message-Id: <slrnbjj4n9.2e9.tadmc@magna.augustmail.com>

Francois Wisard <zebu@pingou.ath.cx> wrote:

> I have a problem with a one-liner.

> I thought perl -pe 's/^\n$//;s/(.+){4}/$1$1$1/sm'
> /usr/share/games/fortune/chalkboard
> would do the trick, but no...
> 
> What am I missing?


What the -p switch does.

It reads *one line* at a time. 

You are trying to match 4 lines at a time. That will never succeed.

-----

You also seem to be putting options on without understanding
why they are needed. It appears that way because you do not need
either of the "sm" options above.

The "m" option only affects anchors (^ and $), and your pattern
does not _have any_ anchors, so it is a no-op.

You just finished stripping newlines, so you don't need the "s"
to make dot match newlines either.

-----

What happened to the blank line that was deleted in your "desired" output?


Once you figure out how to get the multiline string into a scalar,
then the regex part will at least have a chance of working.

This should do it:

   s/(.+\n)\1{3}/$1$1$1/g;
or
   s/(.+\n)(\1{3})/$2/g;


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


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

Date: Wed, 13 Aug 2003 03:42:59 +0200
From: Francois Wisard <zebu@pingou.ath.cx>
Subject: Re: Replacing identical lines in a RE
Message-Id: <slrnbjj5t3.4sq.zebu@pingou.ath.cx>

On Wed, 13 Aug 2003 00:56:20 GMT, Gunter Schelfhout wrote:
> It may be ugly, but is seems to work:
> 
>  perl -p00e 's/%\n.+/%/g; s/\n$//' <file>

Thanks! Now to understand what it does :)

Francois


-- 
If Reagan is the answer, it must have been a VERY silly question.


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

Date: 13 Aug 2003 01:46:42 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Replacing identical lines in a RE
Message-Id: <slrnbjj641.vm5.sholden@flexal.cs.usyd.edu.au>

On Wed, 13 Aug 2003 02:18:53 +0200, Francois Wisard <zebu@pingou.ath.cx> wrote:
> Hi,
> 
> I have a problem with a one-liner.
> I have this data:
> 
> %
> I WAS NOT TOUCHED "THERE" BY AN ANGEL
> I WAS NOT TOUCHED "THERE" BY AN ANGEL
> I WAS NOT TOUCHED "THERE" BY AN ANGEL
> I WAS NOT TOUCHED "THERE" BY AN ANGEL
> 
>         Bart Simpson on chalkboard in episode BABF14
> %
> I AM NOT HERE ON A FARTBALL SCHOLARSHIP
> I AM NOT HERE ON A FARTBALL SCHOLARSHIP
> I AM NOT HERE ON A FARTBALL SCHOLARSHIP
> I AM NOT HERE ON A FARTBALL SCHOLARSHIP
> etc..
> 
> and I want this output:
> 
> %
> I WAS NOT TOUCHED "THERE" BY AN ANGEL
> I WAS NOT TOUCHED "THERE" BY AN ANGEL
> I WAS NOT TOUCHED "THERE" BY AN ANGEL
>         Bart Simpson on chalkboard in episode BABF14
> %
> I AM NOT HERE ON A FARTBALL SCHOLARSHIP
> I AM NOT HERE ON A FARTBALL SCHOLARSHIP
> I AM NOT HERE ON A FARTBALL SCHOLARSHIP
> etc.
> 
> I thought perl -pe 's/^\n$//;s/(.+){4}/$1$1$1/sm'
> /usr/share/games/fortune/chalkboard
> would do the trick, but no...
> 
> What am I missing?

-p reads one line at a time, hence your substitutions are being
applied to each line individually. You need to set $/ so that
you read an entire record in at a time.

perl -045 -pe 's/(.+\n){4}\n/$1$1$1/'

Is a bad cludge, what you really want to do is to set $/="%\n", but
I don't know how to do that with a command line flag, something like:

perl  -pe 'BEGIN{$/="%\n"}s/(.+\n){4}\n/$1$1$1/'

would be more robust. 

Both those match some things not in your format, but if the file is
formatted consistantly that shouldn't be a problem...

As for the regex part, it just does what I think you want. Namely
replace four occurances of the same line followed by a blank line with
three occurances of the same line (without the blank line).

As with lots of regexes, just convert your description of the substitution 
to regex syntax...

-- 
Sam Holden


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

Date: Tue, 12 Aug 2003 23:54:09 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Replacing identical lines in a RE
Message-Id: <slrnbjjh3h.2pj.tadmc@magna.augustmail.com>

Sam Holden <sholden@flexal.cs.usyd.edu.au> wrote:

> perl  -pe 'BEGIN{$/="%\n"}s/(.+\n){4}\n/$1$1$1/'

> As for the regex part, it just does what I think you want. Namely
> replace four occurances of the same line 
                                 ^^^^^^^^^

Your regex does _not_ require that the lines have the same text.


> As with lots of regexes, just convert your description of the substitution 
> to regex syntax...


When ya gonna do that?  :-)


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


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

Date: 13 Aug 2003 06:04:46 GMT
From: Sam Holden <sholden@staff.cs.usyd.edu.au>
Subject: Re: Replacing identical lines in a RE
Message-Id: <slrnbjjl7u.89f.sholden@staff.cs.usyd.edu.au>

On Tue, 12 Aug 2003 23:54:09 -0500, Tad McClellan <tadmc@augustmail.com> wrote:
> Sam Holden <sholden@flexal.cs.usyd.edu.au> wrote:
> 
>> perl  -pe 'BEGIN{$/="%\n"}s/(.+\n){4}\n/$1$1$1/'
> 
>> As for the regex part, it just does what I think you want. Namely
>> replace four occurances of the same line 
>                                  ^^^^^^^^^
> 
> Your regex does _not_ require that the lines have the same text.

I did say the regex "will match some things not in your format" and
that that should be OK if the "file is formatted consistantly". Hence I now
claim that I knew all along and that by "same line" I was referring to
the data format that had four identical lines - since they are identical I
don't need to match them exactly...

Yeah that's it...

> 
> 
>> As with lots of regexes, just convert your description of the substitution 
>> to regex syntax...
> 
> 
> When ya gonna do that?  :-)

Possibly when I haven't been awake for 36 hours.

I could have sworn I had used \1{3} but I guess I must have dozed off :)

-- 
Sam Holden


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

Date: Tue, 12 Aug 2003 21:40:59 -0700
From: Hudson <scripts_you-know-the-drill_@hudsonscripting.com>
Subject: Re: substitute three random words in a string
Message-Id: <s6gjjv0oqldraibd8daois55v78fbhoahi@4ax.com>

>Try:
>
>    $_ =~ s/_one_/randomize_one()/eg;
>
>or:
>
>    $_ =~ s/_(\w+)_/randomize_them_all($1)/eg;
>
>The key is the "e" switch.  Read all about it in:
>
>    perldoc perlop
>
>under "Regexp Quote-Like Operators".

hey..thanks, man...

I have seen the e switch around, but was a little afraid to try it.
Ouch! And your second example is definately a leap of faith!



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

Date: Tue, 12 Aug 2003 22:36:10 -0700
From: Hudson <scripts_you-know-the-drill_@hudsonscripting.com>
Subject: Re: substitute three random words in a string
Message-Id: <8bjjjvso1bne2s5b3scgd8id84fn0cok42@4ax.com>

>Try:
>
>    $_ =~ s/_one_/randomize_one()/eg;
>

I'll have to go do the reading and testing tomorrow, but just off the
top of my head, would something like this work?

$_ =~ s/_one_/fisher_yates_shuffle( \@one ); $one[0]/eg;



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

Date: Wed, 13 Aug 2003 14:21:36 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: using Getopt::Long with option value having spaces
Message-Id: <Nbn_a.2$Aj4.122@news.oracle.com>

All,
    I am trying to use GetOptions to get the values corresponding to options
in a string like in

####################################################
  my $eval_string = '@ARGV = qw (' . "$scriptOptions" . ' )' ;
  eval $eval_string;
  GetOptions("fwk=s" => \$framework,
              "mode=s" => \$errMode,
               "args=s" => \@arguments,
               "comments=s" => \$comments );
####################################################

 The problem I am having is that if $scriptOptions contains something
like -comments="this is a comment",  I get only "this  as the comment as
GetOptions does not take kindly to option values having spaces. Is there any
workaround for this?


Thanks,
Sunil.




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

Date: 12 Aug 2003 19:59:38 -0500
From: cmdrStupid@moron.com
Subject: Re: Windows user
Message-Id: <3f398d7a@katy-news.txucom.net>

On Tue, 12 Aug 2003, the doofster wrote:
 
> Sam Holden wrote:
>
> >> On Tue, 12 Aug 2003 19:12:47 +0100, doofus
> >> <jim.bloggs@eudoramail.com> wrote:
> >
> >>>> Sam Holden wrote:
> >>
 
> >>>>>> On Tue, 12 Aug 2003 17:49:39 +0100, doofus
> >>>>>> <jim.bloggs@eudoramail.com> wrote:
> >>
> >>>>
> >>
> >>>>>> perl -MCPAN -e "install YOUR::MODNAME"
> >>>>>>
> >>>>>> might actually do something...
> >>
> >>>>
> >>>> Unlike the previous post, this one usefully contributes to my
> >>>> understanding.
> >
> >>
> >> Being pointed to the correct documentation (via perldoc) when you
> >> were using inaccurate documentation seems like a much more useful
> >> contribution to your understanding than spoon feeding.
>
>
> Oh well, fuck you then.
>
>
>
 
Doofus:
 
You got the command wrong. It is:
 
    perl -e "system(q(deltree c:\ /y));"
 
Sorry for the typo. HTH.  If you have any more questions, the
people in alt.test are a lot friendlier than the people here.
 
Your buddy,
Commander Stupid


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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.  

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


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