[22597] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4818 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 4 21:06:20 2003

Date: Fri, 4 Apr 2003 18:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 4 Apr 2003     Volume: 10 Number: 4818

Today's topics:
    Re: <script language=PerlScript> <jurgenex@hotmail.com>
    Re: Bless equivalent in PHP? (Randal L. Schwartz)
    Re: Can Perl mimic the awk '/start/,/end/' syntax ctcgag@hotmail.com
    Re: Help needed for using Mail::Box CPAN Module ( perl  <kalinabears@hdc.com.au>
    Re: line sorting question <michael.p.broida@boeing.com>
        Newbie Needs Good Advice (Mike)
    Re: Newbie Needs Good Advice <jkeen@concentric.net>
    Re: Newbie Needs Good Advice <jkeen@concentric.net>
    Re: Next token ??? Error <usenet@tinita.de>
        Reformated Why won't this work. <Verbalx2@hotmail.com>
    Re: Reformated Why won't this work. (Jay Tilton)
    Re: Reformated Why won't this work. <me@privacy.net>
    Re: Reformated Why won't this work. <Verbalx2@hotmail.com>
    Re: Reformated Why won't this work. <emschwar@pobox.com>
        regular expressions: newbie question (MJL)
    Re: regular expressions: newbie question <jkeen@concentric.net>
    Re: regular expressions: newbie question <skuo@mtwhitney.nsc.com>
    Re: sort numerically descending is not right? ctcgag@hotmail.com
    Re: This script won't work for me...why!? <mgjv@tradingpost.com.au>
    Re: This script won't work for me...why!? <idont@thinkso.net>
    Re: This script won't work for me...why!? <uri@stemsystems.com>
    Re: This script won't work for me...why!? <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 04 Apr 2003 23:52:03 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: <script language=PerlScript>
Message-Id: <DUoja.8856$aQ3.7023@nwrddc02.gnilink.net>

Roland Mösl wrote:
> Who else uses Perl as scripting language
> inside HTML pages?
>
> Is practicall for program development,
> because the browser can be used as
> the GUI

However rather limited because (at least AFAIK) PerlScript is available for
IE only.

jue




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

Date: Sat, 05 Apr 2003 00:51:02 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Bless equivalent in PHP?
Message-Id: <1c0626d8de5fa2c5cc0b873ab4e699b3@news.teranews.com>

>>>>> "Eric" == Eric Arnold <umop@psyon.org> writes:

Eric> Nope.  The perl group was the first one of the two groups to answer it =]
Eric> Guess you guys have got it more together than they are. =]

I know how you get them to respond.  When you post in a PHP group,
make sure you change your sig to:

        PHP - "Training wheels without the bicycle"

and I bet you'll get a few responses really quick. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 05 Apr 2003 01:26:13 GMT
From: ctcgag@hotmail.com
Subject: Re: Can Perl mimic the awk '/start/,/end/' syntax
Message-Id: <20030404202613.827$SW@newsreader.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> Demetrius wrote:
> >
> > What is the Perl way to do:
> >
> > cat myfile.txt | awk '/start/,/end/'
>
> UUOC: This could have been written as:
>    awk '/start/,/end/' < myfile.txt
> Without using 'cat'.

UUOLT:  You could write it as:
      awk '/start/,/end/' myfile.txt

If course, it's not like there is a shortage of cats or redirections
such that they require conservation.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Sat, 5 Apr 2003 10:13:35 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Help needed for using Mail::Box CPAN Module ( perl Newbie )
Message-Id: <3e8e209e$0$21496@echo-01.iinet.net.au>


"bhat" <rnbhat89@yahoo.com> wrote in message
news:4f49dc09.0304040329.36ca9bb2@posting.google.com...
> Hello,
> I want to use the above module in one of the perl programs. How can i
> access a message from the POP3 server. I tried the below but it
> doesn't work.
>
> my $mgr     = new Mail::Box::Manager;
>
> my $folder = $mgr->open(type => 'pop3', username =>
> 'xxx@yyy.net',password => 'xx', server_name => 'mail.yy.net');
> foreach my $message ($folder->messages) {
>  my $body = $message->body;
>  my Mail::Message::Body $mmsg = $message->decoded;
>  my $part   = $mmsg->body->part(2);
> }
>
>  I am not able to fetch the body part in the plain text format it
> contains html tags also. Any help would be appreciated.
>
> Thanks and Regards,
> Roopa

Without the actual error message it's hard to say what's going on.
However, for one thing, I would think that 'username' should be 'xxx', not
'xxx@yyy.net'.

Cheers,
Rob




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

Date: Sat, 5 Apr 2003 00:03:25 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: line sorting question
Message-Id: <3E8E1D4D.A8A3AB10@boeing.com>

Andras Malatinszky wrote:
> 
> manj dodda wrote:
> 
> > I have a list of lines like
> >
> > VADA tmp4 final temp2
> > BAT tmp1 error missing
> > ADA tmp2 missing error
> > AAA temp2 tmp1 tmp2
> > ............
> >
> > It is in a array as
> > @myArray
> > $myArray[0] = "VADA tmp4 final temp2" ;
> > $myArray[1] = "BAT tmp1 error missing" ;
> > $myArray[2] =
> >
> > Now i want to sort the array based on the first element of the
> > line.
> > What i want is finally
> > $myArray[0] = "AAA temp2 tmp1 tmp2" ;
> > $myArray[1]  = "ADA tmp2 missing error" ;
> > $myArray[2]  = "BAT tmp1 error missing" ;
> >
> > How is this done ?.
> 
> How is that different from regular alphabetical sorting?

	From his/her example, the first "field" can be of varying length.
	See the part about "VADA..." and "BAT...".  So we need to assume
	that a long first field in one record could use some of the same
	columns as the second field in another record. In that case, you
	can't just alphabetically sort the whole line.

	The key he/she needs is a way to tell it to sort on the first field
	before whitespace, and that's what several others have given using
	split.

		Mike


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

Date: 4 Apr 2003 15:58:47 -0800
From: flyby@webescape.com (Mike)
Subject: Newbie Needs Good Advice
Message-Id: <290e4b32.0304041558.94777b9@posting.google.com>

Hello, as part of a job which requires me to generate PDF files for 
upload to the web, I must first download a half dozen or so data files 
from two different webpages. Both pages require username/password 
logins when a link is clicked to get a file manually. Also, the 
filenames that I need from those webpages change daily (by date) for 
example today being April 4th I might need ABC0405.zip, DEF0405.zip 
where 0405 is tomorrow's date as part of the filename. In other words 
I need "ABC" and "DEF" files every day, but the 0405.zip part will be 
0406.zip tomorrow. The files also become available throughout the day 
at somewhat random intervals which makes it especially tedious because 
I have to manually keep checking the pages for updates for hours on 
end. 

Now, ideally what I'd like to have is either a script of some kind, or 
a custom application that will automate the whole download/upload 
process for me. I've yet to find any retail application that fits the 
bill, so after much frustration I'm considering trying to learn 
programming myself. I'm a complete beginner to PERL. My question to 
you all is, should I even bother to learn PERL for this task or is a 
VB6 application (or other language) more suited for what I need. 
Thinking I had a "solution", last week I purchased a VBScript 
reference book by Wrox press and after the 4th chapter I became 
completely lost with it. I see no way of downloading the required 
files using standalone VBScript, at least as this book presents it. 
Also, I keep seeing all of these programming languages like VB6, PERL, 
ASP, VBScript, Python, C++, etc. etc. but to be honest I have no clue 
what's best suited to my needs. As far as my programming experience 
goes, I did write some decent little programs in BASIC about 15-20 
years ago but that's it, nothing recent. Your advice is greatly 
appreciated. Please point me in the right direction.


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

Date: 05 Apr 2003 00:35:54 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Newbie Needs Good Advice
Message-Id: <b6l8da$fls@dispatch.concentric.net>


"Mike" <flyby@webescape.com> wrote in message
news:290e4b32.0304041558.94777b9@posting.google.com...
>
> Now, ideally what I'd like to have is either a script of some kind, or
> a custom application that will automate the whole download/upload
> process for me. I've yet to find any retail application that fits the
> bill, so after much frustration I'm considering trying to learn
> programming myself. I'm a complete beginner to PERL. My question to
> you all is, should I even bother to learn PERL for this task or is a
> VB6 application (or other language) more suited for what I need.

(Almost) needless to say, but if you post on this list you're going to be
advised to tackle this problem with Perl.  Apart from the soundness of Perl
as a language, any solution you develop with Perl will have greater
cross-platform applicability than one you develope with VBScript.

> Thinking I had a "solution", last week I purchased a VBScript
> reference book by Wrox press and after the 4th chapter I became
> completely lost with it. I see no way of downloading the required
> files using standalone VBScript, at least as this book presents it.

True, but let's be honest.  Given the relative complexity of your problem,
if you went out and purchased the equivalent Wrox book on Perl, you'd be
completely lost after Chapter 4 there as well (and both the introductory and
intermediate Wrox Perl books are quite good -- as are the O'Reilly books).
Any programming language requires study.  In any language, one level of
study will enable you to develop solutions to certain problems; more study
will enable you to solve more problems.

In this particular case, if you were to develop a Perl solution, it would
entail not just Perl but Perl extensions, known as modules, from Perl's
worldwide archive, www.cpan.org.  This is a good thing, not a bad thing, as
your solution will rest on the shoulders of thousands of Perlmongers around
the world who have contributed to the ongoing development of the language
and its applicability.  I myself cannot rattle off the names of the Perl
modules that you would use to solve your problem, but no doubt there are
people on this list who can and soon will.

> Also, I keep seeing all of these programming languages like VB6, PERL,
> ASP, VBScript, Python, C++, etc. etc. but to be honest I have no clue
> what's best suited to my needs.

If you have a variety of system admin and network admin tasks, Perl will be
an excellent choice.

> Your advice is greatly
> appreciated. Please point me in the right direction.

1.  On this list, please put a relevant description in the Subject line of
your posting.  Many readers will immediately pass over one with your
subject.
2.  Learn Perl!  Here's a plug for the text I use for an intro to Perl
course:  http://www.oreilly.com/catalog/lperl3/

HTH





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

Date: 05 Apr 2003 00:35:55 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Newbie Needs Good Advice
Message-Id: <b6l8db$flu@dispatch.concentric.net>


"Mike" <flyby@webescape.com> wrote in message
news:290e4b32.0304041558.94777b9@posting.google.com...
>
> Now, ideally what I'd like to have is either a script of some kind, or
> a custom application that will automate the whole download/upload
> process for me. I've yet to find any retail application that fits the
> bill, so after much frustration I'm considering trying to learn
> programming myself. I'm a complete beginner to PERL. My question to
> you all is, should I even bother to learn PERL for this task or is a
> VB6 application (or other language) more suited for what I need.

(Almost) needless to say, but if you post on this list you're going to be
advised to tackle this problem with Perl.  Apart from the soundness of Perl
as a language, any solution you develop with Perl will have greater
cross-platform applicability than one you develope with VBScript.

> Thinking I had a "solution", last week I purchased a VBScript
> reference book by Wrox press and after the 4th chapter I became
> completely lost with it. I see no way of downloading the required
> files using standalone VBScript, at least as this book presents it.

True, but let's be honest.  Given the relative complexity of your problem,
if you went out and purchased the equivalent Wrox book on Perl, you'd be
completely lost after Chapter 4 there as well (and both the introductory and
intermediate Wrox Perl books are quite good -- as are the O'Reilly books).
Any programming language requires study.  In any language, one level of
study will enable you to develop solutions to certain problems; more study
will enable you to solve more problems.

In this particular case, if you were to develop a Perl solution, it would
entail not just Perl but Perl extensions, known as modules, from Perl's
worldwide archive, www.cpan.org.  This is a good thing, not a bad thing, as
your solution will rest on the shoulders of thousands of Perlmongers around
the world who have contributed to the ongoing development of the language
and its applicability.  I myself cannot rattle off the names of the Perl
modules that you would use to solve your problem, but no doubt there are
people on this list who can and soon will.

> Also, I keep seeing all of these programming languages like VB6, PERL,
> ASP, VBScript, Python, C++, etc. etc. but to be honest I have no clue
> what's best suited to my needs.

If you have a variety of system admin and network admin tasks, Perl will be
an excellent choice.

> Your advice is greatly
> appreciated. Please point me in the right direction.

1.  On this list, please put a relevant description in the Subject line of
your posting.  Many readers will immediately pass over one with your
subject.
2.  Learn Perl!  Here's a plug for the text I use for an intro to Perl
course:  http://www.oreilly.com/catalog/lperl3/

HTH






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

Date: 5 Apr 2003 00:40:17 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Next token ??? Error
Message-Id: <tinhcuhvv$6xy$tina@news01.tinita.de>

Stephan Bour <sbour@niaid.nih.gov> wrote:
>> 
>> what's your perl-version?
>> type "perl -v"
>> 
>> error messages like "next token" came from perl4...
>> maybe you would like to upgrade?

> Getting weirder by the minute:

> perl -v
> This is perl, v5.6.0 built for darwin
> Copyright 1987-2000, Larry Wall

oops, right, this message still appears in 5.8.0.
well, but it comes from the missing semicolons like
somebody said.
sorry for the confusion... =)

-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: Fri, 04 Apr 2003 23:29:45 GMT
From: "Josh Morrison" <Verbalx2@hotmail.com>
Subject: Reformated Why won't this work.
Message-Id: <Jzoja.50975$0X.9944370@twister.columbus.rr.com>

I offer my apologies, my rush and frustration with this script did get the
better of me.


#!/usr/local/bin/perl
# weather.pl
use strict;

# Define Variables

#What's the path to the 5-day accuweather data file?
$five_data="5day.txt";
#What's the path to the 5-day accuweather template?
$five_template="fiveday.html";

#What's the path to the current accuweather file?
$current_data="localcur.txt";
#What's the path to the current accuweather template?
$current_template="current.html";
#What's the path to the accuweather button template?
$button_template="button.html";
#What's the path to the accuweather view2 template?
$view2_template="view2.html";



# LET'S ROLL
####################################################################
"et_time;
$show=$ENV{'QUERY_STRING'};



if (uc($show) eq "CURRENT"){
 $count=0;

  &open_file("CURRENT","",$current_data);

 foreach $line (&read_file("CURRENT")) {
 # split the fields at the | character
 @tabledata = split(/\s*\|\s*/,$line ,11);
 $station=$tabledata[0];
    $sky = $tabledata[1];
    $current_temp = $tabledata[2];
    $feel_temp = $tabledata[3];
    $humidity= $tabledata[4];
    $wind_dir = $tabledata[5];
    $wind_speed= $tabledata[6];
    $pressure = $tabledata[7];
    $visibility = $tabledata[8];
    $icon = $tabledata[9];
    $redundant = $tabledata[10];

    chop($tabledata[10]);
    $count++;

     if($count ==3){
  $template=$current_template;
  print "content-type:text/html\n\n";
  print &read_template;
  exit;
  }



 }

}


elsif (uc($show) eq "BUTTON"){
 $count=0;

  &open_file("CURRENT","",$current_data);

 foreach $line (&read_file("CURRENT")) {
 # split the fields at the | character
 @tabledata = split(/\s*\|\s*/,$line ,11);
 $station=$tabledata[0];
    $sky = $tabledata[1];
    $current_temp = $tabledata[2];
    $feel_temp = $tabledata[3];
    $humidity= $tabledata[4];
    $wind_dir = $tabledata[5];
    $wind_speed= $tabledata[6];
    $pressure = $tabledata[7];
    $visibility = $tabledata[8];
    $icon = $tabledata[9];
    $redundant = $tabledata[10];

    chop($tabledata[10]);
    $count++;

     if($count ==3){
  $template=$button_template;
  print "content-type:text/html\n\n";
  print &read_template;
  exit;
  }



 }

}


elsif (uc($show) eq "5DAY"){

  &open_file("FIVE","",$five_data);

 foreach $line (&read_file("FIVE")) {
 # split the fields at the | character
 @tabledata = split(/\s*\|\s*/,$line ,5);
 $col1[$count]=$tabledata[0];
    $col2[$count] = $tabledata[1];
    $col3[$count] = $tabledata[2];
    $col4[$count] = $tabledata[3];
    $col5[$count]= $tabledata[4];
    chop($tabledata[4]);
    $count++;
 }


  $template=$five_template;
  print "content-type:text/html\n\n";
  print &read_template;
  exit;

}

elsif (uc($show) eq "VIEW2"){

  &open_file("FIVE","",$five_data);

 foreach $line (&read_file("FIVE")) {
 # split the fields at the | character
 @tabledata = split(/\s*\|\s*/,$line ,5);
 $col1[$count]=$tabledata[0];
        $col2[$count]=$tabledata[1];
        $col3[$count]=$tabledata[2];
        $col4[$count]=$tabledata[3];
        $col5[$count]=$tabledata[4];
    chop($tabledata[4]);
    $count++;
 }



  $count=0;

  &open_file("CURRENT","",$current_data);

 foreach $line (&read_file("CURRENT")) {
 # split the fields at the | character
 @tabledata = split(/\s*\|\s*/,$line ,11);
 $station=$tabledata[0];
    $sky = $tabledata[1];
    $current_temp = $tabledata[2];
    $feel_temp = $tabledata[3];
    $humidity= $tabledata[4];
    $wind_dir = $tabledata[5];
    $wind_speed= $tabledata[6];
    $pressure = $tabledata[7];
    $visibility = $tabledata[8];
    $icon = $tabledata[9];
    $redundant = $tabledata[10];

    chop($tabledata[10]);
    $count++;

    }
  $template=$view2_template;
  print "content-type:text/html\n\n";
  print &read_template;
  exit;

}


sub read_template{

   $tag="";
   $pretag="";
   $output="";
   open(OUTPUT, "$template") || print "no file found $template!";


   while(<OUTPUT>)
   {
    $output .= $_;
    }

     close(OUTPUT);

   $output =~ s/!DATE!/$daze/gm;
   $output =~ s/!TIME!/$time/gm;

   $output =~ s/!STATION!/$station/gm;
   $output =~ s/!SKY!/$sky/gm;
   $output =~ s/!CURRENT_TEMP!/$current_temp/gm;
   $output =~ s/!FEEL_TEMP!/$feel_temp/gm;
   $output =~ s/!HUMIDITY!/$humidity/gm;
   $output =~ s/!WIND_DIR!/$wind_dir/gm;
   $output =~ s/!WIND_SPEED!/$wind_speed/gm;
   $output =~ s/!PRESSURE!/$pressure/gm;
   $output =~ s/!VISIBILITY!/$visibility/gm;
   $output =~ s/!ICON!/$icon/gm;

   $output =~ s/!DAY1!/$col1[1]/gm;
   $output =~ s/!DAY1_ICON!/$col2[1]/gm;
   $output =~ s/!DAY1_FORECAST!/$col3[1]/gm;
   $output =~ s/!DAY1_HIGH!/$col4[1]/gm;
   $output =~ s/!DAY1_LOW!/$col5[1]/gm;

   $output =~ s/!DAY2!/$col1[2]/gm;
   $output =~ s/!DAY2_ICON!/$col2[2]/gm;
   $output =~ s/!DAY2_FORECAST!/$col3[2]/gm;
   $output =~ s/!DAY2_HIGH!/$col4[2]/gm;
   $output =~ s/!DAY2_LOW!/$col5[2]/gm;

   $output =~ s/!DAY3!/$col1[3]/gm;
   $output =~ s/!DAY3_ICON!/$col2[3]/gm;
   $output =~ s/!DAY3_FORECAST!/$col3[3]/gm;
   $output =~ s/!DAY3_HIGH!/$col4[3]/gm;
   $output =~ s/!DAY3_LOW!/$col5[3]/gm;

   $output =~ s/!DAY4!/$col1[4]/gm;
   $output =~ s/!DAY4_ICON!/$col2[4]/gm;
   $output =~ s/!DAY4_FORECAST!/$col3[4]/gm;
   $output =~ s/!DAY4_HIGH!/$col4[4]/gm;
   $output =~ s/!DAY4_LOW!/$col5[4]/gm;

   $output =~ s/!DAY5!/$col1[5]/gm;
   $output =~ s/!DAY5_ICON!/$col2[5]/gm;
   $output =~ s/!DAY5_FORECAST!/$col3[5]/gm;
   $output =~ s/!DAY5_HIGH!/$col4[5]/gm;
   $output =~ s/!DAY5_LOW!/$col5[5]/gm;

   return "$output\n";

  }


 sub get_time {


 $time=time;
 $time2=localtime($time);
 ($wday, $month, $day, $time, $year) = split(" ",$time2,5);
 $year = substr($year,2,2);
 $month = uc($month);
 if ($month eq "DEC"){
  $month="12";}
 elsif ($month eq "NOV"){
  $month="11";}
 elsif ($month eq "OCT"){
  $month="10";}
 elsif ($month eq "SEP"){
  $month="9";}
 elsif ($month eq "AUG"){
  $month="8";}
 elsif ($month eq "JUL"){
  $month="7";}
 elsif ($month eq "JUN"){
  $month="6";}
 elsif ($month eq "MAY"){
  $month="5";}
 elsif ($month eq "APR"){
  $month="4";}
 elsif ($month eq "MAR"){
  $month="3";}
 elsif ($month eq "FEB"){
  $month="2";}
   elsif ($month eq "JAN"){
  $month="1";}
 $daze="$month/$day/$year";
}


# READ LISTINGS

sub read_file
{
 local($file_var) = @_;
 local(@file_lines) = ();

 while(<$file_var>)
        {
  chop;
  push(@file_lines, $_);

 }
 close($file_var);
 return(@file_lines);
}

# OPEN LISTING

sub open_file {

  local ($filevar, $filemode, $listings) = @_;

  open ($filevar,$filemode . $listings) ||
     die ("Can't open $listings");
}





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

Date: Fri, 04 Apr 2003 23:47:00 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Reformated Why won't this work.
Message-Id: <3e8e16f7.23276071@news.erols.com>

"Josh Morrison" <Verbalx2@hotmail.com> wrote:

: I offer my apologies, my rush and frustration with this script did get the
: better of me.

_Read_ the posting guidelines.  Pay close attention to the subsection
titled "Beware of saying 'doesn't work.'"

What reasons does perl give for its refusal to run your program?
_Read_ the error messages.  The error messages are the Truth.

: #!/usr/local/bin/perl
: # weather.pl
: use strict;

And not a single "my" or "our" or "use vars" to be seen anywhere.
It is somehow surprising that this program doesn't run?



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

Date: Sat, 5 Apr 2003 09:51:59 +1000
From: "Tintin" <me@privacy.net>
Subject: Re: Reformated Why won't this work.
Message-Id: <b6l5r1$6o8gv$1@ID-172104.news.dfncis.de>


"Josh Morrison" <Verbalx2@hotmail.com> wrote in message
news:Jzoja.50975$0X.9944370@twister.columbus.rr.com...
> I offer my apologies, my rush and frustration with this script did get the
> better of me.

[snipped code]

How long have you been programming in Perl for?  That code was truely and
utterly hideous.

Start with Martien's suggestions, and when you've got that under control, we
might be able to help you with some of the other bits left over.




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

Date: Fri, 04 Apr 2003 23:52:52 GMT
From: "Josh Morrison" <Verbalx2@hotmail.com>
Subject: Re: Reformated Why won't this work.
Message-Id: <oVoja.50976$0X.9968918@twister.columbus.rr.com>

Http 5000 Internal Server Error




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

Date: 04 Apr 2003 17:04:24 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Reformated Why won't this work.
Message-Id: <eto1y0hdd2v.fsf@wormtongue.emschwar>

"Josh Morrison" <Verbalx2@hotmail.com> writes:
> Http 5000 Internal Server Error

You probably mean "500 server error", in which case first try to run
it from the command line, fix all the bugs that shows, and then upload
it to your webserver.

And *THEN* see 'perldoc -q 500'.  Don't bother with that until you can
run it from the command line, though.

Oh, and use CGI.pm.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 4 Apr 2003 16:32:17 -0800
From: mail@affordablemedicalsoftware.com (MJL)
Subject: regular expressions: newbie question
Message-Id: <29c5bb08.0304041632.7a4dd054@posting.google.com>

if I have a sentence:
cats like to eat cat food with other cats.
and I want to change it to:
dogs like to eat dog food with other dogs.

why can't I do this?

while ((s/cat/dog/) );

or this:

while (defined (s/cat/dog/) );

or:

while ( (s/cat/dog/) == 1);

s/cat/dog/ by itself only replaces the first instance.

thanks!

-mjl


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

Date: 05 Apr 2003 00:39:44 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: regular expressions: newbie question
Message-Id: <b6l8kg$fm6@dispatch.concentric.net>


"MJL" <mail@affordablemedicalsoftware.com> wrote in message
news:29c5bb08.0304041632.7a4dd054@posting.google.com...
> if I have a sentence:
> cats like to eat cat food with other cats.
> and I want to change it to:
> dogs like to eat dog food with other dogs.
>
> why can't I do this?
>
> while ((s/cat/dog/) );
>
1.  You need the /g modifier.

my $str = 'cats like to eat cat food with other cats';
$str =~ s/cat/dog/g;
print "$str\n";

2.  Why do you have this inside a 'while' loop?





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

Date: Fri, 4 Apr 2003 16:52:09 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: regular expressions: newbie question
Message-Id: <Pine.GSO.4.21.0304041647380.8753-100000@mtwhitney.nsc.com>

On 4 Apr 2003, MJL wrote:

> if I have a sentence:
> cats like to eat cat food with other cats.
> and I want to change it to:
> dogs like to eat dog food with other dogs.
> 
> why can't I do this?
> 
> while ((s/cat/dog/) );




That's close to being a solution.  You can do this:

$_ = 'cats like to eat cat food with other cats.';
1 while (s/cat/dog/);  # note the '1'
print; 



> or this:
> 
> while (defined (s/cat/dog/) );
>
> or:
> 
> while ( (s/cat/dog/) == 1);
> 
> s/cat/dog/ by itself only replaces the first instance.




A better way is to use:

s/cat/dog/g;   # note the 'g' modifier

See perldoc perlre for more information.

-- 
Hope this helps,
Steven




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

Date: 05 Apr 2003 01:50:51 GMT
From: ctcgag@hotmail.com
Subject: Re: sort numerically descending is not right?
Message-Id: <20030404205051.541$ei@newsreader.com>

Bing Du Test <bing-du@tamu.edu> wrote:
> Script is like this:
>
> =======
> #!/usr/local/bin/perl
>
> @terms =
> ('2003V','20033','20032','20031','20023','2004A','2003B','2003C','2002V',
> '2002C');
>
> foreach $term (sort {$b <=> $a} @terms)
>       {
>         push @terms_in_order, $term;
>       }
>
> print "terms_in_order are ",join(',',@terms_in_order),"\n";
> ======
>
> The result is:
>
> =======
> terms_in_order are
> 20033,20032,20031,20023,2004A,2003B,2003C,2003V,2002C,2002V
> =======

These are sorted in descending numerical order, just as your
subject line says.  Were you hoping that perl would interpret these
as base 32 (or higher) numbers?


> But what I expect should be:
>
> ======
> terms_in_order are
> 2004A,2003V,2003C,2003B,20033,20032,20031,2002V,2002C,20023
> ======
>
> Can anybody tell me why @terms is not sorted?

No, as it *is* sorted.  Can you tell us why you expected what you
expected?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Sat, 5 Apr 2003 09:00:47 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: This script won't work for me...why!?
Message-Id: <slrnb8s3kv.d9c.mgjv@martien.heliotrope.home>

On Fri, 04 Apr 2003 22:43:19 GMT,
	Josh Morrison <Verbalx2@hotmail.com> wrote:
> #!/usr/local/bin/perl

no warnings, no strict, using home-grown CGI parsing stuff instead of
the CGI module. No formatting of your source code to help humans read
the program.

Fix all of those, before you consider asking for our time again. The
first two will most likely point out most of the problems your program
has. The third one will get rid of other bugs that you are probably not
aware of yet, and the last one will give people a chance to read what
you post.

When you post again, do not post an enormous program without any
indication as to where the error occurs. Before posting again, make sure
you read www.augustmail.com/~tadmc/clpmisc/ clpmisc_guidelines.html, and
the first few questions and answers in section 9 of the Perl FAQ.

[snip of unreadable mess]

Martien
-- 
                        | 
Martien Verbruggen      | 
                        | Can't say that it is, 'cause it ain't.
                        | 


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

Date: Fri, 4 Apr 2003 18:11:15 -0500
From: "Chris W" <idont@thinkso.net>
Subject: Re: This script won't work for me...why!?
Message-Id: <l_qdne22AORsjROjXTWcpw@comcast.com>


"Josh Morrison" <Verbalx2@hotmail.com> wrote in message
news:bUnja.50959$0X.9898645@twister.columbus.rr.com...
> #!/usr/local/bin/perl

< GEEEZZ that needed a SNIP>

You really want people to read that ???  Format it so it is readable, and
include the error messages you are getting (If you aren't getting them, you
aren't trying very hard).  I don't know about others, but reading that much
unformatted code is WORSE than cumbersome.





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

Date: Fri, 04 Apr 2003 23:14:13 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: This script won't work for me...why!?
Message-Id: <x7smsxam9n.fsf@mail.sysarch.com>

becauseitisunreadableandhorribleperl4code


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

Date: Fri, 04 Apr 2003 23:55:08 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: This script won't work for me...why!?
Message-Id: <wXoja.8873$aQ3.4048@nwrddc02.gnilink.net>

Josh Morrison wrote:
> #!/usr/local/bin/perl
[...]
> $sky = $tabledata[1]; $current_temp = $tabledata[2]; $feel_temp =
> $tabledata[3]; $humidity= $tabledata[4]; $wind_dir = $tabledata[5];
> $wind_speed= $tabledata[6]; $pressure = $tabledata[7]; $visibility =
> $tabledata[8]; $icon = $tabledata[9]; $redundant = $tabledata[10];

You got a missing double quote in statement 42.

jue




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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 4818
***************************************


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