[25414] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7659 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 17 03:05:54 2005

Date: Mon, 17 Jan 2005 00:05:18 -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           Mon, 17 Jan 2005     Volume: 10 Number: 7659

Today's topics:
    Re: [perl-python] 20050116 defining a function <notvalid@email.com>
        [perl-python] 20050117, filter, map <xah@xahlee.org>
    Re: [perl-python] 20050117, filter, map <steven.bethard@gmail.com>
    Re: [perl-python] 20050117, filter, map <max@alcyone.com>
        A small question blaq.box@gmail.com
    Re: A small question <usa1@llenroc.ude.invalid>
    Re: A small question <spamtrap@dot-app.org>
    Re: Closing Excel <matthew.garrish@sympatico.ca>
    Re: Closing Excel <see.sig@rochester.rr.com>
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
    Re: email regex help <abigail@abigail.nl>
    Re: how can I use perl to do a windows "postmessage"  ? <pauls@nospam.com>
    Re: how can I use perl to do a windows "postmessage"  ? <usa1@llenroc.ude.invalid>
    Re: implementing "protected" in OO perl xhoster@gmail.com
        looking for constructive criticism on this script.... <jsmith@macroshaft.com>
    Re: looking for constructive criticism on this script.. <usa1@llenroc.ude.invalid>
    Re: Need help with Perl and MySQL database data load <toreau@gmail.com>
        Prime numbers: addative property modulo p, where p is p (Jeremy Fischer)
    Re: Print question <jurgenex@hotmail.com>
        redirect & target="_top" socialism001@yahoo.com
    Re: redirect & target="_top" <spamtrap@dot-app.org>
    Re: redirect & target="_top" <igor.lobanov@gmail.com>
    Re: redirect & target="_top" <peroli@gmail.com>
    Re: Script Not Returning Value <hx_101@hotmail.com>
    Re: Script Not Returning Value <jurgenex@hotmail.com>
        Update statement with Perl DBI for MySQL 5.0 <sam.wun@authtec.com>
    Re: Update statement with Perl DBI for MySQL 5.0 <spamtrap@dot-app.org>
        Where do you report perl bugs? <groleau+news@freeshell.org>
    Re: Where do you report perl bugs? <usa1@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 17 Jan 2005 06:38:42 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: [perl-python] 20050116 defining a function
Message-Id: <S3JGd.12448$5R.8662@newssvr21.news.prodigy.com>

Xah Lee wrote:

> ©     my $n= @_[0];

Do you ever test your code before making fun of yourself in front of 
millions?

*plonk*

--Ala



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

Date: 16 Jan 2005 18:48:59 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] 20050117, filter, map
Message-Id: <1105930139.513977.91740@c13g2000cwb.googlegroups.com>

=A9 # -*- coding: utf-8 -*-
=A9 # Python
=A9
=A9 # the "filter" function can be used to
=A9 # reduce a list such that unwanted
=A9 # elements are removed.
=A9 # example:
=A9
=A9 def even(n): return n % 2 =3D=3D 0
=A9 print filter( even, range(11))
=A9
=A9
=A9 # the "map" function applies a function
=A9 # to all elements of a list. Example:
=A9
=A9 def square(n): return n*n
=A9 print map(square, range(11))
=A9
=A9 ------------------------------------
=A9 # similar perl versions
=A9
=A9 use Data::Dumper;
=A9 sub even {return $_[0]%2=3D=3D0};
=A9 print Dumper[ grep {even $_} (0..10)];
=A9
=A9
=A9 # sub square {$n=3Dshift;$n**2;};
=A9 sub square {(shift)**2;};
=A9 print Dumper [ map {square($_)} (0..10)];
=A9
=A9 # the codes above showcase some syntax
=A9 # variations commonly found in perl code
=A9 # base
=A9
=A9 -------------------------
=A9
=A9 # in Mathematica for example, filter is
=A9 # akin to Apply and map is MapThread.
=A9 # The standard Map can be applied
=A9 # according to a level spec of trees
=A9 # and there's also MapAt, Nest,
=A9 # NestList...any many more powerful
=A9 # functions that manipulates trees.
=A9 # lisp languages often have a subset
=A9 # of it.
=A9
=A9 ----------------------------
=A9 Note: this post is from the Perl-Python
=A9 a-day mailing list at
=A9 http://groups.yahoo.com/group/perl-python/
=A9 to subscribe, send an email to
=A9 perl-python-subscribe@yahoogroups.com if
=A9 you are reading it on a web page,
=A9 program examples may not run because
=A9 html conversion often breaks the code.
=A9
=A9   Xah
=A9   xah@xahlee.org
=A9   http://xahlee.org/PageTwo_dir/more.html



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

Date: Sun, 16 Jan 2005 22:39:14 -0700
From: Steven Bethard <steven.bethard@gmail.com>
Subject: Re: [perl-python] 20050117, filter, map
Message-Id: <iI6dnV_4Dafh0nbcRVn-gg@comcast.com>

Xah Lee wrote:
> © Note: this post is from the Perl-Python
> © a-day mailing list at
> © http://groups.yahoo.com/group/perl-python/

Is there any chance you could post these all as part of the same thread? 
   That would be really nice for those of us who aren't interested -- 
then we could just ignore the thread...

Thanks in advance,

Steve


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

Date: Sun, 16 Jan 2005 22:35:08 -0800
From: Erik Max Francis <max@alcyone.com>
Subject: Re: [perl-python] 20050117, filter, map
Message-Id: <VcudnbdblbQBwXbcRVn-ig@speakeasy.net>

Steven Bethard wrote:

> Is there any chance you could post these all as part of the same thread? 
>    That would be really nice for those of us who aren't interested -- 
> then we could just ignore the thread...

Or, better yet, not posting it at all.  He's got his mailing list, what 
does he need to post it here for?

-- 
Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Make it come down / Like molasses rain
   -- Sandra St. Victor


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

Date: 16 Jan 2005 20:27:13 -0800
From: blaq.box@gmail.com
Subject: A small question
Message-Id: <1105936033.003002.134490@f14g2000cwb.googlegroups.com>

hi all

this is my first post to this group.
i have just started learning perl and
i am really amazed to find (infact couldn't find) that no keywords like
'true' or 'false' exist for perl. as we see in C/C++ etc.
experts please ensure me if i am right?

thanks for your time

blaq



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

Date: Sun, 16 Jan 2005 23:35:41 -0500
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: A small question
Message-Id: <pan.2005.01.17.04.35.10.272720@asu1cornelledu>

In article <1105936033.003002.134490@f14g2000cwb.googlegroups.com> posted
on Sun, 16 Jan 2005 20:27:13 -0800, blaq.box wrote:

> this is my first post to this group.
> i have just started learning perl and

The name of the language is Perl.

> i am really amazed to find (infact couldn't find) that no keywords like
> 'true' or 'false' exist for perl. as we see in C/C++ etc. experts please
> ensure me if i am right?

C does not have keywords true and false.

You might want to head on over to <http://learn.perl.org/> for resources
for beginners.

Sinan
-- 
A. Sinan Unur
usa1@llenroc.ude.invalid -- remove invalid and
reverse each component for email address.



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

Date: Mon, 17 Jan 2005 01:22:32 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: A small question
Message-Id: <OPGdnSTXFtE3xHbcRVn-1g@adelphia.com>

blaq.box@gmail.com wrote:

> this is my first post to this group.

Welcome aboard. If you haven't done so already, please have a look at the
posting guidelines that appear here often. No, you haven't done anything
wrong, that's just a generic comment. :-)

> i am really amazed to find (infact couldn't find) that no keywords like
> 'true' or 'false' exist for perl. as we see in C/C++ etc.
> experts please ensure me if i am right?

Well, you're right about Perl - it doesn't have 'true' or 'false' keywords.
C++ does, but C doesn't. C99 defines them as macros.

In C/C++, zero is false, non-zero is true. A NULL pointer is zero, so any
string is true. In Perl, as stated in 'perldoc perlsyn', "The number 0, the
strings '0' and '', the empty list (), and undef are all false in a boolean
context. All other values are true."

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Sun, 16 Jan 2005 19:01:46 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Closing Excel
Message-Id: <EfDGd.8814$W33.211146@news20.bellglobal.com>


"Jay Tilton" <tiltonj@erols.com> wrote in message 
news:41eadcff.63134402@news.erols.com...
> "jim simpson" <jimsimpson@cox.net> wrote:
>
> : I need to determine if Excel is running and if so close it. Can this be 
> done
> : with a Perl script and can someone suggest an approach to do it.
>
>    #!perl
>    use warnings;
>    use strict;
>    use Win32::OLE;
>
>    while(
>        my $excel =
>        Win32::OLE ->GetActiveObject('Excel.Application')
>    ) {
>        $excel ->Quit
>    }
>

I'd add the warning that the user may not appreciate you closing their 
applications. It's generally better practice to warn them that the script 
shouldn't be run while Excel (or whatever) is open and bail out.

Matt 




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

Date: Mon, 17 Jan 2005 02:07:41 GMT
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: Closing Excel
Message-Id: <N5FGd.28764$Xs6.19191@twister.nyroc.rr.com>

Jay Tilton wrote:

> "jim simpson" <jimsimpson@cox.net> wrote:
> 
> : I need to determine if Excel is running and if so close it. Can this be done
> : with a Perl script and can someone suggest an approach to do it.
> 
>     #!perl
>     use warnings;
>     use strict;
>     use Win32::OLE;
> 
>     while( 
>         my $excel = 
>         Win32::OLE ->GetActiveObject('Excel.Application') 
>     ) {
>         $excel ->Quit
>     }
> 

One might want to include a statement like:

     $excel->Application->{DisplayAlerts}='False';

before the ->Quit call if one wishes to ensure Excel actually 
shuts down without user intervention (otherwise, one may get a 
prompt about saving modified worksheets).  This might just apply 
to recent versions of Excel (as I recall, a different sequence 
was required with Excel 97 and earlier??).

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


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

Date: 17 Jan 2005 06:01:29 GMT
From: <jari.aalto <AT> poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1105939854@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto A T poboxes com

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Unix Windows port (for Unix die-hards):
            install http://www.cygwin.com/  which includes native Emacs 21.x.
            and XEmacs port

        o   Pure Native Windows port
            http://www.gnu.org/software/emacs/windows/ntemacs.html
            ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

        o   More Emacs resources at
            http://tiny-tools.sourceforge.net/  => Emacs resource page

Emacs Perl Modules

    Cperl -- Perl programming mode

        http://www.cpan.org/modules/by-authors/id/ILYAZ/cperl-mode/
        http://math.berkeley.edu/~ilya/software/emacs/
        by Ilya Zakharevich

        CPerl is major mode for editing perl files. Forget the default
        `perl-mode' that comes with Emacs, this is much better. Comes
        standard in newest Emacs.

    TinyPerl -- Perl related utilities

        http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Grep through all Perl manpages (.pod)
        o   Follow POD references e.g. [perlre] to next pod with RETURN
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.

        o   Update `$VERSION' variable with YYYY.MMDD on save.
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Prepare script (version numbering) and Upload it to PAUSE
        o   Generate autoload STUBS (Devel::SelfStubber) for you
            Perl Module (.pm)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in Tiny Tools Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up dattabases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to to do the search, You can adjust
        recursive grep options, set search case sensitivity, add user grep
        options etc.

        You can find latest `igrep.el' module at
        <http://groups.google.com/groups?group=gnu.emacs.sources> The
        maintainer is Jefin Rodgers <kevinr <AT> ihs.com>.

    TinyCompile -- To Browse grep results in Emacs *compile* buffer

        TinyCompile is a minor mode for *compile* buffer from where
        you can collapse unwanted lines or shorten file URLs:

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->

            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



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

Date: 16 Jan 2005 23:17:50 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: email regex help
Message-Id: <slrncultgu.ev3.abigail@alexandra.abigail.nl>

nntp (asf@sadfkj.cosdf) wrote on MMMMCLVI September MCMXCIII in
<URL:news:10ulpsn8or9tl22@corp.supernews.com>:
%%  Ive been trying to come up with two regex's but im having trouble...
%%  the script that im writing will first ask for the domain.
%%  im trying to get a regex to match valid domain names.

use Regexp::Common;

my $re = $RE {net} {domain};

 ... /$re/ ...

%%  the second should be able to match an email address (without the
%%  @domain.tld)..
%%  
%%  so far i have this
%%   if ($name !~ /^([a-zA-Z0-9]([a-zA-Z0-9\-\.]{0,63}))$/ ) {
%%                  print "REGEX OK\n";
%%  }

That only allows a limited subset of the possible email addresses.

%%  i really don't know what im doing....

You can say that.

%%                                        but i know im pretty close....


How would you know you're pretty close if you don't know what you
are doing?

Have you read the output of

    perldoc -q "valid mail"

?



Abigail
-- 
@;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
;print@;[@;{A..Z}];


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

Date: Sun, 16 Jan 2005 21:38:08 -0800
From: "Paul S." <pauls@nospam.com>
Subject: Re: how can I use perl to do a windows "postmessage"  ?
Message-Id: <KJidnY_DWJ_d0nbcRVn-2g@seanet.com>

A. Sinan Unur wrote:
> "Paul S." <pauls@nospam.com> wrote in
> news:vqqdnSY_uPI6SHfcRVn-tw@seanet.com: 
> 
> 
>>A. Sinan Unur wrote:
>>
>>>"Paul S." <pauls@nospam.com> wrote in news:raSdndzO7YkcJnfcRVn-
>>>uQ@seanet.com:
>>>
>>>
>>>
>>>>I want to use PERL to communicate with another software package I
>>>>have. The other software allows one to "talk" to it using the
>>>>postmessage command. I am using activestate PERL - do you know where
>>>>I can get a compatible (to active state PERL 5.6) package that has
>>>>the postmessage function?
>>>
>>>
>>>You can use the Win32::API module.
>>>
>>>See also http://tinyurl.com/vy31 
> 
> 
> ...
> 
> 
>>I tried using the Activestate package manager to install the win32-api
>>module but it did not work. You wouldn't happen to know where I could 
>>get the module would you?
> 
> 
> I have only installed Win32::API through ppm but I am using 5.8.
> 
> In any case, you could try:
> 
> <http://ppm.activestate.com/PPMPackages/zips/6xx-builds-only/Win32-API-
> 0.41.zip> (http://tinyurl.com/6dacg in case the URL wraps).
> 
> Google and CPAN are your friends, BTW.
> 
> Hope this helps.
> 
> Sinan.
Hi Sinan,
I installed the newest version of activestate PERL and now was able to 
instally the win32 stuff using the ppm.

Thanks for your help, much appreciated!!

Paul




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

Date: Mon, 17 Jan 2005 02:02:08 -0500
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: how can I use perl to do a windows "postmessage"  ?
Message-Id: <pan.2005.01.17.07.02.08.558680@asu1cornelledu>

In article <KJidnY_DWJ_d0nbcRVn-2g@seanet.com> posted on Sun, 16 Jan 2005
21:38:08 -0800, Paul S. wrote:

> I installed the newest version of activestate PERL and now was able to 
> instally the win32 stuff using the ppm.
> 
> Thanks for your help, much appreciated!!

You are welcome. Hope it works out.

-- 
A. Sinan Unur
usa1@llenroc.ude.invalid -- remove invalid and
reverse each component for email address.



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

Date: 17 Jan 2005 03:46:40 GMT
From: xhoster@gmail.com
Subject: Re: implementing "protected" in OO perl
Message-Id: <20050116224640.421$VY@newsreader.com>

SNeelakantan_C@zaplet.com wrote:
> Is there a way of making a certain variable 'protected' so that only
> methods in derived classes may access it? I would prefer a mechanism
> that doesn't wrap the variable in a method call since performance would
> slow down by an order of magnitude.

My prefered method would be to state my preference in the specs/docs that
coders should not diddle with my privates.  Then do a code review, and fire
any coders who diddled with my privates.  If someone will only follow good
practise when the language itself forces them to do so, I have to consider
that programmer to be armed, hostile, and dangerous.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Sun, 16 Jan 2005 21:08:04 -0500
From: John Smith <jsmith@macroshaft.com>
Subject: looking for constructive criticism on this script....
Message-Id: <pan.2005.01.17.02.08.02.659942@macroshaft.com>

just looking for some constructive criticism on my first real perl script
posted below

TIA

Subject:      my perl script for ripping mp3s...aka MP3scRIPt-.2
From:         John Smith <jsmith@macroshaft.com>
Newsgroups:   comp.unix.bsd.freebsd.misc
Date:         Sat, 15 Jan 2005 02:23:54 -0500

mp3scRIPt-.2
This is a Perl script to convert audio cd tracks to mp3s.  It uses the CDDB at freedb.org for
 title/path creation.  It should require minimal prep work as described
 below.  I have only tested it on my FreeBSD5.3 box and have no plans to
 test it elsewhere.

Requirements: 
1. Perl (I have 5.8.6)
2. CDDB_get perl module found at http://armin.emx.at/cddb/
 - i had to insert a line just above line 407 of the file /usr/local/lib/perl5/site_perl/5.8.5/CDDB_get.pm -> $input=1;
 - "this module requires *BSD, Linux, or SunOS"
3. Internet connectivity
4. Possibly root privs to access the cdrom device
5. Assumes 'lame' and 'cdda2wav' exist and can be found in your path
6. Default encoding is 192 bit (it is hard coded but feel free to change it - line 100)
7. This script is for ATAPI/IDE cdroms -ie not SCSI

This was written on FreeBSD 5.3/i386 using vi...this is my second Perl script ever 
and was written because the Handbook instructions are too arduous (ie I'm
lazy) and xmcd bugs me (however it is based directly on the Handbook,
hence the use of cdda2wav and lame). "Hello World" was my only prior perl
script, so please, be gentle in your criticisms. This script is provided
on an as is basis, no support is assumed or expected from myself. It's a
bit crude and even a little rude...please leave me some feedback here
should you decide to give it a whirl. ps - I realize there are probably
scores of scripts that already do this (not to mention programs) I just
felt like doing it myself

=================================================================

#!/usr/bin/perl -w
#Thank you for trying MP3scRIPt-.2

print "\nWelcome to Steve's MP3 scRIPt\n\n";
print "What is your cdrom device (<enter> for default /dev/acd0): \n";
$cdrom = <STDIN>;
if ($cdrom eq "\n")
   {
      $cdrom = '/dev/acd0';
   }
else
   {
      chomp($cdrom);
   }

use CDDB_get qw( get_cddb );
my %config;
$config{CD_DEVICE}="$cdrom";
my %cd=get_cddb(\%config);
unless(defined $cd{title})
   {
      die "no cddb entry found";
   }

my $whereArtist = index($cd{artist}, "&");
if ($whereArtist ne -1)
   {
      substr($cd{artist}, $whereArtist, 1) = "and";
   }

my $whereTitle = index($cd{title}, "&");
if ($whereTitle ne -1)
   {
      substr($cd{title}, $whereTitle, 1) = "and";
   }

print "Artist: $cd{artist}\n";
print "Title: $cd{title}\n";
print "Category: $cd{cat}\n";
print "CDDD-ID: $cd{id}\n";
print "Tracks: $cd{tno}\n\n";
my $n=1;
foreach my $i ( @{$cd{track}} )
   {
      my $where = index($i, "/");
      if ($where ne -1)
         {
            substr($i, $where, 1) = "-";
         }
      print "Track $n: $i\n";
      $n++;
   }

print "\nWhat is your base mp3 directory? \n";
chomp($path = <STDIN>);
print "\nShall I create \"$path\/$cd{artist}\/$cd{title}\" for you, y or n?\n";
chomp($create_dir = <STDIN>);
if ($create_dir eq 'y')
   {
      $path = "$path\/$cd{artist}\/$cd{title}";
      print "\nThe full pathname will be $path\n";
      system "mkdir -p \"$path\"";
   }

print "\nWhich tracks would you like ripped, entering each track on a seperate line (or '0' for all) and then end with ctrl-D: \n";
chomp(@tracks = <STDIN>);
$i = 0;
$tno = 1;
if ($tracks[0]==0)
   {
      while ($i < $cd{tno})
         {
            $tracks[$i] = $tno;
            $i += 1;
            $tno += 1;
         }
   }

print "\n\nEject when finished (requires eject command), y or n?\n";
chomp($eject = <STDIN>);
print "\n\nYou have chosen the following options: \n";
print "1. Your cdrom device is $cdrom\n";
print "2. Your output path will be $path\n";
print "3. You have chosen to rip track(s) @tracks\n";
print "\nIf you have chosen wisely, please enter 1, otherwise enter 0: \n";
chomp($i = <STDIN>);

if ($i == 1)
   {
      print "\nStarting the MP3 scRIPt...\n\n";
      chdir "$path" or die "Cannot chdir to $path, please create $path and try again: $!";
      print "\nChanged directory to $path...\n\n";
      foreach $tracks (@tracks)
         {
            my $title = @{$cd{track}}[$tracks-1];
            print "\n\n$title is now being ripped...\n\n";
            system "cdda2wav -D $cdrom -t $tracks";
            rename "audio.inf", "audio$tracks.inf";
            rename "audio.wav", "audio$tracks.wav";
            system "lame -h -b 192 --tt \"$title\" --ta \"$cd{artist}\" --tl \"$cd{title}\" audio$tracks.wav \"$title\".mp3";
         }
      unlink glob "*.inf";
      unlink glob "*.wav";
   }

else
   {
      print "Can't you type, you imbecile?!\n";
   }

if ($eject eq 'y')
{
   system "eject $cdrom";
}
print "\nThank you for using MP3 scRIPt\n\n";




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

Date: Sun, 16 Jan 2005 23:55:08 -0500
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: looking for constructive criticism on this script....
Message-Id: <pan.2005.01.17.04.54.37.732388@asu1cornelledu>

In article <pan.2005.01.17.02.08.02.659942@macroshaft.com> posted on Sun,
16 Jan 2005 21:08:04 -0500, John Smith wrote:

> just looking for some constructive criticism on my first real perl
> script posted below

OK, then ...

>  below.  I have only tested it on my FreeBSD5.3 box and have no plans to
>  test it elsewhere.

Whatever floats your boat ...

> #!/usr/bin/perl -w

use warnings;

is preferable.

Also, you are missing 

use strict;

This suggests to me that you did not bother to read the posting guidelines
for this group before posting here. It has valuable information and you
would benefit from reading it and following the advice given there (as I
did when I was first learning Perl).

> #Thank you for trying MP3scRIPt-.2

Well, this immediately screams 'kiddie' to me. You are suggesting that the
script should be run as root. Why should I trust someone who can type
properly?
 
> print "\nWelcome to Steve's MP3 scRIPt\n\n"; 
> print "What is your cdrom device (<enter> for default /dev/acd0): \n";
> $cdrom = <STDIN>; 
> if ($cdrom eq "\n")
>    {
>       $cdrom = '/dev/acd0';
>    }
> else
>    {
>       chomp($cdrom);
>    }

First, you need to declare $cdrom. Second, this is unnecessarily
convoluted:

my $cdrom = <STDIN>;
chomp $cdrom;
$cdrom = '/dev/acd0' unless $cdrom;

is easier to understand.

> use CDDB_get qw( get_cddb );
> my %config;
> $config{CD_DEVICE}="$cdrom";

Useless use of quotes. See

perldoc -q always

The rest of the script is a little too messy for my taste and I don't have
time to reformat it. However,

>    {
>       print "Can't you type, you imbecile?!\n";
>    }

Nice attitude.

Sinan.
-- 
A. Sinan Unur
usa1@llenroc.ude.invalid -- remove invalid and
reverse each component for email address.



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

Date: Mon, 17 Jan 2005 08:17:31 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Need help with Perl and MySQL database data load
Message-Id: <9EJGd.4816$Sl3.113570@news4.e.nsc.no>

Oscar wrote:
> Thanks for the responses.

Please don't top-post.

> I modified my script to declare
> my $user
> my $dsn
> my $pass
> my %args
> and modified my connect command to accomodate the new variables.
> When I ran the script I got the message:
> "Global symbol "$dns" requires explicit package name at sqltst2.pl line 13.

It means that I had a typo in my example. It should be ease for you to 
correct yourself, as Perl tells you on what line the typo is, right?

> I then added the line
> package MySQL;
> at the beginning of my script and got the same error.

Sure. Why should "converting" your script to a package named "MySQL" do 
any good?

Please post a _complete_ script detailing your problems.


-- 
Tore Aursand <tore@aursand.no>
"Poor management can increase software costs more rapidly than any
  other factor." (Barry Boehm)


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

Date: 16 Jan 2005 09:53:59 -0800
From: jeremy_scott_fischer@yahoo.com (Jeremy Fischer)
Subject: Prime numbers: addative property modulo p, where p is prime
Message-Id: <7f2fb830.0501160953.334e0d8a@posting.google.com>

Tom, Larry, Randall....
what do you make of this elegant snippet?


------------------------
#!/usr/local/bin/perl
$|++;

$p = [ 2,3,5,7,11 ];				# P not P
foreach $n (@$p) {				# populate hash and array	
	$p{$n}++;				# with first couple of primes
}						# and set the candidate to the last
						# prime plus one


						# roughly 30 seconds
						# p(2.3.5.7.11 = 2310)
						
						# n.b.
						# p()		function 
						# $p->[]	array 
						# $p->{}	hash
						
$n = 13;
#($p->[-1]) +2;

while (scalar(@$p) < (2*3*5*7*11) ) {  	
	if ( &j($n,$p) ) {
		push (@$p, $n);
		$p{$n}++;
		
		
	}
	$n++;
}


sub j {
	my ($n,$primes) = @_;
	
	foreach $p (@$primes ) {
		if ( $n % $p == 0 ) {
			
			return(0);
		}
	}
	print "$n    + ";
	if ( $tab++ % 3 == 1 ) {
		print "= \n ";
	}
	return(1);
}

sub p {
	my ($n) = @_;
	return ($p->[$n]);
	# given n, return p(n)
}

sub n {
	# given p, return 
	# which one (if prime) 
	# zero (if not)
}

sub pth {
	my ( $th, $width) = @_;
	my $sum = 0;
	
	foreach $q ( ($th -$width) .. ($th +$ width) ) {
		$sum += &p($q);
	}
	
	return ($sum);

}


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

Date: Mon, 17 Jan 2005 06:44:32 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Print question
Message-Id: <k9JGd.6426$c%6.278@trnddc03>

Joe Smith wrote:
> edgrsprj wrote:
>
>> What I am planning to try to do is have that Perl program translated
>> into a CGI type language so that it will run at that U.N. site or
>> some other site.
>
> Perl is a "CGI type language",

This of course triggers the question what is a CGI type language to begin 
with?

CGI defines an interface (*) between two programs, typically between a web 
server and another program. In which programming language this other program 
is written is 100% irrelevant as long as it can read from STDIN and write to 
STDOUT.
I think you would have serious difficulties to find a general purpose 
programming that cannot read/write to/from STDIN/STDOUT. And all other 
languages are "CGI type languages", aren't they?

If you have a different understanding of CGI type language then I would be 
eager to hear it.

(*) Ok, CGI does have some sort of syntax and context and you probably could 
call it a language. Still personally I find that a far stretch.

jue 




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

Date: 16 Jan 2005 21:51:25 -0800
From: socialism001@yahoo.com
Subject: redirect & target="_top"
Message-Id: <1105941085.808966.19070@z14g2000cwz.googlegroups.com>

I have the following code in my cgi script. How would I use
target="_top" in the code below so that it would prevent my page from
opening in a frame.


Thanks,
Chris


*********************
my $url_1 =
'http://www.company.com/cgi-bin/company.cgi/_address?for_sale=&_act=qu...
my $query1 = $query->query_string;
my $query2 = join('',$url_1,$query1);


my $query3 = length($query2);
my $query4 = substr($query2,0,450);
print $query->redirect($query4);
*********************



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

Date: Mon, 17 Jan 2005 01:12:27 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: redirect & target="_top"
Message-Id: <WbednZ2lGqHQynbcRVn-tw@adelphia.com>

socialism001@yahoo.com wrote:

> I have the following code in my cgi script. How would I use
> target="_top" in the code below so that it would prevent my page from
> opening in a frame.

You wouldn't. You're talking about an HTML attribute, and your script
doesn't produce any HTML, just a redirect header. It's off-topic for this
group, so I won't go into details, but there are some hacks you can use to
avoid getting "framed". Have a look at:

    <http://www.htmlhelp.com/faq/html/frames.html>

If you need more help, try a group under the comp.infosystems.www.*
hierarchy.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 16 Jan 2005 22:16:49 -0800
From: "lio" <igor.lobanov@gmail.com>
Subject: Re: redirect & target="_top"
Message-Id: <1105942609.099128.244130@f14g2000cwb.googlegroups.com>

Netscape must support header:

Windows-Target: _top

But this is NOT CROSS-BROWSER solution. Don't use it :)
--
Regards, lio
http://www.template-toolkit.ru/



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

Date: 16 Jan 2005 23:07:06 -0800
From: "Peroli" <peroli@gmail.com>
Subject: Re: redirect & target="_top"
Message-Id: <1105942703.661428.132550@z14g2000cwz.googlegroups.com>

hi Chris,
It is not possible to enforce an url to load in the top frame using
server side scripting ( or i dont know). You can rather use a small
javascript file included in everypage to check whether your page is
loaded in a frame or not.

(ex)
if (location.href != top.location.href) {
top.location.href = location.href;
}

This will check for the presence of any top level frame, if so it will
load your document in the main window.

Peroli Sivaprakasam



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

Date: Sun, 16 Jan 2005 18:45:00 -0500
From: Digger  <hx_101@hotmail.com>
Subject: Re: Script Not Returning Value
Message-Id: <dqulu0pc77aai04ujlpj3dp53e6066abdk@4ax.com>

On Sat, 15 Jan 2005 18:58:47 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:

>Digger wrote:
>
>For a script to return a custom return value you have to use the exit() 
>function.
>I don't see you using it anywhwere in your code.
>
>> #!/usr/bin/perl -w
>> #
>> $ARGV[0] = 'url2.log';
>> my %status;
>> while (<>) {
>>        / (FAILURE|SUCCESS).+?from (.+)/ and $status{$2} = $1;
>> }
>> print "URLs whose last status was SUCCESS:\n";
>> $status{$_} eq 'SUCCESS' and print "  $_\n" for sort keys %status;
>>
>> print "\nURLs whose last status was FAILED:\n";
>> $status{$_} eq 'FAILURE'  and print "  $_\n" for sort keys %status;
>> #
>
>jue 
>


Here's what I have so far....


#!/usr/bin/perl -w 
#
open (SNMPLOG, ">snmp.log");
$ARGV[0] = 'url2.log';
my %status;
while (<>) {
        / (FAILURE|SUCCESS).+?from (.+)/ and $status{$2} = $1;
}
$status{$_} eq 'FAILURE'  and print SNMPLOG " 0 " for sort keys
%status;

$status{$_} eq 'SUCCESS' and print SNMPLOG " 1 " for sort keys
%status;

The logfile has the following:

 1  0  0  0


Is there a way to do the following:

If there is a FAILURE print 0 to the logfile then exit. Or if no url's
FAILURE print the 1 to the log file...... I guess I would have to nest
an if statement in there some how???


$status{$_} eq 'FAILURE'  and print SNMPLOG " 0 " for sort keys
%status;

$status{$_} eq 'SUCCESS' and print SNMPLOG " 1 " for sort keys
%status;


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

Date: Mon, 17 Jan 2005 06:53:28 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Script Not Returning Value
Message-Id: <IhJGd.6449$c%6.3112@trnddc03>

Digger wrote:
> On Sat, 15 Jan 2005 18:58:47 GMT, "Jürgen Exner"
> <jurgenex@hotmail.com> wrote:
>
>> Digger wrote:
>>
>> For a script to return a custom return value you have to use the
>> exit() function.
>> I don't see you using it anywhwere in your code.
[First code snipped]
>
> Here's what I have so far....

[updated code snipped]

Ok, very slowly again:
You want your script to return a value.
To define the return value of a script and to terminate it at the same time 
you use the exit() function in Perl.
Your updated program still does not call the exit() function anywhere.
Therefore it does not return a value (well, depending on you OS it may 
return some default value for success or failure).

jue




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

Date: Mon, 17 Jan 2005 14:05:37 +0800
From: sam <sam.wun@authtec.com>
Subject: Update statement with Perl DBI for MySQL 5.0
Message-Id: <csfm61$ime$1@news.hgc.com.hk>

Hi,
Here is my sample code:
$sql ="update transaction set salesvolume=$salesvol, netsales=$netsales,
                        transtype=\"$transtype\", 
returnreason=\"$returnreason\"
                        where prodcode=\"$prodcode\" and 
custcode=\"$custcode\" and date=$transdate";
$udpate_sql = qq {$sql;};
$sth = $dbh->prepare($update_sql) || die "prepare: $update_sql: 
$DBI::errstr";
$sth->execute || die "Unable to execute query: $dbh->errstr\n";
$sth->finish;
print $sql;

Currently I found somethingn strange with mysql(perhaps with perl dbi as 
well), after setup 1 or 2 test data, I tried to make a change to one of 
the fiield in a table, but after update is completed, I don't see the 
corresponding field in a record is updated by the new value.

If I copy the update statement exactly from the output of the print 
statement ( print $sql), and paste it to the mysql login prompt to 
execute it, the update statement  update the record instantly. I don't 
know what is happening here, why perl dbi does not do what the update 
statement supposed to do? Have I missed a commit statement? but I don't 
have idea how to place a commit statement to perl dbi.

Thanks
Sam


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

Date: Mon, 17 Jan 2005 01:38:44 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Update statement with Perl DBI for MySQL 5.0
Message-Id: <94-dnQ-5WbvrwHbcRVn-ow@adelphia.com>

sam wrote:

> $sql ="update transaction set salesvolume=$salesvol, netsales=$netsales,
>                         transtype=\"$transtype\",
> returnreason=\"$returnreason\"
>                         where prodcode=\"$prodcode\" and
> custcode=\"$custcode\" and date=$transdate";
> $udpate_sql = qq {$sql;};
> $sth = $dbh->prepare($update_sql) || die "prepare: $update_sql:
> $DBI::errstr";
> $sth->execute || die "Unable to execute query: $dbh->errstr\n";
> $sth->finish;
> print $sql;
> 
> Currently I found somethingn strange with mysql(perhaps with perl dbi as
> well), after setup 1 or 2 test data, I tried to make a change to one of
> the fiield in a table, but after update is completed, I don't see the
> corresponding field in a record is updated by the new value.

It sounds like a quoting problem - your example is just *begging* for
placeholders anyway. Here's how you'd use placeholders instead:

my $sql = 'update transaction
               set salesvolume=?, netsales=?,
                   transtype=?, returnreason=?,
               where prodcode=? and custcode=? and date=?';

my $sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";

$sth->execute($salesvol, $netsales, $transtype, $returnreason,
              $prodcode, $custcode, $transdate) ||
    die "Unable to execute query: $dbh->errstr";
$sth->finish;

Using placeholders does two things for you: First, it handles all the
quoting automagically. That's handy. And second, if you're inserting more
than one row, it's far more efficient: Instead of repeatedly building up a
series of SQL strings that you prepare() and execute() one at a time, you
need only call prepare() once, and then make as many calls to execute() as
you need to.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Sun, 16 Jan 2005 23:04:18 -0500
From: Wes Groleau <groleau+news@freeshell.org>
Subject: Where do you report perl bugs?
Message-Id: <U_qdncm7WdNVoHbcRVn-ig@gbronline.com>

I have a case where adding a space in a place where it's
not supposed to matter makes a program work.

wgroleau$ diff ~/bin/GEDCOM_DB ./tempGCDB
1c1
< #!/usr/bin/perl -w -CSD
---
 > #!/usr/bin/perl -w  -CSD

od -xc revealed that the extra space is indeed a (hex 20)
regular space and not a UTF-8 construct.

Without the extra space, it refuses to run on v5.8.0 built for 
alpha-netbsd 1.6.2_STABLE and it crashes (segmentation fault/bus error)
on perl, v5.8.1-RC3 built for darwin-thread-multi-2level 7.7.0

-- 
Wes Groleau

Truth often suffers more from the heat of its defenders
than from the arguments of its opposers.
                        -- William Penn


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

Date: Sun, 16 Jan 2005 23:38:44 -0500
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Where do you report perl bugs?
Message-Id: <pan.2005.01.17.04.38.44.142182@asu1cornelledu>

In article <U_qdncm7WdNVoHbcRVn-ig@gbronline.com> posted on Sun, 16 Jan
2005 23:04:18 -0500, Wes Groleau wrote:

> Subject: Re: Where do you report perl bugs?

[ Incomplete symptom description snipped ]

Please don put your entire question in the subject line. 

Use perlbug to report perl bugs (shocking, I know).

Sinan

-- 
A. Sinan Unur
usa1@llenroc.ude.invalid -- remove invalid and
reverse each component for email address.



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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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