comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
March 2008
motuwethfrsasuw
     12 9
3456789 10
10111213141516 11
17181920212223 12
24252627282930 13
31       14
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.perl.misc Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  sort         


Author: asgweb
Date: Mar 7, 2008 19:03

hello. i have code (below) that sorts the contents of a directory. it
works fine, but i need to show only files that start with an 'R'.
thanks in advance for your help.
opendir(STOCKBACKGROUND, ".") || &error("STOCKBACKGROUND");
@stockbackgrounds = readdir(STOCKBACKGROUND);
@stockbackgrounds = sort {lc($a) cmp lc($b)} @stockbackgrounds;
closedir(STOCKBACKGROUND);
2 Comments
  FAQ 5.1 How do I flush/unbuffer an output filehandle? Why must I do this?         


Author: PerlFAQ Server
Date: Mar 7, 2008 18:03

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.1: How do I flush/unbuffer an output filehandle? Why must I do this?

Perl does not support truly unbuffered output (except insofar as you can
"syswrite(OUT, $char, 1)"), although it does support is "command
buffering", in which a physical write is performed after every output
command.

The C standard I/O library (stdio) normally buffers characters sent to
devices so that there isn't a system call for each byte. In most stdio
implementations, the type of output buffering and the size of the buffer
varies according to the type of device. Perl's "print()" and "write()"
functions normally buffer output, while "syswrite()" bypasses buffering
all together.
Show full article (3.22Kb)
2 Comments
  Grabbing GPS data using perl         


Author: deadpickle
Date: Mar 7, 2008 13:48

I have been using the perl module perl-GPS to grab data from a DeLorme
(NMEA) GPS device though I am having some problems with this module.
The first thing is that the module is blocking when it grabs data. the
second is that the location is off by a lot.I have emailed the creator
but what I am wondering is if there are other GPS perl module that I
can use to get GPS data from a COM port or USB?
1 Comment
  Question on regex         


Author: cyrusgreats
Date: Mar 7, 2008 13:17

I'm using the following regex using perl to get anything that is not
0.0 but it doesn't work the way I want it, I need to print those that
are not 0.0

The string is:

0.0 19968 admin /bin/bash -l
1.0 20037 admin /bin/bash -l
0.2 20085 admin /bin/bash -l
0.0 20363 admin /bin/bash -l

next if $line =~ /^\s0.0/; # skip 0.0
print $line, "\n";

the out put is:
next if $line =~ /^\s0.0/; # skip 0.0

But I all I want is:

1.0 20037 admin /bin/bash -l
0.2 20085 admin /bin/bash -l

Anyone out there know how to fix this one?
Thanks in advance..
19 Comments
  FAQ 4.61 What's the difference between "delete" and "undef" with hashes?         


Author: PerlFAQ Server
Date: Mar 7, 2008 12:03

This is an excerpt from the latest version perlfaq4.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 .

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

4.61: What's the difference between "delete" and "undef" with hashes?

Hashes contain pairs of scalars: the first is the key, the second is the
value. The key will be coerced to a string, although the value can be
any kind of scalar: string, number, or reference. If a key $key is
present in %%hash, "exists($hash{$key})" will return true. The value for
a given key can be "undef", in which case $hash{$key} will be "undef"
while "exists $hash{$key}" will return true. This corresponds to ($key,
"undef") being in the hash.

Pictures help... here's the %%hash table:
Show full article (3.56Kb)
no comments
  FAQ 4.74 How do I define methods for every class/object?         


Author: PerlFAQ Server
Date: Mar 7, 2008 06:03

This is an excerpt from the latest version perlfaq4.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 .

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

4.74: How do I define methods for every class/object?

Use the "UNIVERSAL" class (see UNIVERSAL).

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

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.
no comments
  a better code by foreach?         


Author: Rose
Date: Mar 7, 2008 05:50

Is it possible for me to use "foreach" to make the following codes in a
better way? I don't want to create subroutine and call. Because I can't use
@%%arr this time (%%arr1 not equal to %%arr[1]). Copying the %%arr1, %%arr2, ...,
%%arrn into a single large array is impractical, because %%arr1, ...n is
already very large each.

while (($loc, $sub) = each(%%arr1)) {
print "$loc\tSub\t$sub\t$notes[0]\t$start\t$end\n";
}

while (($loc, $sub) = each(%%arr2)) {
print "$loc\tSub\t$sub\t$notes[0]\t$start\t$end\n";
}

...

while (($loc, $sub) = each(%%arrn)) {
print "$loc\tSub\t$sub\t$notes[0]\t$start\t$end\n";
}
4 Comments
  Using Perl to get data from website         


Author: fiazidris
Date: Mar 7, 2008 01:58

Previously, I have written a perl script to access data from this URL:

http://www.bangkokflightservices.com/our_cargo_track.php

Some sample: MAWB - Master Airwaybill Number

724-26332482
724-61480672
724-61441122

and this was the final URL:

http://203.151.118.123:8090/showc_track.php?m_prefix=724&m_sn=26332482&h_prefix=...=

But, now there is a change on the website and I couldn't extract
through the same script. One change I noticed is the URL has changed
to:



How can I programmatically obtain data for a list of MAWBs.

Here is a sample script that I wrote which previously worked:

#!/usr/bin/perl

while (<>) {
chomp;
Show full article (1.93Kb)
4 Comments
  Posting Guidelines for comp.lang.perl.misc ($Revision: 1.8 $)         


Author: tadmc
Date: Mar 7, 2008 00:17

Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information ...
Show full article (16.63Kb)
no comments
  FAQ 4.73 How do I print out or copy a recursive data structure?         


Author: PerlFAQ Server
Date: Mar 7, 2008 00:03

This is an excerpt from the latest version perlfaq4.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 .

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

4.73: How do I print out or copy a recursive data structure?

The "Data::Dumper" module on CPAN (or the 5.005 release of Perl) is
great for printing out data structures. The "Storable" module on CPAN
(or the 5.8 release of Perl), provides a function called "dclone" that
recursively copies its argument.

use Storable qw(dclone);
$r2 = dclone($r1);

Where $r1 can be a reference to any kind of data structure you'd like.
It will be deeply copied. Because "dclone" takes and returns references,
you'd have to add extra punctuation if you had a hash of arrays that you
wanted to copy.

%%newhash = %%{ dclone(\%%oldhash) };

--------------------------------------------------------------------
Show full article (1.66Kb)
no comments