Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Triple Tech posted:

Uhh, what does your exposure to Perl have to with it? You could have done the exact same thing, storing an anonymous array as the value of each key.

That doesn't really work. In Perl, hash keys aren't real scalars, they're just strings. This means that if you do:
code:
$hash{ [1, 9] } = 1;
print @{ (keys %hash)[0] };
Perl will complain because (keys %hash)[0] is the string ARRAY(0x........) and not a real array reference. And if you're storing objects you have to be careful about string overload.

You can still store references as hash keys (and I do it occasionally) but it has some heavy caveats. This is what mister_gosh meant.

If you're set on doing it though, use Tie::RefHash or Tie::RefHash::Weak which will actually do what you want.

Filburt Shellbach fucked around with this message at 16:21 on Mar 27, 2008

Adbot
ADBOT LOVES YOU

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Triple Tech posted:

Clearly not.

Oh. I misunderstood. You guys keep saying "the value for each key" and I took that to mean "each key", not "each value". English! :argh:

Anyway, keying by object is useful, and I do wish Perl supported it better.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Tots posted:

code:
echo "This is 'Tot's' sample string" | sed "s|\(*'*\)\('\)\(*'*\)|\1\2\2\3|"
Regex are not shell globs. * is only a quantifier, it doesn't mean anything on its own. Replacing * with .* might do it. You can also remove some clutter from your code:
code:
sed "s|\('.*\)'\(.*'\)|\1''\2|"
I sure hope you aren't using this to quote-escape a string for a database..

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
I'd just like to point out that Perl has changed in the last decade, so please stop getting your Perl code from Matt's Script Archive.

It'd also be nice if people would discuss programming without getting into language debates..

StumblyWumbly: I'd recommend any of Perl, Python, or Ruby. I know Perl can run fine on Windows, but I don't know about the other two. Look up ActiveState Perl or Strawberry Perl.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Avenging Dentist posted:

Does anyone in the world actually do web development exclusively in UNIX?

Of course. Firebug is godly.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Mr.Radar posted:

I have a question about automake. My program's source code includes a header file which is automatically derived from another file by a Perl script. I want make to run the Perl script whenever the derived header file is out-of-date (i.e. when its modification timestamp is earlier the one on the file it is derived from). How do I do this?

Have a rule that creates the header file from the other_file, and has the header file depend on both the script and other_file:

code:
header_file: script other_file
        perl script other_file > header_file
make uses timestamps to figure out which files are out of date, so you get that last part for free.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Terminal.app seems to screw up the basic 16 colors. Turning off bold and using "Use bright colors for bold text" is still not good enough. It also doesn't let you tweak the exact colors you use (except for foreground and background).

I can't seem to get rid of the scrollbar. This is totally a nitpick but it's annoying. Even tuning scrollback lines down to zero doesn't hide it. I use screen so I never actually scroll up in the terminal itself. The scrollbar is ugly wasted space.

The block cursor does not draw whatever character is under it. Playing with its color's opacity does help, but I shouldn't have to do that. I don't like the other cursor displays because it's harder to find the cursor.

iTerm gets these all of these right, so I use it. Unfortunately, it crashes practically every day. But I always run everything in screen, so it's no more than a few seconds of annoyance.

Filburt Shellbach fucked around with this message at 13:14 on Jul 10, 2008

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
(We have a Perl thread, you know :))

One part that's definitely wrong is:

code:
foreach $key (keys %ThreeHash){
    print "$key appeared $hash{$_} times.\n";
You're iterating over the keys, storing each one in $key, but then you index into the hash using $_. Change that to $key.

If that doesn't fix your bug, please post more code.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

tripwire posted:

but I don't want to capture the nested substring because that will fuckup later captures I have to do.

Are you sure? In Perl anyway this doesn't apply; each open paren indicates a new capture. As in, open paren in the regex literal. Nesting doesn't create new captures. It becomes really easy to reason about how substrings are being captured once you internalize this.

code:
$ perl -le '"abcdX" =~ /((.)+)(X)/; warn "$1 $2 $3"'
abcd d X at -e line 1.
I think you're expecting it to result in abcd a b. I sure hope it doesn't.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

tripwire posted:

This won't work in the posix api because you can't access captured group by name, you have to access them by order in which they appeared. The URI could contain a variable amount of capture groups in it, as could the headers.

Please reread my post, because this is exactly the point I address.

tripwire posted:

Like I posted earlier, If I was using perl I wouldn't have this problem. I'm forced to use the posix regex.h api which doesn't support captures in nearly as easy a way.

I know. I was just using Perl as an example. Just try it with your regex library. I bet it'll work.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

The Dissonant posted:

I'm interested in doing some AI programming. Anyone know any websites that offer some good exercises for doing this kind of stuff?

You're going to want to get a book. I highly recommend Russel and Norvig's AI: A Modern Approach.

Adbot
ADBOT LOVES YOU

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Vince McMahon posted:

Is there perhaps a way to force a redirect from the thumbnail to the high resolution image?

No browser would request the thumbnail URI again, and that's such a specific need that I doubt any browser supports it.

Could you instead direct your users to click the thumbnail then save that image?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply