[12256] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5856 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 2 01:07:16 1999

Date: Tue, 1 Jun 99 22:00:21 -0700
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, 1 Jun 1999     Volume: 8 Number: 5856

Today's topics:
        A new module: Naming, etc ?? <phillips@central.murdoch.edu.au>
    Re: Better solution ? (Ronald J Kimball)
    Re: Can I do this with an "if" statement? (Ronald J Kimball)
        empty line (ramon)
        extract only characters from string? (Ken Williams)
    Re: extract only characters from string? <uri@sysarch.com>
    Re: extract only characters from string? <rootbeer@redcat.com>
        Help with parsing... <portboy@home.com>
    Re: Help with parsing... <rootbeer@redcat.com>
    Re: hey p5p! Bug w/proto (\@)? (Ronald J Kimball)
        How do you print a file backwards by line? <inca@incaic.engr.sgi.com>
        how to attach a file to the mail? <globus@infonet.ee>
    Re: how to attach a file to the mail? <rootbeer@redcat.com>
        How to DeCrypt ? <d951686@sftw.umac.mo>
    Re: How to DeCrypt ? <rootbeer@redcat.com>
        How to list all installed modules <djm@tintagel.net>
    Re: How to list all installed modules <rootbeer@redcat.com>
    Re: Making Perl Wait (Ronald J Kimball)
        Remove all whitespace from string? (Ken Williams)
    Re: Remove all whitespace from string? <uri@sysarch.com>
        Removing blank lines... <portboy@home.com>
    Re: Removing blank lines... <g.sands@auckland.ac.nz>
    Re: Removing blank lines... (jaya)
    Re: Removing blank lines... (Fuzzy Warm Moogles)
    Re: Removing blank lines... <rootbeer@redcat.com>
    Re: string comparison - exact matching... (Tad McClellan)
    Re: string comparison - exact matching... <laurens@bsqaure.com>
        Termios question... <portboy@home.com>
        test <ron.dilley@ada.com>
    Re: Time Error <uri@sysarch.com>
    Re: undesired result with .* in s command (Ronald J Kimball)
    Re: Using Perl to call DLL functions <inca@incaic.engr.sgi.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 02 Jun 1999 11:40:45 +0800
From: Trevor Phillips <phillips@central.murdoch.edu.au>
Subject: A new module: Naming, etc ??
Message-Id: <3754A7BD.D116CA00@central.murdoch.edu.au>

Hi! I'm taking my first steps into writing a Perl Module with the intent
of publically distributing it via CPAN. As such, I'm after some tips on
some issues, the biggie being what to call the smegger, and to see if
anything similar has been done.

The module involves creating of form/record fields. Each field is an
object, and contains a number of properties, including name, type,
value, plus type-specific properties. There are then a number of methods
for changing and accessing the field content, depending on what is
required.

The intent is to get a level of abstraction in CGI's for form elements,
recognising that a field is different depending on whether you are
concerned with the raw value, a text-readable value, a HTML-readable
value, a HTML Form editable element, etc ...

Further down the email is a simple example of use of it in its current
infant state (Cut-down version of a test CGI).

Now, I haven't seen anything like this, so either it hasn't been done,
or it's not where I looked. ^_^

The main issue currently is what do I call it? I'm fairly certain I want
to keep it as "Fields", but the directory to place it in I'm not sure
yet. My first thought was HTML/Fields, as it is primarily for making
HTML forms easier. However, it is concievable to be used in a context
where HTML is not required at all, as there are a number of non-HTML
ways of representing the fields.

For example, I plan to add an "as_sql" method, to return the value of
the field as something which can be put straight into a SQL Query, so
feasably it could be used to read an SQL table, do some internal value
processing, and then output a plaintext report!

So something fairly generic would be good, so maybe Data/Fields ?? What
do people think??

Once this is done, I'll probably look at making an accompanying Records
module, allowing a Record to contain a number of fields in one object,
etc ...

Any opinions, ideas, etc, would be most appreciated!

Sample Usage:

#!/usr/local/bin/perl

use Fields;

@fields = ();
$nf = Fields->new("name");
$nf->type("string");
$nf->value("Joe Blow");
push(@fields,$nf);
$nf = Fields->new("desc","text");
$nf->value("Here's some multi-line text!\nWhaddya think?");
push(@fields,$nf);

print <<STOP;
Content-type: text/html


<FORM>
<TABLE BORDER=1>
STOP

foreach $name (@fields)
{
   print "<TR>\n";
   print "   <TD VALIGN=TOP>".$name->name."</TD>\n";
   print "   <TD VALIGN=TOP>".$name->type."</TD>\n";
   print "   <TD VALIGN=TOP>".$name->value."</TD>\n";
   print "   <TD VALIGN=TOP>".$name->as_html."</TD>\n";
   print "   <TD VALIGN=TOP>".$name->as_form."</TD>\n";
   print "</TR>\n";
}

print <<STOP;
</TABLE>
</FORM>
STOP

Note: This eg doesn't show changing properties of fields, such as a
strings size, etc...
Note 2: This eg shows field type "string" for a single-line string, and
"text" for multi-line text. These are fairly simple data types, and easy
to translate to form elements. This module will really shine (hopefully)
with more complex data types, such as dates, URL's, etc ...

-- 
 . Trevor Phillips             -           http://jurai.murdoch.edu.au/ . 
: CWIS Technical Officer         -           T.Phillips@murdoch.edu.au : 
| IT Services                       -               Murdoch University | 
 >------------------- Member of the #SAS# & #CFC# --------------------<
| On nights such as this, evil deeds are done. And good deeds, of     /
| course. But mostly evil, on the whole.                             /
 \      -- (Terry Pratchett, Wyrd Sisters)                          /


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

Date: Wed, 2 Jun 1999 00:40:29 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Better solution ?
Message-Id: <1dsqs1h.17ng0e11hpic74N@p229.block1.tc6.state.ma.tiac.com>

Dale Henderson <dhenders@cpsgroup.com> wrote:

>     n> I never can remember those switches :)
> 
>     Uri> you should know -p and -n and -e. then add -0, -l and a few
>     Uri> others. most of the others are not that commonly used.
>      
>      Of the above I'm vaguely familiar with -n and -p. I know -e, -c, -d,
>      -w and -T. (constantly using those last two.)

What about the poor -s?  No one ever uses -s!

:)

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
      perl -e'for(sort keys%main::){print if $$_ eq 1}
            ' -s  -- -' Just' -' another ' -'Perl ' -'hacker 
' http://www.tiac.net/users/chipmunk/ [rjk@linguist.dartmouth.edu]


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

Date: Wed, 2 Jun 1999 00:40:32 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Can I do this with an "if" statement?
Message-Id: <1dsqsf3.1l54y62171bfoxN@p229.block1.tc6.state.ma.tiac.com>

Ala Qumsieh <aqumsieh@matrox.com> wrote:

>   if 1 <= ans <= 60:
>     # bla bla
> 
> Is this a tough thing to add to Perl? I'll try to investigate this
> myself, but maybe someone else (more knowledgable with Perl's guts)
> would be able to elaborate more on this.

Well, you can do this, anyway:

$ans = 10;
if (60 => $ans => 1) {
  print "woo!\n";
}


;)


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Wed, 02 Jun 1999 03:32:03 GMT
From: ramon@gila.sunion.arizona.edu (ramon)
Subject: empty line
Message-Id: <3754a2e1.171010510@news.azstarnet.com>

HELO:

i have a file containing questions separated by space as such:
--------------------------------
1. Summertime in the Northern Hemisphere is when

2. Where and when would you look for a nearly new Moon in the sky?

3. Planet X has a nearly circular orbit and a rotation axis which
is perpendicular to the plane of its orbit around a star. The seasons
on Planet X would be

etc....
 ------------------------------
which i place into an array. some of the questions are more than one
line and i want to combine these lines and place them into another
array. i am having trouble checking for these empty lines. what are
they ie, ('\n')? what can i compare them to?

thanks,
r



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

Date: Wed, 02 Jun 1999 03:48:40 GMT
From: tekkin@hotmail.com (Ken Williams)
Subject: extract only characters from string?
Message-Id: <3754a9b7.0@news.cgocable.net>

How do I extract only alphabet characters(a-z) from a string?

Thanks.


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

Date: 02 Jun 1999 00:06:09 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: extract only characters from string?
Message-Id: <x7vhd7cklq.fsf@home.sysarch.com>

>>>>> "KW" == Ken Williams <tekkin@hotmail.com> writes:

  KW> How do I extract only alphabet characters(a-z) from a string?

what do you mean by extract? do you want all non-alphas to be deleted?
do you want a contiguous string of alphas to be extracted? you have to
be clearer with your request.

and have you actually tried anything yourself after reading a goo perl
book, the faq and some of the docs? i answerd the previous post but i
won't do 2 in a rwo from you unless you do some homework.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 1 Jun 1999 21:49:59 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: extract only characters from string?
Message-Id: <Pine.GSO.4.02A.9906012146040.15746-100000@user2.teleport.com>

On Wed, 2 Jun 1999, Ken Williams wrote:

> How do I extract only alphabet characters(a-z) from a string?

I'm not sure which of these you want, if any. But I'm sure that
discovering what they do (and how they do it) will be an educational
experience. :-)

    my @letters = ($string =~ /([a-z])/g);

    my @letters = ($string =~ /([A-Za-z])/g);

    my $letters = join '', ($string =~ /([A-Za-z]+)/g);

    (my $letters = $string) =~ tr/a-zA-Z\0-\xff/a-za-z/d;

    $string =~ tr/a-z//d;

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 02 Jun 1999 01:01:27 GMT
From: Mitch <portboy@home.com>
Subject: Help with parsing...
Message-Id: <37541294.9154578E@home.com>

Okay, I have a config file that contains info looking something like
given below.  Now my question is, I'm able to read everything into my
program up to the first /foo/bar/foo1/foofile1 etc.  I'm reading it by
the using code taken from the Cookbook.  Here it is:

sub read_config
{
                open(CFG, $CONFIG);
                while(<CFG>) {
                chomp;
                s/#.*//;
                s/^\s+//;
                s/\s+$//;
                next unless length;
                my ($var, $value) = split ' ', $_, 2;
                $$var = $value;
        }
        return;
}

Now, here is where my problem is.  When reading the config file, and I
come across a /foo/bar/foo?/foofile?  I need to create that directory
and subsequently create the file with the text listed below the
/foo/bar/foo?/foofile? and up to the next /foo/bar/foo?/foofile?

Now the big question.  Help, how can I do this?

Thanks again,

Mitch.

-config file below

heart disable
spill
spillms 10
byp_tmo 7
res_tmo 45
/foo/bar/foo1/foofile1
A Bunch of text
goes here
/foo/bar/foo1/foofile2
A Bunch of text
goes here
/foo/bar/foo2/foofile1
A Bunch of text
goes here
/foo/bar/foo2/foofile2
A bunch of text also goes
here blah blah




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

Date: Tue, 1 Jun 1999 21:20:37 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Help with parsing...
Message-Id: <Pine.GSO.4.02A.9906012107510.15746-100000@user2.teleport.com>

On Wed, 2 Jun 1999, Mitch wrote:

> I'm reading it by the using code taken from the Cookbook.  Here it is:
> 
> sub read_config
> {
>                 open(CFG, $CONFIG);

Does the Cookbook really omit checking the return value of open? I don't
see that in my copy.

> I need to create that directory and subsequently create the file
 
> Now the big question.  Help, how can I do this?

To create a directory, you may use the mkdir function. To create a file,
you may use the open function. Both are described in the perlfunc manpage.
Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 2 Jun 1999 00:40:35 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: hey p5p! Bug w/proto (\@)?
Message-Id: <1dsqtit.1yy8j3s191h03zN@p229.block1.tc6.state.ma.tiac.com>

Bill Huston <bhuston@eden.com> wrote:

> Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
> : No.  Not even Perl builtins can do this.  I'm not even sure what
> : "builtin behavior" you refer to above.
> 
> I'm refering to how when passing a list-like thing to most perlfuncs
> which take such, one can use an array, a literal list, a sub (or another
> perlfunc) which returns a list. Examples:

So do you want the behavior of builtins or not?


> So... if these can be called identically...
> 
>     sub s1 (@) {
>       ...play with @_
>     }
> 
>     sub s2 (\@) {
>       ... play with ref to array
>     }

Those can't be called identically.  The first takes a list.  The second
requires a named array.


The prototype for join() is ($@).  If you use that prototype on your
subroutine, you get identical behavior to join().

The prototype for shift() is (\@).  If you use that prototype on your
subroutine, you get identical behavior to shift().

Either way, you can already get the behavior of builtins, using the
appropriate prototypes.  So, I'm still not quite sure what you're asking
for.


> I think if the behavior of (\@) [or some new proto character]
> could be enhanced to provide the sub a reference to any list-like 
> thing passed into it (perhaps read-only), it would make subs much 
> more powerful.

I think I see why you would want to do this, but frankly, I don't see it
happening.  Perl always flattens lists: ((1, 2, 3), 4, (5, 6)) is the
same as (1, 2, 3, 4, 5, 6).  I don't think it would be possible to
change that at this stage in the game.


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 01 Jun 1999 20:16:57 -0700
From: Edwin Salgado <inca@incaic.engr.sgi.com>
Subject: How do you print a file backwards by line?
Message-Id: <3754A229.24C1FD81@incaic.engr.sgi.com>

Hello,

Is it possible to print a file backwards line by line?

My code looks something like the following:
 .
 ..
 ...
open(FILEA, $fileA) || die "\nERROR: Couldn't open $fileA - $!\n";
open(FILEB, ">$fileB") || die "\nERROR: Couldn't open $fileA - $!\n";

while (<FILE>) {
	if (/<--a regular expression-->/) {
		print FILEB $_;  # this is where I want to print in reverse order.
	}
}

close(FILEB)
close(FILEA)
 ...
 ..
 .

I couldn't find anything in O'Reilly's "Programming Perl" or
"Perl Cookbook".

Any suggestions?

Thanks,
Edwin-


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

Date: Wed, 02 Jun 1999 06:25:05 +0300
From: Gleb Ekker <globus@infonet.ee>
Subject: how to attach a file to the mail?
Message-Id: <3754A411.3BC696DD@infonet.ee>

Hi,

can anybody help me with my problem - how to attach a file to the mail
sent by using Sendmail program? Better would be not to use any module.
Usually I send mails from my scripts as follows:

#!/usr/bin/perl
$mailprog = "/usr/sbin/sendmail";
$recipient= "globus\@infonet.ee";

open(MAIL, "|$mailprog $recipient") || die;
print MAIL "To: $recipient\n";
print MAIL "From: Your Web Site\n";
print MAIL "Subject: Test Mail\n\n";
print MAIL "? ? ? ? ? ? ? ? ? ? ? ?\n\n";
close(MAIL);

What line must I put to attach some file, for example, test.zip?

Thanks,
Gleb      globus@infonet.ee



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

Date: Tue, 1 Jun 1999 21:45:27 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: how to attach a file to the mail?
Message-Id: <Pine.GSO.4.02A.9906012144190.15746-100000@user2.teleport.com>

On Wed, 2 Jun 1999, Gleb Ekker wrote:

> can anybody help me with my problem - how to attach a file to the mail
> sent by using Sendmail program? 

Sure - the docs, FAQs, and newsgroups about sendmail can tell you how to
use it. But it would be better to use a module.

> Better would be not to use any module.

Oh. Well, whatever you say!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 02 Jun 1999 10:34:42 +0800
From: "Chow Hoi Ka, Eric" <d951686@sftw.umac.mo>
Subject: How to DeCrypt ?
Message-Id: <37549841.AF4EE503@sftw.umac.mo>

Hello,

Is it possible to ddecode the string which encoded by CRYPT in Perl ?


Eric



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

Date: Tue, 1 Jun 1999 21:26:58 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How to DeCrypt ?
Message-Id: <Pine.GSO.4.02A.9906012125590.15746-100000@user2.teleport.com>

On Wed, 2 Jun 1999, Chow Hoi Ka, Eric wrote:

> Is it possible to ddecode the string which encoded by CRYPT in Perl ?

Yes, but not sufficiently efficiently to be useful. :-)

See the FAQ for more information. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 1 Jun 1999 21:56:10 -0500
From: "Jasmine" <djm@tintagel.net>
Subject: How to list all installed modules
Message-Id: <37549dab.0@206.103.97.91>

Hello,

Is there a way to determine all of the modules that are installed on my
hosts installation of perl?

Thank you,
Jasmine
jasmine@merceds.com




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

Date: Tue, 1 Jun 1999 21:42:45 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How to list all installed modules
Message-Id: <Pine.GSO.4.02A.9906012127310.15746-100000@user2.teleport.com>

On Tue, 1 Jun 1999, Jasmine wrote:

> Is there a way to determine all of the modules that are installed on
> my hosts installation of perl?

There are a number of methods, none perfect, each with potential
shortcomings, limitations, exclusions, or even possible false positives or
false negatives. You may therefore choose to use one or a combination of
several methods. Here are a few ideas for your consideration,
illumination, and amusement.

1. Examine the perllocal (not perllocale) manpage.

2. Use the 'perl -V' command to see what the @INC paths are, then
    examine the files found in those directories to see whether they
    might be valid and properly-installed modules.

    2a.      find `perl -e 'print "@INC"'` -name '*.pm' -print

3. Take a sysadmin to dinner, buy the drinks for the first hour, then ask
    for a list of the installed modules. If you buy drinks for more than 
    one hour, also ask for the root password (in order to make it easier
    to install modules of your choice in the future, of course).

4. Use the File::Find module to search for files whose names end in .pm,
    then algorithmically or pragmatically determine whether or not that's
    a valid and properly-installed module.

5. Write a program which generates random 'use' directives, then see which 
    of those succeed in loading one or more modules.

6. Ask the Internet Oracle <oracle@cs.indiana.edu>.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 2 Jun 1999 00:40:39 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Making Perl Wait
Message-Id: <1dsqvd3.119wjvucagj9wN@p229.block1.tc6.state.ma.tiac.com>

Greg Bacon <gbacon@itsc.uah.edu> wrote:

> In article <therzog-0106990214050001@therzog-host105.dsl.visi.com>,
>   therzog@knotech.com (Tim Herzog) writes:
> : which of course is plenty for anyone with a Unix or programming
> : background, but to anyone else sounds like:
> 
> If someone doesn't have a programming background, what is he doing using
> a programming language?

Trying to get a programming background?

Now we're back to that circular reference thing again...

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Wed, 02 Jun 1999 03:47:48 GMT
From: tekkin@hotmail.com (Ken Williams)
Subject: Remove all whitespace from string?
Message-Id: <3754a983.0@news.cgocable.net>

How do I remove ALL whitespace from a string.  The faq only says how to remove 
starting and trailing whitespace.

Thanks.


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

Date: 02 Jun 1999 00:03:37 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Remove all whitespace from string?
Message-Id: <x7zp2jckpy.fsf@home.sysarch.com>

>>>>> "KW" == Ken Williams <tekkin@hotmail.com> writes:

  KW> How do I remove ALL whitespace from a string.  The faq only says
  KW> how to remove starting and trailing whitespace.

it depends are your definition of whitespace. if you mean just blanks
then this will do it:

	$string =~ tr/ //d ;

you can add more whitespace chars to that if you want

	$string =~ tr/ \n\r\t//d ;

note that tr/// is much faster then the regex version:

	$string =~ s/\s+//g ;

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 02 Jun 1999 01:56:40 GMT
From: Mitch <portboy@home.com>
Subject: Removing blank lines...
Message-Id: <37541F85.A5A706F4@home.com>

How can I remove blank lines in a file? e.g.

foo bar

foo this

after remove becomes

foo bar
foo this

Thanks, Mitch



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

Date: Wed, 02 Jun 1999 14:07:12 +1200
From: Gregory Sands <g.sands@auckland.ac.nz>
Subject: Re: Removing blank lines...
Message-Id: <375491D0.89FB531E@auckland.ac.nz>

What about:

while (<>) {
    print unless /^\s*$/;
}

Greg




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

Date: 2 Jun 1999 02:37:12 GMT
From: teqqus@asdf (jaya)
Subject: Re: Removing blank lines...
Message-Id: <7j25co$ibo4p@fido.engr.sgi.com>

removing newlines, you are trying to.

how about:

while (<FILE>) {
  print $_ unless ($oldline == "\n");
  $oldline = $_;
}



Mitch (portboy@home.com) wrote:
: How can I remove blank lines in a file? e.g.

: foo bar

: foo this

: after remove becomes

: foo bar
: foo this

: Thanks, Mitch



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

Date: Wed, 02 Jun 1999 03:52:15 GMT
From: tgy@chocobo.org (Fuzzy Warm Moogles)
Subject: Re: Removing blank lines...
Message-Id: <3754a320.192053051@news.oz.net>

On Wed, 02 Jun 1999 01:56:40 GMT, Mitch <portboy@home.com> wrote:

>How can I remove blank lines in a file? e.g.

  perl -lp00e1 file.old > file.new

-- 
Fuzzy | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: Tue, 1 Jun 1999 21:25:25 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Removing blank lines...
Message-Id: <Pine.GSO.4.02A.9906012121270.15746-100000@user2.teleport.com>

On 2 Jun 1999, jaya wrote:

> how about:
> 
> while (<FILE>) {
>   print $_ unless ($oldline == "\n");
>   $oldline = $_;
> }

I don't think that's doing what you meant it to do, even if you fix it to
use a text comparison operator for comparing text. In fact, I'm not sure
that you weren't trying to solve a different task than the one requested.
This seems to be intended to print all lines not preceeded by a blank
line, which is not the same as all lines which are not blank. 

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 1 Jun 1999 16:17:53 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: string comparison - exact matching...
Message-Id: <h5f1j7.9m5.ln@magna.metronet.com>

Mr. Pumpkin (pumpkin@nowhere.com) wrote:
: in the following statement:

: if (X eq Y)

   if ($X eq $Y)


:    {
:    allowed
:    }
: else
:   {
:    disallow
:   }

: How would you get it to return true ONLY if the two strings (x and y) are
: exactly the same. 


   Pretty much the way you have it there (except it doesn't "return
   anything, and it is not even Perl code...)


: The way it is now doesn't work - if x is "waf" and y is
: "w", right now it is evaluating as true. 


   I do not believe you (ignoring the fact that you are now talking
   about yet more variables. This is the first place that x and y
   are mentioned. X and Y are not the same as x and y).

   Prove it with Perl code that does what you says it will do.

  
: Any ideas? 


   One idea would be to post Perl code to the Perl newsgroup that
   exhibits the behavior that you want to discuss.


: (for passwords)


   I don't know what that might mean, but there are 4 Frequently
   Asked Questions that have "password" in them. Maybe they will
   help with whatever it is that you are wanting.


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

my $x = 'waf';
my $y = 'w';

if ( $x eq $y )
   { print "true\n" }
else
   { print "false\n" }
------------------------

output:

false


   See? Barely more characters than you were already typing, but
   it is Perl code not pseudo-code.


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


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

Date: Tue, 1 Jun 1999 18:14:38 -0700
From: "Lauren Smith" <laurens@bsqaure.com>
Subject: Re: string comparison - exact matching...
Message-Id: <7j20hu$f5s$1@brokaw.wa.com>


Mr. Pumpkin wrote in message ...
>in the following statement:
>
>if (X eq Y)
>   {
>   allowed
>   }
>else
>  {
>   disallow
>  }
>
>How would you get it to return true ONLY if the two strings (x and y) are
>exactly the same. The way it is now doesn't work - if x is "waf" and y is
>"w", right now it is evaluating as true. Any ideas? (for passwords)
>
>Thanks,
>Forest Johns
>fdjohns@home.com
>
>

#!/usr/bin/perl -w

$x = "waf";
$y = "w";

if ($x eq $y) {
   print "good";
} else {
   print "bad";
}

output:  bad

It works for me.

Lauren




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

Date: Wed, 02 Jun 1999 03:06:41 GMT
From: Mitch <portboy@home.com>
Subject: Termios question...
Message-Id: <37542FEE.A0C39F6F@home.com>

Okay I'd like to set the baud rate, data bits (7 or 8), stop bits (1 or
2), and parity (even, odd, none) (although for practical purposes, the
only thing anyone will ever use is baud rate and 8N1 at either 115200 or
9600). The default should be 9600 8N1.  Here's some code I was using to
tinker with this stuff...

#!/usr/bin/perl5
use POSIX;

$termios = POSIX::Termios->new;
$termios->getattr(1);
$ispeed = $termios->getispeed;
$ospeed = $termios->getospeed;
print "$ispeed\n";
print "$ospeed\n";
$termios->setispeed(&POSIX::B2400);
$ispeed2 = $termios->getispeed;
print "$ispeed2\n";
$termios->setispeed(&POSIX::B9600);

As you can tell I know how to set the input speed.  However, how do I
set the data bits, stop bits, and parity?  for the data bits, I assume
I'd use the c_cflag CS7 or CS8.  however, I'm not sure how to set
everything.  I can't seem to find any documentation on what any of the
other flags in the Posix::Termios module.

Can you help point me to which flags I need to set to obtain the
settings I want?

Thanks,

Mitch



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

Date: Tue, 01 Jun 1999 19:16:07 -0700
From: Ron Dilley <ron.dilley@ada.com>
Subject: test
Message-Id: <375493E7.80514FE6@ada.com>

test

-- 
+--------------------------------------------------------+
|   Ron Dilley          Sr. UNIX Network Administrator   |
|   ron.dilley@ada.com          Applied Digital Access   |
+--------------------------------------------------------+


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

Date: 01 Jun 1999 22:42:15 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Time Error
Message-Id: <x77lpne320.fsf@home.sysarch.com>

>>>>> "BJ" == Bill Jones <bill@fccj.org> writes:

  BJ> $year += 1900; # Damn, there goes Y2k again...

  BJ> The time is $hour:$min$sec and
                            ^
missing :

boy, was that broken!! don't post broken and untested code!

:-)

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 2 Jun 1999 00:40:42 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: undesired result with .* in s command
Message-Id: <1dsqxac.16x2xiigl4ua8N@p229.block1.tc6.state.ma.tiac.com>

Larry Rosler <lr@hpl.hp.com> wrote:

> > That didn't work since the .* matches the longest possible pattern. ...
> 
> .*? matches the shortest possible pattern.  Read about 'non-greedy 
> quantifiers' in perlre.

 .*? finds the shortest possible _leftmost_ match.  A subtle distinction,
but an important one, that often catches people unawares.

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
      perl -s -e'print sort grep {/\s+?/} keys %main::
            ' -- -is -' Just' -' another ' -'Perl ' -'hacker 
' http://www.tiac.net/users/chipmunk/ [rjk@linguist.dartmouth.edu]


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

Date: Tue, 01 Jun 1999 19:56:27 -0700
From: Edwin Salgado <inca@incaic.engr.sgi.com>
Subject: Re: Using Perl to call DLL functions
Message-Id: <37549D5B.C71EF59C@incaic.engr.sgi.com>

"Nicholas A. Robarge" wrote:
> 
> Hello!
> 
> Does anyone know of a way to have a perl program load a dynamic link
> library (DLL, on a Windows machine) and call its functions?  The
> functions were written in C and C++.  Also, similar functionality is
> needed for UNIX libraries as well.
> 
> Thank you in advance.  If you have or could point me to example code, I
> would greatly appreciate it!
> 
> Nick

You can use the "Simplified Wrapper and Inerface Generator" at:

http://www.swig.org/

which by the way is *free*.

I am currently using it to interface into C programs and haven't had any
problems as of yet.

Good Luck,
Edwin-


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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