[31369] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2621 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 4 18:09:25 2009

Date: Sun, 4 Oct 2009 15:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 4 Oct 2009     Volume: 11 Number: 2621

Today's topics:
    Re: CGI and UTF-8 <benkasminbullock@gmail.com>
    Re: CGI and UTF-8 <cmic@live.fr>
        FAQ 5.35 Why can't I use "C:\temp\foo" in DOS paths?  W <brian@theperlreview.com>
        FAQ 5.7 How can I manipulate fixed-record-length files? <brian@theperlreview.com>
        FAQ 7.18 How can I access a dynamic variable while a si <brian@theperlreview.com>
        FAQ 7.8 How do I declare/create a structure? <brian@theperlreview.com>
        FAQ 8.41 How do I use an SQL database? <brian@theperlreview.com>
        FAQ 8.42 How do I make a system() exit on control-C? <brian@theperlreview.com>
        FAQ 8.5 How do I read just one key without waiting for  <brian@theperlreview.com>
        Invalid URI in request  \x83\xff\xce\x9dj\xa2ER\xcbz'\x <jessecknight@gmail.com>
    Re: Invalid URI in request \x83\xff\xce\x9dj\xa2ER\xcbz <smallpond@juno.com>
        Remove Unicode control character from string <ryanchan404@gmail.com>
    Re: Remove Unicode control character from string <benkasminbullock@gmail.com>
    Re: Remove Unicode control character from string <tadmc@seesig.invalid>
    Re: Remove Unicode control character from string <jurgenex@hotmail.com>
    Re: simple hash <benkasminbullock@gmail.com>
    Re: sort function warning, variable will not stay share <martien.verbruggen@invalid.see.sig>
    Re: sort function warning, variable will not stay share <ben@morrow.me.uk>
    Re: ~ substitute ' with ` <whynot@pozharski.name>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 3 Oct 2009 03:51:08 -0700 (PDT)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: CGI and UTF-8
Message-Id: <defd83f5-0d34-4e22-8487-f5490c3b14da@p10g2000prm.googlegroups.com>

On Oct 3, 12:04=A0am, Helmut Richter <hh...@web.de> wrote:
> On Mon, 28 Sep 2009, s...@netherlands.com wrote:
> > From the docs:
> > " PRAGMAS
> > =A0 -utf8
> > =A0 This makes CGI.pm treat all parameters as UTF-8 strings.
> > =A0 Use this with care, as it will interfere with the processing of bin=
ary uploads.
>
> This is the same problem for *both* solutions offered in this thread:
> the utf8 pragma, and setting binmode on both STDIN and STDOUT. In fact, I
> have the suspicion that the effect of the pragma is not much more than
> such
> a setting.

This web page has a working example of what sln is discussing:

http://www.lemoda.net/perl/strip-diacritics/

The line

use CGI '-utf8';

makes CGI.pm do what you seem to want it to do: convert the input from
the form into Perl's "utf8" or "character semantics" or whatever
they're calling it these days.

(I tried to send this by a free server & that seems to have failed, so
I am resending via Google Groups. Apologies if this message turns up
twice.)


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

Date: Sun, 4 Oct 2009 12:38:12 -0700 (PDT)
From: cmic <cmic@live.fr>
Subject: Re: CGI and UTF-8
Message-Id: <d76d7009-33cd-4306-abc5-0cd9261af905@k26g2000vbp.googlegroups.com>

Hello

On 29 sep, 00:46, Ben Morrow <b...@morrow.me.uk> wrote:
 ...
> Of course, perl's definition of 'utf8' is different from the Unicode
> Consortium's 'UTF-8': the standard forbids representations of surrogates
> and unassigned codepoints (and possibly other things I've forgotten). If
> you want perl to enforce these restrictions you need to ask for it with
> :encoding(UTF-8) (this appears to only be documented in perldoc Encode).

OK. But I can't find any clear explanation in perldoc Encode, but in
perldoc binmode.

Thank you for allowing me to rehearse this point though
Rgds
--
michel maron caka cmic


>
> Ben



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

Date: Sat, 03 Oct 2009 10:00:11 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 5.35 Why can't I use "C:\temp\foo" in DOS paths?  Why doesn't `C:\temp\foo.exe` work?
Message-Id: <LgFxm.11284$QG1.9910@newsfe23.iad>

This is an excerpt from the latest version perlfaq5.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

5.35: Why can't I use "C:\temp\foo" in DOS paths?  Why doesn't `C:\temp\foo.exe` work?

    Whoops! You just put a tab and a formfeed into that filename! Remember
    that within double quoted strings ("like\this"), the backslash is an
    escape character. The full list of these is in "Quote and Quote-like
    Operators" in perlop. Unsurprisingly, you don't have a file called
    "c:(tab)emp(formfeed)oo" or "c:(tab)emp(formfeed)oo.exe" on your legacy
    DOS filesystem.

    Either single-quote your strings, or (preferably) use forward slashes.
    Since all DOS and Windows versions since something like MS-DOS 2.0 or so
    have treated "/" and "\" the same in a path, you might as well use the
    one that doesn't clash with Perl--or the POSIX shell, ANSI C and C++,
    awk, Tcl, Java, or Python, just to mention a few. POSIX paths are more
    portable, too.



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Sun, 04 Oct 2009 04:00:03 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 5.7 How can I manipulate fixed-record-length files?
Message-Id: <75Vxm.124867$Y83.34950@newsfe21.iad>

This is an excerpt from the latest version perlfaq5.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

5.7: How can I manipulate fixed-record-length files?

    The most efficient way is using pack() and unpack(). This is faster than
    using substr() when taking many, many strings. It is slower for just a
    few.

    Here is a sample chunk of code to break up and put back together again
    some fixed-format input lines, in this case from the output of a normal,
    Berkeley-style ps:

            # sample input line:
            #   15158 p5  T      0:00 perl /home/tchrist/scripts/now-what
            my $PS_T = 'A6 A4 A7 A5 A*';
            open my $ps, '-|', 'ps';
            print scalar <$ps>;
            my @fields = qw( pid tt stat time command );
            while (<$ps>) {
                    my %process;
                    @process{@fields} = unpack($PS_T, $_);
            for my $field ( @fields ) {
                    print "$field: <$process{$field}>\n";
            }
            print 'line=', pack($PS_T, @process{@fields} ), "\n";
            }

    We've used a hash slice in order to easily handle the fields of each
    row. Storing the keys in an array means it's easy to operate on them as
    a group or loop over them with for. It also avoids polluting the program
    with global variables and using symbolic references.



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Sun, 04 Oct 2009 22:00:04 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 7.18 How can I access a dynamic variable while a similarly named lexical is in scope?
Message-Id: <EV8ym.29614$As.21553@newsfe13.iad>

This is an excerpt from the latest version perlfaq7.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

7.18: How can I access a dynamic variable while a similarly named lexical is in scope?

    If you know your package, you can just mention it explicitly, as in
    $Some_Pack::var. Note that the notation $::var is not the dynamic $var
    in the current package, but rather the one in the "main" package, as
    though you had written $main::var.

            use vars '$var';
            local $var = "global";
            my    $var = "lexical";

            print "lexical is $var\n";
            print "global  is $main::var\n";

    Alternatively you can use the compiler directive our() to bring a
    dynamic variable into the current lexical scope.

            require 5.006; # our() did not exist before 5.6
            use vars '$var';

            local $var = "global";
            my $var    = "lexical";

            print "lexical is $var\n";

            {
                    our $var;
                    print "global  is $var\n";
            }



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Sat, 03 Oct 2009 16:00:31 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 7.8 How do I declare/create a structure?
Message-Id: <zyKxm.221828$sC1.177077@newsfe17.iad>

This is an excerpt from the latest version perlfaq7.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

7.8: How do I declare/create a structure?

    In general, you don't "declare" a structure. Just use a (probably
    anonymous) hash reference. See perlref and perldsc for details. Here's
    an example:

            $person = {};                   # new anonymous hash
            $person->{AGE}  = 24;           # set field AGE to 24
            $person->{NAME} = "Nat";        # set field NAME to "Nat"

    If you're looking for something a bit more rigorous, try perltoot.



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Sat, 03 Oct 2009 22:00:17 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.41 How do I use an SQL database?
Message-Id: <RPPxm.24767$As.11830@newsfe13.iad>

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

8.41: How do I use an SQL database?

    The DBI module provides an abstract interface to most database servers
    and types, including Oracle, DB2, Sybase, mysql, Postgresql, ODBC, and
    flat files. The DBI module accesses each database type through a
    database driver, or DBD. You can see a complete list of available
    drivers on CPAN: http://www.cpan.org/modules/by-module/DBD/ . You can
    read more about DBI on http://dbi.perl.org .

    Other modules provide more specific access: Win32::ODBC, Alzabo, iodbc,
    and others found on CPAN Search: http://search.cpan.org .



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Sun, 04 Oct 2009 16:00:03 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.42 How do I make a system() exit on control-C?
Message-Id: <7E3ym.247310$0e4.145473@newsfe19.iad>

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

8.42: How do I make a system() exit on control-C?

    You can't. You need to imitate the system() call (see perlipc for sample
    code) and then have a signal handler for the INT signal that passes the
    signal on to the subprocess. Or you can check for it:

            $rc = system($cmd);
            if ($rc & 127) { die "signal death" }



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Sun, 04 Oct 2009 10:00:02 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.5 How do I read just one key without waiting for a return key?
Message-Id: <Cm_xm.229336$cf6.11024@newsfe16.iad>

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

8.5: How do I read just one key without waiting for a return key?

    Controlling input buffering is a remarkably system-dependent matter. On
    many systems, you can just use the stty command as shown in "getc" in
    perlfunc, but as you see, that's already getting you into portability
    snags.

            open(TTY, "+</dev/tty") or die "no tty: $!";
            system "stty  cbreak </dev/tty >/dev/tty 2>&1";
            $key = getc(TTY);               # perhaps this works
            # OR ELSE
            sysread(TTY, $key, 1);  # probably this does
            system "stty -cbreak </dev/tty >/dev/tty 2>&1";

    The Term::ReadKey module from CPAN offers an easy-to-use interface that
    should be more efficient than shelling out to stty for each key. It even
    includes limited support for Windows.

            use Term::ReadKey;
            ReadMode('cbreak');
            $key = ReadKey(0);
            ReadMode('normal');

    However, using the code requires that you have a working C compiler and
    can use it to build and install a CPAN module. Here's a solution using
    the standard POSIX module, which is already on your systems (assuming
    your system supports POSIX).

            use HotKey;
            $key = readkey();

    And here's the HotKey module, which hides the somewhat mystifying calls
    to manipulate the POSIX termios structures.

            # HotKey.pm
            package HotKey;

            @ISA = qw(Exporter);
            @EXPORT = qw(cbreak cooked readkey);

            use strict;
            use POSIX qw(:termios_h);
            my ($term, $oterm, $echo, $noecho, $fd_stdin);

            $fd_stdin = fileno(STDIN);
            $term     = POSIX::Termios->new();
            $term->getattr($fd_stdin);
            $oterm     = $term->getlflag();

            $echo     = ECHO | ECHOK | ICANON;
            $noecho   = $oterm & ~$echo;

            sub cbreak {
                    $term->setlflag($noecho);  # ok, so i don't want echo either
                    $term->setcc(VTIME, 1);
                    $term->setattr($fd_stdin, TCSANOW);
            }

            sub cooked {
                    $term->setlflag($oterm);
                    $term->setcc(VTIME, 0);
                    $term->setattr($fd_stdin, TCSANOW);
            }

            sub readkey {
                    my $key = '';
                    cbreak();
                    sysread(STDIN, $key, 1);
                    cooked();
                    return $key;
            }

            END { cooked() }

            1;



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Sat, 3 Oct 2009 05:33:02 -0700 (PDT)
From: Jesse <jessecknight@gmail.com>
Subject: Invalid URI in request  \x83\xff\xce\x9dj\xa2ER\xcbz'\x16)g\xae\x8b\xed\xab\x1d\xb4\x13\x03k/k3\xd7\x81\xf77\x9a\x8a\xd1_o;k\x9b\xcf\x83\x8c\t\x8320tg
Message-Id: <07809d0f-87ff-41fd-b7d0-d129a7b77a58@r36g2000vbn.googlegroups.com>

Im running Windows Vista Home, I've installed a mysql database, PHP,
and apache 2.2.113 without crypto.

I can configure everything to work and run from my owncomputer when I
test the local host ip in my browser, but when I try to test it from
other computers using my public ip i get no results and this is the
error that showed up in my log.

Invalid URI in request  \x83\xff\xce\x9dj\xa2ER\xcbz'\x16)g\xae\x8b\xed
\xab\x1d\xb4\x13\x03k/k3\xd7\x81\xf77\x9a\x8a\xd1_o;k\x9b\xcf\x83\x8c\t
\x8320tg

(not including the ip obviously)

I am just trying to play around with the server to learn more about
how it works, does anyone have a solution or an idea of what I might
be doing wrong?

Thanks alot,

Jesse


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

Date: Sat, 3 Oct 2009 13:42:14 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Invalid URI in request \x83\xff\xce\x9dj\xa2ER\xcbz'\x16)g\xae\x8b\xed\xab\x1d\xb4\x13\x03k/k3\xd7\x81\xf77\x9a\x8a\xd1_o;k\x9b\xcf\x83\x8c\t\x8320tg
Message-Id: <e92546d6-651c-47d7-9a50-af965f278fdc@p36g2000vbn.googlegroups.com>

On Oct 3, 8:33=A0am, Jesse <jesseckni...@gmail.com> wrote:
> Im running Windows Vista Home, I've installed a mysql database, PHP,
> and apache 2.2.113 without crypto.
>
> I can configure everything to work and run from my owncomputer when I
> test the local host ip in my browser, but when I try to test it from
> other computers using my public ip i get no results and this is the
> error that showed up in my log.
>
> Invalid URI in request =A0\x83\xff\xce\x9dj\xa2ER\xcbz'\x16)g\xae\x8b\xed
> \xab\x1d\xb4\x13\x03k/k3\xd7\x81\xf77\x9a\x8a\xd1_o;k\x9b\xcf\x83\x8c\t
> \x8320tg
>
> (not including the ip obviously)
>
> I am just trying to play around with the server to learn more about
> how it works, does anyone have a solution or an idea of what I might
> be doing wrong?
>


Do you prefer your eggs fried or scrambled?





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

Date: Sun, 4 Oct 2009 07:30:15 -0700 (PDT)
From: Ryan Chan <ryanchan404@gmail.com>
Subject: Remove Unicode control character from string
Message-Id: <bccd5690-8e19-44a9-8611-bfe80258b809@y10g2000prg.googlegroups.com>

Hello,

Consider the sample code:
##############
use strict;

my $in = "\U0004";
my $out = chr($in) . "apple";

$out =~ s/[:cntrl:]//gi;
print $out;
##############

I want to remove the the first unicode char (e.g. "\U0004") from the
string, I found the above code does not work as expected, any idea?

Thanks.




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

Date: Sun, 4 Oct 2009 08:40:34 -0700 (PDT)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: Remove Unicode control character from string
Message-Id: <aead487a-6ef8-4437-9b41-01d106a1fd20@h14g2000pri.googlegroups.com>

On Oct 4, 11:30=A0pm, Ryan Chan <ryanchan...@gmail.com> wrote:
> Hello,
>
> Consider the sample code:
> ##############
> use strict;
>
> my $in =3D "\U0004";
> my $out =3D chr($in) . "apple";
>
> $out =3D~ s/[:cntrl:]//gi;
> print $out;
> ##############
>
> I want to remove the the first unicode char (e.g. "\U0004") from the
> string, I found the above code does not work as expected, any idea?

I got a message like this:

POSIX syntax [: :] belongs inside character classes in regex; marked
by <-- HERE
 in m/[:cntrl:] <-- HERE / at ./moo.pl line 6.

It seems you need more []s.

$out =3D~ s/[[:cntrl:]]//gi;

seems to do the trick.


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

Date: Sun, 04 Oct 2009 10:52:13 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Remove Unicode control character from string
Message-Id: <slrnhchga9.cqh.tadmc@tadmc30.sbcglobal.net>

Ryan Chan <ryanchan404@gmail.com> wrote:

> $out =~ s/[:cntrl:]//gi;

> any idea?


You should always enable warnings when developing Perl code!


    perl -we 's/[:cntrl:]//gi;'


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sun, 04 Oct 2009 08:52:23 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Remove Unicode control character from string
Message-Id: <51hhc5d2gmj8q423121u1pse328hrfuim5@4ax.com>

Ryan Chan <ryanchan404@gmail.com> wrote:
>$out =~ s/[:cntrl:]//gi;
>
>I want to remove the the first unicode char (e.g. "\U0004") from the
>string, I found the above code does not work as expected, any idea?

You can use the notation [:cntrl:] only inside of a character class.
From "perldoc perlre":

 The POSIX character class syntax

     [:class:]

 is also available. Note that the "[" and "]" brackets are *literal*;
 they must always be used within a character class expression.

     # this is correct:
     $string =~ /[[:alpha:]]/;

     # this is not, and will generate a warning:
     $string =~ /[:alpha:]/;

jue


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

Date: Sat, 3 Oct 2009 05:27:50 -0700 (PDT)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: simple hash
Message-Id: <96ff4e79-393f-4a0b-8763-53e3933caa0e@a37g2000prf.googlegroups.com>

On Oct 2, 6:52=A0pm, Justin C <justin.0...@purestblue.com> wrote:
> On 2009-10-02, Nene <rodbas...@gmail.com> wrote:
>
>
>
>
>
> > Why is this code not working?
>
> > #!/usr/bin/perl -w
> > use strict;
> > use warnings;
>
> > my %years;
> > while (<DATA>) {
> > chomp;
> > my $year =3D (split /\t/)[3];
> > $years{$year}++;
> > }
> > foreach (sort keys %years) {
> > print "In $_, $years{$_} CDs were released.\n";
> > }
>
> > __DATA__
> > Bragg, Billy =A0Workers' Playtime =A0Cooking Vinyl =A01987
> > ###
>
> > I keep getting:
>
> > Use of uninitialized value in hash element at ./hash.pl line 9, <DATA>
> > line 1.
>
> There are no tabs (\t) in your data. If you edit the data and make sure
> that they are *real* tabs then it works. You may want to choose an
> alternative field separator.

This works too:

my $year =3D (split /\t|\s{2,}/)[3];


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

Date: Sat, 3 Oct 2009 14:43:46 +1000
From: Martien Verbruggen <martien.verbruggen@invalid.see.sig>
Subject: Re: sort function warning, variable will not stay shared
Message-Id: <2qk6ah.68i.ln@news.heliotrope.home>

On Fri, 2 Oct 2009 07:32:40 -0700 (PDT),
	ccc31807 <cartercc@gmail.com> wrote:
> Suggestions for dealing with a warning for a sort function, please.

The answer has already been given by Ben and Randal, but for future
reference, you should be aware of the perldiag documentation, which
documents all of Perl's warnings and errors, together with possible
causes and fixes. 

Regards,
Martien
-- 
                             | 
Martien Verbruggen           | The Second Law of Thermodenial: In any
first.last@heliotrope.com.au | closed mind the quantity of ignorance
                             | remains constant or increases.


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

Date: Sat, 3 Oct 2009 13:37:53 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: sort function warning, variable will not stay shared
Message-Id: <16tjp6-r9q1.ln1@osiris.mauzo.dyndns.org>


Quoth merlyn@stonehenge.com (Randal L. Schwartz):
> >>>>> "Ben" == Ben Morrow <ben@morrow.me.uk> writes:
> 
> Ben>  The technical reason for this is
> Ben> that named subs are not closures in Perl 5:
> 
> You have "not" in there, where I think you meant "named subs *are* closures",
> because you correctly describe the effect of it being a closure here:
> 
> Ben>  in simple terms, the
> Ben> *second* time you run the block of code that does the sort the sub will
> Ben> still be looking at the $content variable from the *first* time, and you
> Ben> will get incorrect results.
> 
> As in, the variables get the closure treatment the first time, and therefore
> they are no longer "shared".

Hmm. I suppose you could call that 'closing over the variables in scope
at compile time'. Usually, though, the term 'closure' refers to a
situation where you can create multiple instantiations of the same
function, which differ only in which set of variables they close over.
That isn't possible in Perl with named subs, but is with anon subs.

Ben



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

Date: Sat, 03 Oct 2009 11:48:53 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: ~ substitute ' with `
Message-Id: <slrnhce3vk.po5.whynot@orphan.zombinet>

On 2009-10-02, Uri Guttman <uri@StemSystems.com> wrote:
>>>>>> "B" == BJ  <BJ@Isabe.com> writes:
*SKIP*
>  B> $title =~s\/'/\`/g ;
>
> here you have the op correct but the s\/ is insane. i am not even sure
> if that parses.

It doesn't

	Substitution replacement not terminated at -e line 1.

*CUT*

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


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

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:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 2621
***************************************


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