[21901] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4105 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 12 14:12:24 2002

Date: Tue, 12 Nov 2002 11:10:15 -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           Tue, 12 Nov 2002     Volume: 10 Number: 4105

Today's topics:
    Re: Perl: string vs. numeric (Tad McClellan)
    Re: Perl: string vs. numeric (Tad McClellan)
        please interpret highlighted lines of script for me (pat2469)
    Re: please interpret highlighted lines of script for me <nospam@nospam.org>
        Question on -B <rdsmith@sedona.intel.com>
    Re: sendmail diagnostic <nobull@mail.com>
        simple newbie question <japie@nospam.org>
    Re: simple newbie question <nobull@mail.com>
    Re: simple newbie question <fxn@hashref.com>
    Re: simple newbie question <japie@nospam.org>
    Re: simple newbie question <japie@nospam.org>
        Some Perl LWP problem (dan123)
    Re: Splitting on a line break that isn't (Tad McClellan)
    Re: Splitting on a line break that isn't <jurgenex@hotmail.com>
    Re: Splitting on a line break that isn't (robertbu)
    Re: string vs. numeric <jurgenex@hotmail.com>
    Re: What began everything? <postmaster@127.0.0.1>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 12 Nov 2002 07:20:43 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl: string vs. numeric
Message-Id: <slrnat201b.346.tadmc@magna.augustmail.com>

yisraelharris <member@mainframeforum.com> wrote:


> If there's a better solution, where the function knows that the first
> element had quotations and the second doesn't, and proceeds accordingly,
> I'd be very grateful if someone could tell me.


   sub function {
      my($first, $second) = @_;
      if ( $first = /^'[^']*'$/ and $second !~ /^'[^']*'$/ ) {
         proceed_accordingly();
      }
   }


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


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

Date: Tue, 12 Nov 2002 07:17:38 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl: string vs. numeric
Message-Id: <slrnat1vri.346.tadmc@magna.augustmail.com>

yisraelharris <member@mainframeforum.com> wrote:

> If you please: I'd appreciate no advice, comments, questions, etc.


Then don't post to Usenet, because that is what happens here.


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


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

Date: 12 Nov 2002 10:24:44 -0800
From: PAT2469@YAHOO.COM (pat2469)
Subject: please interpret highlighted lines of script for me
Message-Id: <b7c2ebdb.0211121024.1c5f0dee@posting.google.com>

#! /usr/local/bin/sybperl
#
# Trim Trailing Whitespace
#
$file = $ARGV[0];
$newfile = $file .".new";
open (NF, ">$newfile");
while(<>) {
   s/\s+$//;
   print NF $_, "\n";
}


pat2469@yahoo.com


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

Date: Tue, 12 Nov 2002 13:36:05 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: please interpret highlighted lines of script for me
Message-Id: <aqrhml$r417@nrn2.NRCan.gc.ca>


"pat2469" <PAT2469@YAHOO.COM> wrote in message
news:b7c2ebdb.0211121024.1c5f0dee@posting.google.com...
> #! /usr/local/bin/sybperl
> #
> # Trim Trailing Whitespace
> #
> $file = $ARGV[0];

take the filename from the console (e.g. perl myprogram.pl filename)

> $newfile = $file .".new";

create a new name by adding ".new" as a suffix: filename.new

> open (NF, ">$newfile");

open filename.new

> while(<>) {

for each line

>    s/\s+$//;

replace any number of space at the end of the line with nothing

>    print NF $_, "\n";

print the line to the file

> }

Should be that...

Christian




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

Date: Tue, 12 Nov 2002 11:48:09 -0700
From: Ron Smith <rdsmith@sedona.intel.com>
Subject: Question on -B
Message-Id: <3DD14CE9.887CF8A2@sedona.intel.com>

I am working on a file scanning script where I would like to scan
text-like files, avoiding binary files.  It needs to be
relatively quick, and it needs to support files that have been gzipped.

The problem I have is that if I do a -B test on a "binary" file, it
works fine.  If I test a *.gz file, it incorrectly tosses away the file
(of course).  So I have to make *.gz an exception, but this causes files
which were "binary" before they were gzipped to be incorrectly included
in the scan.

If I open the file handle like this:

open(IN,"gzcat $file|");

then I cannot use the -B test because it complains that -B and -T has
not been implemented on filehandles.  (Even though it parses...)

I'd like a quick and *efficient* way to do an "accurate" -B test,
regardless of whether or not the file is currently gzipped.  (By
*efficient*, it should be assumed that I do not intend to gunzip the
file, just to make the test.)

And, yes I did rtfm and do a google search, but nothing directly
relevant seemed to come up, just a whole bunch of people asking "how do
I tell if the file is a <splat>" kind of posting.


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

Date: 12 Nov 2002 17:52:16 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: sendmail diagnostic
Message-Id: <u9k7jizne7.fsf@wcl-l.bham.ac.uk>

"Anthony" <anthony.heuveline@wanadoo.fr> writes:

>     I am using sendmail to keep my website visitors informed. These visitors
> make part of several categories and their informations are saved in a
> database. When I want to send an email, I select the concerned categories
> and then send the email to the addresses which belong to these categories
> using a while loop.
> 
>     My problem is that all works fine, exept with one category. I checked
> the addresses of this category and they seem to be valid. How can I get
> error messages giving informations on the problem that occured?

What evidence you have that any problem occured?

>     my $sendmail="/usr/lib/sendmail -t -oi -odq";

>     open(MAIL, "|$sendmail") || die "Can't start sendmail: $!";

>     close(MAIL);

Sendmail usually mails errors back to the sender. You should look in
the sender's mailbox.  Of course you can't usefully do this
immediately since the messages will still be in the queue.

A few errors are reported in the exit status.  You should check the
value of ($? << 8) after the close() and interpret it as per the
sendmail manual or sysexits.h.

You may also want to consider redirecting the STDOUT of sendmail to a
file and examinining that file.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 12 Nov 2002 17:38:00 GMT
From: Japie <japie@nospam.org>
Subject: simple newbie question
Message-Id: <Y%aA9.14$Lu1.4596@amsnews02.chello.com>

Hello,

Trying to addapt an existing perl script I ran into the following
problem:

my $thepath = "$home/.bday";
my $header = "$thepath/message_header";
print MESSAGE $header;

The command print MESSAGE $header; prints just the filename to message,
but I want it to print the contens of the file, like in:
cat $header >> message
Can someone help me?


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

Date: 12 Nov 2002 18:00:24 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: simple newbie question
Message-Id: <u9fzu6zn0n.fsf@wcl-l.bham.ac.uk>

Japie <japie@nospam.org> writes:

> Subject: simple newbie question

Please put the subject of your post in the Subject of your post.  If
in doubt try this simple test.  Imagine you could have been bothered
to have done a search before you posted.  Next imagine you found a
thread with your subject line.  Would you have been able to recognise
it as the same subject?

If the best you can come up with to describe your problem is "simple
newbie question" then you've given the matter nowhere near enough
thought to be asking help from other people.

> my $header = "$thepath/message_header";
> print MESSAGE $header;
> 
> The command print MESSAGE $header; prints just the filename to message,
> but I want it to print the contens of the file

You could use the File::Copy module.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 12 Nov 2002 19:16:56 +0100
From: Xavier Noria <fxn@hashref.com>
Subject: Re: simple newbie question
Message-Id: <87heemy7on.fsf@kodo.localdomain>

Japie <japie@nospam.org> writes:

: my $thepath = "$home/.bday";
: my $header = "$thepath/message_header";
: print MESSAGE $header;
: 
: The command print MESSAGE $header; prints just the filename to message,
: but I want it to print the contens of the file, like in:
: cat $header >> message
: Can someone help me?

We need to open the file, read its content, and print it to MESSAGE:

  my $thepath = "$home/.bday";
  my $header  = "$thepath/message_header";

  open HEADER, $header or die $!;
  my $header_content = do { local $/; <HEADER> }; # slurp the content
  close HEADER;

  print MESSAGE $header_content;

-- fxn  


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

Date: Tue, 12 Nov 2002 18:38:58 GMT
From: Japie <japie@nospam.org>
Subject: Re: simple newbie question
Message-Id: <6VbA9.29$1B1.12334@amsnews02.chello.com>

On Tue, 12 Nov 2002 19:16:56 +0100, Xavier Noria wrote:

> We need to open the file, read its content, and print it to MESSAGE:

Works like a sharm (don't know the correct spelling ;-)
Thanks a lot!!!


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

Date: Tue, 12 Nov 2002 18:40:21 GMT
From: Japie <japie@nospam.org>
Subject: Re: simple newbie question
Message-Id: <pWbA9.48$1B1.18314@amsnews02.chello.com>

On Tue, 12 Nov 2002 19:00:24 +0100, Brian McCauley wrote:

> Please put the subject of your post in the Subject of your post.

I'am sorry, I won't do it again, but thanks for your responce.


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

Date: 12 Nov 2002 10:32:45 -0800
From: my@startpage.co.il (dan123)
Subject: Some Perl LWP problem
Message-Id: <3df40d14.0211121032.5ba4c17f@posting.google.com>

I need your help with LWP module

I have some Perl/CGI script that fetching HTML web data

automaticly from 10 different sources and prints on our site.

After ~ 500 fetchings ( ~ 5 hours of working ) LWP module stucks and
doesn't work any more

till next Server reset.

We have Win 2000 server and Active PERL 5.61.

Please help me.

Thank you.


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

Date: Tue, 12 Nov 2002 07:50:34 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Splitting on a line break that isn't
Message-Id: <slrnat21pa.346.tadmc@magna.augustmail.com>

Rubber Duck <rubberducky703@hotmail.com> wrote:

> I'd love to parse on the "square box" but i don't know and can't find the
> ascii code for it.


Write a Perl program that prints every character along with its
character code, and run it against your data file.

------------------------------------
#!/usr/bin/perl
use warnings;
use strict;

while ( <> ) {
   foreach ( split // ) {
      my $asciinum = ord;
      print "$_  ==>  ($asciinum)\n";
   }
}
------------------------------------


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


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

Date: Tue, 12 Nov 2002 15:27:12 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Splitting on a line break that isn't
Message-Id: <k59A9.7957$6Z.7498@nwrddc01.gnilink.net>

Rubber Duck wrote:
> "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
> message news:aqqk99$5aj$1@nets3.rz.RWTH-Aachen.DE...
>> Also sprach Rubber Duck:
>>> I have a CSV file which separates records on a 'square box'
>>> character. (its the best way i can describe it).  I'm trying to
>>> parse the file on \n but it's not working.  All i get is one BIG
>>> line (500k) which is really about 3000 separate records.
>>
>> It's not likely to work if you parse on \n but the separator is in
>> fact a 'square box' (whatever that is; the ascii code would be
>> helpful) character. So why not parse on this squarebox instead?
>
> I'd love to parse on the "square box" but i don't know and can't find
> the ascii code for it. It looks similare to # 219 on
> http://www.asciitable.com/ except its hollow???

That's probably just a replacement in the display for non-displayable
characters.
Why don't you check the actual value in a binary editor (debug or emacs in
hexl-mode or ....).

jue




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

Date: 12 Nov 2002 07:38:45 -0800
From: robertbu@hotmail.com (robertbu)
Subject: Re: Splitting on a line break that isn't
Message-Id: <8c7725ac.0211120738.339f5228@posting.google.com>

> > >
> > > | I'd love to parse on the "square box" but i don't know and can't find
>  the
> > > | ascii code for it. It looks similare to # 219 on
>  http://www.asciitable.com/
> > > | except its hollow???
> > >
> > > Would I be correct in assuming you're developing this on a windoze box?
> > > IF so, I've got a feeling I had a similar problem writing a program a
> > > lil while back. Instead of using "\n", have you tried "\r"? It solved my
> > > problem =)

For the future, ord()allows you to dump ascii values:

my $st = "some stuff \r asdf \t asdf \g asdf \a asdf asdf \xFE"
my @arChrs = split '', $st;
foreach (@arChrs)
  {
  print "[$_] is ${\ord($_)}\n";
  }


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

Date: Tue, 12 Nov 2002 15:32:22 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: string vs. numeric
Message-Id: <aa9A9.7960$6Z.776@nwrddc01.gnilink.net>

yisraelharris wrote:
> When I pass an array which contains ('hi', 3) to a function, and
> then the function takes each element a builds a string, I get
> ".....hi 3......".
>
> What I really want is to get ".....'hi' 3....."
>
> For now, I'm passing it ("'hi'", 3) and that works. (That's single
> quotes inside double quotes, if it's difficult to discern.)

Well, it depends what you want. Do you just want to mark the text as string
or do you want to the string to include the single quotes as characters?
In both cases the solution you already got is perfectly fine.

> If there's a better solution, where the function knows that the first
> element had quotations and the second doesn't, and proceeds
> accordingly, I'd be very grateful if someone could tell me.

Of course you can always just add the quotes aroung the string:
    $string = "'$string'";

> If you please: I'd appreciate no advice, comments, questions, etc.
> Please direct solutions to this question only. Thank you :)

Haeee? What da ya mean?

jue




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

Date: Tue, 12 Nov 2002 18:42:11 +0100
From: "Divin Marquis" <postmaster@127.0.0.1>
Subject: Re: What began everything?
Message-Id: <pan.2002.11.12.17.42.01.452183@127.0.0.1>

On Sat, 09 Nov 2002 14:33:04 -0600, browntown wrote:

> If there's not a creator God, then what began everything?

#!/usr/bin/perl
$everything = "everything";
$god = "god";
while (1) {
	$everything = "what began $everything ";
	$god = "who created $god ";
}
print 42;




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

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


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