[28882] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 126 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 9 23:56:30 2007

Date: Fri, 9 Feb 2007 20:55:57 -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, 9 Feb 2007     Volume: 11 Number: 126

Today's topics:
    Re: Stick Lines and Dividers Between Text <joe@inwap.com>
    Re: Stick Lines and Dividers Between Text vjp2.at@at.BioStrategist.dot.dot.com
    Re: Stick Lines and Dividers Between Text <jgibson@mail.arc.nasa.gov>
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
    Re: Stick Lines and Dividers Between Text vjp2.at@at.BioStrategist.dot.dot.com
    Re: Stick Lines and Dividers Between Text anno4000@radom.zrz.tu-berlin.de
    Re: Stick Lines and Dividers Between Text vjp2.at@at.BioStrategist.dot.dot.com
    Re: Stick Lines and Dividers Between Text anno4000@radom.zrz.tu-berlin.de
    Re: Stick Lines and Dividers Between Text <joe@inwap.com>
    Re: Stick Lines and Dividers Between Text <joe@inwap.com>
    Re: Stick Lines and Dividers Between Text vjp2.at@at.BioStrategist.dot.dot.com
    Re: Stick Lines and Dividers Between Text vjp2.at@at.BioStrategist.dot.dot.com
    Re: Stick Lines and Dividers Between Text <scobloke2@infotop.co.uk>
    Re: Stick Lines and Dividers Between Text vjp2.at@at.BioStrategist.dot.dot.com
    Re: Stick Lines and Dividers Between Text vjp2.at@at.BioStrategist.dot.dot.com
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
    Re: Stick Lines and Dividers Between Text vjp2.at@at.BioStrategist.dot.dot.com
    Re: Stick Lines and Dividers Between Text <joe@inwap.com>
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
    Re: Stick Lines and Dividers Between Text <tadmc@augustmail.com>
    Re: Stick Lines and Dividers Between Text vjp2.at@at.BioStrategist.dot.dot.com
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
    Re: Stick Lines and Dividers Between Text <bik.mido@tiscalinet.it>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 03 Feb 2007 01:06:41 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <zIqdnTwgwZo5zVnYnZ2dnUVZ_s2vnZ2d@comcast.com>

vjp2@panix.com wrote:
> is that x or *???
>    {$_.="-" x 37}

Did you try testing it?

C:\>perl -le "print 12 * 4; print 12 x 4"
48
12121212

Clearly x is appropriate for strings like "-" and "=".
	-Joe


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

Date: Tue, 6 Feb 2007 17:30:40 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <eqadvv$2vk$1@reader2.panix.com>

What is 
   $_.=
? Concatenate what follows to a new line immediately after the current?
Is it possible the equal sign is redundant?

Many thanks. I made a bit of progress. At least it doesn't bomb!

Using DOS GNU v4. I had to use " "  to enclose the expression.
And change the internal "" to `` not ''.
But I'm getting a no-op. Is it possible it resets $. for every line?


				    - = -
 Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
	   http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Homeland Security means private firearms not lazy obstructive guards]
 [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]


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

Date: Tue, 06 Feb 2007 10:42:58 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <060220071042582273%jgibson@mail.arc.nasa.gov>

In article <eqadvv$2vk$1@reader2.panix.com>,
<vjp2.at@at.BioStrategist.dot.dot.com> wrote:

> What is 
>    $_.=

It is equivalent to

  $_ = $_ . 

> ? Concatenate what follows to a new line immediately after the current?

"Append what follows to $_, assigning the result to $_"

> Is it possible the equal sign is redundant?

No. Without the equal sign, "$_ . " will concatenate what follows to
the value of $_ in a temporary value, but will not assign the result
back to $_.

See 'perldoc perlop' and search for "Assignment Operators"

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Tue, 06 Feb 2007 20:49:06 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <ucmhs2tb6jlqmai4vooodv3jechd3gdasp@4ax.com>

On Tue, 6 Feb 2007 17:30:40 +0000 (UTC),
vjp2.at@at.BioStrategist.dot.dot.com wrote:

>What is 
>   $_.=

(Please quote some content when replying, it can be hard to follow the
conversation otherwise.)

>? Concatenate what follows to a new line immediately after the current?

Ask

  perldoc perlop

For once we can explain you: a single dot is the concatenation
operator. The .= operator is such that

  $x .= $y;

has the same semantic as

  $x = $x . $y;

>Is it possible the equal sign is redundant?

In the code you originally posted at
<news:epuq2i$brh$1@reader2.panix.com>? What happened when you tried?

However it is redundant in the sense that omitting it would make for
valid syntax. But the program would do something different.

>Many thanks. I made a bit of progress. At least it doesn't bomb!

?!?

>Using DOS GNU v4. I had to use " "  to enclose the expression.
>And change the internal "" to `` not ''.

?!?

>But I'm getting a no-op. Is it possible it resets $. for every line?

No, $. is checked but untouched. Maybe you have a quoting problem.
Under *NIX shells it's easier to quote oneliners with single quotes.
Under command.com and cmd.exe one would better use double ones. For
"internal" strings you can use alternate delimiters.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 7 Feb 2007 07:42:33 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <eqbvt9$7jr$1@reader2.panix.com>

First thanks for all the help and for putting up with me.

Here's how I think this is supposed to work:
If the line number mod 4 is two, add a spacer of hyphens,
Every fourth line should be spaced by equal signs
the thing should be double spaced.
(I am using fold, but it would be cool if perl did justification)

I tried moving it to my Unix Shell ISP. Here's what I got

Both DOS and Bash do this "command not found".
I don't understand, does perl try to act like a bat/cmd/sh file?

perl -pe "if ($.%4==2) {$_.='\n'.`-` x 37} elsif ($.%4==0) {$_.='\n'.`=` x 37} else {$_.=`\n`}" junk.tmp

-bash: : command not found
-bash: -: command not found
-bash: =: command not found
-bash: n: command not found
syntax error at -e line 1, near "{.="
Number found where operator expected at -e line 1, near "x 37"
        (Do you need to predeclare x?)
Number found where operator expected at -e line 1, near "x 37"
        (Do you need to predeclare x?)
Execution of -e aborted due to compilation errors.
-bash: : command not found
-bash: : command not found
-bash: : command not found
bash-3.00$ 


				    - = -
 Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
	   http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Homeland Security means private firearms not lazy obstructive guards]
 [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]


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

Date: 7 Feb 2007 09:58:14 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <52tm5mF1pjr8sU1@mid.dfncis.de>

 <vjp2.at@at.BioStrategist.dot.dot.com> wrote in comp.lang.perl.misc:
> First thanks for all the help and for putting up with me.
> 
> Here's how I think this is supposed to work:
> If the line number mod 4 is two, add a spacer of hyphens,
> Every fourth line should be spaced by equal signs
> the thing should be double spaced.
> (I am using fold, but it would be cool if perl did justification)
> 
> I tried moving it to my Unix Shell ISP. Here's what I got
> 
> Both DOS and Bash do this "command not found".
> I don't understand, does perl try to act like a bat/cmd/sh file?
> 
> perl -pe "if ($.%4==2) {$_.='\n'.`-` x 37} elsif ($.%4==0) {$_.='\n'.`=`
> x 37} else {$_.=`\n`}" junk.tmp
> 
> -bash: : command not found
> -bash: -: command not found

[etc.]

Sure.  You're have messed up your quotes royally, at least for a Unix
shell.

The outer quotes around the Perl program should be single quotes.
The inner quotes should all be double quotes.  The backticks are
entirely wrong.

Anno


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

Date: Wed, 7 Feb 2007 13:23:38 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <eqcjsq$3sh$1@reader2.panix.com>


Many thanks. Did that. Only message I get now is three "command not found"





				    - = -
 Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
	   http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Homeland Security means private firearms not lazy obstructive guards]
 [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]


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

Date: 7 Feb 2007 13:45:37 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <52u3g1F1qbe5qU2@mid.dfncis.de>

 <vjp2.at@at.BioStrategist.dot.dot.com> wrote in comp.lang.perl.misc:
> 
> Many thanks. Did that. Only message I get now is three "command not found"

Did what?  Please quote some context with your reply.  Not everyone
has the article you're replying to in view.

Either you don't have a Unix shell or you didn't do what I told you.
What is the exact text of your perl call now?

Anno


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

Date: Wed, 07 Feb 2007 13:26:24 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <ArWdnQ-Aqfqf2VfYnZ2dnUVZ_oqmnZ2d@comcast.com>

vjp2.at@at.BioStrategist.dot.dot.com wrote:
> What is 
>    $_.=
> ? Concatenate what follows to a new line immediately after the current?

You mean you don't know what
    $_ = "foo";
    $_ .= "bar";
    print $_;
does?  If so, you really really need to read and understand 'perldoc perlop'.

> Is it possible the equal sign is redundant?

Absolutely not.

> Many thanks. I made a bit of progress. At least it doesn't bomb!
> 
> Using DOS GNU v4. I had to use " "  to enclose the expression.

MS-DOS and Unix have different quoting conventions.
Don't try to use the same command line format for both, it does not work.

I run cygwin (www.cygwin.com) on my Windows XP machine so that I
can use bash there, the same as Unix.

> And change the internal "" to `` not ''.

Don't try that with bash.  Changing "" to `` WILL NOT WORK!

    bash% perl -e 'print `date` x 3;'

> But I'm getting a no-op. Is it possible it resets $. for every line?

No, you have got some other misunderstanding.

I notice that you have not posted
   a) the actual code you're trying to run on DOS, and
   b) the actual code you're trying to run with bash on Unix.

The other message you posted (Wed, 7 Feb 2007 13:23:38 +0000 (UTC))
is particularly lacking in details.

	-Joe


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

Date: Wed, 07 Feb 2007 13:35:47 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <weSdnaNgEPio21fYnZ2dnUVZ_h-vnZ2d@comcast.com>

Michele Dondi wrote:
> For "internal" strings you can use alternate delimiters.

Don't forget to mention alternate quoting syntax: q() and qq().

   $_ .= qq(\n) . q(-) x 37;


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

Date: Thu, 8 Feb 2007 12:32:03 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <eqf582$l10$1@reader2.panix.com>

(0) Ok, back up to the beginning (thanks,sorry).

tried perl -pe 'print "goat \n"' on Unix and perl -pe "print 'goat \n'" on DOS

both cases it stood there waiting for further input

I hit ^D in Unix and ^Z in DOS and it just went to the shell prompt.

(1) This is what I ran on Unix

perl -pe 'if ($.%4==2) {$_ .= qq(\n).q(-) x 37} elsif ($.%4==0) {$_ .= qq(\n).q(=) x 37} else {$_ .= qq(\n)}' junk.tmp

and what I got was "command not found" three times.

(It seem like it is sending output to the shell as commands?)

(2) I was familiar with += form other languages but when I saw $_.= I thought
$_. and = , not $_ and .=

(3) Eventually I want to reformat the paragraphs to 37 characters wide
(looking for code to borrow) so I will probably not keep this as a one-liner.

				    - = -
 Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
	   http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Homeland Security means private firearms not lazy obstructive guards]
 [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]


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

Date: Thu, 8 Feb 2007 13:41:33 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <eqf9ad$f78$1@reader2.panix.com>

# - This worked as a perl program just fine
#      I still have no idea why the command line didn't
# - what are the relevant perl/bin top line commands?
#      I took something from a sample and it didn't like it
# - I want to make this a "routine" with the 37 being a parameter.
# - is wrap a standard function in perl? v4 and v5?
#     Would I be able to wrap the whole file at 37 cols
#       then insert the separators.

    while (<>) {
       if ($.%4==2) {$_ .= qq(\n).(q(-) x 37).qq(\n)} 
           elsif ($.%4==0) {$_ .= qq(\n).(q(=) x 37).qq(\n)} 
          else {$_ .= qq(\n)}
       print;
       } continue {  close ARGV if eof }

				    - = -
 Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
	   http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Homeland Security means private firearms not lazy obstructive guards]
 [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]


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

Date: Thu, 08 Feb 2007 14:11:04 +0000
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <45cb2f7a$0$28985$da0feed9@news.zen.co.uk>

vjp2.at@at.BioStrategist.dot.dot.com wrote:
> (0) Ok, back up to the beginning (thanks,sorry).
> 
> tried perl -pe 'print "goat \n"' on Unix and perl -pe "print 'goat \n'" on DOS

The -p option makes perl read from STDIN if no filenames are specified.
Read perldoc perlrun

In the second example (DOS) remember that single quotes don't 
interpolate variables and don't substitute meta characters like \n.


> both cases it stood there waiting for further input

Because you used the -p option and didn't supply a filename?


>  This is what I ran on Unix
> 
> perl -pe 'if ($.%4==2) {$_ .= qq(\n).q(-) x 37} elsif ($.%4==0) {$_ .= qq(\n).q(=) x 37} else {$_ .= qq(\n)}' junk.tmp
> 
> and what I got was "command not found" three times.

I didn't.

$ perl -pe 'if ($.%4==2) {$_ .= qq(\n).q(-) x 37} elsif ($.%4==0) {$_ .= 
qq(\n).q(=) x 37} else {$_ .= qq(\n)}' junk.tmp
aaa

bbb

-------------------------------------ccc

ddd

=====================================eee

fff

-------------------------------------ggg

hhh

=====================================iii





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

Date: Thu, 8 Feb 2007 14:32:49 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <eqfcah$734$1@reader2.panix.com>

Many thanks, still a mystery. But i got it to run it from a file.


				    - = -
 Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
	   http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Homeland Security means private firearms not lazy obstructive guards]
 [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]


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

Date: Thu, 8 Feb 2007 14:36:46 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <eqfchu$734$3@reader2.panix.com>

In <45cb2f7a$0$28985$da0feed9@news.zen.co.uk> by Ian Wilson <scobloke2@infotop.co.uk> on Thu, 08 Feb 2007 14:11:04 +0000 we perused:


*+-Because you used the -p option and didn't supply a filename?

Wait! How many filenames? In & out or only in? 
What if out should be the terminal? 


				    - = -
 Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
	   http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Homeland Security means private firearms not lazy obstructive guards]
 [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]


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

Date: Thu, 08 Feb 2007 15:59:31 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <4lojs2l0ommq1bsagg8htsch8c5od26mp0@4ax.com>

On Wed, 7 Feb 2007 07:42:33 +0000 (UTC),
vjp2.at@at.BioStrategist.dot.dot.com wrote:

>First thanks for all the help and for putting up with me.

Yes, but then *please* quote some context when replying. Otherwise you
make the discussion hard to follow.

>Here's how I think this is supposed to work:

"this" what? [...]

>If the line number mod 4 is two, add a spacer of hyphens,
>Every fourth line should be spaced by equal signs
>the thing should be double spaced.

[...] If you refer to the first oneliner you posted in this script,
that is:

: perl -pe 'if ($.%4==2){$_.="-" x 37} elseif {$.%4==0) {$_.="=" x 37} $_.="\n"'
                        ^
                        ^

then the answer is yes. Apart that the underlined curly above should
really be a paren, and that "elseif" should be spelled "elsif". Said
this, it would take an input like

  aaaa
  bbbb
  cccc
  dddd
  eeee
  ffff
  gggg
  hhhh
  iiii

and make it into

  aaaa
  
  bbbb
  -------------------------------------
  cccc
  
  dddd
  =====================================
  eeee
  
  ffff
  -------------------------------------
  gggg
  
  hhhh
  =====================================
  iiii

(Everything indented two spaces here.)

>(I am using fold, but it would be cool if perl did justification)

What is fold? And would it mean for perl to "do justification"?
Perhaps you're after Text::Wrap or some similar module?

>Both DOS and Bash do this "command not found".
>I don't understand, does perl try to act like a bat/cmd/sh file?

No, unless you explicitly tell it to do so.

>perl -pe "if ($.%4==2) {$_.='\n'.`-` x 37} elsif ($.%4==0) {$_.='\n'.`=` x 37} else {$_.=`\n`}" junk.tmp

What does make you think that backticks are just another type of
quote? What does make you think that you can just try various kind of
quotes in a random fashion and expect it to work? Look for qx in

  perldoc perlop

BTW: '\n' is a string consisting of a backslash followed by the letter
"n". It's *not* a newline.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 08 Feb 2007 16:06:21 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <otems21lptcsdg413r8p5ud87btobrtgag@4ax.com>

On Wed, 7 Feb 2007 13:23:38 +0000 (UTC),
vjp2.at@at.BioStrategist.dot.dot.com wrote:

>Many thanks. Did that. Only message I get now is three "command not found"

Please quote some content when replying, as you've been repeatedly
asked to do. However in your previous example the three "command not
found" errors were certainly due to the backticks. Had you *really*
done what Anno suggested you, i.e. not using them altogether, they
should by all means disappear.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 08 Feb 2007 16:12:12 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <12fms2hjc83a3lr46fuvthjvrq15bdngso@4ax.com>

On Thu, 8 Feb 2007 12:32:03 +0000 (UTC),
vjp2.at@at.BioStrategist.dot.dot.com wrote:

>(0) Ok, back up to the beginning (thanks,sorry).

Of what?!? *P-L-E-A-S-E* quote something of the message you reply to!!

>tried perl -pe 'print "goat \n"' on Unix and perl -pe "print 'goat \n'" on DOS
>
>both cases it stood there waiting for further input

That's to be expected. That's what -p does. It "adds something" around
you code. Just see for yourself:

  perl -MO=Deparse, -pe ""

>(1) This is what I ran on Unix
>
>perl -pe 'if ($.%4==2) {$_ .= qq(\n).q(-) x 37} elsif ($.%4==0) {$_ .= qq(\n).q(=) x 37} else {$_ .= qq(\n)}' junk.tmp
>
>and what I got was "command not found" three times.

I don't. And I don't see any reason why I should.

>(2) I was familiar with += form other languages but when I saw $_.= I thought
>$_. and = , not $_ and .=

Yet there are many others as well, as you can clearly see in

  perldoc perlop

>(3) Eventually I want to reformat the paragraphs to 37 characters wide
>(looking for code to borrow) so I will probably not keep this as a one-liner.

You may consider giving a peek into Text::Wrap, as hinted in my other
post.

>				    - = -

Can you please use a standard .sig delimiter, so that a compliant
client will strip it duly?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 08 Feb 2007 16:16:03 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <cffms2d8ujr7cae5r47jo35ln6ebapptrv@4ax.com>

On Wed, 07 Feb 2007 13:35:47 -0800, Joe Smith <joe@inwap.com> wrote:

>> For "internal" strings you can use alternate delimiters.
>
>Don't forget to mention alternate quoting syntax: q() and qq().
>
>   $_ .= qq(\n) . q(-) x 37;

Well, all this thread is much in a "spoon feed me" fashion. And I
tried to point the OP to the documentation repeatedly, so as to
*encourage* him/her to RTFM rather than blindily asking here.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 08 Feb 2007 16:24:24 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <gmfms25llud6v5bsdhtn1s33age5bruhqm@4ax.com>

On Thu, 8 Feb 2007 13:41:33 +0000 (UTC),
vjp2.at@at.BioStrategist.dot.dot.com wrote:

># - This worked as a perl program just fine
>#      I still have no idea why the command line didn't

Hard to say without seeing the actual command line one.

># - what are the relevant perl/bin top line commands?

Huh?!? Are you referring to the shebang line? That is usually

  #!/usr/bin/perl

or

  #!/usr/bin/env perl

>#      I took something from a sample and it didn't like it

What didn't like what?

># - I want to make this a "routine" with the 37 being a parameter.

Read

  perldoc perlsub

Then wrap around your code below a sub passing a $length parameter
(and possibly a filehandle one as well, instead of having to use ARGV)
and proceed from there.

># - is wrap a standard function in perl? v4 and v5?

  perldoc -f wrap

>#     Would I be able to wrap the whole file at 37 cols
>#       then insert the separators.

Is this a question? If so, then the answer is: it only depends on your
programming skills. As already suggested you may either use Text::Wrap
or, if for some reason it doesn't suit your needs, hack away its code.

>    while (<>) {
>       if ($.%4==2) {$_ .= qq(\n).(q(-) x 37).qq(\n)} 
>           elsif ($.%4==0) {$_ .= qq(\n).(q(=) x 37).qq(\n)} 
>          else {$_ .= qq(\n)}
>       print;
>       } continue {  close ARGV if eof }

(Code left here since I refer to it above.)


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 8 Feb 2007 15:44:37 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <eqfgh5$p12$1@reader2.panix.com>


*+-Huh?!? Are you referring to the shebang line? That is usually

*+-  #!/usr/bin/perl

Yeah, thanks.. the one I copied had switches on it, I guess

				    - = -
 Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
	   http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Homeland Security means private firearms not lazy obstructive guards]
 [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]


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

Date: Thu, 08 Feb 2007 10:27:44 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <_7idnfZ0i9M89lbYnZ2dnUVZ_vCknZ2d@comcast.com>

vjp2.at@at.BioStrategist.dot.dot.com wrote:
> In <45cb2f7a$0$28985$da0feed9@news.zen.co.uk> by Ian Wilson <scobloke2@infotop.co.uk> on Thu, 08 Feb 2007 14:11:04 +0000 we perused:
> *+-Because you used the -p option and didn't supply a filename?
> 
> Wait! How many filenames? In & out or only in?

You can discover the answer to that question yourself by reading the docs.
As many as you want (zero names = read from STDIN).
In only.

> What if out should be the terminal? 

The -p option does not change where STDOUT goes.


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

Date: Thu, 08 Feb 2007 23:27:39 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <et8ns25p7ap2vqqc23t7shg4m204bn6bhm@4ax.com>

On Thu, 8 Feb 2007 15:44:37 +0000 (UTC),
vjp2.at@at.BioStrategist.dot.dot.com wrote:

>*+-Huh?!? Are you referring to the shebang line? That is usually
>
>*+-  #!/usr/bin/perl
>
>Yeah, thanks.. the one I copied had switches on it, I guess

Then just see what those switches mean and do not copy them blindily.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 08 Feb 2007 23:27:43 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <jp8ns2hvfumkc7kg2650pvo0k27sbbvjeh@4ax.com>

On Thu, 8 Feb 2007 14:36:46 +0000 (UTC),
vjp2.at@at.BioStrategist.dot.dot.com wrote:

>Wait! How many filenames? In & out or only in? 

Just as many as you like. Or none. In which case your program will
wait to read from STDIN.

>What if out should be the terminal? 

Huh?!?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 8 Feb 2007 19:21:55 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <slrnesnj5j.lhb.tadmc@tadmc30.august.net>

Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Wed, 7 Feb 2007 07:42:33 +0000 (UTC),
> vjp2.at@at.BioStrategist.dot.dot.com wrote:


>: perl -pe 'if ($.%4==2){$_.="-" x 37} elseif {$.%4==0) {$_.="=" x 37} $_.="\n"'
>                         ^
>                         ^
>
> Apart that the underlined curly above should
> really be a paren, and that "elseif" should be spelled "elsif".


All of that was pointed out to this poster 4 months ago when he
posted this exact same code...

Message-Id: <slrnehvihv.jkv.tadmc@magna.augustmail.com>


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


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

Date: Fri, 9 Feb 2007 12:03:47 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <eqhnv3$dul$1@reader2.panix.com>

BTW, my main problem was DOS-UNIX cr/lf.. stay tuned


				    - = -
 Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
	   http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Homeland Security means private firearms not lazy obstructive guards]
 [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]


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

Date: Fri, 09 Feb 2007 15:04:14 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <8ovos2ho7vgf2hmri65fhalp0t4kvauupp@4ax.com>

On Thu, 8 Feb 2007 19:21:55 -0600, Tad McClellan
<tadmc@augustmail.com> wrote:

>All of that was pointed out to this poster 4 months ago when he
>posted this exact same code...
>
>Message-Id: <slrnehvihv.jkv.tadmc@magna.augustmail.com>

It's not on my newsserver, but I could find it on GG. Indeed at least
there one could understand the reason why he was asking whether it
were 'x' or '*'.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 09 Feb 2007 15:09:09 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <qqvos2t4grm42134spuknr2t75dmu704kr@4ax.com>

On Fri, 9 Feb 2007 12:03:47 +0000 (UTC),
vjp2.at@at.BioStrategist.dot.dot.com wrote:

>BTW, my main problem was DOS-UNIX cr/lf.. stay tuned
>
>
>				    - = -

Personally I've tried to be helpful as much and as long as possible.
But, also in view of Tad's pointing out that you posted the very same
question 4 months ago, due to your repeated refusal to quote properly
and to use a proper .sig separator, I think I'm gonna killfile you.


PS: you don't even mind specifying whether the problem you had with
line endings was in the source or had to do with the file(s) you're
processing.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

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 V11 Issue 126
**************************************


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