When threatened or at rest, the hermit crab caterpillar, seen here head-on, retreats into its camouflage leaf case for protection.

A caterpillar that was recently discovered in Peru exhibits a behavior previously unknown in caterpillars. It pieces together a tube of leaves and crawls inside; then, it "walks" by grabbing bits of the forest undergrowth with its mouth and pulling itself and its leafy covering forward.

This never-before-seen activity was spotted and documented by Joe Hanson, creator and host of the YouTube science channel "It's OK to Be Smart" presented by PBS Digital Studios, while filming in the Peruvian Amazon with entomologist Aaron Pomerantz and guide Pedro Lima.

When Hanson picked up the caterpillar, it retreated inside the protective tube, "like a knight inside a suit of armor," Hanson said in a video, suggesting that it was using the tube as a type of camouflage and protection against predators. [In Photos: Bizarre Animals That Masquerade as Plants]

Caterpillars are known to employ a range of unusual strategies to protect themselves. Some use a "freeze-and-drop" defense against wasps, deliberately falling off leaves when wasps fly near, to avoid being eaten or parasitized. Others curl up so they resemble tiny piles of bird poop. Certain caterpillars are even known to protect themselves with defensive barfing, regurgitating a foul-smelling liquid that stops predators in their tracks, while others warn away threats with puffs of nicotine.

The very first moment that guide Pedro Lima noticed the "hermit crab caterpillar" crawling on the ground, captured by Joe Hanson's iPhone camera. (Image credit: It’s Okay To Be Smart/PBS Digital Studios)

But this is the first known example of a caterpillar building itself a mobile leafy shelter, Hanson told Live Science. The leaf appeared to have been cut and pasted together, with the pieces likely glued in place by the caterpillar's silk or saliva-like secretions, Hanson explained.

There was also a distinctive bulge in the center of the tube, which appeared in four specimens that Hanson and his colleagues collected. The extra space may have allowed the caterpillar to turn completely around while still inside, enabling it to escape from the other end, Hanson said.

They observed one caterpillar as it pupated and emerged from the chrysalis as a moth, photographing the adult before releasing it. The team dubbed their discovery — which may be a new species — the "hermit crab caterpillar" for its resemblance to the tiny crustacean that also carries a disposable hiding place on its back. DNA comparisons to known species and more detailed analysis of the adult moth's body structures will help entomologists to find a place for this tube-builder on the insect family tree.

The hermit crab caterpillar demonstrates its method of camouflaged movement on the leaf-littered rainforest floor in Tambopata National Reserve in the Peruvian Amazon rainforest. (Image credit: It’s Okay To Be Smart/PBS Digital Studios)

Finding this unusual creature is an important reminder that the Amazon is still full of species that are yet to be discovered — and protected, Hanson said.

"Imagine a chemist not having a full periodic table. As biologists, we still have such a poor understanding of what's out there," he said. "We talk about conservation, but we can only do it if we know what we're conserving."

Original article on Live Science.