[17263] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4685 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 21 18:05:41 2000

Date: Sat, 21 Oct 2000 15:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972165912-v9-i4685@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 21 Oct 2000     Volume: 9 Number: 4685

Today's topics:
        Deleting lines in a text file??? <tony.dalbrekt@swipnet.se>
    Re: Deleting lines in a text file??? <simonis@myself.com>
    Re: Dynamic Regex building? <bkennedy@hmsonline.com>
        ftp with perl. <yilias@hotmail.com>
    Re: ftp with perl. (Clay Irving)
    Re: ftp with perl. <tony_curtis32@yahoo.com>
    Re: help printing variable in table <simonis@myself.com>
    Re: help printing variable in table <erin@emmweb.com>
    Re: Help with array concatenation (Tad McClellan)
    Re: here and filehandle <uri@sysarch.com>
    Re: here and filehandle <harrisr@bignet.net>
    Re: here and filehandle <adalessandro@odione.com>
    Re: here and filehandle (Andrew J. Perrin)
    Re: here and filehandle <ryantate@OCF.Berkeley.EDU>
        newline in Unix and DOS [Was: Removing line breaks from <MBalenger@worldnet.att.net>
    Re: palm wap sorta a perl question <gus@black.hole-in-the.net>
    Re: Perl 5.005 or 5.6? (Tad McClellan)
    Re: perldoc equivalent (Tad McClellan)
    Re: perldoc equivalent <tzz@heechee.beld.net>
    Re: Regex and end of line wierdness (Ilya Zakharevich)
    Re: Removing line breaks from a string - HELP! <godzilla@stomp.stomp.tokyo>
    Re: Removing line breaks from a string - HELP! <ryantate@OCF.Berkeley.EDU>
    Re: Removing line breaks from a string - HELP! <andy@andyuk.net>
    Re: should be easy, but not working - help ! <none@nospam.com>
        still need help/beginner....pulling my hair ! <none@nospam.com>
        use linux cmd 'passwd' with perl <jonas@free-support.de>
    Re: use linux cmd 'passwd' with perl <tony_curtis32@yahoo.com>
    Re: use linux cmd 'passwd' with perl <jonas@free-support.de>
        Using text file to display form data <thectrain@hotmail.com>
        Windows directory separators [was Re: Writing multiple  <MBalenger@worldnet.att.net>
    Re: Windows directory separators [was Re: Writing multi (Logan Shaw)
    Re: Writing multiple files to a particular directory (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 21 Oct 2000 21:16:21 +0200
From: "Tony Dalbrekt" <tony.dalbrekt@swipnet.se>
Subject: Deleting lines in a text file???
Message-Id: <YSlI5.3454$Z75.8952@nntpserver.swip.net>

How do I delete selected lines in a text file?

//Tony




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

Date: 21 Oct 2000 19:27:47 GMT
From: Drew Simonis <simonis@myself.com>
Subject: Re: Deleting lines in a text file???
Message-Id: <39F1EB79.F2418242@myself.com>

Tony Dalbrekt wrote:
> 
> How do I delete selected lines in a text file?
> 
> //Tony

Have you read the FAQ?  Please do start there.


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

Date: Sat, 21 Oct 2000 19:31:56 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Dynamic Regex building?
Message-Id: <MamI5.61419$td5.9352514@news1.rdc2.pa.home.com>


"Michael Hoffman" <mrh@panix.com> wrote in message
news:8sqglc$3o8$1@news.panix.com...
>
> Lets say I want to add 3 new fields between the 2nd and 3rd field.
> $orig = ^([^\|]*)\|([^\|]*)\|([^\|]*)\|$
> $repl = $1|$2||||$3|
>
> Given Data like:  Hi|Hello|Howdy|
> I am returned:    $1|$2||||$3|
>
> How do I get Perl to recognize the $repl string as a Regex?  Before you
> suggest using "/e", I did that already with no change in results.

The replacement pattern is not a regexp, its just an interpolated string (or
chunk of code with /e).  Thus there are pitfalls since $1, $2 have to be
filled at runtime.  Unless this happens, the string that contains $1 and $2
etc will just contain those literal strings.  You can fix this by eval'ing
the replacement expression:

my $orig = '^([^\|]*)\|([^\|]*)\|([^\|]*)\|$';
my $repl = '$1|$2||||$3|';

my $text = "aaaaaaaaaa|bbbbbbbbbb|cccccccccccccc|";
$text =~ s/$orig/eval qq{"$repl"}/e;

# the qq is a generalized way of saying eval "\"$repl\""

print "Out: $text\n";

However, the cleanest way is to get your data into an array with split(),
then use splice() to add elements, then output with join().  It is also
better to try to boil down your questions a bit - a lot of people tune out
posts that contain a lot of code.  Hope this helps --

--Ben Kennedy





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

Date: Sat, 21 Oct 2000 20:14:45 GMT
From: "ronald" <yilias@hotmail.com>
Subject: ftp with perl.
Message-Id: <VOmI5.504$iF1.4942@typhoon.bart.nl>

Could someone tell me how i can make a connection via ftp with perl scipt?
It is for a web-site.
The username and password are predefined. Also the folder to upload is
predefined.

who could help me.


tnx
Ronald




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

Date: 21 Oct 2000 20:20:02 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: ftp with perl.
Message-Id: <slrn8v3uji.j8r.clay@panix2.panix.com>

On Sat, 21 Oct 2000 20:14:45 GMT, ronald <yilias@hotmail.com> wrote:

>Could someone tell me how i can make a connection via ftp with perl scipt?
>It is for a web-site.
>The username and password are predefined. Also the folder to upload is
>predefined.

The Net::FTP module perhaps?

-- 
Clay Irving <clay@panix.com>
I didn't claw my way to the top of the food chain just to eat leaves! 
- Michael Rivero 


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

Date: 21 Oct 2000 15:20:29 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: ftp with perl.
Message-Id: <874s26c5f6.fsf@limey.hpcc.uh.edu>

>> On Sat, 21 Oct 2000 20:14:45 GMT,
>> "ronald" <yilias@hotmail.com> said:

> Could someone tell me how i can make a connection via
> ftp with perl scipt?  It is for a web-site.  The
> username and password are predefined. Also the folder to
> upload is predefined.

http://search.cpan.org/doc/GBARR/libnet-1.0703/Net/FTP.pm

Install it with cpan (or ppm if ActiveState).

> who could help me.

CPAN could!  And did :-)

hth
t
-- 
Eih bennek, eih blavek.


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

Date: 21 Oct 2000 19:33:34 GMT
From: Drew Simonis <simonis@myself.com>
Subject: Re: help printing variable in table
Message-Id: <39F1ECD4.B2A666B2@myself.com>

"Erin M. McDaniel" wrote:
> 
> I have a variable, $comments, which is a long text field stored in a
> mysql database. When I try to print that variable's value in a table, it
> won't work. If I use:
> 
> print $comments;
> 
> it works fine.
> 
> If I print other variables which are only a word or two long, in a table
> that works fine. But trying to print $comments in a table is not
> working. Here's that portion of my code:

"not working" helps no one to work on this problem with you.
Can you be more specific?  If the output isn't as you expect,
what is it?  Is there any output at all?  Have you tried 
debugging from a command line?  Be as specific as possible.


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

Date: Sat, 21 Oct 2000 15:50:32 -0500
From: "Erin M. McDaniel" <erin@emmweb.com>
Subject: Re: help printing variable in table
Message-Id: <39F20198.5B6805F7@emmweb.com>

there is no output at all. However, if I just use

print $comments;

the output is perfect. There is no output however if it is placed inside a
table.


Drew Simonis wrote:

> "Erin M. McDaniel" wrote:
> >
> > I have a variable, $comments, which is a long text field stored in a
> > mysql database. When I try to print that variable's value in a table, it
> > won't work. If I use:
> >
> > print $comments;
> >
> > it works fine.
> >
> > If I print other variables which are only a word or two long, in a table
> > that works fine. But trying to print $comments in a table is not
> > working. Here's that portion of my code:
>
> "not working" helps no one to work on this problem with you.
> Can you be more specific?  If the output isn't as you expect,
> what is it?  Is there any output at all?  Have you tried
> debugging from a command line?  Be as specific as possible.



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

Date: Sat, 21 Oct 2000 12:47:55 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with array concatenation
Message-Id: <slrn8v3i5r.70b.tadmc@magna.metronet.com>

On Sat, 21 Oct 2000 12:40:58 -0400, Jody Fedor <Jodyman@usa.net> wrote:
>Uri Guttman wrote in message ...
>>>>>>> "JF" == Jody Fedor <Jodyman@usa.net> writes:
>>
><snip>
>>-w is good. why no use strict?
>>
>
>I'm a lazy programmer! :-)


No you're not.

Lazy programmers want the machine to find errors in milliseconds,
rather than find them themselves in seconds/minutes/hours
(that a *whole lot* of milliseconds).

Lazy programmers want all the help they can get because, ...well,
because they are lazy  :-)

Lazy programmers always enable warnings and use strict so
a machine can find errors for them.


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


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

Date: Sat, 21 Oct 2000 18:03:58 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: here and filehandle
Message-Id: <x7og0eoyuv.fsf@home.sysarch.com>

>>>>> "AD" == Arthur Dalessandro <adalessandro@odione.com> writes:

  AD>         print SMB_CONF <<END_OF_FILEHANDLE; # line 67 **
  AD>         writable = yes
  AD>         create mask = 0700
  AD>         directory mask = 0700

BIG snip>


  AD> END_OF_FILEHANDLE
  AD>         close (SMB_FILE);

  AD> It produces this error:
  AD> Use of uninitialized value at ./artd.test.escalateaddcompany.pl line 67.
  AD> Use of uninitialized value at ./artd.test.escalateaddcompany.pl line 67.

  AD> Any help would be greatly appreciated.. Thanks.

well, at least you said in another post it is working, because the code
looks fine. now, as for your uninitialized values, that means YOU HAVE
THEM. where? inside the here document itself. the line number is
slightly misleading but that is where the here doc starts. perl is not
counting lines in the doc text for you.

so caefully check the output and see where you are not interpolating
anything. check that all your vars inthe doc are set to something defined.

you can print out or use any of the variables individually to isolate
which ones are undefined.

and next time, be clearer about the problem. your here doc works, your
data is bad.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 21 Oct 2000 14:49:58 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: here and filehandle
Message-Id: <sv3p9i8qg23853@corp.supernews.com>

Arthur Dalessandro <adalessandro@odione.com> wrote in message
news:sv3ldnv2j5idc@corp.supernews.com...
> Here is my current code example:
>         # Writes out an SMB conf file, and dates.
>         $SMB_CONF_FILE = '/tmp/artd.testing';
>         open SMB_CONF,">${SMB_CONF_FILE}" or die "Can't create
> $SMB_CONF_FILE\n";
>         print SMB_CONF <<END_OF_FILEHANDLE; # line 67 **
[snip...]

One simple approach to finding the problem, might be to simply examine
your output file to see which of the variables didn't interpolate.
There aren't that many variables in your here document, it should be
easy to compare to the output.

Also, keep in mind, you are getting two uninitialized value errors,
$companyid is used several times, $ip and $netmask are each used once.
(just a guess)

Randy Harris




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

Date: Sat, 21 Oct 2000 14:57:36 -0400
From: "Arthur Dalessandro" <adalessandro@odione.com>
Subject: Re: here and filehandle
Message-Id: <sv3pp7c1i5nj0d@corp.supernews.com>

I didn't think to look anywhere but the line 67 where the error was getting
reported.. Thanks.....

"Randy Harris" <harrisr@bignet.net> wrote in message
news:sv3p9i8qg23853@corp.supernews.com...
> Arthur Dalessandro <adalessandro@odione.com> wrote in message
> news:sv3ldnv2j5idc@corp.supernews.com...
> > Here is my current code example:
> >         # Writes out an SMB conf file, and dates.
> >         $SMB_CONF_FILE = '/tmp/artd.testing';
> >         open SMB_CONF,">${SMB_CONF_FILE}" or die "Can't create
> > $SMB_CONF_FILE\n";
> >         print SMB_CONF <<END_OF_FILEHANDLE; # line 67 **
> [snip...]
>
> One simple approach to finding the problem, might be to simply examine
> your output file to see which of the variables didn't interpolate.
> There aren't that many variables in your here document, it should be
> easy to compare to the output.
>
> Also, keep in mind, you are getting two uninitialized value errors,
> $companyid is used several times, $ip and $netmask are each used once.
> (just a guess)
>
> Randy Harris
>
>




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

Date: 21 Oct 2000 14:33:31 -0500
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: here and filehandle
Message-Id: <87bswem1kk.fsf@nujoma.perrins>

"Arthur Dalessandro" <adalessandro@odione.com> writes:

> I am trying to print to a filehandle using the HERE document type, it is not
> working, any ideas on how to accomplish this task?
>     open (SMB_CONF,">>$SMB_CONF_FILE");
>      print SMB_CONF <<EOF;

Lose the ; here

> ....
> .....
> EOF

and add it here.

open (SMB_CONF, ">>$SMB_CONF_FILE") or die $!;
print SMB_CONF <<EOF
 ....
 .....
EOF;

----------------------------------------------------------------------
Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology  
Chapel Hill, North Carolina, USA - http://demog.berkeley.edu/~aperrin
        aperrin@socrates.berkeley.edu - aperrin@igc.apc.org


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

Date: 21 Oct 2000 21:10:41 GMT
From: Ryan Travis Tate <ryantate@OCF.Berkeley.EDU>
Subject: Re: here and filehandle
Message-Id: <8st0oh$9dq$2@agate.berkeley.edu>

 |>      print SMB_CONF <<EOF;

goddamnit everyone -- QUOTE MARKS!!

print SMB CONF <<"EOF";

like that. i pulled out my camel book and everything ...


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

Date: Sat, 21 Oct 2000 21:24:05 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: newline in Unix and DOS [Was: Removing line breaks from a string - HELP!]
Message-Id: <VPnI5.1523$MR3.79698@bgtnsc04-news.ops.worldnet.att.net>
Keywords: DOS HPUX newline

Along a similar line:

Seems that within Perl "\n" means different things on Unix and Win32
systems.  (So far, no brainer.  Classic Unix vs. DOS (and of course
WinDOS) brain split.)

Here's where the brain split comes in for me.

Where does the translation happen?


My experimental data:

================================================================
On WinDOS (using MKS ksh (accidently spelled sh))

# DOS Perl thinks "\n" is *one* character.
$ perl -e '$x="\n"; print length "$x", "\n";'
1

# The shell sees *two* characters.
$ perl -e '$x="\n"; print $x;' | wc -c
      2

# And here are the *two* characters that it sees.
$ perl -e '$x="\n"; print $x;' | od -cx
0000000000    \r  \n
                0A0D

================================================================
On HPUX (using (appropriately spelled) ksh)
# HPUX Perl thinks "\n" is *one* character - same as DOS
$ perl -e '$x="\n"; print length "$x", "\n";'
1

# The shell sees *one* character - unlike DOS.
$ perl -e '$x="\n"; print $x;' | wc -c
      1

# And here is the *one* character that it sees - unlike DOS.
$ perl -e '$x="\n"; print $x;' | od -cx
0000000    0a00
         \n

================================================================

Summary.

Consistency: Internally to Perl, "\n" is one character in DOS and
HPUX.

Inconsistency: Looking at Perl's STDOUT gives different results.  DOS
shows 2 characters.  HPUX shows 1 character.

# Literal   DOS          HPUX
# \n        \0x0A\0x0D   \0x0A

# Hex     Octal   Dec   ASCII Ctrl
# \x0A == \012 == 10 == nl == \cJ
# \x0D == \015 == 13 == cr == \cM


================================================================

Questions:

Where does the translation happen?

Is there a dos2unix or unix2dos translation program or module?


================
Extra credit:

Are these programs portable?  (i.e. do both programs work in both
environments?).  I have written both programs in both environments,
but they are different programs.  (i.e. they are *not* portable).  I
think that's because I'm trying to use the \n and \r literals.  I have
a feeling that using hex characters would work, but haven't tried it
yet.


================
Real Motivation:

I'm transferring source code and data from my home office PC to my
client site Unix machine.





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

Date: Sat, 21 Oct 2000 19:10:58 GMT
From: Gus <gus@black.hole-in-the.net>
Subject: Re: palm wap sorta a perl question
Message-Id: <972155458.14207.0.nnrp-09.c29f015a@news.demon.co.uk>

Kermit Lowry, III <ultrak@my-deja.com> wrote:
> I am reverting to this forum because I have been spurned during 5 days
> of research where I have joined every WAP development list ever
> produced.

Oh. Have you tried http://www.egroups.com/group/wmlprogramming and
http://mail.anywhereyougo.com/mailman/listinfo/wap-dev ? Both are
good.

> I have been given the job of writing some cgi (in Perl) that will
> direct the client/browser to palm vii specific code (wml?) if the
> client is a palm.

Check the HTTP_ACCEPT header. 

use CGI::WML;
$q = CGI::WML->new();

if ($q->http('accept') !~ /vnd\.wap\.wml/) {
    print
        $q->redirect("http://othersite/htmlstuf/");
}else{
   dostuff($q);
}

> I am expecting to use m/.wml\b/ or something similar on the http_accept
> environment variable and/or using http_user_agent on a list of wap
> browser types.

Don't look at the USER_AGENT stuff, or you'll enslave yourself to keeping
your application up to date with every new device/browser etc. Of course
the best solution is to use a different URL.

> Does anyone have experience and perhaps a code snippet for doing such?
> I've seen that there is a CGI::WAP but I think that that is for
> formating pages.  Is this correct?

It's CGI::WML, not CGI::WAP (I'm the author). CGI::WAP was a mistake I
made a few months ago when uploading to PAUSE for the first time.

CGI::WML is a subclass of CGI.pm, so it does all the general CGI.pm
goodies adds WML-specific bits, as well as overriding some CGI.pm methods
like the default content-type. 

BTW, this really belongs in comp.infosystems.www.authoring.cgi

Followups set.

Regards,
	_Gus


-- 
gus@black.hole-in-the.net
0x58E18C6D
82 AA 4D 7F D8 45 58 05  6D 1B 1A 72 1E DB 31 B5
http://black.hole-in-the.net/gus/


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

Date: Sat, 21 Oct 2000 13:00:35 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl 5.005 or 5.6?
Message-Id: <slrn8v3itj.70b.tadmc@magna.metronet.com>

On Sun, 22 Oct 2000 01:15:12 +1000, Marc Fearby <marc@fearby.com> wrote:

>The Perl re-write that's supposed to be going on - will that be Perl 6?
>If so, would it be better to wait for that instead?


I expect there won't be a stable release of Perl 6 for 18-24 months.

That's too long to wait.

Don't think about Perl 6 yet.


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


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

Date: Sat, 21 Oct 2000 13:14:21 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: perldoc equivalent
Message-Id: <slrn8v3jnd.70b.tadmc@magna.metronet.com>

On Fri, 20 Oct 2000 23:41:12 +0100, James Taylor 
   <james@NOSPAM.demon.co.uk> wrote:
>Not a single thread in this group goes by without someone posting a
>perldoc reference. 


>Can someone 


How about some thing instead of someone?


>tell me what the various incantations of
>perldoc actually 


You read the documentation for perldoc. If you need more,
you read the source code for perldoc.


>Perhaps there is already a version of perldoc written in Perl


There is. It is called 'perldoc'  :-)


>Without *some* kind of perldoc equivalent many of the answers given
>on this group are completely unhelpful
                   ^^^^^^^^^^

They are not _completely_ unhelpful.

You just need to know what perldoc's switches do (perldoc perldoc),
then translate it into English.

   perldoc -f sort  ==>  "See the sort() function in perlfunc.pod"

   perldoc -q sort  ==>  "See the FAQs that mention sorting in the
                          perlfaq[1-9].pod files"

   perldoc perlrun  ==>  "See the perlrun.pod file"

   perldoc Obscure::Module  ==>  "See the docs embedded in the module's source"



Hmmm. It might be kind of fun to write a 'perldoc2english' script...


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


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

Date: 21 Oct 2000 15:04:37 -0400
From: Ted Zlatanov <tzz@heechee.beld.net>
Subject: Re: perldoc equivalent
Message-Id: <m3snpq10e2.fsf@heechee.beld.net>

James Taylor <james@NOSPAM.demon.co.uk> writes:

> Not a single thread in this group goes by without someone posting a
> perldoc reference. This has long been a frustration to me because I do
> not have perldoc on my RISC OS machine or my EPOC device, even though
> I have Perl for both.
> 
> Without *some* kind of perldoc equivalent many of the answers given
> on this group are completely unhelpful, and I can't be the only one
> in this position. If you can give me enough detail to completely
> duplicate perldoc for use with the HTML docs, then my resulting
> program may be useful to many.

You could try http://www.perldoc.com, if that works on your platform.
It's a very nice website, I think - thanks to Carlos Ramirez, the
maintainer.

-- 
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais


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

Date: 21 Oct 2000 19:38:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Regex and end of line wierdness
Message-Id: <8ssrbc$o6b$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Bart Lateur 
<bart.lateur@skynet.be>],
who wrote in article <2aqvus03vrvl6bo2rhlalgva4e8qldsb07@4ax.com>:
>  * Make sure that your string doesn't contain a newline. For example,
> you can test for /\n/.
> 
>  * Replace '$' with '\z', which *really* means end of string, not "end
> of line".

In retrospect, it is clear that my choice `\z' of the name for this
construct was not the best one possible.  Obviously, it should have
been written as `$$$'.

And for those who wonder how to read `??', `$$$' should be read

  End-of-string.  Yes, I really mean it.  Pleeeease?

Ilya


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

Date: Sat, 21 Oct 2000 11:19:58 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <39F1DE4E.DEE2609B@stomp.stomp.tokyo>

Randy Harris, really pissed off, hisses:
 
> Godzilla! posted true test results:
> > Clay Irving posted fake code results:

(snipped)

> Either you invented your PRINTED RESULTS or you didn't run the code
> posted by Clay.  Not malice, just fact.


 
Have you considered others may very well copy
and paste your code and data, verbatim, then
run tests of their own, Frank?

* enjoys another laugh *

I love the smell of cyber-napalm in the morning.


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: 21 Oct 2000 20:57:01 GMT
From: Ryan Travis Tate <ryantate@OCF.Berkeley.EDU>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <8ssvut$9dq$1@agate.berkeley.edu>

AndyUK <andy@andyuk.net> wrote:
 | at the moment i have a form which submits a <textarea> field to a text file.
 | I want the line breaks that are make in the <textarea> field to be converted
 | to <br> tags. (Which i can then put into a HTML page).

 | If i submit this...

 | --------------
 | Line 1

 | Line 2

 | -------------------
 | I get this returned:
 | --------------------
 | Line 1
 | <br>
 | Line 2
 | <br>
 | -------------------
 | This is what i would like to get returned....
 | ------------
 | Line 1<br>Line 2<br>
 | -----------------------

i was able to reproduce your problem ...

adding the following line before the \n/<br> replacement made it work for
me:
$mystring =~ s/\r//g;

there are hard carriage returns in the form input string that are not
replaced by your regex. they seem to appear along with the newlines
(\n) rather than in place of them, strangely.

this is why the tests of other posters did not reveal the problem -- the
issue is how the form and/or CGI.pm are modifying the input string, not
with the regex.

cheers
ryan


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

Date: Sat, 21 Oct 2000 22:58:12 +0100
From: "AndyUK" <andy@andyuk.net>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <1boI5.3113$Ms3.136096@stones>

Thanks for all your help guys..got the problem sorted now!

Ryan had the anwser i was looking for. The hard carriage returns were not
being taken out of the string, so that created a line break in the text file
that i didn't want.

Thanks again,

Andy


> i was able to reproduce your problem ...
>
> adding the following line before the \n/<br> replacement made it work for
> me:
> $mystring =~ s/\r//g;
>
> there are hard carriage returns in the form input string that are not
> replaced by your regex. they seem to appear along with the newlines
> (\n) rather than in place of them, strangely.
>
> this is why the tests of other posters did not reveal the problem -- the
> issue is how the form and/or CGI.pm are modifying the input string, not
> with the regex.
>
> cheers
> ryan
> -- end of forwarded message --
>
>
>
> _________________________________
> Ryan Tate
> mailto:ryan.tate@bigfoot.com
> fax:603.590.1672
>




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

Date: Sat, 21 Oct 2000 16:50:03 -0400
From: "none" <none@nospam.com>
Subject: Re: should be easy, but not working - help !
Message-Id: <19nI5.1950$bM2.2828@newsfeed.slurp.net>

Thanks for the help, but that didn't work either.
Any other ideas ?

"Gwyn Judd" <tjla@guvfybir.qlaqaf.bet> wrote in message
news:slrn8v2haf.clf.tjla@thislove.dyndns.org...
> I was shocked! How could none <none@nospam.com>
> say such a terrible thing:
> >I have the following code, basically all I need to do is from a form that
> >allowed multiple checkboxes, is count the number of boxes that were
checked.
>
> >@line = qw($input{toppings});
> >$toppingtotal = @line;
> >------------------
> >$toppingtotal shows as a value of 1, even when checking them all.
> >I also tried it without the qw and it didn't work.
>
> You mean, I think:
>
> @line = @{$input{toppings}};
> $toppingtotal = @line;
>
> $input{toppings} is a *scalar* value, so I guess it is a reference to an
> array, therefore you need to dereference it. The 'qw($input{toppings})'
> thing is just wrong. If you did a 'print @line' after doing that, you
> would know what it actually does, which I think is different from what
> you think it does. I think.
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> Psychiatry enables us to correct our faults by confessing our parents'
> shortcomings.
> -- Laurence J. Peter, "Peter's Principles"




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

Date: Sat, 21 Oct 2000 17:37:57 -0400
From: "none" <none@nospam.com>
Subject: still need help/beginner....pulling my hair !
Message-Id: <2TnI5.1990$bM2.1631@newsfeed.slurp.net>

All this has to do is COUNT the freakin numer of boxes that were checked for
toppings - all it ever shows is 1.  I've tried everything, including adding
spaces after the topping value in the form, etc.  Anyway to get this to
work, I've only wasted around 4 hours on it.

Thanks. (see bottom part of program for 'toppings' - that's what I'm trying
to count) also in sub order_form_pizza you can see where I am mixing and
matching values (with space, with comma, without, etc) trying to get
something to work.  None of it does.  $test has a value of 1 when I display
it.  aline,s1line,sline,toptot are all blank.


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

#!c:\perl\bin\perl.exe
# This is pizzahome.pl

require 'cgi-lib.pl';

$now = localtime;

&ReadParse(*input);

print "Content-type: text/html\n\n";

if ($input{form} eq "form_1") {
   &name_address_form;
} elsif ($input{form} eq "form_2") {
   &order_form_pizza;
} elsif ($input{form} eq "form_3") {
   &order_form_payment;
} elsif ($input{form} eq "form_4") {
   &order_form_thanks;
} else {
   &name_address_form;
}


sub name_address_form
{
 print qq~
 <html>
 <head>
   <title>Perfect Pizza Order Form: Name and Address</title>
 </head>
 <body>
   <h2>Perfect Pizza Order Form: Name and Address</h2>
   <p>Please enter your name, address and phone number below</p>

   <form action="/cgi-bin/pizzaorder.pl" method="post">
     <input type="hidden" name="form" value="form_2">
     <table border="0">
       <tr><td>Name:</td>
           <td><input type="text" name="name"></td></tr>
       <tr><td>Address:</td>
           <td><input type="text" name="address"></td></tr>
       <tr><td>Phone:</td>
           <td><input type="text" name="phone"></td></tr>
       <tr><td></td>
           <td><input type="submit" value="Continue">
               <input type="reset" value="Clear Form"></td></tr>
     </table>
   </form>
  </body>
  </html>~;
} # end of entering name and address

sub order_form_pizza
{
  print qq~
 <html>
  <head>
    <title>Perfect Pizza Order Form: Pizza</title>
  </head>
  <body>
  <h2>Perfect Pizza Order Form: Pizza</h2>
  <p>Please customize your pizza below.</p>

  <form action="/cgi-bin/pizzaorder.pl" method="post">
    <input type="hidden" name="form" value="form_3">
    <input type="hidden" name="name" value="$input{name}">
    <input type="hidden" name="address" value="$input{address}">
    <input type="hidden" name="phone" value="$input{phone}">
    <table border="0">
      <tr><td>What size pizza would you like?<p></td></tr>
      <tr><td><input type="radio" name="pizzasize" value="Small">Small<br>
              <input type="radio" name="pizzasize" value="Medium">Medium<br>
              <input type="radio" name="pizzasize" value="Large"
checked>Large<br>
              <input type="radio" name="pizzasize"
value="X-Large">X-Large<p></td></tr>

      <tr><td>Which toppings would you like? (All pizzas include cheese and
tomato sauce)<p></td></tr>
      <tr><td><input type="checkbox" name="toppings" value="X-Cheese,
">Extra Cheese<br>
              <input type="checkbox" name="toppings" value="Pepperoni,
">Pepperoni<br>
              <input type="checkbox" name="toppings" value="Sausage,
">Sausage<br>
              <input type="checkbox" name="toppings" value="Onion">Onion<br>
              <input type="checkbox" name="toppings"
value="Anchovy">Anchovy<br>
              <input type="checkbox" name="toppings"
value="Mushroom">Mushroom<br>
              <input type="checkbox" name="toppings" value="Ham">Ham<br>
              <input type="checkbox" name="toppings"
value="Pineapple">Pineapple<br>
              <input type="checkbox" name="toppings"
value="GreenPeppers">Green Peppers<br>
              <input type="checkbox" name="toppings"
value="JalepenoPeppers">Jalepeno Peppers<p></td></tr>

       <tr><td>Additional Comments:</td></tr>
       <tr><td><input type="text" name="comments" size="20"
maxlength="30"><p></td></tr>
       <tr><td><input type="submit" value="Continue">
               <input type="reset" value="Clear Form"></td></tr>
    </table>
  </form>

  </body>
  </html>~;


} # end of entering pizza selection

sub order_form_payment
{
  print qq~
 <html>
  <head>
    <title>Perfect Pizza Order Form: Payment</title>
  </head>
  <body>
  <h2>Perfect Pizza Order Form: Payment</h2>
  <p>Please select your payment option below.</p>

  <form action="/cgi-bin/pizzaorder.pl" method="post">
    <input type="hidden" name="form" value="form_4">
    <input type="hidden" name="name" value="$input{name}">
    <input type="hidden" name="address" value="$input{address}">
    <input type="hidden" name="phone" value="$input{phone}">
    <input type="hidden" name="pizzasize" value="$input{pizzasize}">
    <input type="hidden" name="toppings" value="$input{toppings}">
    <input type="hidden" name="comments" value="$input{comments}">

    <table border="0">
      <tr><td><input type="radio" name="payment" value="pickup">Pick-Up (No
Delivery)<p>
              <input type="radio" name="payment" value="COD"
checked>Cash/Check<p>
              <input type="radio" name="payment" value="charge">Charge
              <select name="chargetype" size="1">
                <option value="visa">Visa
                <option value="mc">Master Card
                <option value="amex">American Express
              </select>
          Card Number:<input type="text" name="cardnumber" size="20"
maxlength="30"><p></td></tr>
       <tr><td><input type="submit" value="Continue">
               <input type="reset" value="Clear Form"></td></tr>
    </table>
  </form>
  <input type="hidden" name="payment" value="$input{payment}">
  <input type="hidden" name="chargetype" value="$input{chargetype}">
  <input type="hidden" name="cardnumber" value="$input{cardnumber}">
  </body>
  </html>~;
} # end of entering pizza payment

sub order_form_thanks
{
  if ($input{pizzasize} eq "Small") {
      $pizzacost = 7;
  } elsif ($input{pizzasize} eq "Medium") {
      $pizzacost = 9;
  } elsif ($input{pizzasize} eq "Large") {
      $pizzacost = 10;
  } else {
      $pizzacost = 12;
  }

@line = @$input{toppings};
$test = @line;

$totalcost = $pizzacost + $toppingtotal;

  print qq~
<html>
  <head>
    <title>Perfect Pizza Order Form: Thanks</title>
  </head>
  <body>
  <h2>Thanks for your order!</h2>

  <table>

    <tr><td>Your pizza will be delivered piping hot in 30 minutes or less.
If you chose "Pick-Up", your pizza will be ready in about 10
minutes.</td></tr>
    <tr>
  </table>

    test = $test<br>
    aline = @line<br>
    s1line = $line[0]<br>
    sline = $line<br>
    toptot = $toppingtotal<br>
    name=$input{name}<br>
    address=$input{address}<br>
    phone=$input{phone}<br>
    pizzasize=$input{pizzasize}<br>
    toppings=$input{toppings}<br>
    payment=$input{payment}<br>
    chargetype=$input{chargetype}<br>
    cardnumber=$input{cardnumber}<br>
    total=$totalcost
    comments=$input{comments}
<p>
<a href="/pizzahome.html">Return Home</a>
 </body>
  </html>
~;
}










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

Date: Sat, 21 Oct 2000 22:06:27 +0200
From: Jonas Ryser <jonas@free-support.de>
Subject: use linux cmd 'passwd' with perl
Message-Id: <39F1F743.A35347D2@free-support.de>

Hi,

I'm searching a possibility to use shell progs such as passwd or su in
perl.
I know how to start passwd, but if passwd asks for the password I can't
print the passwd to the prog. I tried out that:

open (PASSWD, "|/bin/passwd");
print PASSWD "password\r";
close PASSWD;

I also tried to use \n instead of \r and to use them both. 

Does anybody know how to do that?


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

Date: 21 Oct 2000 15:50:01 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: use linux cmd 'passwd' with perl
Message-Id: <87og0ddime.fsf@limey.hpcc.uh.edu>

>> On Sat, 21 Oct 2000 22:06:27 +0200,
>> Jonas Ryser <jonas@free-support.de> said:

> Hi, I'm searching a possibility to use shell progs such
> as passwd or su in perl.  I know how to start passwd,
> but if passwd asks for the password I can't print the
> passwd to the prog. I tried out that:

> open (PASSWD, "|/bin/passwd"); print PASSWD
> "password\r"; close PASSWD;

passwd has to fiddle with a terminal to turn off echo.  It
doesn't read from stdin.

"perldoc -q password" may offer some enlightenment.  Also
see the Expect module,

  http://search.cpan.org/doc/RGIERSIG/Expect-1.08/Expect.pod

for how to automate interactive commands.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Sat, 21 Oct 2000 22:31:16 +0200
From: Jonas Ryser <jonas@free-support.de>
Subject: Re: use linux cmd 'passwd' with perl
Message-Id: <39F1FD14.284D415D@free-support.de>


> Also
> see the Expect module,

Exactly what I searched, thanks very much.

Jonas Ryser


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

Date: Sat, 21 Oct 2000 20:44:11 GMT
From: "Matt Perzel" <thectrain@hotmail.com>
Subject: Using text file to display form data
Message-Id: <venI5.30591$24.6690884@news0.telusplanet.net>

I am trying to make a program that reads a text file with a list of names in
it, then it uses the varibles that have the names from the file to get data
posted from the form. I can get the data from the form, read the text-file,
split the text file. Everything except use the varible name. Here is my code
if you can't understand my blabbering.

NOTE: When I try to use the headings, nothing is displayed. But when I hard
code it, it works.

#!/usr/bin/perl

#Get Data From Form *Works
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
}

#Open the headings text file
open(INF,"headings.dat")
@ary = <INF>;
close(INF);

#Write HTML

print "Content-type:text/html\n\n";
print <<EndHdr;
<html><head><title>FSA READ/WRITE TEST</title></head>
<body>
EndHdr

#This is where I am trying to use the headings from the file to display the
form data
foreach $i (@ary) {
    print $FORM{'$i'};
}
#Here is the problem

print <<EndFooter;
</body>
</html>
EndFooter





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

Date: Sat, 21 Oct 2000 20:37:42 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: Windows directory separators [was Re: Writing multiple files to a particular directory]
Message-Id: <q8nI5.2069$UL.112429@bgtnsc07-news.ops.worldnet.att.net>

> Using / separators instead of \ would have avoided
> the situation that led to this thread in the first place.


I recently found out that perl is happy to use "/" as a file separator on
Win32 systems.  Yeah!  That's great for me since I'm doing development at my
home office for a client running a Unix machine.

But I recently ran into the File::Spec module.  It returns files with "\\"
as file separators.  These work perfectly fine in my subsequent 'open'
commands, but they break some of my regular expressions that Ihad written to
look for "/".  Not a *big* deal.  I can go modify the RE's, but it does
point toward a maintenance portability problem.

So, the question.

Is there a canonical file naming module that would allow me to avoid having
to use RE's to munge file names?

Thanks,
Mike






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

Date: 21 Oct 2000 16:36:10 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Windows directory separators [was Re: Writing multiple files to a particular directory]
Message-Id: <8st28a$mib$1@provolone.cs.utexas.edu>

In article <q8nI5.2069$UL.112429@bgtnsc07-news.ops.worldnet.att.net>,
Michael Balenger <MBalenger@worldnet.att.net> wrote:
>I recently found out that perl is happy to use "/" as a file separator on
>Win32 systems.  Yeah!  That's great for me since I'm doing development at my
>home office for a client running a Unix machine.
>
>But I recently ran into the File::Spec module.  It returns files with "\\"
>as file separators.  These work perfectly fine in my subsequent 'open'
>commands, but they break some of my regular expressions that Ihad written to
>look for "/".  Not a *big* deal.  I can go modify the RE's, but it does
>point toward a maintenance portability problem.

You could use File::Spec's splitpath() and splitdir() to decompose the
pathname, then do your regexp(s) on whatever part(s) are needed, then
rebuild the path from the modified components.

This would involve rewriting all the code that munges paths, though.

  - Logan


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

Date: Sat, 21 Oct 2000 13:22:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Writing multiple files to a particular directory
Message-Id: <slrn8v3k71.70b.tadmc@magna.metronet.com>

On Fri, 20 Oct 2000 16:59:46 -0700, John W. Krahn <krahnj@acm.org> wrote:
>Jeff Zucker wrote:
>> 
>> "John W. Krahn" wrote:
>> >
>> > or
>> > open (FIXEDLOG, '>c:\baalogs\fixeddirectory\' . $fixed) ...
>> 
>> Did you try that one? :-)
>
>I'm running on Linux so I don't have a c: drive or \ directory
>separators. :-)


People on Windoze don't have to use \ directory separators either
(though lots of them think they must).

Only people using the command interpreter on Windows _have to_
use \ directory separators  :-)

     open (FIXEDLOG, '>c:/baalogs/fixeddirectory/' . $fixed) ...

should work fine on Windows.



Using / separators instead of \ would have avoided
the situation that led to this thread in the first place.


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


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4685
**************************************


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