[8332] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1949 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 22 01:08:48 1998

Date: Sat, 21 Feb 98 22:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 21 Feb 1998     Volume: 8 Number: 1949

Today's topics:
    Re: "Learning Perl" questions and frustrations <bf8$s03c92f97$a93d2@kf8nh.apk.net>
    Re: "Learning Perl" questions and frustrations <leviro@yahoo.com>
    Re: An easy question or two (Nathan V. Patwardhan)
        better way to do this? (blacktape)
    Re: better way to do this? (Steve Linberg)
    Re: better way to do this? (Craig Berry)
    Re: Cacheing and Back Button question. <ebohlman@netcom.com>
    Re: Can I write sockets apps with Perl + Win 95? (Jonathan Stowe)
    Re: CGI scripts and frames? (Jonathan Stowe)
    Re: CGI.pm error - Modification of Read-Only Value <mroeser@removethis.gte.net>
    Re: Delete record from fixed-length random access datab <beans@bedford.net>
        DES compilation. (with stdarg.h) <yingyang@knob.com>
    Re: executing perl scripts on NT (Jonathan Stowe)
        HELP - SQL into Access (win NT) from Perl (Ed Egan)
        Help need with SQL into Access database from Perl (Ed Egan)
    Re: Help need with SQL into Access database from Perl (Jim Michael)
    Re: Help please: Conversion problems from numeric to as (Craig Berry)
    Re: Home Page Click. <beans@bedford.net>
    Re: if (-d $filename) in Win32 perl.user@sndk.se
        Installation-Problem on NT 4.0 <p.wermelinger@bluewin.ch>
        Need autoreply script for addresses buried in text & ma <jp@glpbooks.BADMAIL.com>
    Re: newbie: breaking a line of text into two chunks (Jonathan Stowe)
    Re: Powered by Perl logo <bgrosman@healey.com.au>
        Regexp question... (Spencer Lu)
    Re: Regexp question... <doug@tc.net>
        Regexp question (Spencer Lu)
        Regexp question (Spencer Lu)
    Re: script incombatibility. (Jonathan Stowe)
    Re: SEND E-MAIL , HELP! (Ed Egan)
    Re: Sorting dbm files (and hashes) <beans@bedford.net>
    Re: ts: how to parse embedded commas <nardo@pobox.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 21 Feb 98 19:43:13 -0500
From: "Brandon S. Allbery KF8NH" <bf8$s03c92f97$a93d2@kf8nh.apk.net>
Subject: Re: "Learning Perl" questions and frustrations
Message-Id: <34ef750b$2$ofn$mr2ice@speaker>

In <34ee3454.50494916@news.csrlink.net>, on 02/21/98 at 02:14 AM,
   dep2@csrlink.net (David Pinkerton) said:
+-----
| syntax error in file hello.sh at line 5, next 2 tokens "chomp (" Execution
| of hello.sh aborted due to compilation errors.
+--->8

Looks like you're running Perl 4; chomp() was added in Perl 5.  I suggest you
upgrade:  Perl4 has known security holes, Perl 5 has more functionality, and
most of the current development is in the form of modules, which only work in
Perl 5.

-- 
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)



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

Date: Sat, 21 Feb 1998 21:23:22 -0500
From: "Les" <leviro@yahoo.com>
Subject: Re: "Learning Perl" questions and frustrations
Message-Id: <6co28u$mbr@bgtnsc01.worldnet.att.net>

The 'chomp' function is only available with Perl 5 or higher. Check with
your server to see which version they use.

Les O'Connor
webmaster@pnlweb.com
P & L Web Design
Designing The Web To Work For You
http://www.pnlweb.com

David Pinkerton wrote in message <34ee3454.50494916@news.csrlink.net>...
>I've been starting to work my way through this book recently and have
>come across several operators (?) that have not worked.  The first is
>the "chomp" command.  This is the example:
>
>$name = <STDIN>;
>chomp ($name);
>
>and here is the error I receive:
>
>syntax error in file hello.sh at line 5, next 2 tokens "chomp ("
>Execution of hello.sh aborted due to compilation errors.
>
>*Luckily* I happened to read (somewhere else) that "chop" can be
>substitued for "chomp."  So far this has worked but can anyone tell me
>why "chomp" will not work?  This is SunOS Unix if that makes a
>difference.  I'm not sure what version of Perl this is and I have no
>idea how to find out.





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

Date: 21 Feb 1998 23:16:13 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: An easy question or two
Message-Id: <6cnn7t$dvv@fridge.shore.net>

Amy Hartman (amylynne@shadow.net) wrote:
: Sorry for the newbie questions; I'm still learning all the intricacies
: of Perl.
     ^^^^
Please, please don't get confused about what's what early-on!  Your
questions could really be asked with any language in mind, but are
still not directly related to any of (said) languages.

: 1) Is there any way for Perl to modify an already existing form that is
: being displayed on a web browser? (without rewriting the whole page)

Use CGI.pm.  It will do this.

: 2) Is there any way for Perl to pass variables to Javascript?  On the
: same token, how does Perl set or change cookies?

Use CGI.pm.  It includes an example or two to work with Javascript.
Perl *doesn't* set or change cookies.  Perl has nothing to do with
cookies, whatsoever.  Cookies have to do with browsers or something
else not related to Perl.  CGI.pm includes an example or two about
using cookies with the module, however.

If you don't have it already, you can get CGI.pm at:
http://www.perl.com/CPAN/modules/by-module/CGI/

Followups set.

--
Nathan V. Patwardhan


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

Date: Sun, 22 Feb 1998 00:18:48 GMT
From: mocat@NOSPAM.best.com (blacktape)
Subject: better way to do this?
Message-Id: <34ef6e05.687476@nntp.best.com>

After learning a bit more about regexps, I've started work on a script
that'll clean up my html files a bit.  I was wondering if there is a
better way to do this... I know it's crude, but it works. ;)

Also, I was wondering if there is a way to read AND write to the same
file... I've tried to do this in the past, but I've ended up having to
open a seperate file for writing... it'd be so much easier if I could
just do the whole shebang with one filehandle open.

Thanks for any help...

what I have done of the script is attached below...

#!/usr/bin/perl
open(HTMLFILE, "$ARGV[0]") or die "cant open $ARGV[0]: $!";
@html = <HTMLFILE>;
foreach $line (@html) {
	$line =~ /<img(.*?)>/i;
	$one = $1;
	if ($one !~ /alt\s?=/i) {
		$one =~ /.*?src\s?=\s?"(.*?)"/i;
		$one = $1;
		$line =~ s/src/alt="$one" src/i;
		print $line;
	} else { 
		print $line; 
	}
}


-j
the dumber a person is, the longer it will take for them to find out that you're killing them


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

Date: Sat, 21 Feb 1998 20:47:44 -0500
From: see-below@crocker.com (Steve Linberg)
Subject: Re: better way to do this?
Message-Id: <see-below-2102982047450001@pri03-047.oldcity.dca.net>

In article <34ef6e05.687476@nntp.best.com>, mocat@NOSPAM.best.com
(blacktape) wrote:

> After learning a bit more about regexps, I've started work on a script
> that'll clean up my html files a bit.  I was wondering if there is a
> better way to do this... I know it's crude, but it works. ;)

What about this:

<p>here is some HTML causing the IMG tag to wrap: <img
src="/foo.gif"></p>

-- 
slinberg@        com
         crocker.

Try that one, spambots!


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

Date: 22 Feb 1998 01:39:09 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: better way to do this?
Message-Id: <6cnvjt$gc9$2@marina.cinenet.net>

blacktape (mocat@NOSPAM.best.com) wrote:
: After learning a bit more about regexps, I've started work on a script
: that'll clean up my html files a bit.  I was wondering if there is a
: better way to do this... I know it's crude, but it works. ;)
: 
: #!/usr/bin/perl

Where's the -w ?

: open(HTMLFILE, "$ARGV[0]") or die "cant open $ARGV[0]: $!";
: @html = <HTMLFILE>;

Why not just let defaults take their natural course, and eliminate the 
open() line, replacing the next line with '@html = <>;' ?

: foreach $line (@html) {
: 	$line =~ /<img(.*?)>/i;

This regex won't work in the (admittedly rare) case of (say) alt text 
with a > in it.

: 	$one = $1;

Rather than doing it this way, how about replacing the two previous lines 
with

        my ($imgArgs) = $line =~ /<img(.*?)>/i;

and then operating on $imgArgs rather than $one?

: 	if ($one !~ /alt\s?=/i) {

Might suggest /\balt\s*=/i instead.

: 		$one =~ /.*?src\s?=\s?"(.*?)"/i;

The initial .*? doesn't mean anything.  I would suggest 
/\bsrc\s*=\s*"(.*?)"/i.

: 		$one = $1;

Again, might want to use match capturing as I showed above.

: 		$line =~ s/src/alt="$one" src/i;

You really want to make the alt text the name of the image file?

: 		print $line;
: 	} else { 
: 		print $line; 
: 	}

Why not drop the inside-condition 'print $line's and the else part, and 
put a single 'print $line' outside the if block?

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Sat, 21 Feb 1998 23:33:46 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Cacheing and Back Button question.
Message-Id: <ebohlmanEor5GA.2yw@netcom.com>

[followups limited to c.i.w.a.h as there's nothing Perl-specific here]

Remove NOSPAM to reply <ldn123NOSPAM@pobox.com> wrote:
: Hello.  I've been trying without luck to figure out how to prevent the
: user from using the back button from a certain page.

: My problem is that I have form that is used for editing the
: state of something.  A perl script handles the POST method
: and generates a new version of the form with each interaction.
: If I allow the user to use the back button, then they will be
: able to step back to a previous version of the form, which
: will contain out of date state information.

This situation is an example of what's called "premature closure."  
You've jumped too quickly from the problem you need to solve to a possible 
solution.  Your actual problem is not "how do I disable the back 
button?"; it's "how do I keep resubmissions of old forms from messing my 
system up?"  Disabling the back button is *one* conceivable solution (but 
not, as it turns out, a workable one).

: I have tried using Pragma: no-cache, and also using the
: Expired header with both "0" and an old date as
: Content.  They only work intermittently in Netscape 4.04.

The HTTP and HTML specifications draw a clear distinction between caching 
and the browser history mechanism.  Disabling caching is *not* supposed 
to disable browser history.  In fact, there's *no way* to disable browser 
history, so you need to go back to your problem statement and find a 
different way of dealing with the problem.

Since you're obviously tracking state at the server end somehow, why not 
generate a sequence number of some sort and include it in an <INPUT 
TYPE=hidden> field on the generated pages.  In your script, keep track of 
the last sequence number you generated for a particular "session" and 
reject submissions with earlier sequence numbers.  This also sounds like 
an application where you could put a cookie to good use.


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

Date: Sat, 21 Feb 1998 04:55:26 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Can I write sockets apps with Perl + Win 95?
Message-Id: <34ee236c.166952172@news.btinternet.com>

On Thu, 19 Feb 1998 23:59:00 -0500, Chris <chris@surewould.com> wrote:

>About 4 years ago (pre-Win95) I got into writing Winsock apps. That was
>about the same time I first used Perl, and remember hoping that it would
>be as easy to write sockets code with Perl under Windows 3.1 as under
>Unix. But of course it wasn't.
>
>It's much later now, and I'd like to revisit this concept. I'm doing
>some sockets stuff now under Win95 and it's all in Java, which (although
>much better than C/C++) is becoming cumbersome. Can today's Perl tackle
>this?
>
Yes,  
Check out the copious thus oriented modules on CPAN specifically
IO::Socket.  Although the chances are there will be a Module providing
a higher degree of abstraction for any common protocol you may wish to
use.

/J\


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

Date: Sat, 21 Feb 1998 04:55:32 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: CGI scripts and frames?
Message-Id: <34ee4166.174477446@news.btinternet.com>

On Fri, 20 Feb 1998 21:51:14 +0100, mikael@techtalk.se (Mikael
Skogstrom) wrote:

>It's quite allright to use the HTML tag:
>
>   <A HREF="mypage.html" TARGET="MainFrame">This page</A>
>
>Consequently it should be possible to code it this way:
>
>  <A HREF="mypage.cgi" TARGET="MainFrame">This page</A>
>
>Where the page is generated dynamically by a script. But when I do this,
>the browser wipes away all the frames and starts writing on a new page. Is
>there some sort of Mime header I need to include, apart from the
>traditional "Content-type: text/html \n\n"?
>

Deep down in your heart of hearts you know that this has nothing
whatsoever to do with Perl, whatever language was used to produce your
CGI program.

However if you are using the CGI module (and I sincerely hope you are)
I suggest that you read the section in the documentation entitled:

WORKING WITH NETSCAPE FRAMES

which provides several strategies for working with frames.

Happy reading

/J\


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

Date: Sat, 21 Feb 1998 17:01:31 -0800
From: Michael Roeser <mroeser@removethis.gte.net>
To: "Jonathan D. Feinberg" <jdf@pobox.com>
Subject: Re: CGI.pm error - Modification of Read-Only Value
Message-Id: <6cnt6b$ovn$1@gte1.gte.net>

Jonathan D. Feinberg wrote:
> 
> In article <6cl98i$fu6$1@gte2.gte.net>, Michael Roeser wrote:
> >   "...got line "modification of a read-only value attempted at
> >    /usr/freeware/lib/perl5/cgi.pm line 308"
> 
> >   308      ${$var} = $value[0];
> 
> Are there any form elements on your page named "1" or "2," or perhaps "."
> or something similar?
> 
> --
> Jonathan Feinberg     jdf@pobox.com     Sunny Brooklyn, NY

Aha -- that's it!  I had a form element name that began with a "1". 
Changed it, and now things work as they're supposed to.

Thanks for your help!

Mike


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

Date: 21 Feb 98 23:09:13 GMT
From: "TomH" <beans@bedford.net>
Subject: Re: Delete record from fixed-length random access databases
Message-Id: <01bd3ea7$56eee800$889163ce@beans.bedford.net>

If you think about it, this really doesn't make sense. 

What happens whan you "delete" a record? Does a blank record still exist in
its place? Does the rest of the file get pulled up to fill the hole? A
random access file (even if perl supported them, which I don't think it
does) couldn't have a record deleted from it or you would mess up every
other record number following it.  

I think what you want is a DBMS. 

aniz Uhler <Aniz@auctionz.com> wrote in article
<34EDCA24.1061E3BD@auctionz.com>...
 ...
> However when I want to delete a specify record in a file.
> 1) I want to use seek to move a particular record.
>     seek(AA, 80, 0)
 ...


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

Date: Sat, 21 Feb 1998 16:54:45 -0800
From: Rocko Pebcakio <yingyang@knob.com>
Subject: DES compilation. (with stdarg.h)
Message-Id: <34EF7755.67368748@electriciti.com>

Hello,
we are trying to use the DES.pm module, and when we compile the C source
code we find that we are missing a file. We are missing the file
"stdarg.h"  This file is neccesary for the compilation of the DES
library.  If anyone has it please send it along to
davidu@electriciti.com.  Also any information you have would be
appreciated.
-Thank you,
DavidU



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

Date: Sat, 21 Feb 1998 04:58:39 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: executing perl scripts on NT
Message-Id: <34ee5e61.181077838@news.btinternet.com>

On 20 Feb 1998 04:16:52 GMT, amihara@Hawaii.Edu (James Amihara) wrote:

>	this is really a newbie question about running
>	perl scripts on my NT but how do you do server
>	side includes?
>
I would strongly suggest asking this question in 

    comp.infosystems.www.servers.ms-windows

as this is a server-related question and nothing really to do with
perl as such.

/J\


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

Date: Sat, 21 Feb 1998 21:17:45 GMT
From: ed@vtrad.com (Ed Egan)
Subject: HELP - SQL into Access (win NT) from Perl
Message-Id: <34f04408.4094828@news.poptel.org.uk>

Help!

Has anyone done this before???

I would really appreciate a code snippet showing how it is done.

I can't find anything about it in anywhere!

Many Thanks,

Ed.


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

Date: Sat, 21 Feb 1998 21:03:01 GMT
From: ed@vtrad.com (Ed Egan)
Subject: Help need with SQL into Access database from Perl
Message-Id: <34ef409a.3216354@news.poptel.org.uk>

Can anybody help me with SQL into Access database from Perl?

I would really appreciate a code snippet showing how it is done or
even just useful comments/suggestions as to where I should start.

Deadlines are killing me!

Thanks,

Ed.



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

Date: Sat, 21 Feb 1998 22:55:08 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Help need with SQL into Access database from Perl
Message-Id: <genepoolEor3nw.9np@netcom.com>

Ed Egan (ed@vtrad.com) wrote:
: Can anybody help me with SQL into Access database from Perl?
: Deadlines are killing me!

when deadlines are killing you
turn to dejanews
query on perl odbc access
soon you will have success

Cheers,

Jim (with apologies to ee)


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

Date: 22 Feb 1998 00:35:35 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help please: Conversion problems from numeric to ascii
Message-Id: <6cnrsn$gc9$1@marina.cinenet.net>

Brent (brent@sympatico.ca) wrote:
:     I'm trying to convert a number to a letter based upon the ascii
: table (e.g. 65=A, 97=a)  The reason for this is that I'm randomly
: generating user id's for account creation. I'm currently using a Novell
: Web Server and their Perl server however after coding I must port it
: over to a UNIX server.  Does anyone know the syntax I can use to perform
: these two tasks?
: 
:     I have tried using the $userid[$i]=chr($randomnum) within a loop
: however from extensive testing, the chr() function doesn't seem to be
: returning anything.  I tested this by performing a dump of the variable
: contents prior and after conversion attempt.

One possible problem is that not all ASCII values are printable, nor are 
all of them likely to be valid user ID characters.  What I'd suggest 
(untested):

  @validChars = ( 'A' .. 'Z', 'a' .. 'z', '_');   # Or whatever.
  $nameLen    = 7;                                # Or whatever.

  $name  = '';
  $name .= $validChars[random(@validChars)] while length($name) < $nameLen;

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 21 Feb 98 22:51:17 GMT
From: "TomH" <beans@bedford.net>
Subject: Re: Home Page Click.
Message-Id: <01bd3ea4$d58713c0$889163ce@beans.bedford.net>

what does this have to do with perl?

Ray <raymond@sj.bigger.net> wrote in article
<34EF1E31.234AC19D@sj.bigger.net>...
> Does anyone know how to add an element to a page so that when the user
> clicks on it, it becomes their home page?
 ...


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

Date: Sat, 21 Feb 1998 23:04:39 GMT
From: perl.user@sndk.se
Subject: Re: if (-d $filename) in Win32
Message-Id: <34f25c05.43368619@news.algonet.se>

I finalized a working soloution to my search problem, below. Thanks
Guy and Jonathan!

\\Staffan


print &scan_for_documents('d:/', '.pl', '.perl')

sub scan_for_documents
{
  local($dir, @document_extensions) = @_;
  local(@filenames) = ();
  local($filename) = '';
  local($path) = '';
  local(@result) = ();

  opendir DIRHANDLE, $dir;
  @filenames = grep {!m#^\.\.?$#} readdir DIRHANDLE;
  closedir(DIRHANDLE);

  foreach $filename (@filenames)
  { # for each file in this directory...
    $path = $dir . (substr($dir, length($dir) - 1, 1) eq '/' ? '' :
'/') . $filename;

    if (-d $path)
    { # this is a directory, let's scan it's files as well
      push @result, &scan_for_documents($path, @document_extensions);
    }
    else
    { # this is _not_ a directory
      foreach $extension (@document_extensions)
      {
        if ($extension eq substr($filename, length($filename) -
length($extension), length($extension)))
        { # this file is a proper document
          push(@result, $path);
        }
      }
    }
  }

  @result;
}



On Fri, 20 Feb 1998 15:19:51 GMT, perl.user@sndk.se wrote:
>Why isn't the following ok in Win32? Is -d only working in unix perl?
>I want to scan the whole of d:\ for perl-files (extension "pl").
>
>
>#!/usr/bin/perl
>
>@dirs = 
>(
>  'd:\\'
>);
>
>foreach $dir (@dirs)
>{ # for each directory on d:\
>  opendir(HOMEDIR, $dir);
>  while (defined($filename = readdir(HOMEDIR)))
>  { # for each file in this directory...
>    if ((-d $filename) and !($filename eq '.' or $filename eq '..'))
>    { # this is a directory, let's scan it's files as well
>      push(@dirs, "$dir\\$filename");
>    }
>    elsif (-1 != index($filename, ".pl"))
>    { # this is a perl file since it has ".pl" in it's name
>      print "Perlfile named \"$dir\\$filename\"\n";
>    }
>  }
>  closedir(HOMEDIR);
>}
>
>
>
>
>\\Staffan



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

Date: Sun, 22 Feb 1998 00:59:29 +0100
From: Peter Wermelinger <p.wermelinger@bluewin.ch>
Subject: Installation-Problem on NT 4.0
Message-Id: <34EF6A61.D337A438@bluewin.ch>

New in the field of Perl I can't get the Perl-Installation run on my NT
4.0 server (Back Office Small Business Server). I always get the message
"HTTP/1.0 501 Not supported". The perl-version was downlaod from
"www.ActiveState.com" Perl for Win32 Build 315 and the installation went
automatic.

Peter

pwermelinger@access.ch




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

Date: Sat, 21 Feb 1998 16:36:10 +0000
From: Jeff Potter <jp@glpbooks.BADMAIL.com>
Subject: Need autoreply script for addresses buried in text & mail prog...
Message-Id: <34EF027A.280E@glpbooks.BADMAIL.com>

Hi all...I'm just getting started but here's what I need.
I'd appreciate any help/leads in solving this.

I have email text files full of email addresses. I need
to glean the addresses from the text then reply to them
with a set message. --I'll need to also 'auto-quote' from
the text following the email address and append a message 
asking for permission to re-use that quote. I also have
a bunch of emails in various mailboxes on my Eudora 
program (Mac). I'd like to be able to autorespond to them
not as they come in but on a per-mailbox basis. Is this
doable? How? THANKS!!!

-- 

Jeff Potter   jp@glpbooks.BADMAIL.com   delete '.BADMAIL' to reply
***"Out Your Backdoor": Friendly Magazine of DIY Adventure and Culture
       http://www.glpbooks.com/oyb ... with new bookstore & bulletin board


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

Date: Sat, 21 Feb 1998 04:55:29 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: newbie: breaking a line of text into two chunks
Message-Id: <34ee37ed.172077223@news.btinternet.com>

On Fri, 20 Feb 1998 15:59:12 -0800, Joe Wahrhaftig
<joew@xaostools.com> wrote:

>
>--------------AEFF896B91F8332F794DCC6D
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
>  Yes I expect to get flamed for this one:
>

Well then you should also expect to get flamed for posting in MIME.
I would consider very seriously getting a different newsreader.

>I've got a database where the entries are as follows
>
>
>            item1_name        "comment string for item 1"
>            item2_name        "comment string for item 2"
>
>                                            ... etc.
>
The answer can be found in perfaq4 in the bit entitled:

" How can I split a [character] delimited string except when inside
[character]? (Comma-separated files)"

For your purposes this is not going to give a "Plug and Play" example
but it can certainly be altered to do what you want.

>I want to take the item_name and "comment about item n" and store them
>in different variables. I tried reading these two entries per line with
>a split as shown below:
>
> ($Item_Name, $Comment_String) = split(/ /, $_);
>
>This worked fine for $Item_Name. $Comment_String however, now only holds
>one word. Does anyone out there have a suggestion for putting the entire
>comment string
>(plus the quotes around it) in into $Comment_String?
>
<snipped redundant <ahem > rich content>

/J\



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

Date: Sun, 22 Feb 1998 10:50:02 +1100
From: Benjamin Grosman <bgrosman@healey.com.au>
To: Jim Scofield <jscofield@mindspring.com>
Subject: Re: Powered by Perl logo
Message-Id: <34EF682A.BE233836@healey.com.au>

> Some time ago, I saw a nice Powered by Perl logo.  It was a small rectangle
> with the Camel pictured.  Does anybody know where I can get a copy of this?

The logo is copyright O'Reilly and Associates, but is permitted for use under
certain guidelines. Go to http://www.ora.com and check it out there.

Ben




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

Date: 22 Feb 1998 00:12:10 GMT
From: fake.address@no.spam.com (Spencer Lu)
Subject: Regexp question...
Message-Id: <hIjs9p2YyqR0-pn2-3mqgY8Oiv7Bw@207-172-113-134.s134.tnt5.ann.erols.com>

Hi,
 
I'm writing a perl script, and one of the things it does is remove
all trailing spaces from all lines of a text file.  My initial attempt
at this failed, and I'm not sure why.  Here is the relevant code:
 
while ($line = <FILE>) {
  $line =~ s/^(.*) *\n/$1\n/;
  $filestring = $filestring . $line;
}
 
I recently discovered that I could just use:
        $line =~ s/ *\n/\n/;
which is simpler and works, but I am curious
as to why my initial attempt failed.
 
Thanks!

--
Spencer Lu
Email: spencer.lu@erols.com  <--- Use this address when replying



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

Date: 21 Feb 1998 20:10:58 -0500
From: Douglas McNaught <doug@tc.net>
Subject: Re: Regexp question...
Message-Id: <m2afbkl9zx.fsf@ono.tc.net>

fake.address@no.spam.com (Spencer Lu) writes:

> I'm writing a perl script, and one of the things it does is remove
> all trailing spaces from all lines of a text file.  My initial attempt
> at this failed, and I'm not sure why.  Here is the relevant code:
>  
> while ($line = <FILE>) {
>   $line =~ s/^(.*) *\n/$1\n/;
>   $filestring = $filestring . $line;
> }

What's happening is that the * operator is greedy.  It will always try
to match as much as possible, as long as the overall regex matches.
Thus, the (.*) term matches everything up to the end, including all
trailing spaces.  The following ' *' term can succeed by matching
nothing, so it does, and the substitution becomes a no-op, since the
parenthesized term matches the entire string up to the newline. 

-Doug
-- 
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";


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

Date: 22 Feb 1998 00:02:07 GMT
From: fake.address@no.spam.com (Spencer Lu)
Subject: Regexp question
Message-Id: <hIjs9p2YyqR0-pn2-pQkzgcYEkISZ@207-172-113-134.s134.tnt5.ann.erols.com>

Hi,

I'm writing a perl script, and one of the things it does is remove
all trailing spaces from all lines of a text file.  My initial attempt
at this failed, and I'm not sure why.  Here is the relevant code:

while ($line = <FILE>) {
  $line =~ s/^(.*) *\n/$1\n/;
  $filestring = $filestring . $line;
}

I recently discovered that I could just use:
	$line =~ s/ *\n/\n/;
which is simpler and works, but I am curious
as to why my initial attempt failed.

Thanks!

--
Spencer Lu
Email: spencer.lu@erols.com  <--- Use this address when replying



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

Date: 22 Feb 1998 00:06:19 GMT
From: fake.address@no.spam.com (Spencer Lu)
Subject: Regexp question
Message-Id: <hIjs9p2YyqR0-pn2-f3XOt0dodziI@207-172-113-134.s134.tnt5.ann.erols.com>

Hi,
 
I'm writing a perl script, and one of the things it does is remove
all trailing spaces from all lines of a text file.  My initial attempt
at this failed, and I'm not sure why.  Here is the relevant code:
 
while ($line = <FILE>) {
  $line =~ s/^(.*) *\n/$1\n/;
  $filestring = $filestring . $line;
}
 
I recently discovered that I could just use:
        $line =~ s/ *\n/\n/;
which is simpler and works, but I am curious
as to why my initial attempt failed.
 
Thanks!

--
Spencer Lu
Email: spencer.lu@erols.com  <--- Use this address when replying



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

Date: Sat, 21 Feb 1998 04:55:34 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: script incombatibility.
Message-Id: <34ee5927.179740414@news.btinternet.com>

On Fri, 20 Feb 1998 16:36:12 -0500, jdf@pobox.com (Jonathan Feinberg)
wrote:

<snip>
>I'm no security expert, but this looks horribly wrong to me.  It appears that 
>you're taking a parameter from an HTML form and throwing it into a system call 
>without untainting it.  Anyone else care to comment on this?
>
This is subject of CERT advisory CA-97.25 available at

http://www.cert.org/pub/advisories/CA-97.25.CGI_metachar.html

There is Technical tip sheet at:

ftp://ftp.cert.org/pub/tech_tips/cgi_metacharacters

/J\


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

Date: Sat, 21 Feb 1998 21:21:58 GMT
From: ed@vtrad.com (Ed Egan)
Subject: Re: SEND E-MAIL , HELP!
Message-Id: <34f1452e.4388950@news.poptel.org.uk>

On Sat, 21 Feb 1998 13:36:03 -0800, Alexander Kovalenko
<techsoft@abcpages.com> wrote:

>hey , how is it going?
>I have a problem with following procedure...
>sub send_mail
>{
>  local($addressee, $subject, $message) = @_;
>  local($sendmail) = "/usr/sbin/sendmail";
>  open(SENDMAIL, "| $sendmail -t");
>  print SENDMAIL "To: ", $addressee, "\n";
>  print SENDMAIL "Subject: ", $subject, "\n\n",
>  print SENDMAIL "$message\n";
>  close(SENDMAIL);
>}
>it sends e-mail , ok... but it does not use a subject , so it just leave
>it blank...
>what's wrong am I doing ? thanks in advance!
>
>--
>With best wishes,
>Alex.
>
>------------------
>To purchase your own www.yourcompany.com,
>please, click here: http://www.philex.net/agents/0053/
>    The Best Prices on the Net!!!
>    19.95$ for 250Mb per month
>                  +
>     many additional options.
>
>

Alex,

I use Blat.exe, 'cause I had problems and this worked!

	# Send mail using blat and the system command ############
	
	$commandline = $blatpath;
	$commandline .= $message." ";
	$commandline .= "-s \"$subject\" " if $subject;
	$commandline .= "-t \"$recipients\" " if $recipients;
	$commandline .= "-i $from " if $from;
	$commandline .= "-f $sender " if $sender;
	$commandline .= "-c $ccaddress " if $ccaddress;
	$commandline .= "-b $bccaddress " if $bccaddress;
	system($commandline);

Might be a solution if all else fails.

Ed.




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

Date: 21 Feb 98 23:23:33 GMT
From: "TomH" <beans@bedford.net>
Subject: Re: Sorting dbm files (and hashes)
Message-Id: <01bd3ea9$57732140$889163ce@beans.bedford.net>

Somewhere in the middle, shortly before my eyes glazed over I saw this:

>     push %people, $NextHashRow;
>   }
>   print "Then we hash it on out \n";
>
>   foreach $value (@people) {

The push function takes an array, not a hash. You use %people and @people,
which are entirely different identifiers.


Laurel Shimer <autopen@autopen.com> wrote in article
<autopen-2102981229270001@dynamic7.pm04.mv.best.com>...
> This question has to do with sorting data stored in a dbm file. I have
> included all the sample code that I created while trying to figure this
> task out. 
 ...
< cut about 300 lines of stuff>


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

Date: Sat, 21 Feb 1998 17:34:09 -0600
From: Bryan Wilkinson <nardo@pobox.com>
Subject: Re: ts: how to parse embedded commas
Message-Id: <34EF6471.D23A117@pobox.com>

>    $x= "var1,var2, sum(sum(i,j), sum(k, sum(l, m))) as var3";

you should be able to do something like:

while($x =~ s/sum\(([^()]*)\)/&sum($1)/e) {}

sub sum
 {
   my ($v1, $v2) = split(/\s*,\s*/, $_[0]);
   return $v1 + $v2;
 }

if you have other function names you should be able to substitute the
following while loop

while($x =~ s/sum\(([^()]*)\)/&sum($1)/e || $x =~
s/product\(([^()])\)/&product($1)/e) {}

by using the [^()] in the regex, it ensures that it parses the innermost
functions calls first.


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1949
**************************************

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