[13215] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 625 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 23 22:07:24 1999

Date: Mon, 23 Aug 1999 19:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 23 Aug 1999     Volume: 9 Number: 625

Today's topics:
    Re: "Odd number of elements in hash list" (error messag (Eric Bohlman)
    Re: $$var[xxx] vs ${var}[xxx] <mpersico@erols.com>
    Re: Alt format for man pages? <cassell@mail.cor.epa.gov>
    Re: Backtracking up through parent directories (Doran L. Barton)
        Can you print     "  ? (Graham)
    Re: Can you print     "  ? <cassell@mail.cor.epa.gov>
    Re: Can you print     "  ? (David Efflandt)
    Re: Cron Job limitations - help needed (Doran L. Barton)
    Re: directory processing (Billy Chan)
    Re: email address verification <webmaster@mendonet.com>
    Re: file merged (Eric Bohlman)
        File Upload for WinNT W/ ActivePerl and CGI.pm-2.54 <dallas.jones@tech4learning.com>
    Re: How to use a module???? <cassell@mail.cor.epa.gov>
    Re: Perl Email With Netscape <jimmy@blackhole-designs.com>
        Running Apache & Active PERL! <webhead@columbus.rr.com>
    Re: Running Apache & Active PERL! <cassell@mail.cor.epa.gov>
        setuid question mr_potato_head@my-deja.com
    Re: Simple text rotating and gif98a generating perl scr <flavell@mail.cern.ch>
    Re: Simple text rotating and gif98a generating perl scr <hanenkamp@networksplus.net>
    Re: Substitute <hanenkamp@networksplus.net>
        testing <leenick@interchange.ubc.ca>
    Re: The scipt dont work.!!!help me <cassell@mail.cor.epa.gov>
    Re: The scipt dont work.!!!help me (elephant)
    Re: URGENT: Freelance perl coder required <cassell@mail.cor.epa.gov>
        writing formatted text to console on Win32 <laith1@my-deja.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 23 Aug 1999 23:15:41 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: "Odd number of elements in hash list" (error message)
Message-Id: <7pskmt$ci3@dfw-ixnews6.ix.netcom.com>

Bill Williams (biwillia@cisco.com) wrote:
: At the risk of appearing more inept, here is my logic. Open a text file
: that has parameters in it like :
: 
: value1 = filename
: 
: then
: 
: ----pseudo - code ------
: 
: while (<PFILE>){
:         chomp;
:             %parvals = split('=',$_);
:             %parameters = (%parameters, %parvals);

This is about the most inefficient possible way to add an entry to a 
hash.  Most people would write something like:

my ($key,$val)=split(/=/); #split works on $_ by default
$parameters{$key}=$val;

Your problem is almost certainly that one of the lines you're reading 
contains more than one equal sign.  If the value portion of the line 
contains an odd number of equal signs (e.g. the line was "formula=E=MC^2") 
you'll get the warning you described.  If it contains an even number of 
equal signs (e.g. "condition=a=b=c") you won't get any warnings, but you 
won't be storing what you want (you'll be setting $parameters{condition} 
to 'a' and $parameters{b} to 'c').

Check out the documentation for the split function (perldoc -f split) for 
a way to keep this from happening.

:     }
:     $value1 = $parameters{value1};


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

Date: Mon, 23 Aug 1999 21:37:58 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: $$var[xxx] vs ${var}[xxx]
Message-Id: <37C1F776.4C504587@erols.com>

elephant wrote:
> 
> the only things that Matthew's code does show is that using the '-w'
> switch really is not a joke - and that code should always be tested
> before being posted to this newsgroup .. incorrect answers are worse
> than no answer at all

Glad to have been of service. :-(

> 
> --
>  jason - elephant@squirrelgroup.com -

-- 
Matthew O. Persico
    
You'll have to pry my Emacs from my cold dead oversized
   control-pressing left pinky finger. -- Randal L. Schwartz


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

Date: Mon, 23 Aug 1999 17:13:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Alt format for man pages?
Message-Id: <37C1E3B3.6F75C269@mail.cor.epa.gov>

Doran L. Barton wrote:
> 
> deane_barker@my-deja.com writes:
> 
> >Is there anyway I can get the PERL man pages in
> >some kind of word-processing format, like .DOC or
> >.WPD, or even .RTF?
> 
> >I'm trying to print them out in HTML, but there
> >just too much information to make it manageable.
> 
> Blasphemy!

:-)

> No really, the solution to this is simple: Use your browsers "Save As"
> feature to save the file as HTML. Most word processing applications (even
> the evil one) will import HTML. Then you can do whatever the hell you want!

It's even easier than that for win32 citizens.  ActiveState
Perl comes with a huge HTML tree which sits in the directory
whre Perl was installed, and these can be directly imported
by anything which reads in HTML files.  And if you don't want
to do that, there's a pod2html Perl program that comes with
the install, which will be easier than pulling up the
browser and doing all the files page-by-page.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 23 Aug 1999 17:17:30 -0600
From: fozz@xmission.xmission.com (Doran L. Barton)
Subject: Re: Backtracking up through parent directories
Message-Id: <7pskqa$87t$1@xmission.xmission.com>

"E. Preble" <preble@ipass.net> writes:
>...It's easy to add a substitution call to the script
>to remove any '..' occurances.
>$file = s/..//g;

Keep in mind that the '.' (period) character has special meaning in regular
expressions. Specifically it matches any single character. I believe you
want this:

  s/\.\.//g;

AND.... additionally, the '=' operator used above will only assign the
result of the regular expression as it is applied to the default scalar
($_). I suspect what you REALLY meant to say was:

  $file =~ s/\.\.//g;

But that still won't provide you with all the security you're hoping for.

>Are there other things I should be worried about?  Are there
>other ways to backtrack up through directories like this and
>grab un-authorized files?

I'm assuming your intention here is to limit the user's access to the files
in one single directory and nowhere else. This would entail stripping any
and all path information off the front of the filename:

  ($realfile) = file =~ /^.*\/([^\/]+)$/g;

Hope that helps.

-=Fozz

-- 
Doran L. Barton = fozz@xmission.com && http://www.xmission.com/~fozz/
** Dynamic web developer, Perl hacker.  Using the Internet since 1990. **
 "I have learned much more about Microsoft by using the Linux operating 
  system than I ever would have done by using Windows." - Neal Stephenson


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

Date: Mon, 23 Aug 1999 23:10:10 GMT
From: graham@hglmotors.co.uk (Graham)
Subject: Can you print     "  ?
Message-Id: <37c5d40f.20528533@news.btinternet.com>

I am writing/modifying a perl script to send web access details to a
log.dat file. I need certain parts to be included within     " " 
(for a stat reader I have that requires it)


ie in the below   $ENV{'HTTP_REFERER'} would give http://www..........
but I need it as "http://www......."

open (LOGFILE,">>$statfile");print LOGFILE ("$ENV{'REMOTE_HOST'} - -
$date GET $ENV{'REQUEST_URI'} HTTP/1.0 - - $ENV{'HTTP_REFERER'}
$ENV{'HTTP_USER_AGENT'}\n"); close LOGFILE;


As  "  apears to be a reserved letter for coding can I some how ouptut
it to the .dat file.   So far all attempts have resulted in errors.

TIA

Regards,
Graham
http://www.hglmotors.co.uk - new site.


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

Date: Mon, 23 Aug 1999 17:17:51 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Can you print     "  ?
Message-Id: <37C1E4AF.E036CDB0@mail.cor.epa.gov>

Graham wrote:
> 
> I am writing/modifying a perl script to send web access details to a
> log.dat file. I need certain parts to be included within     " "
> (for a stat reader I have that requires it)
> 
> ie in the below   $ENV{'HTTP_REFERER'} would give http://www..........
> but I need it as "http://www......."
> 
> open (LOGFILE,">>$statfile");print LOGFILE ("$ENV{'REMOTE_HOST'} - -
> $date GET $ENV{'REQUEST_URI'} HTTP/1.0 - - $ENV{'HTTP_REFERER'}
> $ENV{'HTTP_USER_AGENT'}\n"); close LOGFILE;

You actually have multiple options in Perl.  I would recommend
that instead of putting the whole ball of wax inside double
quotes, stick it in this:
    qq(   )
which acts like a set of double quotes.  You can read all
about qq() and its friends in the perlop manpage under this 
heading: "Quote and Quote-like Operators".  You can read all
the Perl manpages using perldoc, by typing at a command
prompt:
    perldoc perlop
[or using man, or reading the POD, or browsing the HTML,
or whatever you prefer].

You can also backwhack those " like this: \" so they won't
get treated as the end of the quoted material.  But qq()
looks nicer.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 24 Aug 1999 00:33:45 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Can you print     "  ?
Message-Id: <slrn7s3qbb.jv.efflandt@efflandt.xnet.com>

On Mon, 23 Aug 1999 23:10:10 GMT, Graham <graham@hglmotors.co.uk> wrote:
>I am writing/modifying a perl script to send web access details to a
>log.dat file. I need certain parts to be included within     " " 
>(for a stat reader I have that requires it)
>
>ie in the below   $ENV{'HTTP_REFERER'} would give http://www..........
>but I need it as "http://www......."
>
>open (LOGFILE,">>$statfile");print LOGFILE ("$ENV{'REMOTE_HOST'} - -
>$date GET $ENV{'REQUEST_URI'} HTTP/1.0 - - $ENV{'HTTP_REFERER'}
>$ENV{'HTTP_USER_AGENT'}\n"); close LOGFILE;

Either escape double quotes (\") in double quoted strings or use qq()
as a substitute for double quotes around the whole thing (or qq|| or qq//
or other characters not in the string).  The "here doc" thing also works.

open (LOGFILE,">>$statfile");print LOGFILE qq($ENV{'REMOTE_HOST'} - -
$date GET $ENV{'REQUEST_URI'} HTTP/1.0 - - "$ENV{'HTTP_REFERER'}"
$ENV{'HTTP_USER_AGENT'}\n); close LOGFILE;

-- 
David Efflandt   efflandt@xnet.com   http://www.xnet.com/~efflandt/
http://www.de-srv.com/   http://cgi-help.virtualave.net/


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

Date: 23 Aug 1999 17:09:07 -0600
From: fozz@xmission.xmission.com (Doran L. Barton)
Subject: Re: Cron Job limitations - help needed
Message-Id: <7pskaj$77n$1@xmission.xmission.com>

sangiro <sangiro@dropzone.com> writes:

>Me ISP allows me to run a single cron job on my system every night
>only. I would like to know if there is a way to have this cron job run
>a small cgi file that will in return kick-off or execute two or three
>other small files.

>Does anyone have a script to this effect?

Huh? CGI applications are for execution by web servers, not cron daemons.
If you mean a Perl script, that makes a lot of sense- but say what you
mean.

But, seriously, why use Perl if you don't have to? This can be done using
Unix shell script much more effectively than with a Perl script- unless
you plan to somehow process the output of your different jobs in some
fashion. Here's how I would do it:

  #!/bin/sh

  # cronjob.sh - runs multiple jobs for me

  /path/to/job1
  /path/to/job2
  # ...
  /path/to/jobn

Make sense?

-=Fozz

-- 
Doran L. Barton = fozz@xmission.com && http://www.xmission.com/~fozz/
** Dynamic web developer, Perl hacker.  Using the Internet since 1990. **
 "I have learned much more about Microsoft by using the Linux operating 
  system than I ever would have done by using Windows." - Neal Stephenson


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

Date: Tue, 24 Aug 1999 10:02:56 +0800
From: bilchan@bigfoot.com (Billy Chan)
Subject: Re: directory processing
Message-Id: <MPG.122bece015ba0c759896a5@news.glink.net.hk>

In article <7prldn$3db$1@nnrp1.deja.com>, pandey@my-deja.com says...
> Hello,
> I am new to perl. I am writing a function
> to process a directory. It reads a directory
> and processes all the files in that directory
> one by one by a certain rule.
> 
> What are the constructs to use for this
> operation?

opendir (DH,".");
@files=grep { /\.txt$/i } readdir DH;
closedir(DH);

for ($i=0; $i<@files; $i++) {
  print @files[$i];
}


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

Date: Mon, 23 Aug 1999 18:48:52 -0700
From: Jon Hollcraft <webmaster@mendonet.com>
To: Paul Falardeau <pef@tp.net>
Subject: Re: email address verification
Message-Id: <37C1FA04.2D64@mendonet.com>

Paul Falardeau wrote:
> 
> Hello,
> 
> I know I've seen this posted to this list before, but I just can't find
> it.
> 
> Can somebody please post a snippet of code which will check the validity
> 
> of an email address?  For example I want to return an error if someone
> enters something like jsmith@aol rather than jsmith@aol.com
> 
> Thanks,
> 
> Paul...

This works for most (on Perl 5.004_4 unix box).  Jon

# $in{'address'} is from your already parsed form input data

sub validate  {    #------------------ VALIDATE EMAIL
FORMAT--------------------
	$hold = "$in{'address'}";  # &bademail uses $hold in html error message
to screen 
	{		
	if ($in{'address'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/) 
	{$bad=$_[1]; &bademail}   #you need to build a sub for error handling
like &badwhatever
	
	if ($in{'address'} !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) 
	 {$bad=$_[2]; &bademail}   #bad 1 and 2 for separate error trapping if
desired
	
	if (($bad==$_[0]) && ($in{'action'} eq 'Condition One'))
{&dosomething};
	if (($bad==$_[0]) && ($in{'action'} eq 'Condition Two'))
{&dosomethingelse};
	if ($bad==$_[0]) {&something};
	}
exit:
}


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

Date: 23 Aug 1999 23:38:19 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: file merged
Message-Id: <7psm1b$ci3@dfw-ixnews6.ix.netcom.com>

b_lucas@my-deja.com wrote:
: i am trying to write a routine to take 2 inputs and merge it in a third
: file. one line of each under the other. i am new to perl, so probably i
: am doing it all wrong.  here is:

Actually, you're doing quite a few things right (-w, use strict, checking 
the results of your opens) but you've got a major lapse in logic.

: #!/usr/bin/perl -w
: use strict;
: $argnum = @ARGV;

Since you used strict (a very good idea), you need to declare all your 
variables *before* you use them.  You need to do this with $argnum, $in and 
$out.

 : if ($argnum < 2 || $argnum > 2) {

1) There's no reason to assign @ARGV to a variable just to use it in a 
comparison.

2) That's a rather bizarre way of writing "if ($argnum != 2)", isn't it?

3) You said you were dealing with *three* files here (two inputs and one 
output) but you're only looking for two arguments.  Hmmm...

 :   print("Enter input filename:");
:   $in = <STDIN>;
:   chop($in);

Get in the habit of using chomp() rather chop() after reading input.  It 
won't make any difference in this case, but it will if you're reading 
other-than-line-sized records from a file.

:   print("Enter output filename:");
:   $out = <STDIN>;
:   chop($out);}
: else {
:   $in = shift(@ARGV);
:   $out = shift(@ARGV);}

Could have been written as:

($in,$out)=@ARGV;

: 
: open(inf, "$in") || die("Can't open input file:$!\n");

No need for the quotes around $in here.

: open(outf,">$out") || die("Can't open ouput file:$!\n");

You should use all-uppercase names for file handles because such names
will never have any special meanings in future versions of Perl.  The code 
you wrote would suddenly fail if a future version were to include 
keywords or built-in functions called 'inf' or 'outf'. 

: my $in = <inf>;
: my $out = <outf>;

Er, you opened the file (whose handle is called 'outf') for *output*, but
you're trying to *read* from it?  Shouldn't that be telling you that
something's wrong here?  What happened is that you mentally skipped over
the need to get the name of and open your second input file. 

: while (defined($in) || defined($out)) {
:     if (defined($in)) {
:         print MERGE $line1;

And of course you never opened MERGE.

:         $in = <inf>;
:     }
:     if (defined($line2)) {
:         print MERGE $line2;
: 	    $out = <outf>;
: 	}
: }

Really, all you need to do is fix the declarations problem and insert the 
code to open the second input file (preferably renaming you filehandles 
to something that isn't misleading) and you should be set.


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

Date: Mon, 23 Aug 1999 23:32:31 GMT
From: "Dallas Jones" <dallas.jones@tech4learning.com>
Subject: File Upload for WinNT W/ ActivePerl and CGI.pm-2.54
Message-Id: <jSkw3.40759$pq3.207914@news1.rdc1.sdca.home.com>

Hi, all:

I'm running NT and have ActivePerl and CGI.pm-2.54 installed. I can't get
any of the scripts I've found to upload a file from a user's browser. I've
searched through the posts herein and through the help files, but I still
don't really have a handle on what's going on. If someone would be so kind
as to explain to me what needs to be done, I will in turn create a web page
explaining that same process and post it as a resource for people who ask in
the future.

Thanks,

Dallas





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

Date: Mon, 23 Aug 1999 17:11:02 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to use a module????
Message-Id: <37C1E316.36FF0222@mail.cor.epa.gov>

Rodrigo Cortés wrote:
> 
> I have a perl script that need a module (Size.pm) but the server does'nt
> support it..
> How i can use this module???

You'll want to look at several helpful answers in the Perl
FAQ.  What they tell you is that you can get a module and keep
it in your own private directories, as long as you tell Perl
where it resides.  Try this command at a command prompt:

perldoc -q module/library

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 24 Aug 1999 02:00:39 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: Re: Perl Email With Netscape
Message-Id: <37C1FD6E.5F905872@blackhole-designs.com>

Will you guys stop flaiming me, I'm new to newsgroups. I can't help you hate
downloading extra mail, and there would be a lot less "junk mail" if you would
stop attacking people who like me, don't have much time, and just hit the reply
button.

Jimmy
elephant wrote:

>
>
> pleeeaaase - saaave me
>
> plonk
>
> --
>  jason - elephant@squirrelgroup.com -



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

Date: Mon, 23 Aug 1999 19:29:08 -0400
From: Brian Enderle <webhead@columbus.rr.com>
Subject: Running Apache & Active PERL!
Message-Id: <37C1D944.297BFDCA@columbus.rr.com>

This is a multi-part message in MIME format.
--------------A1EB85CA85EEE2CD241AE43D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Once I have installed both Apache and ActivePerl, how do I go about
running a cgi script on my personal computer?

Thanxs

--------------A1EB85CA85EEE2CD241AE43D
Content-Type: text/x-vcard; charset=us-ascii;
 name="webhead.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Brian Enderle
Content-Disposition: attachment;
 filename="webhead.vcf"

begin:vcard 
n:Enderle;Brian
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:webhead@columbus.rr.com
fn:Brian Enderle
end:vcard

--------------A1EB85CA85EEE2CD241AE43D--



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

Date: Mon, 23 Aug 1999 17:20:08 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Running Apache & Active PERL!
Message-Id: <37C1E538.EC11E6C5@mail.cor.epa.gov>

Brian Enderle wrote:
> 
> Once I have installed both Apache and ActivePerl, how do I go about
> running a cgi script on my personal computer?

The first thing to do is to go to your Start Menu and click
on the Perl documentation.  Your favorite browser will come up,
with the docs in frames.  Go to the ActivePerl FAQ and click on
the sub-heading "Web Server Config".  There's a whole section
on getting Apache to run Perl scripts.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 24 Aug 1999 00:16:23 GMT
From: mr_potato_head@my-deja.com
Subject: setuid question
Message-Id: <7pso8d$ut6$1@nnrp1.deja.com>

Hi,
  I have some users that need to drop tables in my informix database but
I do not want to give any user "resource" or "dba" permission.  Can
anyone show me in a simple perl script on how to change the user's id to
run my perl scripts as a different user?   This way I can allow the user
to drop tables but without giving them permissions other than "connect".
 Any other ideas would be appreciated.   Thanks in advance...


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 24 Aug 1999 01:19:16 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Simple text rotating and gif98a generating perl script ??
Message-Id: <Pine.HPP.3.95a.990824011845.907C-100000@hpplus03.cern.ch>

On Mon, 23 Aug 1999 marcza@my-deja.com wrote:

> So what should I do if I often need text 90 degrees clockwise rotated ?

GD.pm, surely?



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

Date: Mon, 23 Aug 1999 19:13:10 -0500
From: Andrew Sterling Hanenkamp <hanenkamp@networksplus.net>
Subject: Re: Simple text rotating and gif98a generating perl script ??
Message-Id: <37C1E396.A76981D1@networksplus.net>

Try checking CPAN for GD.pm.  I believe it uses a C library and is
designed to create gifs on the fly.  I believe I've seen it do text like
you need.  (I've never used personally, but I've use scripts from others
that make use of it.)  It's not very large, certainly not large enough to
be any kind of concern and it is quite fast.  If it doesn't suit you, you
ought to check CPAN for similar graphics modules.

marcza@my-deja.com wrote:

> As you might know HTML + Javascript don't offer a feature
> to write text vertical (from bottom to top).
>
> So what should I do if I often need text 90 degrees clockwise rotated ?
> The text itself depends from user entries and is unpredictable.
>
> Well I don't want java because the potential users might have disable
> their browser java capability. Moreover java is slow...
>
> One way could be
> to use an external graphic program,
> call this program from perl (cgi) script with the desired text through
>    an appropriate API,
> let the program rotate this text
> produce a transparent gif file
> and finally take this gif file and insert it into the original html
> code.
>
> Beside the fact that I don't know a graphic program that let me
> do such things through an API, I fear that this could be a fat program
> like photoshop - This is unacceptable due to performance problems.
>
> So my last hope is a perl script which could do the job.
>
> In general perl can generate image file. Example (ignore line wraps):
> print "Content-type:
> image/gif\n\nGIF89a\1\0\1\0\200\0\0\0\0\0\0\0\0!\371\4\1\0\0\0\0,\0\0\0
> \0\1\0\1\0\0\2\2D\1\0\n";
>
> Does anyboday know a script which let me do the task mentioned above ?
>
> Thanx
>
> Marcus
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.



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

Date: Mon, 23 Aug 1999 19:04:03 -0500
From: Andrew Sterling Hanenkamp <hanenkamp@networksplus.net>
Subject: Re: Substitute
Message-Id: <37C1E172.63C2435D@networksplus.net>

Andrew Sterling Hanenkamp wrote:

> If the line is in $_ then:
>
> s/ +/,/g;       # convert space into ','
> @num = split /,/;
>
> Or if line is variable $val
>
> $val =~ s/ +/,/g;
> @num = split /,/, $val;
>
> FYI, s/a/b/ will substitute regular expression a with regular expression b.

Er, correction.  I meant to say "FYI, s/a/b/ will substitute regular expression a
with an expression or string b."  Sorry for my mistype.  Thanks to Matthew for
pointing this out to me.

>
> and the 'g' option on the end tells it to replace all matches instead of just
> the first.  The split function returns a list containing the values split apart
> by the given regular expression.
>
> Darren wrote:
>
> > Hi
> >
> > Heres what I need to be able to do ...
> >
> > I have a line of text like ...
> >
> > one   two      three four
> >
> > I need to remove the spaces, replace them with a , and then call them from a
> > variable like $num[0] $num[1].
> >
> > All help appreciated.
> >
> > Regards
> >
> > Darren



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

Date: Mon, 23 Aug 1999 09:36:28 -0700
From: Nick Lee <leenick@interchange.ubc.ca>
Subject: testing
Message-Id: <37C1788C.23898A5E@interchange.ubc.ca>

sorry for any inconvenience


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

Date: Mon, 23 Aug 1999 17:08:48 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: The scipt dont work.!!!help me
Message-Id: <37C1E290.D5C92453@mail.cor.epa.gov>

Rodrigo Cortés wrote:
> 
> I recently write a script in perl. In my computer it work perfectly but
> when i try to execute it in the server (virtualave.net) does'nt work.

This occurs so often that it is the first question in
perlfaq9 [the 9th section of the Perl Frequently Asked
Questions]  Since you have Perl on your own computer, you
can type this at a command prompt and get a list of valuable
URLs:

perldoc -q "server error"

In addition to these, there is a rudely-named but quite
helpful guide on this at:

http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html

It will walk you through a series of reasons why your script
may have failed, and hopefully get you going.

Good luck,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 24 Aug 1999 12:01:25 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: The scipt dont work.!!!help me
Message-Id: <MPG.122ca7fe38a70c55989c75@news-server>

Rodrigo =?iso-8859-1?Q?Cort=E9s?= writes ..
>I recently write a script in perl. In my computer it work perfectly but
>when i try to execute it in the server (virtualave.net) does'nt work.

there's a bug on line 17 of your code which doesn't happen on your 
computer but does on the server (virtualave.net)

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 23 Aug 1999 17:03:09 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: URGENT: Freelance perl coder required
Message-Id: <37C1E13D.78CF4A2D@mail.cor.epa.gov>

James Liu wrote:
[snip]
[I'm leaving James' text where it was, even though it is placed 
above the post instead of below it]

> as a matter of fact, i'm doing both.  i have one for B, and i'm
> working on A.  I'll e-mail you w/ a.

Before you do too much on something to parse a CSV table,
try the DBD::CSV and TEXT::CSV modules, noe of which should
do just what you want without a lot of extra work.

> Tony Dillon <tonyd@kellion.demon.co.uk> wrote in message
> news:935308579.5212.0.nnrp-12.9e987314@news.demon.co.uk...
> > I have a couple of small Perl scripts I need written immediately.
> > Nothing too complicated, but tight deadlines mean that I don't have
> > the time to write them myself.
> >
> > I need:
> >
> > a) A script to parse a CSV file into a table. The CSV is located on
> > another server. b) A script to create a straight HTML menu of text
> > files in a folder, using the first line of each file to create the
> > menu headings, and then generate a HTML page using the se;ected
> > text file.
[snip of following trayf]

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 23 Aug 1999 23:30:15 GMT
From: Laith Suheimat <laith1@my-deja.com>
Subject: writing formatted text to console on Win32
Message-Id: <7psli8$t2m$1@nnrp1.deja.com>

Hello,

I'm currently writing a perl script to extract the users on an Oracle
7.3 database on NT 4.0, displaying the output to the console.

The output is seven columns wide, the total width being over 80 chars.

Although printf works OK, the output wraps unless I size the cmd
console correctly. As I really want to avoid doing this, is there any
way of forcing a no-wrap? Even better, is there a way of resizing the
console to the maximum width of the output?

I have also tried using format to define a report format. However, not
only is it very ugly-looking code, the following doesn't work unless I
put commas between the fieldholders (it also causes all code after the
fieldholders to become highlighted in Visual Slick Edit):

format  =
  @<<<<<<<<  @<<<<<<<<  @<<<<<<<<
  'name', 'machine', 'terminal'
  @<<<<<<<<  @<<<<<<<<  @<<<<<<<<
  '_________', '_________', '_________'
  @<<<<<<<<  @<<<<<<<<  @<<<<<<<<
  $name, $mach, $term
  .


Laith Suheimat


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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